Markdown message (half) support
This commit is contained in:
1 parent
e07f8ee05f
commit
eb9a1ad9e8
9 files changed
+147
-92
No files matched your search
@@ -71,6 +71,8 @@ class ExpertAgent(Agent):
|
||||
elif model_engine == "replicate":
|
||||
if 'parameters' in db_model:
|
||||
opts['parameters'] = db_model['parameters']
|
||||
if 'format' in db_model:
|
||||
opts['format'] = db_model['format']
|
||||
|
||||
response = await inference.replicate_completion(self.app, messages, model=db_model.value['model'], opts=opts)
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ class ChatMixin:
|
||||
sender=sender,
|
||||
kind=kind or 'message',
|
||||
subkind=subkind,
|
||||
#format=format,
|
||||
format=format,
|
||||
content=initial_content,
|
||||
thread_id=thread_id
|
||||
)
|
||||
@@ -159,7 +159,7 @@ class ChatMixin:
|
||||
for agent_id in agent_ids:
|
||||
if str(agent_id) != str(sender):
|
||||
await self.notify_message_to_agent(agent_id, message)
|
||||
|
||||
|
||||
def notify_users():
|
||||
nonlocal updating
|
||||
self.notify_message_to_user(chat_owner_id, message, updating)
|
||||
|
||||
+4
-1
@@ -8,13 +8,14 @@ import temporary as tmp
|
||||
MESSAGE_PAGE_SIZE = 256
|
||||
|
||||
class Message:
|
||||
def __init__(self, id, content, sender, time=None, kind='message', subkind=None, thread_id=None):
|
||||
def __init__(self, id, content, sender, time=None, kind='message', subkind=None, format=None, thread_id=None):
|
||||
self.id = id
|
||||
self.content = content
|
||||
self.sender = sender
|
||||
self.time = time
|
||||
self.kind = kind
|
||||
self.subkind = subkind
|
||||
self.format = format
|
||||
self.thread_id = thread_id
|
||||
|
||||
def from_db_record(record):
|
||||
@@ -32,6 +33,8 @@ class Message:
|
||||
"time": self.time,
|
||||
"sender": self.sender,
|
||||
"kind": self.kind,
|
||||
"subkind": self.subkind,
|
||||
"format": self.format,
|
||||
"content": self.content,
|
||||
"threadId": self.thread_id,
|
||||
}
|
||||
|
||||
+10
-1
@@ -31,7 +31,16 @@ async def init_database (data_directory):
|
||||
|
||||
# Checks whether an object is an instance of any database model
|
||||
def is_instance (value):
|
||||
isinstance(value, models.Model)
|
||||
import temporary as tmp
|
||||
if hasattr(value, 'id'):
|
||||
if tmp.is_tmp_id(value.id):
|
||||
return False
|
||||
|
||||
if isinstance(value, models.Model):
|
||||
return True
|
||||
|
||||
print("NOT A DB INSTANCE??? " + repr(value))
|
||||
return False
|
||||
|
||||
class User(models.Model):
|
||||
id = fields.IntField(pk=True)
|
||||
|
||||
@@ -33,8 +33,8 @@ def get_llama_cpp_model(app, model_file):
|
||||
return last_model_instance
|
||||
|
||||
if last_model_instance is not None:
|
||||
#last_model_instance = None
|
||||
del last_model_instance
|
||||
last_model_instance = None
|
||||
#del last_model_instance
|
||||
|
||||
last_model_file = model_file
|
||||
last_model_instance = Llama(
|
||||
@@ -176,7 +176,7 @@ async def replicate_base_completion(app, model, input):
|
||||
|
||||
def run_replicate_inference_loop(replicate_client, model, input, content_stream):
|
||||
print("START INFERENCE")
|
||||
completion = replicate_client.run(model, input=input)
|
||||
completion = replicate_client.run(model, input=input, stream=True)
|
||||
for event in completion:
|
||||
if event:
|
||||
content_stream.feed(str(event))
|
||||
|
||||
@@ -12,12 +12,12 @@ from stream import Stream
|
||||
# relative to the module file???? wtf
|
||||
frontend_path = '../../frontend/dist'
|
||||
|
||||
def start_server(app):
|
||||
async def start_server(app):
|
||||
nest_asyncio.apply()
|
||||
|
||||
server = Quart(__name__, static_folder=frontend_path)
|
||||
server.secret_key = 'horde-secret'
|
||||
auth_manager = QuartAuth(server, mode="brearer")
|
||||
auth_manager = QuartAuth(server, mode="bearer")
|
||||
|
||||
stream_listeners = {}
|
||||
|
||||
@@ -116,7 +116,7 @@ def start_server(app):
|
||||
return
|
||||
|
||||
# TODO: print username instead, same in the finally block
|
||||
print("User logged in:", user_id)
|
||||
print("User logged in:", user_id)
|
||||
await websocket.send(json.dumps({'message': 'authentication successful'}))
|
||||
|
||||
send_queue = asyncio.Queue()
|
||||
@@ -307,4 +307,4 @@ def start_server(app):
|
||||
print("User logged out:", user_id)
|
||||
app.remove_user_connection(user_id, send_queue)
|
||||
|
||||
server.run(debug=True)
|
||||
server.run(debug=True)
|
||||
Reference in new issue
Block a user