ai-agent1 / AI_Agent /chains /synthesis_chain.py
curiouscurrent's picture
Create synthesis_chain.py
7903612 verified
raw
history blame contribute delete
644 Bytes
# AI_Agent/chains/synthesis_chain.py
class SynthesisChain:
def __init__(self, llm_adapter):
self.llm = llm_adapter
async def run(self, prompt, reasoning_text, contexts):
synth_prompt = (
"You are a synthesis assistant. Combine reasoning and contexts to produce a concise final answer.\n\n"
f"User prompt:\n{prompt}\n\n"
f"Reasoning:\n{reasoning_text}\n\n"
f"Contexts:\n" + "\n".join([f"- {c}" for c in contexts]) +
"\n\nFinal answer:"
)
out = await self.llm.generate(synth_prompt)
return {"answer": out["text"], "raw": out.get("raw")}