Spaces:
Running
Running
updated prmopt
Browse files
agent.py
CHANGED
|
@@ -57,7 +57,7 @@ load_dotenv()
|
|
| 57 |
#webpage_scrape: Scrape content from a specific webpage URL when Tavily Search and Wikipedia Search do not return a result. Provide a valid URL to extract information from a particular web page.
|
| 58 |
#Give preference to using Tavily Search and Wikipedia Search before using web_search or webpage_scrape. When Web_search does not return a result, use Tavily Search.
|
| 59 |
|
| 60 |
-
SYSTEM_PROMPT = """Answer the following questions as best you can. If it is a basic question, answer it using your internal knowledge. If it is a complex question that requires facts, use the tools to answer it DO NOT rely on your internal knowledge unless the tools fail to provide a result:
|
| 61 |
For simple questions, you can use your internal knowledge and answer directly.
|
| 62 |
|
| 63 |
The way you use the tools is by specifying a json blob.
|
|
@@ -78,6 +78,7 @@ read_file: Read and display the contents of a text file, args: {"file_path": {"t
|
|
| 78 |
|
| 79 |
If you get stuck, try using another tool. For example if you are unable to find relevant information from the tavily_search tool, try using the wikipedia_search tool and vice versa.
|
| 80 |
IMPORTANT: Make sure your JSON is properly formatted with double quotes around keys and string values.
|
|
|
|
| 81 |
|
| 82 |
Example use for tools:
|
| 83 |
|
|
|
|
| 57 |
#webpage_scrape: Scrape content from a specific webpage URL when Tavily Search and Wikipedia Search do not return a result. Provide a valid URL to extract information from a particular web page.
|
| 58 |
#Give preference to using Tavily Search and Wikipedia Search before using web_search or webpage_scrape. When Web_search does not return a result, use Tavily Search.
|
| 59 |
|
| 60 |
+
SYSTEM_PROMPT = """ You are a genuis deep reseach assistant called TurboNerd, made by Vividh Mahajan (@Lasdw). Answer the following questions as best you can. If it is a basic question, answer it using your internal knowledge. If it is a complex question that requires facts, use the tools to answer it DO NOT rely on your internal knowledge unless the tools fail to provide a result:
|
| 61 |
For simple questions, you can use your internal knowledge and answer directly.
|
| 62 |
|
| 63 |
The way you use the tools is by specifying a json blob.
|
|
|
|
| 78 |
|
| 79 |
If you get stuck, try using another tool. For example if you are unable to find relevant information from the tavily_search tool, try using the wikipedia_search tool and vice versa.
|
| 80 |
IMPORTANT: Make sure your JSON is properly formatted with double quotes around keys and string values.
|
| 81 |
+
If you do not wish to use any tool, leave the action field empty.
|
| 82 |
|
| 83 |
Example use for tools:
|
| 84 |
|
app.py
CHANGED
|
@@ -43,7 +43,7 @@ def chat_with_agent(question: str, file_uploads, history: list) -> tuple:
|
|
| 43 |
if not query_limiter.is_allowed(user_id):
|
| 44 |
remaining_time = query_limiter.get_time_until_reset(user_id)
|
| 45 |
error_message = (
|
| 46 |
-
f"Rate limit exceeded. You can make {query_limiter.max_queries} queries per hour. "
|
| 47 |
f"Please wait {int(remaining_time)} seconds before trying again."
|
| 48 |
)
|
| 49 |
history.append((question, error_message))
|
|
@@ -113,7 +113,6 @@ def chat_with_agent(question: str, file_uploads, history: list) -> tuple:
|
|
| 113 |
|
| 114 |
# Add remaining queries info
|
| 115 |
remaining_queries = query_limiter.get_remaining_queries(user_id)
|
| 116 |
-
formatted_response += f"\n\n---\nRemaining queries this hour: {remaining_queries}/{query_limiter.max_queries}"
|
| 117 |
|
| 118 |
# Add question and response to history in the correct format (as tuples)
|
| 119 |
history.append((question, formatted_response))
|
|
|
|
| 43 |
if not query_limiter.is_allowed(user_id):
|
| 44 |
remaining_time = query_limiter.get_time_until_reset(user_id)
|
| 45 |
error_message = (
|
| 46 |
+
f"Rate limit exceeded. You can make {query_limiter.max_queries} queries per hour. Think of my bank account🙏. "
|
| 47 |
f"Please wait {int(remaining_time)} seconds before trying again."
|
| 48 |
)
|
| 49 |
history.append((question, error_message))
|
|
|
|
| 113 |
|
| 114 |
# Add remaining queries info
|
| 115 |
remaining_queries = query_limiter.get_remaining_queries(user_id)
|
|
|
|
| 116 |
|
| 117 |
# Add question and response to history in the correct format (as tuples)
|
| 118 |
history.append((question, formatted_response))
|