mirror of
https://git.squeakyrat.moe/faggot-chan/
synced 2026-11-04 18:35:45 +01:00
grr
This commit is contained in:
1 parent
64af28f820
commit
fec259bb5c
2 files changed
+8
-9
No files matched your search
@@ -120,9 +120,6 @@ async def call_main(payload: str) -> tuple[bool, str]:
|
||||
if "error" in data:
|
||||
return False, data["error"]
|
||||
return True, data["ok"]
|
||||
except websockets.exceptions.ConnectionClosedOK:
|
||||
_main_ws = None
|
||||
return False, f"[{now_str()}] websocket closed cleanly (no reply)"
|
||||
except Exception as e:
|
||||
_main_ws = None
|
||||
if attempt == 0:
|
||||
|
||||
@@ -65,14 +65,16 @@ def rebuild_vector_db(longterm_lines: list[str]):
|
||||
|
||||
|
||||
async def ollamachat(websocket):
|
||||
# loop over every message on this connection instead of handling one and returning —
|
||||
# returning from this function is what makes the websockets lib close the connection,
|
||||
# which was breaking bot.py's persistent connection after every single reply
|
||||
async for raw in websocket:
|
||||
try:
|
||||
# bot sends one json payload with everything main needs
|
||||
raw = await websocket.recv()
|
||||
payload = json.loads(raw)
|
||||
|
||||
if payload.get("auth_token") != AUTH_TOKEN:
|
||||
await websocket.send(json.dumps({"error": "bad auth token"}))
|
||||
return
|
||||
continue
|
||||
|
||||
system_prompt = payload["system_prompt"]
|
||||
user_input = payload["user_input"]
|
||||
@@ -129,10 +131,10 @@ async def ollamachat(websocket):
|
||||
current_user_lines = []
|
||||
seen_last = None # for dedup
|
||||
|
||||
for raw in shortterm:
|
||||
if is_skip(raw):
|
||||
for line in shortterm:
|
||||
if is_skip(line):
|
||||
continue
|
||||
speaker, text = parse_line(raw)
|
||||
speaker, text = parse_line(line)
|
||||
if not speaker or not text:
|
||||
continue
|
||||
entry = f"{speaker}: {text}"
|
||||
|
||||
Reference in new issue
Block a user