Update agent.py
Browse files
agent.py
CHANGED
|
@@ -43,21 +43,24 @@ class BasicAgent():
|
|
| 43 |
|
| 44 |
def __call__(self, question: str) -> str:
|
| 45 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 46 |
-
|
| 47 |
-
answer = response['messages'][-1].content
|
| 48 |
-
print(f"Agent returning answer: {answer}")
|
| 49 |
-
return answer
|
| 50 |
-
|
| 51 |
-
def assistant(self,state: AgentState):
|
| 52 |
-
prompt = """Please reason step by step.
|
| 53 |
-
|
| 54 |
When providing the final answer, be as concise as possible, provide only the FINAL ANSWER. For example:
|
| 55 |
QUESTION: What was the actual enrollment count of the clinical trial on H. pylori in acne vulgaris patients from Jan-May 2018 as listed on the NIH website?
|
| 56 |
FINAL ANSWER: 90
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
return {
|
| 60 |
-
"messages": [self.chat_with_tools.invoke(
|
| 61 |
}
|
| 62 |
|
| 63 |
|
|
|
|
| 43 |
|
| 44 |
def __call__(self, question: str) -> str:
|
| 45 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 46 |
+
agent_prompt = f"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
When providing the final answer, be as concise as possible, provide only the FINAL ANSWER. For example:
|
| 48 |
QUESTION: What was the actual enrollment count of the clinical trial on H. pylori in acne vulgaris patients from Jan-May 2018 as listed on the NIH website?
|
| 49 |
FINAL ANSWER: 90
|
| 50 |
+
|
| 51 |
+
Now:
|
| 52 |
+
QUESTION: {question}
|
| 53 |
+
FINAL ANSWER: """
|
| 54 |
|
| 55 |
+
messages=[HumanMessage(content=agent_prompt)]
|
| 56 |
+
response = self.agent.invoke({"messages":messages})
|
| 57 |
+
answer = response['messages'][-1].content
|
| 58 |
+
print(f"Agent returning answer: {answer}")
|
| 59 |
+
return answer
|
| 60 |
+
|
| 61 |
+
def assistant(self, state: AgentState):
|
| 62 |
return {
|
| 63 |
+
"messages": [self.chat_with_tools.invoke(state["messages"])],
|
| 64 |
}
|
| 65 |
|
| 66 |
|