ai-agent1 / AI_Agent /chains /reasoning_chain.py
curiouscurrent's picture
Create reasoning_chain.py
772425d verified
raw
history blame contribute delete
579 Bytes
# AI_Agent/chains/reasoning_chain.py
class ReasoningChain:
def __init__(self, llm_adapter):
self.llm = llm_adapter
async def run(self, prompt, contexts):
reasoning_prompt = (
"You are a reasoning assistant.\n"
f"User prompt:\n{prompt}\n\n"
f"Context documents:\n" + "\n".join([f"- {c}" for c in contexts]) +
"\n\nProvide step-by-step reasoning and intermediate conclusions."
)
out = await self.llm.generate(reasoning_prompt)
return {"reasoning": out["text"], "raw": out.get("raw")}