Dodanie historii wiadomości

This commit is contained in:
l.gabrysiak 2025-03-02 21:23:11 +01:00
parent 38c7ab8956
commit 52f4e8579e
1 changed files with 9 additions and 0 deletions

View File

@ -319,9 +319,18 @@ async def chat_endpoint(request: ChatRequest):
weaviate_results = hybrid_search(keywords)
prompt_data += "\n".join([f"Źródło: {doc['file_name']}\n{doc['relevant_fragment']}\n\n" for doc in weaviate_results])
#messages_with_context =[
# {"role": "system", "content": prompt_system},
# {"role": "system", "content": prompt_data},
# {"role": "user", "content": prompt_answer.format(query=query)}
# ]
# Zmieniamy, aby przekazać pełną historię wiadomości
messages_with_context =[
{"role": "system", "content": prompt_system},
{"role": "system", "content": prompt_data},
# Dodajemy wszystkie wiadomości z historii
*[{"role": message.role, "content": message.content} for message in request.messages],
{"role": "user", "content": prompt_answer.format(query=query)}
]