Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
Signed-off-by: viste <viste02@gmail.com>
  • Loading branch information
Viste committed Oct 7, 2024
1 parent 03f3aa3 commit 7fa677c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ async def comment_on_photo(message: types.Message):
file_info = await message.bot.get_file(message.photo[-1].file_id)
image_url = f"https://api.telegram.org/file/bot{config.token}/{file_info.file_path}"

comment = await openai.generate_comment_from_image(image_url)
comment = await openai.generate_comment_from_image(image_url, message.chat.id)

await message.reply(comment)

Expand All @@ -116,7 +116,7 @@ async def process_ask_chat(message: types.Message) -> None:
logger.info("%s", message)
text = html.escape(message.text)

replay_text = await oai.get_resp(text, message.from_user.id)
replay_text = await oai.get_resp(text, message.chat.id)
chunks = split_into_chunks(replay_text)
for index, chunk in enumerate(chunks):
if index == 0:
Expand Down
4 changes: 2 additions & 2 deletions tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ async def send_reply(message: types.Message, text: str) -> None:
try:
history = UserHistoryManager()
await message.reply(text, parse_mode=ParseMode.HTML)
await history.add_to_history(message.from_user.id, "assistant", text)
await history.add_to_history(message.chat.id, "assistant", text)
except Exception as err:
logger.info('Exception while sending reply: %s', err)
try:
Expand All @@ -66,7 +66,7 @@ def __init__(self):
self.client = AsyncOpenAI(api_key=os.getenv('OPENAI_API_KEY'), base_url='http://31.172.78.152:9000/v1')
self.args = {"max_tokens": 1024}

async def generate_comment_from_image(self, image_url: str) -> str:
async def generate_comment_from_image(self, image_url: str, user_id: int) -> str:
try:
if user_id not in self.history.user_dialogs:
await self.history.reset_history(user_id)
Expand Down

0 comments on commit 7fa677c

Please sign in to comment.