Update app.py
Browse files
app.py
CHANGED
|
@@ -31,7 +31,7 @@ def get_hf_model():
|
|
| 31 |
token = os.environ.get("HF_TOKEN")
|
| 32 |
if not token:
|
| 33 |
raise ValueError("HF_TOKEN is not set in environment variables.")
|
| 34 |
-
return HfApiModel("deepseek-ai/DeepSeek-R1", provider="together",max_tokens=
|
| 35 |
|
| 36 |
class BasicAgent:
|
| 37 |
def __init__(self):
|
|
@@ -70,8 +70,8 @@ class BasicAgent:
|
|
| 70 |
additional_authorized_imports=[
|
| 71 |
'youtube_dl', 'io','urllib', 'chess', 'requests', 'bs4', 'pybaseball', 'numpy', 'pandas', 'accelerate'
|
| 72 |
],
|
| 73 |
-
max_print_outputs_length=
|
| 74 |
-
max_steps=
|
| 75 |
)
|
| 76 |
|
| 77 |
def __call__(self, question: str,file_name: str) -> str:
|
|
@@ -88,14 +88,14 @@ class BasicAgent:
|
|
| 88 |
"(5) Never use synonyms not present in the question. "
|
| 89 |
"(6) Some questions may include a path to an attached file. If it contains an mp3 audio, use audio_tool to translate it to text." #If it contains an image, use image_tool to describe it.
|
| 90 |
"(7) If you need to know the list of vegetables, you will find it with vegetable_info_retriever."
|
| 91 |
-
"(8) If you need to read a python file, use the custom tool reader_python. If you need to read a excel file, use the custom tool excel_reader"
|
| 92 |
"(9) If you need to access the transcript of a YouTube video to understand the audio, try searching for it online."
|
| 93 |
"Never make assumptions to answer a question. . If you do not know the answer, say so clearly. Always report your thoughts and finish your answer with the following template: "
|
| 94 |
"FINAL ANSWER: [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. "
|
| 95 |
"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. "
|
| 96 |
"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. "
|
| 97 |
"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. "
|
| 98 |
-
f"Here are the questions
|
| 99 |
)
|
| 100 |
answer = self.alfred.run(prompt)
|
| 101 |
print(f"Agent returning fixed answer: {answer}")
|
|
|
|
| 31 |
token = os.environ.get("HF_TOKEN")
|
| 32 |
if not token:
|
| 33 |
raise ValueError("HF_TOKEN is not set in environment variables.")
|
| 34 |
+
return HfApiModel("deepseek-ai/DeepSeek-R1", provider="together",max_tokens=10000,token=token)
|
| 35 |
|
| 36 |
class BasicAgent:
|
| 37 |
def __init__(self):
|
|
|
|
| 70 |
additional_authorized_imports=[
|
| 71 |
'youtube_dl', 'io','urllib', 'chess', 'requests', 'bs4', 'pybaseball', 'numpy', 'pandas', 'accelerate'
|
| 72 |
],
|
| 73 |
+
max_print_outputs_length=1000,
|
| 74 |
+
max_steps=15,
|
| 75 |
)
|
| 76 |
|
| 77 |
def __call__(self, question: str,file_name: str) -> str:
|
|
|
|
| 88 |
"(5) Never use synonyms not present in the question. "
|
| 89 |
"(6) Some questions may include a path to an attached file. If it contains an mp3 audio, use audio_tool to translate it to text." #If it contains an image, use image_tool to describe it.
|
| 90 |
"(7) If you need to know the list of vegetables, you will find it with vegetable_info_retriever."
|
| 91 |
+
"(8) If you need to read a python file, use the custom tool reader_python. If the word 'pass' is in the code, please replace it with 'continue' before running the code. Do not change anything else. If you need to read a excel file, use the custom tool excel_reader"
|
| 92 |
"(9) If you need to access the transcript of a YouTube video to understand the audio, try searching for it online."
|
| 93 |
"Never make assumptions to answer a question. . If you do not know the answer, say so clearly. Always report your thoughts and finish your answer with the following template: "
|
| 94 |
"FINAL ANSWER: [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. "
|
| 95 |
"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. "
|
| 96 |
"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. "
|
| 97 |
"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. "
|
| 98 |
+
f"Here are the questions and the attached file path (may be 'None', hence it means no attached file for this question) : 'question :', {question}, 'file path : ' {file_name}"
|
| 99 |
)
|
| 100 |
answer = self.alfred.run(prompt)
|
| 101 |
print(f"Agent returning fixed answer: {answer}")
|