Mohammad Haghir commited on
Commit
057b801
·
1 Parent(s): 25973ca
Files changed (2) hide show
  1. agent_utils.py +1 -1
  2. app.py +6 -4
agent_utils.py CHANGED
@@ -16,5 +16,5 @@ def wiki_ret(question: str) -> str:
16
  ]
17
  )
18
 
19
- return formatted_search_docs
20
 
 
16
  ]
17
  )
18
 
19
+ return {"context": formatted_search_docs}
20
 
app.py CHANGED
@@ -29,7 +29,7 @@ llm = ChatGroq(api_key=groq_api_key, model="llama-3.3-70b-versatile")
29
 
30
  class GraphState(TypedDict):
31
  messages: str #Annotated[list, operator.add]
32
- answer: str
33
 
34
  # --- Basic Agent Definition ---
35
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
@@ -42,13 +42,14 @@ class BasicAgent:
42
  response = (self.graph).invoke({"messages": question})
43
  return response
44
 
45
- def agent(self, question: str) -> str:
46
 
47
  # print(f"Agent received question (first 50 chars): {question[:50]}...")
48
  # fixed_answer = "This is a default answer. --- 1"
49
  # print(f"Agent returning fixed answer: {fixed_answer}")
50
  # context = self.wiki_ret(question)
51
-
 
52
  prompt = f"""
53
  You are a general AI assistant. I will ask you a question.
54
  YOUR FINAL ANSWER should be a number OR
@@ -58,7 +59,8 @@ class BasicAgent:
58
  a string, don't use articles, neither abbreviations (e.g. for cities), and write
59
  the digits in plain text unless specified otherwise. If you are asked for a comma
60
  separated list, apply the above rules depending of whether the element to be put
61
- in the list is a number or a string. Question: {question}"""
 
62
  # Your answer must be in the following format:
63
 
64
  # {{"task_id": "task_id_1", "model_answer": "Answer 1 from your model", "reasoning_trace": "The different steps by which your model reached answer 1"}}
 
29
 
30
  class GraphState(TypedDict):
31
  messages: str #Annotated[list, operator.add]
32
+ context: str
33
 
34
  # --- Basic Agent Definition ---
35
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
 
42
  response = (self.graph).invoke({"messages": question})
43
  return response
44
 
45
+ def agent(self, state: GraphState):
46
 
47
  # print(f"Agent received question (first 50 chars): {question[:50]}...")
48
  # fixed_answer = "This is a default answer. --- 1"
49
  # print(f"Agent returning fixed answer: {fixed_answer}")
50
  # context = self.wiki_ret(question)
51
+ context = state.get("context", "")
52
+ question = state.get("messages", "")
53
  prompt = f"""
54
  You are a general AI assistant. I will ask you a question.
55
  YOUR FINAL ANSWER should be a number OR
 
59
  a string, don't use articles, neither abbreviations (e.g. for cities), and write
60
  the digits in plain text unless specified otherwise. If you are asked for a comma
61
  separated list, apply the above rules depending of whether the element to be put
62
+ in the list is a number or a string. Question: {question}
63
+ For answering the question use this context: {context}"""
64
  # Your answer must be in the following format:
65
 
66
  # {{"task_id": "task_id_1", "model_answer": "Answer 1 from your model", "reasoning_trace": "The different steps by which your model reached answer 1"}}