Update app.py
Browse files
app.py
CHANGED
@@ -33,9 +33,12 @@ class BasicAgent:
|
|
33 |
print("BasicAgent initialized.")
|
34 |
def __call__(self, question: str) -> str:
|
35 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
|
|
|
|
39 |
print(f"Agent returning fixed answer: {answer}")
|
40 |
return answer
|
41 |
|
@@ -43,7 +46,7 @@ class State(TypedDict):
|
|
43 |
question: str
|
44 |
answer: str
|
45 |
context: Annotated[list, operator.add]
|
46 |
-
|
47 |
def search_tavily(state):
|
48 |
|
49 |
""" Retrieve docs from web search """
|
@@ -96,7 +99,7 @@ def generate_answer(state):
|
|
96 |
answer = llm.invoke([SystemMessage(content=final_instruction)] + [HumanMessage(content=f"Answer the question: {question}")])
|
97 |
|
98 |
# Append it to state
|
99 |
-
return {"answer": answer
|
100 |
|
101 |
|
102 |
builder = StateGraph(State)
|
|
|
33 |
print("BasicAgent initialized.")
|
34 |
def __call__(self, question: str) -> str:
|
35 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
36 |
+
initial_state = {
|
37 |
+
"question": "What is the capital of France?",
|
38 |
+
"context": []
|
39 |
+
}
|
40 |
+
final_state = self.graph.invoke(initial_state)
|
41 |
+
answer = final_state["answer"]
|
42 |
print(f"Agent returning fixed answer: {answer}")
|
43 |
return answer
|
44 |
|
|
|
46 |
question: str
|
47 |
answer: str
|
48 |
context: Annotated[list, operator.add]
|
49 |
+
|
50 |
def search_tavily(state):
|
51 |
|
52 |
""" Retrieve docs from web search """
|
|
|
99 |
answer = llm.invoke([SystemMessage(content=final_instruction)] + [HumanMessage(content=f"Answer the question: {question}")])
|
100 |
|
101 |
# Append it to state
|
102 |
+
return {"answer": answer}
|
103 |
|
104 |
|
105 |
builder = StateGraph(State)
|