Commit 3a6de9fc authored by Kantz's avatar Kantz
Browse files

Überarbeitung des Retrivals

parent 1ddd502e
......@@ -21,6 +21,8 @@ def generate_hint(
)
if history:
prompt += "\nHistorie:\n" + history + "\n"
if context_sheet:
prompt += "\nKontext:\n" + context_sheet + "\n"
prompt += "Halte dich kurz und klar. Gibt nicht die Lösung aus."
result = llm_client.chat(
......
......@@ -107,23 +107,25 @@ def add_math_solution(
sheet["updated_at"] = _utc_now()
def add_tool_output(sheet: dict[str, Any], entry: dict[str, Any]) -> None:
sheet["tool_outputs"].append(entry)
sheet["updated_at"] = _utc_now()
def add_decision(sheet: dict[str, Any], decision: dict[str, Any]) -> None:
entry = {"timestamp": _utc_now(), **decision}
sheet["decisions"].append(entry)
sheet["updated_at"] = _utc_now()
# wird aktuell nicht benutzt
def latest_math_solution(sheet: dict[str, Any]) -> str:
if not sheet["math_solutions"]:
return ""
return sheet["math_solutions"][-1].get("solution", "")
def first_math_solution(sheet: dict[str, Any]) -> str:
if not sheet["math_solutions"]:
return ""
return sheet["math_solutions"][0].get("solution", "")
def format_sheet(sheet: dict[str, Any]) -> str:
parts = []
history = format_history(sheet.get("history", []))
......
......@@ -10,10 +10,6 @@ def _append_tool_log(tool_log: list[dict], name: str, args: dict, response: obje
def _bootstrap_context(sheet: dict, query_text: str, tool_log: list[dict]) -> None:
context, sources = retrieval_service.retrieve_context(query_text=query_text)
context_store.add_retrieval_context(sheet, query_text, context, sources)
context_store.add_tool_output(
sheet,
{"name": "retrieve_context", "arguments": {"query": query_text}, "response": context},
)
_append_tool_log(tool_log, "retrieve_context", {"query": query_text}, {"context": context, "sources": sources})
math_request = math_intent_LLM.extract_math_request(query_text)
......@@ -26,10 +22,6 @@ def _bootstrap_context(sheet: dict, query_text: str, tool_log: list[dict]) -> No
math_request.get("symbols"),
solution,
)
context_store.add_tool_output(
sheet,
{"name": "sympy_solve", "arguments": math_request, "response": solution},
)
_append_tool_log(tool_log, "sympy_solve", math_request, solution)
......@@ -68,12 +60,11 @@ def run_chat(messages: list[dict], draft: str | None = None) -> dict:
# Hinweis und Ausgaben generierung
hint_args = {
"task": last_user.get("content", ""),
"solution": context_store.latest_math_solution(sheet),
"solution": context_store.first_math_solution(sheet),
"history": history_text,
"context_sheet": sheet_text,
}
reply = hint_LLM.generate_hint(**hint_args)
context_store.add_tool_output(sheet, {"name": "generate_hint", "arguments": hint_args, "response": reply})
_append_tool_log(tool_log, "generate_hint", hint_args, reply)
if not reply:
......
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