Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,7 +53,7 @@ def get_ref_content(path: str) -> str | object:
|
|
| 53 |
if path.endswith('mp3') or path.startswith('https://www.youtube.com/'):
|
| 54 |
file = librosa.load(path)
|
| 55 |
elif path.endswith('.xlsx') or path.endswith('.xls'):
|
| 56 |
-
file = pd.read_excel(path).to_csv(
|
| 57 |
elif path.startswith('http'):
|
| 58 |
file = requests.get(path).content
|
| 59 |
else:
|
|
@@ -112,7 +112,7 @@ extract_text_tool = Tool(
|
|
| 112 |
)
|
| 113 |
|
| 114 |
tools = [get_file_path_tool, get_content_tool, extract_text_tool, search_web_tool]
|
| 115 |
-
chat_with_tools = chat.bind_tools(tools, parallel_tool_calls=
|
| 116 |
|
| 117 |
|
| 118 |
# Generate the AgentState and Agent graph
|
|
@@ -163,7 +163,7 @@ class BasicAgent:
|
|
| 163 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 164 |
message = HumanMessage(content=question)
|
| 165 |
print(message)
|
| 166 |
-
answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit":
|
| 167 |
answer = "".join(re.findall(r'(FINAL ANSWER.*)', answer, flags=re.M))
|
| 168 |
answer = answer.replace('FINAL ANSWER:', '')
|
| 169 |
answer = answer.replace('FINAL ANSWER', '')
|
|
|
|
| 53 |
if path.endswith('mp3') or path.startswith('https://www.youtube.com/'):
|
| 54 |
file = librosa.load(path)
|
| 55 |
elif path.endswith('.xlsx') or path.endswith('.xls'):
|
| 56 |
+
file = pd.read_excel(path).to_csv()
|
| 57 |
elif path.startswith('http'):
|
| 58 |
file = requests.get(path).content
|
| 59 |
else:
|
|
|
|
| 112 |
)
|
| 113 |
|
| 114 |
tools = [get_file_path_tool, get_content_tool, extract_text_tool, search_web_tool]
|
| 115 |
+
chat_with_tools = chat.bind_tools(tools, parallel_tool_calls=False)
|
| 116 |
|
| 117 |
|
| 118 |
# Generate the AgentState and Agent graph
|
|
|
|
| 163 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 164 |
message = HumanMessage(content=question)
|
| 165 |
print(message)
|
| 166 |
+
answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit": 5})['messages'][-1].content
|
| 167 |
answer = "".join(re.findall(r'(FINAL ANSWER.*)', answer, flags=re.M))
|
| 168 |
answer = answer.replace('FINAL ANSWER:', '')
|
| 169 |
answer = answer.replace('FINAL ANSWER', '')
|