Skip to content

Commit

Permalink
try to show model loading again (bit gets avalible during loading, un…
Browse files Browse the repository at this point in the history
…avalible after loaded then typing starts during processing)
  • Loading branch information
Christian Ulrich committed Jul 12, 2024
1 parent b0ea743 commit 10e7c5b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion source/ai
Submodule ai updated 1 files
+4 −2 llm.py
28 changes: 18 additions & 10 deletions source/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ async def handle_message_openai(room,server,message,match):
except: server.history_count = 0
try: server.threading = server.threading.lower() == 'true' or server.threading == 'on'
except: server.threading = True
await bot.api.async_client.set_presence('unavailable','')
await bot.api.async_client.set_presence('available','')
load_model = asyncio.create_task(server._model.avalible())
#get History
events = await get_room_events(bot.api.async_client,room.room_id,int(server.history_count*2))
thread_rel = None
Expand Down Expand Up @@ -91,6 +92,8 @@ async def handle_message_openai(room,server,message,match):
ajson[param] = float(getattr(server,param))
except: logging.warning('failed to set parameter:'+param)
"""
res = await load_model
await bot.api.async_client.set_presence('unavailable','')
res = await bot.api.async_client.room_typing(room.room_id,True,timeout=300000)
message_p = await server._model.query(' '.join(words),history,images=images)
if not thread_rel:
Expand All @@ -103,16 +106,21 @@ async def handle_message_openai(room,server,message,match):
"formatted_body": markdown.markdown(message_p,
extensions=['fenced_code', 'nl2br'])
}
if server.threading:
msgc['m.relates_to'] = {
"event_id": thread_rel,
"rel_type": "m.thread",
"is_falling_back": True,
"m.in_reply_to": {
"event_id": message.event_id
}
else:
msgc = {
"msgtype": "m.text",
"body": server._model.LastError,
}
if server.threading:
msgc['m.relates_to'] = {
"event_id": thread_rel,
"rel_type": "m.thread",
"is_falling_back": True,
"m.in_reply_to": {
"event_id": message.event_id
}
await bot.api.async_client.room_send(room.room_id,'m.room.message',msgc)
}
await bot.api.async_client.room_send(room.room_id,'m.room.message',msgc)
except BaseException as e:
logger.error(str(e), exc_info=True)
await bot.api.send_text_message(room.room_id,str(e))
Expand Down

0 comments on commit 10e7c5b

Please sign in to comment.