Commit dae35034 authored by Kantz's avatar Kantz
Browse files

more testing

parent ef617e1d
...@@ -67,7 +67,7 @@ def save_canvas(request: CanvasSaveRequest) -> CanvasSaveResponse: ...@@ -67,7 +67,7 @@ def save_canvas(request: CanvasSaveRequest) -> CanvasSaveResponse:
with file_path.open("wb") as handle: with file_path.open("wb") as handle:
handle.write(raw) handle.write(raw)
latex = "\\frac{a}{b}" latex = "\\frac{a}{b}" # Placeholder
if mathpix_client: if mathpix_client:
try: try:
image = mathpix_client.image_new(str(file_path)) image = mathpix_client.image_new(str(file_path))
......
...@@ -39,7 +39,7 @@ class IngestRequest(BaseModel): ...@@ -39,7 +39,7 @@ class IngestRequest(BaseModel):
class QueryRequest(BaseModel): class QueryRequest(BaseModel):
pg_url: Optional[str] = None pg_url: Optional[str] = None
query: str = Field(..., min_length=1) query: str = Field(..., min_length=1)
k: int = 8 k: int = 4
expand_links: bool = True expand_links: bool = True
section_index: Optional[int] = None section_index: Optional[int] = None
subsection_index: Optional[int] = None subsection_index: Optional[int] = None
......
...@@ -19,7 +19,7 @@ Zitiere Quellen inline mit den eckigen Klammern, die im Kontext vorangestellt si ...@@ -19,7 +19,7 @@ Zitiere Quellen inline mit den eckigen Klammern, die im Kontext vorangestellt si
""" """
CONTEXT_LIMITS = { CONTEXT_LIMITS = {
"direct": 8, "direct": 4,
"indirect": 6, "indirect": 6,
"subsection": 2, "subsection": 2,
"section": 1, "section": 1,
......
...@@ -14,7 +14,7 @@ _LOG_DIR = os.path.join("logs", "context_sheets") ...@@ -14,7 +14,7 @@ _LOG_DIR = os.path.join("logs", "context_sheets")
def _utc_now() -> str: def _utc_now() -> str:
return datetime.utcnow().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: def is_new_chat(messages: list[dict]) -> bool:
......
...@@ -62,12 +62,15 @@ def run_chat(messages: list[dict], draft: str | None = None) -> dict: ...@@ -62,12 +62,15 @@ def run_chat(messages: list[dict], draft: str | None = None) -> dict:
_bootstrap_context(sheet, last_user.get("content", ""), tool_log) _bootstrap_context(sheet, last_user.get("content", ""), tool_log)
sheet_text = context_store.format_sheet(sheet) sheet_text = context_store.format_sheet(sheet)
reply = hint_tool.generate_hint( hint_args = {
task=last_user.get("content", ""), "task": last_user.get("content", ""),
solution=context_store.latest_math_solution(sheet), "solution": context_store.latest_math_solution(sheet),
history=history_text, "history": history_text,
context_sheet=sheet_text, "context_sheet": sheet_text,
) }
reply = hint_tool.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: if not reply:
reply = "Dazu steht nichts im Material" reply = "Dazu steht nichts im Material"
......
...@@ -20,7 +20,7 @@ SYSTEM_PROMPT = ( ...@@ -20,7 +20,7 @@ SYSTEM_PROMPT = (
) )
CONTEXT_LIMITS = { CONTEXT_LIMITS = {
"direct": 8, "direct": 4,
"indirect": 6, "indirect": 6,
"subsection": 2, "subsection": 2,
"section": 1, "section": 1,
......
...@@ -272,7 +272,7 @@ def retrieve( ...@@ -272,7 +272,7 @@ def retrieve(
pg_url: str, pg_url: str,
embedder: EmbeddingLike, embedder: EmbeddingLike,
query: str, query: str,
k: int = 8, k: int = 4,
section_index: Optional[int] = None, section_index: Optional[int] = None,
subsection_index: Optional[int] = None, subsection_index: Optional[int] = None,
type_filter: Optional[List[str]] = None, type_filter: Optional[List[str]] = None,
......
...@@ -9,7 +9,7 @@ def generate_hint( ...@@ -9,7 +9,7 @@ def generate_hint(
) -> str: ) -> str:
prompt = ( prompt = (
"Du bist ein didaktischer Tutor. " "Du bist ein didaktischer Tutor. "
"Gib einen naechsten hilfreichen Hinweis, aber keine komplette Loesung. " "Gib einen naechsten hilfreichen Hinweis, gib auf keinen Fall eine Lösung aus. Wiederhole nicht den Kontex"
"Halte dich kurz und klar.\n\n" "Halte dich kurz und klar.\n\n"
"Aufgabe:\n" "Aufgabe:\n"
+ task + task
......
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