Spaces:
Runtime error
Runtime error
add notebook for testing
Browse files- notebook.ipynb +99 -0
notebook.ipynb
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"cells": [
|
3 |
+
{
|
4 |
+
"cell_type": "markdown",
|
5 |
+
"id": "cb28dbf0",
|
6 |
+
"metadata": {},
|
7 |
+
"source": [
|
8 |
+
"#### Do the imports and prepare the agent code"
|
9 |
+
]
|
10 |
+
},
|
11 |
+
{
|
12 |
+
"cell_type": "code",
|
13 |
+
"execution_count": null,
|
14 |
+
"id": "6cff8644",
|
15 |
+
"metadata": {},
|
16 |
+
"outputs": [],
|
17 |
+
"source": [
|
18 |
+
"import os\n",
|
19 |
+
"token = os.getenv(\"HF_TOKEN\")\n",
|
20 |
+
"\n",
|
21 |
+
"if token is None:\n",
|
22 |
+
" raise ValueError('You must set the HF_TOKEN environment variable')\n",
|
23 |
+
"else:\n",
|
24 |
+
" print('Token was found')\n",
|
25 |
+
" #print('Token:', token)\n"
|
26 |
+
]
|
27 |
+
},
|
28 |
+
{
|
29 |
+
"cell_type": "code",
|
30 |
+
"execution_count": null,
|
31 |
+
"id": "a414cce1",
|
32 |
+
"metadata": {},
|
33 |
+
"outputs": [],
|
34 |
+
"source": [
|
35 |
+
"from smolagents import CodeAgent, Tool, InferenceClientModel\n",
|
36 |
+
"from tools import fetch_file\n",
|
37 |
+
"\n",
|
38 |
+
"#model = InferenceClientModel(model_id=\"Qwen/Qwen2.5-Coder-7B-Instruct\", provider=\"nscale\")\n",
|
39 |
+
"model = InferenceClientModel()\n",
|
40 |
+
"\n",
|
41 |
+
"from app import BasicAgent\n",
|
42 |
+
"\n",
|
43 |
+
"agent = CodeAgent(tools=[fetch_file], model=model, additional_authorized_imports=['requests', 'bs4'])\n",
|
44 |
+
"\n",
|
45 |
+
"\n"
|
46 |
+
]
|
47 |
+
},
|
48 |
+
{
|
49 |
+
"cell_type": "markdown",
|
50 |
+
"id": "9190ad36",
|
51 |
+
"metadata": {},
|
52 |
+
"source": [
|
53 |
+
"Run first question against agent"
|
54 |
+
]
|
55 |
+
},
|
56 |
+
{
|
57 |
+
"cell_type": "code",
|
58 |
+
"execution_count": null,
|
59 |
+
"id": "09b50aa1",
|
60 |
+
"metadata": {},
|
61 |
+
"outputs": [],
|
62 |
+
"source": [
|
63 |
+
"item = {\n",
|
64 |
+
" \"task_id\": \"8e867cd7-cff9-4e6c-867a-ff5ddc2550be\",\n",
|
65 |
+
" \"question\": \"How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia.\",\n",
|
66 |
+
" \"Level\": \"1\",\n",
|
67 |
+
" \"file_name\": \"\"\n",
|
68 |
+
" }\n",
|
69 |
+
"\n",
|
70 |
+
"question_text = item[\"question\"]\n",
|
71 |
+
"print(f\"Question: {question_text}\")\n",
|
72 |
+
"\n",
|
73 |
+
"task_id = item[\"task_id\"]\n",
|
74 |
+
"submitted_answer = agent(question_text)\n"
|
75 |
+
]
|
76 |
+
}
|
77 |
+
],
|
78 |
+
"metadata": {
|
79 |
+
"kernelspec": {
|
80 |
+
"display_name": "Python 3",
|
81 |
+
"language": "python",
|
82 |
+
"name": "python3"
|
83 |
+
},
|
84 |
+
"language_info": {
|
85 |
+
"codemirror_mode": {
|
86 |
+
"name": "ipython",
|
87 |
+
"version": 3
|
88 |
+
},
|
89 |
+
"file_extension": ".py",
|
90 |
+
"mimetype": "text/x-python",
|
91 |
+
"name": "python",
|
92 |
+
"nbconvert_exporter": "python",
|
93 |
+
"pygments_lexer": "ipython3",
|
94 |
+
"version": "3.13.5"
|
95 |
+
}
|
96 |
+
},
|
97 |
+
"nbformat": 4,
|
98 |
+
"nbformat_minor": 5
|
99 |
+
}
|