HCho commited on
Commit
1777a88
·
verified ·
1 Parent(s): 3b1fa94

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -18
app.py CHANGED
@@ -19,24 +19,20 @@ class BasicAgent:
19
  self.graph = build_graph()
20
 
21
  def __call__(self, question: str) -> str:
22
- print(f"Agent received question (first 50 chars): {question[:50]}...")
23
- messages = [HumanMessage(content=question)]
24
- messages = self.graph.invoke({"messages": messages})
25
- answer_full = messages['messages'][-1].content
26
-
27
- # Use .split() to get the part after "FINAL ANSWER: "
28
- # .strip() removes any leading/trailing whitespace
29
- if answer_full.startswith("FINAL ANSWER: "):
30
- answer = answer_full.split("FINAL ANSWER: ", 1)[1].strip()
31
- else:
32
- # Handle cases where the prefix might be missing
33
- # or the LLM didn't follow the format.
34
- # You might want to log this or return the full answer_full
35
- # depending on how strictly you want to enforce the format.
36
- answer = answer_full
37
- print(f"Warning: 'FINAL ANSWER:' prefix not found. Returning full response: {answer_full[:100]}...")
38
-
39
- return answer
40
 
41
  def run_and_submit_all( profile: gr.OAuthProfile | None):
42
  """
 
19
  self.graph = build_graph()
20
 
21
  def __call__(self, question: str) -> str:
22
+ print(f"Agent received question (first 50 chars): {question[:50]}...")
23
+ messages = [HumanMessage(content=question)]
24
+ messages = self.graph.invoke({"messages": messages})
25
+ answer_full = messages['messages'][-1].content
26
+
27
+ # "FINAL ANSWER: " 접두사 제거
28
+ if "FINAL ANSWER: " in answer_full:
29
+ answer = answer_full.split("FINAL ANSWER: ", 1)[1].strip()
30
+ else:
31
+ # 접두사가 없는 경우 전체 응답 반환
32
+ answer = answer_full.strip()
33
+ print(f"Warning: 'FINAL ANSWER:' prefix not found. Returning full response: {answer[:100]}...")
34
+
35
+ return answer
 
 
 
 
36
 
37
  def run_and_submit_all( profile: gr.OAuthProfile | None):
38
  """