Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -35,6 +35,9 @@ class BasicAgent:
|
|
| 35 |
api_key=self.api_key,
|
| 36 |
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
| 37 |
temperature=0,
|
|
|
|
|
|
|
|
|
|
| 38 |
)
|
| 39 |
self.tools = []
|
| 40 |
self.chat_with_tools = self.model.bind_tools(self.tools)
|
|
@@ -57,16 +60,17 @@ class BasicAgent:
|
|
| 57 |
self.react_graph = builder.compile()
|
| 58 |
|
| 59 |
def __call__(self, question: str) -> str:
|
| 60 |
-
print(f"Agent received question: {question}")
|
| 61 |
|
| 62 |
try:
|
| 63 |
|
| 64 |
answer = self.answer_question(question)
|
| 65 |
-
|
| 66 |
-
|
|
|
|
| 67 |
|
| 68 |
except Exception as e:
|
| 69 |
-
print(f"Agent error: {e}")
|
| 70 |
return ""
|
| 71 |
def assistant(self, state: AgentState):
|
| 72 |
sys_msg = SystemMessage(content=f"""
|
|
|
|
| 35 |
api_key=self.api_key,
|
| 36 |
base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
|
| 37 |
temperature=0,
|
| 38 |
+
timeout=30,
|
| 39 |
+
max_retries=1,
|
| 40 |
+
max_tokens=128,
|
| 41 |
)
|
| 42 |
self.tools = []
|
| 43 |
self.chat_with_tools = self.model.bind_tools(self.tools)
|
|
|
|
| 60 |
self.react_graph = builder.compile()
|
| 61 |
|
| 62 |
def __call__(self, question: str) -> str:
|
| 63 |
+
print(f"Agent received question: {question[:200]}", flush=True)
|
| 64 |
|
| 65 |
try:
|
| 66 |
|
| 67 |
answer = self.answer_question(question)
|
| 68 |
+
answer = str(answer).strip()
|
| 69 |
+
print(f"Agent answer: {answer[:200]}", flush=True)
|
| 70 |
+
return answer
|
| 71 |
|
| 72 |
except Exception as e:
|
| 73 |
+
print(f"Agent error: {e}", flush=True)
|
| 74 |
return ""
|
| 75 |
def assistant(self, state: AgentState):
|
| 76 |
sys_msg = SystemMessage(content=f"""
|