Spaces:
Sleeping
Sleeping
| # 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")} | |