Stabilize frontend login. Make chat messages multiline.

This commit is contained in:
Shivering Ocelot committed 2025-05-31 13:33:42 -05:00
1 parent 5bbdfe8747
commit 3f37f727af
6 files changed
+71 -31

No files matched your search

-2
View File
@@ -34,8 +34,6 @@ class Agent:
]
tools = []
# while this constructor accepts two parameters,
# all subclasses must also accept a fourth 'data' parameter
def __init__(self, app, agent_id, data):
self.app = app
self.agent_id = agent_id
+2 -4
View File
@@ -31,7 +31,7 @@ class App:
if replicate_api_token:
self.replicate_client = replicate.Client(api_token=replicate_api_token)
else:
raise Exception("Horde only works with a replicate client. Please provide an API Token.")
raise Exception("Horde only works with a replicate connection. Please provide an API Token.")
# `Agent` is the kind 'basic', will be class `BasicAgent` in the future
self.agent_classes = [Agent]
@@ -119,7 +119,7 @@ class App:
if data:
# Assign a copy to trigger a value change
agent.data = agent.data.copy()
agent.data = agent.data.copy() if agent.data else {}
agent.data.update(data)
summary.extend([f"data.{name}" for name in data.keys()])
@@ -335,8 +335,6 @@ if __name__ == "__main__":
print("No directory specified. Using current directory as default.")
data_directory = "."
print("api token", os.getenv('REPLICATE_API_TOKEN'))
app = App(
data_directory=data_directory,
replicate_api_token=os.getenv('REPLICATE_API_TOKEN'),
+5
View File
@@ -86,6 +86,10 @@ def start_server(app):
await websocket.send(json.dumps({'error': 'invalid credentials'}))
return
# TODO: print username instead, same in the finally block
print("User logged in:", user_id)
await websocket.send(json.dumps({'message': 'authentication successful'}))
send_queue = asyncio.Queue()
async def sender_task():
nonlocal send_queue
@@ -190,6 +194,7 @@ def start_server(app):
else:
await send({'error': 'unknown action: ' + action, 'nonce': nonce})
finally:
print("User logged out:", user_id)
app.remove_user_connection(user_id, send_queue)
server.run(debug=True)