File size: 579 Bytes
772425d
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 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")}