Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -42,11 +42,11 @@ def safe_json(text: str) -> Optional[Dict[str, Any]]:
|
|
| 42 |
return None
|
| 43 |
|
| 44 |
|
| 45 |
-
def brief(d: Dict[str, Any]) -> str:
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
|
| 51 |
# βββββββββββββββββββββββββββ Agent state β¬ βββββββββββββββββββββββββββββββ
|
| 52 |
|
|
@@ -87,7 +87,7 @@ def tool_selector(state: AgentState) -> AgentState:
|
|
| 87 |
def wiki_tool(state: AgentState) -> AgentState:
|
| 88 |
out = wikipedia_search_tool({"wiki_query": state.query or ""})
|
| 89 |
state.tool_calls += 1
|
| 90 |
-
state.add(SystemMessage(content=f"WIKI_TOOL_OUT: {
|
| 91 |
state.next_action = None
|
| 92 |
return state
|
| 93 |
|
|
@@ -95,7 +95,7 @@ def wiki_tool(state: AgentState) -> AgentState:
|
|
| 95 |
def ocr_tool(state: AgentState) -> AgentState:
|
| 96 |
out = ocr_image_tool({"task_id": state.task_id, "ocr_path": ""})
|
| 97 |
state.tool_calls += 1
|
| 98 |
-
state.add(SystemMessage(content=f"OCR_TOOL_OUT: {
|
| 99 |
state.next_action = None
|
| 100 |
return state
|
| 101 |
|
|
@@ -103,7 +103,7 @@ def ocr_tool(state: AgentState) -> AgentState:
|
|
| 103 |
def audio_tool(state: AgentState) -> AgentState:
|
| 104 |
out = audio_transcriber_tool({"task_id": state.task_id, "audio_path": ""})
|
| 105 |
state.tool_calls += 1
|
| 106 |
-
state.add(SystemMessage(content=f"AUDIO_TOOL_OUT: {
|
| 107 |
state.next_action = None
|
| 108 |
return state
|
| 109 |
|
|
@@ -114,7 +114,7 @@ def excel_tool(state: AgentState) -> AgentState:
|
|
| 114 |
})
|
| 115 |
out = {"excel_result": result}
|
| 116 |
state.tool_calls += 1
|
| 117 |
-
state.add(SystemMessage(content=f"EXCEL_TOOL_OUT: {
|
| 118 |
state.next_action = None
|
| 119 |
return state
|
| 120 |
|
|
|
|
| 42 |
return None
|
| 43 |
|
| 44 |
|
| 45 |
+
# def brief(d: Dict[str, Any]) -> str:
|
| 46 |
+
# for k in ("wiki_result", "ocr_result", "transcript"):
|
| 47 |
+
# if k in d:
|
| 48 |
+
# return f"{k}: {str(d[k])[:160].replace('\n', ' ')}β¦"
|
| 49 |
+
# return "(no output)"
|
| 50 |
|
| 51 |
# βββββββββββββββββββββββββββ Agent state β¬ βββββββββββββββββββββββββββββββ
|
| 52 |
|
|
|
|
| 87 |
def wiki_tool(state: AgentState) -> AgentState:
|
| 88 |
out = wikipedia_search_tool({"wiki_query": state.query or ""})
|
| 89 |
state.tool_calls += 1
|
| 90 |
+
state.add(SystemMessage(content=f"WIKI_TOOL_OUT: {out}"))
|
| 91 |
state.next_action = None
|
| 92 |
return state
|
| 93 |
|
|
|
|
| 95 |
def ocr_tool(state: AgentState) -> AgentState:
|
| 96 |
out = ocr_image_tool({"task_id": state.task_id, "ocr_path": ""})
|
| 97 |
state.tool_calls += 1
|
| 98 |
+
state.add(SystemMessage(content=f"OCR_TOOL_OUT: {out}"))
|
| 99 |
state.next_action = None
|
| 100 |
return state
|
| 101 |
|
|
|
|
| 103 |
def audio_tool(state: AgentState) -> AgentState:
|
| 104 |
out = audio_transcriber_tool({"task_id": state.task_id, "audio_path": ""})
|
| 105 |
state.tool_calls += 1
|
| 106 |
+
state.add(SystemMessage(content=f"AUDIO_TOOL_OUT: {out}"))
|
| 107 |
state.next_action = None
|
| 108 |
return state
|
| 109 |
|
|
|
|
| 114 |
})
|
| 115 |
out = {"excel_result": result}
|
| 116 |
state.tool_calls += 1
|
| 117 |
+
state.add(SystemMessage(content=f"EXCEL_TOOL_OUT: {out}"))
|
| 118 |
state.next_action = None
|
| 119 |
return state
|
| 120 |
|