extends notebook
Browse files- notebook.ipynb +25 -13
- prompts.yaml +19 -0
notebook.ipynb
CHANGED
|
@@ -32,27 +32,40 @@
|
|
| 32 |
"metadata": {},
|
| 33 |
"outputs": [],
|
| 34 |
"source": [
|
| 35 |
-
"
|
| 36 |
-
"\n",
|
| 37 |
-
"#print(dir(smolagents.models))\n",
|
| 38 |
-
"#print(smolagents.__version__)\n",
|
| 39 |
-
"\n",
|
| 40 |
"\n",
|
|
|
|
|
|
|
| 41 |
"from tools import fetch_file\n",
|
| 42 |
"\n",
|
| 43 |
-
"model = InferenceClientModel(model_id=\"Qwen/
|
| 44 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
"\n",
|
| 46 |
"#from app import BasicAgent\n",
|
| 47 |
"\n",
|
| 48 |
-
"
|
| 49 |
"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.\n",
|
| 50 |
"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.\n",
|
| 51 |
"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.\n",
|
| 52 |
"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. \n",
|
|
|
|
|
|
|
| 53 |
"\"\"\"\n",
|
| 54 |
"\n",
|
| 55 |
-
"agent = CodeAgent(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
"\n",
|
| 57 |
"\n"
|
| 58 |
]
|
|
@@ -80,13 +93,12 @@
|
|
| 80 |
" }\n",
|
| 81 |
"\n",
|
| 82 |
"question_text = item[\"question\"]\n",
|
|
|
|
| 83 |
"\n",
|
| 84 |
-
"
|
| 85 |
-
"\n",
|
| 86 |
-
"print(f\"Question: {question}\")\n",
|
| 87 |
"\n",
|
| 88 |
"#task_id = item[\"task_id\"]\n",
|
| 89 |
-
"submitted_answer = agent(
|
| 90 |
]
|
| 91 |
}
|
| 92 |
],
|
|
|
|
| 32 |
"metadata": {},
|
| 33 |
"outputs": [],
|
| 34 |
"source": [
|
| 35 |
+
"import yaml\n",
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
"\n",
|
| 37 |
+
"from smolagents import CodeAgent, Tool, InferenceClientModel, DuckDuckGoSearchTool, WikipediaSearchTool\n",
|
| 38 |
+
"from smolagents import OpenAIServerModel\n",
|
| 39 |
"from tools import fetch_file\n",
|
| 40 |
"\n",
|
| 41 |
+
"#model = InferenceClientModel(model_id=\"Qwen/Qwen3-32B\", provider=\"nscale\")\n",
|
| 42 |
+
"model = InferenceClientModel(model_id=\"deepseek-ai/DeepSeek-R1-Distill-Llama-70B\", provider=\"nscale\")\n",
|
| 43 |
+
"\n",
|
| 44 |
+
"# Set your Gemini API key in the environment variable GEMINI_API_KEY_1\n",
|
| 45 |
+
"#model = OpenAIServerModel(\n",
|
| 46 |
+
"# model_id=\"gemini-2.5-flash\", \n",
|
| 47 |
+
"# api_base=\"https://generativelanguage.googleapis.com/v1beta\", \n",
|
| 48 |
+
"# api_key=os.getenv(\"GEMINI_API_KEY_1\")\n",
|
| 49 |
+
"# ) \n",
|
| 50 |
+
"#print('API key was found:', os.getenv(\"GEMINI_API_KEY_1\") is not None)\n",
|
| 51 |
"\n",
|
| 52 |
"#from app import BasicAgent\n",
|
| 53 |
"\n",
|
| 54 |
+
"system_prompt = \"\"\"You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template: \n",
|
| 55 |
"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.\n",
|
| 56 |
"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.\n",
|
| 57 |
"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.\n",
|
| 58 |
"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. \n",
|
| 59 |
+
"\n",
|
| 60 |
+
"Here is the question: {question}\n",
|
| 61 |
"\"\"\"\n",
|
| 62 |
"\n",
|
| 63 |
+
"agent = CodeAgent(\n",
|
| 64 |
+
" model=model, \n",
|
| 65 |
+
" tools=[fetch_file, DuckDuckGoSearchTool(), WikipediaSearchTool()], \n",
|
| 66 |
+
" add_base_tools=True,\n",
|
| 67 |
+
" additional_authorized_imports=['requests', 'bs4'] \n",
|
| 68 |
+
" )\n",
|
| 69 |
"\n",
|
| 70 |
"\n"
|
| 71 |
]
|
|
|
|
| 93 |
" }\n",
|
| 94 |
"\n",
|
| 95 |
"question_text = item[\"question\"]\n",
|
| 96 |
+
"prompt_with_question = system_prompt.format(question=question_text)\n",
|
| 97 |
"\n",
|
| 98 |
+
"print(f\"Question: {prompt_with_question}\")\n",
|
|
|
|
|
|
|
| 99 |
"\n",
|
| 100 |
"#task_id = item[\"task_id\"]\n",
|
| 101 |
+
"submitted_answer = agent(prompt_with_question)\n"
|
| 102 |
]
|
| 103 |
}
|
| 104 |
],
|
prompts.yaml
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"system_prompt": |-
|
| 2 |
+
You are a general AI assistant. I will ask you a question. Report your thoughts, and finish your answer with the following template:
|
| 3 |
+
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.
|
| 4 |
+
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.
|
| 5 |
+
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.
|
| 6 |
+
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.
|
| 7 |
+
"planning" :
|
| 8 |
+
"initial_facts": ""
|
| 9 |
+
"initial_plan": ""
|
| 10 |
+
"update_facts_pre_messages": ""
|
| 11 |
+
"update_facts_post_messages": ""
|
| 12 |
+
"update_plan_pre_messages": ""
|
| 13 |
+
"update_plan_post_messages": ""
|
| 14 |
+
"managed_agent":
|
| 15 |
+
"task": ""
|
| 16 |
+
"report": ""
|
| 17 |
+
"final_answer":
|
| 18 |
+
"pre_messages": ""
|
| 19 |
+
"post_messages": ""
|