Spaces:
Sleeping
Sleeping
feat: tools update and system prompt
Browse files
app.py
CHANGED
@@ -6,35 +6,31 @@ import pandas as pd
|
|
6 |
import json
|
7 |
import copy
|
8 |
|
9 |
-
from langchain_community.agent_toolkits.openapi.toolkit import RequestsToolkit
|
10 |
-
from langchain_community.utilities.requests import TextRequestsWrapper
|
11 |
-
|
12 |
from basic_agent import ToolAgent
|
13 |
from tools import (
|
|
|
14 |
search_and_extract,
|
|
|
|
|
|
|
15 |
youtube_search_tool,
|
16 |
load_youtube_transcript,
|
17 |
-
|
18 |
image_query_tool,
|
19 |
transcribe_audio,
|
20 |
-
read_file_tool
|
21 |
)
|
22 |
|
23 |
-
request_toolkit = RequestsToolkit(
|
24 |
-
requests_wrapper=TextRequestsWrapper(headers={}),
|
25 |
-
allow_dangerous_requests=True, # ✅ must opt-in
|
26 |
-
)
|
27 |
-
request_tools = request_toolkit.get_tools()
|
28 |
-
|
29 |
TOOLS = [
|
|
|
30 |
search_and_extract,
|
|
|
|
|
|
|
31 |
youtube_search_tool,
|
32 |
load_youtube_transcript,
|
33 |
-
|
34 |
image_query_tool,
|
35 |
transcribe_audio,
|
36 |
-
read_file_tool,
|
37 |
-
*request_tools
|
38 |
]
|
39 |
|
40 |
tool_names = [tool.name if hasattr(tool, "name") else str(tool) for tool in TOOLS]
|
@@ -69,12 +65,15 @@ Terminate your loop with:
|
|
69 |
|
70 |
**Tool Use Constraints:**
|
71 |
- Never use any tool more than **3 consecutive times** without either:
|
72 |
-
-
|
73 |
-
-
|
|
|
74 |
- Do not ask the user for additional clarification or input. Work with only what is already provided.
|
75 |
|
76 |
**If you are unable to answer:**
|
77 |
-
- If neither your knowledge nor tool outputs yield useful information
|
|
|
|
|
78 |
> Final Answer: I could not find any useful information to answer your query.
|
79 |
- If the question is unanswerable due to lack of input (e.g., missing attachment) or is fundamentally outside your scope, say:
|
80 |
> Final Answer: I don't have the ability to answer this query: [brief reason]
|
|
|
6 |
import json
|
7 |
import copy
|
8 |
|
|
|
|
|
|
|
9 |
from basic_agent import ToolAgent
|
10 |
from tools import (
|
11 |
+
smart_read_file,
|
12 |
search_and_extract,
|
13 |
+
search_and_extract_from_wikipedia,
|
14 |
+
aggregate_information,
|
15 |
+
extract_clean_text_from_url,
|
16 |
youtube_search_tool,
|
17 |
load_youtube_transcript,
|
18 |
+
get_audio_from_youtube,
|
19 |
image_query_tool,
|
20 |
transcribe_audio,
|
|
|
21 |
)
|
22 |
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
TOOLS = [
|
24 |
+
smart_read_file,
|
25 |
search_and_extract,
|
26 |
+
search_and_extract_from_wikipedia,
|
27 |
+
aggregate_information,
|
28 |
+
extract_clean_text_from_url,
|
29 |
youtube_search_tool,
|
30 |
load_youtube_transcript,
|
31 |
+
get_audio_from_youtube,
|
32 |
image_query_tool,
|
33 |
transcribe_audio,
|
|
|
|
|
34 |
]
|
35 |
|
36 |
tool_names = [tool.name if hasattr(tool, "name") else str(tool) for tool in TOOLS]
|
|
|
65 |
|
66 |
**Tool Use Constraints:**
|
67 |
- Never use any tool more than **3 consecutive times** without either:
|
68 |
+
- Aggregating the information received so far: you can call the `summarize_search_results` tool and analyze the tool outputs to answer the question.
|
69 |
+
- If you need more information, use a different tool or break the problem down further, but do not return a final answer yet.
|
70 |
+
- Do not exceed **5 total calls** to *search-type tools* per query (such as `search_and_extract`, `search_and_extract_from_wikipedia`, `extract_clean_text_from_url`).
|
71 |
- Do not ask the user for additional clarification or input. Work with only what is already provided.
|
72 |
|
73 |
**If you are unable to answer:**
|
74 |
+
- If neither your knowledge nor tool outputs yield useful information:
|
75 |
+
- Use the output tools the best you can to answer the question, even if it's not perfect.
|
76 |
+
If not, say:
|
77 |
> Final Answer: I could not find any useful information to answer your query.
|
78 |
- If the question is unanswerable due to lack of input (e.g., missing attachment) or is fundamentally outside your scope, say:
|
79 |
> Final Answer: I don't have the ability to answer this query: [brief reason]
|