curiouscurrent commited on
Commit
772425d
·
verified ·
1 Parent(s): 8e72609

Create reasoning_chain.py

Browse files
Files changed (1) hide show
  1. AI_Agent/chains/reasoning_chain.py +14 -0
AI_Agent/chains/reasoning_chain.py ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AI_Agent/chains/reasoning_chain.py
2
+ class ReasoningChain:
3
+ def __init__(self, llm_adapter):
4
+ self.llm = llm_adapter
5
+
6
+ async def run(self, prompt, contexts):
7
+ reasoning_prompt = (
8
+ "You are a reasoning assistant.\n"
9
+ f"User prompt:\n{prompt}\n\n"
10
+ f"Context documents:\n" + "\n".join([f"- {c}" for c in contexts]) +
11
+ "\n\nProvide step-by-step reasoning and intermediate conclusions."
12
+ )
13
+ out = await self.llm.generate(reasoning_prompt)
14
+ return {"reasoning": out["text"], "raw": out.get("raw")}