Commit 4406f4f2 authored by Kantz's avatar Kantz
Browse files

new chat check verschoben

parent 4c15ecde
...@@ -17,10 +17,6 @@ def _utc_now() -> str: ...@@ -17,10 +17,6 @@ def _utc_now() -> str:
return datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ") return datetime.now().strftime("%Y-%m-%dT%H:%M:%SZ")
def is_new_chat(messages: list[dict]) -> bool:
return not any(m.get("role") == "assistant" for m in messages)
def get_chat_id(messages: list[dict], draft: str | None = None) -> str: def get_chat_id(messages: list[dict], draft: str | None = None) -> str:
if draft: if draft:
return f"draft_{draft}" return f"draft_{draft}"
......
...@@ -4,6 +4,9 @@ from app.LLM_services import hint_LLM, decision_LLM, math_intent_LLM, solver_LLM ...@@ -4,6 +4,9 @@ from app.LLM_services import hint_LLM, decision_LLM, math_intent_LLM, solver_LLM
from typing import List from typing import List
def _is_new_chat(messages: list[dict]) -> bool:
return not any(m.get("role") == "assistant" for m in messages)
def _append_tool_log(tool_log: list[dict], name: str, args: dict, response: object) -> None: def _append_tool_log(tool_log: list[dict], name: str, args: dict, response: object) -> None:
tool_log.append({"name": name, "arguments": args, "response": response}) tool_log.append({"name": name, "arguments": args, "response": response})
...@@ -57,7 +60,7 @@ def run_chat(messages: list[dict], draft: str | None = None) -> dict: ...@@ -57,7 +60,7 @@ def run_chat(messages: list[dict], draft: str | None = None) -> dict:
# Context Store Mangement # Context Store Mangement
chat_id = context_store.get_chat_id(messages, draft=draft) chat_id = context_store.get_chat_id(messages, draft=draft)
new_chat = context_store.is_new_chat(messages) new_chat = _is_new_chat(messages)
sheet = context_store.load_sheet(chat_id) sheet = context_store.load_sheet(chat_id)
if new_chat or not sheet: if new_chat or not sheet:
sheet = context_store.init_sheet(chat_id, messages) sheet = context_store.init_sheet(chat_id, messages)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment