File size: 419 Bytes
81b1a96
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
def generate_answer(query: str, retrieved_docs: list[str], history: list[dict]) -> str:
    history_text = "\n".join(
        f"{m['role']}: {m['content']}" for m in history
    )

    context = "\n".join(retrieved_docs[:3])

    return f"""
Conversation so far:
{history_text}

Knowledge base:
{context}

Answer:
We have received your request regarding "{query}".
Our support team will assist you shortly.
""".strip()