Updated system prompt
Browse files
app.py
CHANGED
|
@@ -51,7 +51,21 @@ class BasicAgent:
|
|
| 51 |
# Define your system prompt
|
| 52 |
self.system_prompt = """You are a general AI assistant. I will ask you a question. Finish your answer with only YOUR FINAL ANSWER. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
|
| 53 |
|
| 54 |
-
If visit_webpage fails with a 403 error, fetch the page directly using requests with a User-Agent header: import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
YouTube URLs cannot be accessed directly. For YouTube questions, search for the video title or topic using web_search to find the answer indirectly.
|
| 57 |
"""
|
|
|
|
| 51 |
# Define your system prompt
|
| 52 |
self.system_prompt = """You are a general AI assistant. I will ask you a question. Finish your answer with only YOUR FINAL ANSWER. YOUR FINAL ANSWER should be a number OR as few words as possible OR a comma separated list of numbers and/or strings. If you are asked for a number, don't use comma to write your number neither use units such as $ or percent sign unless specified otherwise. If you are asked for a string, don't use articles, neither abbreviations (e.g. for cities), and write the digits in plain text unless specified otherwise. If you are asked for a comma separated list, apply the above rules depending of whether the element to be put in the list is a number or a string.
|
| 53 |
|
| 54 |
+
If visit_webpage fails with a 403 error, fetch the page directly using requests with a User-Agent header: import requests
|
| 55 |
+
headers = {"User-Agent": "Mozilla/5.0 (compatible; MyAgent/1.0)"}
|
| 56 |
+
response = requests.get(url, headers=headers)
|
| 57 |
+
text = response.text
|
| 58 |
+
|
| 59 |
+
When fetching pages with requests, always parse with BeautifulSoup to extract readable text instead of raw HTML:
|
| 60 |
+
from bs4 import BeautifulSoup
|
| 61 |
+
soup = BeautifulSoup(response.text, 'html.parser')
|
| 62 |
+
text = soup.get_text()
|
| 63 |
+
print(text[:3000])
|
| 64 |
+
|
| 65 |
+
To read downloaded files, use io.BytesIO instead of open(). Example for Excel:
|
| 66 |
+
import requests, io, pandas as pd
|
| 67 |
+
response = requests.get(url)
|
| 68 |
+
df = pd.read_excel(io.BytesIO(response.content))
|
| 69 |
|
| 70 |
YouTube URLs cannot be accessed directly. For YouTube questions, search for the video title or topic using web_search to find the answer indirectly.
|
| 71 |
"""
|