Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,7 +29,7 @@ print("Loading LLM...")
|
|
| 29 |
chat = ChatMistralAI(
|
| 30 |
model="mistral-medium-2505",
|
| 31 |
temperature=0.1,
|
| 32 |
-
max_retries=
|
| 33 |
mistral_api_key = os.getenv("Mistral")
|
| 34 |
)
|
| 35 |
print(f"Model {chat.model} downloaded!")
|
|
@@ -133,7 +133,7 @@ run_code_tool = Tool(
|
|
| 133 |
description="Executes a python code."
|
| 134 |
)
|
| 135 |
|
| 136 |
-
tools = [get_file_path_tool, get_content_tool,
|
| 137 |
chat_with_tools = chat.bind_tools(tools, parallel_tool_calls=False)
|
| 138 |
|
| 139 |
|
|
@@ -175,6 +175,7 @@ system_prompt = SystemMessage(
|
|
| 175 |
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.\
|
| 176 |
If the question refers to an external content and there is no reference file attached, perform a web search and retrieve relevant information from the internet. \
|
| 177 |
If there is a file attached, open the file and read it. \
|
|
|
|
| 178 |
Make sure that each final answer is preceded with 'FINAL ANSWER:' and is short: it should contain a number (without full stop at the end), a string (one or two words only, without full stop at the end) or a comma-separated list (without full stops at the end), nothing else. "
|
| 179 |
)
|
| 180 |
|
|
@@ -186,7 +187,7 @@ class BasicAgent:
|
|
| 186 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 187 |
message = HumanMessage(content=question)
|
| 188 |
print(message)
|
| 189 |
-
answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit":
|
| 190 |
answer = "".join(re.findall(r'(FINAL ANSWER.*)', answer, flags=re.M))
|
| 191 |
answer = answer.replace('FINAL ANSWER:', '')
|
| 192 |
answer = answer.replace('FINAL ANSWER', '')
|
|
|
|
| 29 |
chat = ChatMistralAI(
|
| 30 |
model="mistral-medium-2505",
|
| 31 |
temperature=0.1,
|
| 32 |
+
max_retries=3,
|
| 33 |
mistral_api_key = os.getenv("Mistral")
|
| 34 |
)
|
| 35 |
print(f"Model {chat.model} downloaded!")
|
|
|
|
| 133 |
description="Executes a python code."
|
| 134 |
)
|
| 135 |
|
| 136 |
+
tools = [get_file_path_tool, get_content_tool, search_web_tool, extract_text_tool, play_chess_tool, run_code_tool]
|
| 137 |
chat_with_tools = chat.bind_tools(tools, parallel_tool_calls=False)
|
| 138 |
|
| 139 |
|
|
|
|
| 175 |
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.\
|
| 176 |
If the question refers to an external content and there is no reference file attached, perform a web search and retrieve relevant information from the internet. \
|
| 177 |
If there is a file attached, open the file and read it. \
|
| 178 |
+
If there is a code, execute it.
|
| 179 |
Make sure that each final answer is preceded with 'FINAL ANSWER:' and is short: it should contain a number (without full stop at the end), a string (one or two words only, without full stop at the end) or a comma-separated list (without full stops at the end), nothing else. "
|
| 180 |
)
|
| 181 |
|
|
|
|
| 187 |
print(f"Agent received question (first 50 chars): {question[:50]}...")
|
| 188 |
message = HumanMessage(content=question)
|
| 189 |
print(message)
|
| 190 |
+
answer = alfred.invoke(input={"messages": [system_prompt, message]},config={"recursion_limit": 3})['messages'][-1].content
|
| 191 |
answer = "".join(re.findall(r'(FINAL ANSWER.*)', answer, flags=re.M))
|
| 192 |
answer = answer.replace('FINAL ANSWER:', '')
|
| 193 |
answer = answer.replace('FINAL ANSWER', '')
|