Commit 39de7efd authored by Kantz's avatar Kantz
Browse files

anpassung des retrival fertig und kleine anpassung an der Hint generierung.

parent 9bd364f5
...@@ -2,6 +2,7 @@ from app.deterministic_services import llm_client ...@@ -2,6 +2,7 @@ from app.deterministic_services import llm_client
def generate_hint( def generate_hint(
query: str,
task: str, task: str,
LLM_solution: str, LLM_solution: str,
math_solution: str | None = None, math_solution: str | None = None,
...@@ -10,9 +11,9 @@ def generate_hint( ...@@ -10,9 +11,9 @@ def generate_hint(
) -> str: ) -> str:
system_prompt = ( system_prompt = (
"Du bist ein didaktischer Tutor. " "Du bist ein didaktischer Tutor. "
"Gebe dem Nutzer hilfreiche Tipps um mathematische Aufgaben zu lösen. " "Gebe dem Nutzer hilfreiche Tipps um mathematische Aufgaben zu lösen."
"Antworte nur mit dem Tipp, ohne weitere Erklärungen." "Gebe keine Beispiele oder Erklärungen, sondern nur den Tipp."
"Gibe keine komplette Lösung der Aufgabe." "Gebe keine komplette Lösung der Aufgabe."
"Die Mathematische Lösung hat immer Vorrang vor der LLM Lösung." "Die Mathematische Lösung hat immer Vorrang vor der LLM Lösung."
"Halte dich kurz und prägnant." "Halte dich kurz und prägnant."
) )
...@@ -27,10 +28,12 @@ def generate_hint( ...@@ -27,10 +28,12 @@ def generate_hint(
if math_solution: if math_solution:
prompt += "Mathematische Loesung:\n" + math_solution + "\n" prompt += "Mathematische Loesung:\n" + math_solution + "\n"
if history: if history:
prompt += "\nHistorie:\n" + history + "\n" prompt = "\nHistorie:\n" + history + "\n" + prompt
if sources: if sources:
prompt = "\nKontext:\n" + sources + "\n" + prompt prompt = "\nKontext:\n" + sources + "\n" + prompt
prompt += "\nGebe einen hilfreichen Tipp zur Lösung der Aufgabe. Halte dich kurz und prägnant." if query:
prompt += "\n Aktuelle Frage:" + query
prompt += "\nGebe einen hilfreichen Tipp zur Lösung der Aufgabe der mir bei meiner aktuellen Frage hilft. Halte dich kurz und prägnant."
result = llm_client.chat( result = llm_client.chat(
messages=[{"role": "system", "content": system_prompt}, {"role": "user", "content": prompt}], messages=[{"role": "system", "content": system_prompt}, {"role": "user", "content": prompt}],
) )
......
...@@ -8,8 +8,8 @@ from fastapi import APIRouter, HTTPException, Path, Query ...@@ -8,8 +8,8 @@ from fastapi import APIRouter, HTTPException, Path, Query
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from app.deterministic_services import session_store from app.deterministic_services import session_store
from app.deterministic_services.orchestrators import orchestrator_tutor from app.deterministic_services.orchestrators import orchestrator_tutor as orchestrator
from app.deterministic_services.orchestrators import orchestrator_QA as orchestrator from app.deterministic_services.orchestrators import orchestrator_QA
......
...@@ -91,6 +91,7 @@ def run_chat(messages: list[dict], draft: str | None = None) -> dict: ...@@ -91,6 +91,7 @@ def run_chat(messages: list[dict], draft: str | None = None) -> dict:
# Hinweis und Ausgaben generierung # Hinweis und Ausgaben generierung
hint_args = { hint_args = {
"query": last_user if not new_chat else None,
"task": context_store.get_task(sheet), "task": context_store.get_task(sheet),
"LLM_solution": context_store.last_LLM_solution(sheet), "LLM_solution": context_store.last_LLM_solution(sheet),
"math_solution": context_store.first_math_solution(sheet), "math_solution": context_store.first_math_solution(sheet),
......
...@@ -11,7 +11,7 @@ from app.deterministic_services import vector_store ...@@ -11,7 +11,7 @@ from app.deterministic_services import vector_store
def retrieve_context(query_text: str, pg_url: str | None = None) -> List[Source]: def retrieve_context(query_text: str, pg_url: str | None = None) -> List[Source]:
embedder = EmbeddingFactory.create(config.get_embedding_config()) embedder = EmbeddingFactory.create(config.get_embedding_settings())
url = pg_url or config.get_postgres_url() url = pg_url or config.get_postgres_url()
sources = vector_store.retrieve( sources = vector_store.retrieve(
pg_url=url, pg_url=url,
......
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