Spaces:
Running
Running
Mahdiyar
commited on
Commit
·
dae0ada
1
Parent(s):
61c20c3
Switch to QWEN from OpenAI
Browse files- .gitignore +1 -0
- README.md +6 -0
- app.py +10 -6
- helper.py +8 -0
- requirements.txt +1 -1
.gitignore
ADDED
@@ -0,0 +1 @@
|
|
|
|
|
1 |
+
__pycache__/helper.cpython-311.pyc
|
README.md
CHANGED
@@ -27,6 +27,9 @@ TinyCodeAgent is an extention to [TinyAgent](https://github.com/askbudi/tinyagen
|
|
27 |
You can extend it using TinyAgent Hooks system, and use it with Gradio Integration.
|
28 |
Your agent could become a MCP Server or tool for another agent.
|
29 |
|
|
|
|
|
|
|
30 |
## Benefits
|
31 |
- Stateful python code using Modal Functions (Instead of using a sandbox, Faster and cheaper)
|
32 |
- Use TinyAgent Hooks system to extend your agent
|
@@ -34,6 +37,8 @@ Your agent could become a MCP Server or tool for another agent.
|
|
34 |
- Log System
|
35 |
- Storage
|
36 |
- Multi MCP Connections
|
|
|
|
|
37 |
|
38 |
|
39 |
|
@@ -52,3 +57,4 @@ Your agent could become a MCP Server or tool for another agent.
|
|
52 |
|
53 |
|
54 |
|
|
|
|
27 |
You can extend it using TinyAgent Hooks system, and use it with Gradio Integration.
|
28 |
Your agent could become a MCP Server or tool for another agent.
|
29 |
|
30 |
+
This Project is using **Qwen/Qwen3-30B-A3B-fast** from [Nebius](https://nebius.ai/) thanks to their support.
|
31 |
+
|
32 |
+
|
33 |
## Benefits
|
34 |
- Stateful python code using Modal Functions (Instead of using a sandbox, Faster and cheaper)
|
35 |
- Use TinyAgent Hooks system to extend your agent
|
|
|
37 |
- Log System
|
38 |
- Storage
|
39 |
- Multi MCP Connections
|
40 |
+
- Support Models through LiteLLM
|
41 |
+
|
42 |
|
43 |
|
44 |
|
|
|
57 |
|
58 |
|
59 |
|
60 |
+
|
app.py
CHANGED
@@ -8,6 +8,7 @@ import modal
|
|
8 |
import cloudpickle
|
9 |
|
10 |
|
|
|
11 |
def clean_response(resp):
|
12 |
return {k:v for k,v in resp.items() if k in ['printed_output','return_value','stderr','error_traceback']}
|
13 |
|
@@ -262,9 +263,9 @@ async def run_example():
|
|
262 |
ui_logger.info("--- Starting GradioCallback Example ---")
|
263 |
# --- End Logging Setup ---
|
264 |
|
265 |
-
api_key = os.environ.get("
|
266 |
if not api_key:
|
267 |
-
ui_logger.error("
|
268 |
return
|
269 |
|
270 |
# Create a temporary folder for file uploads
|
@@ -277,7 +278,7 @@ async def run_example():
|
|
277 |
|
278 |
# Initialize the agent
|
279 |
|
280 |
-
from helper import translate_tool_for_code_agent,load_template,render_system_prompt,prompt_code_example
|
281 |
tools = [get_weather,get_traffic]
|
282 |
|
283 |
tools_meta_data = {}
|
@@ -285,10 +286,13 @@ async def run_example():
|
|
285 |
metadata = translate_tool_for_code_agent(tool)
|
286 |
tools_meta_data[metadata["name"]] = metadata
|
287 |
template_str = load_template("./prompts/code_agent.yaml")
|
288 |
-
system_prompt = render_system_prompt(template_str, tools_meta_data, {}, ["tinyagent","gradio","requests","asyncio"]) + prompt_code_example
|
289 |
-
agent = TinyAgent(model="
|
|
|
290 |
logger=agent_logger,
|
291 |
-
system_prompt=system_prompt
|
|
|
|
|
292 |
python_interpreter = PythonCodeInterpreter(log_manager=log_manager,code_tools=tools)
|
293 |
agent.add_tool(python_interpreter.run_python)
|
294 |
|
|
|
8 |
import cloudpickle
|
9 |
|
10 |
|
11 |
+
|
12 |
def clean_response(resp):
|
13 |
return {k:v for k,v in resp.items() if k in ['printed_output','return_value','stderr','error_traceback']}
|
14 |
|
|
|
263 |
ui_logger.info("--- Starting GradioCallback Example ---")
|
264 |
# --- End Logging Setup ---
|
265 |
|
266 |
+
api_key = os.environ.get("NEBIUS_API_KEY")
|
267 |
if not api_key:
|
268 |
+
ui_logger.error("NEBIUS_API_KEY environment variable not set.")
|
269 |
return
|
270 |
|
271 |
# Create a temporary folder for file uploads
|
|
|
278 |
|
279 |
# Initialize the agent
|
280 |
|
281 |
+
from helper import translate_tool_for_code_agent,load_template,render_system_prompt,prompt_code_example,prompt_qwen_helper
|
282 |
tools = [get_weather,get_traffic]
|
283 |
|
284 |
tools_meta_data = {}
|
|
|
286 |
metadata = translate_tool_for_code_agent(tool)
|
287 |
tools_meta_data[metadata["name"]] = metadata
|
288 |
template_str = load_template("./prompts/code_agent.yaml")
|
289 |
+
system_prompt = render_system_prompt(template_str, tools_meta_data, {}, ["tinyagent","gradio","requests","asyncio"]) + prompt_code_example + prompt_qwen_helper
|
290 |
+
agent = TinyAgent(model="openai/Qwen/Qwen3-30B-A3B-fast", api_key=api_key,
|
291 |
+
model_kwargs=dict(base_url="https://api.studio.nebius.com/v1/"),
|
292 |
logger=agent_logger,
|
293 |
+
system_prompt=system_prompt,
|
294 |
+
|
295 |
+
)
|
296 |
python_interpreter = PythonCodeInterpreter(log_manager=log_manager,code_tools=tools)
|
297 |
agent.add_tool(python_interpreter.run_python)
|
298 |
|
helper.py
CHANGED
@@ -15,6 +15,14 @@ run_python("task='How the following repo has implemented Logging, and how can I
|
|
15 |
|
16 |
|
17 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
""")
|
19 |
|
20 |
def load_template(path: str) -> str:
|
|
|
15 |
|
16 |
|
17 |
|
18 |
+
""")
|
19 |
+
|
20 |
+
prompt_qwen_helper = dedent("""
|
21 |
+
|
22 |
+
**Your learning from past mistakes**
|
23 |
+
- User can't directly see the response of run_python tool, so you need to use final_answer or ask_question whenever you want to show a response to the user.
|
24 |
+
Other tools calls and their responses are not visible to the user.
|
25 |
+
- run_python is a capable tool, if you need to call a function with different arguments, you can do it in one take, just like you would do in a python code you developed to be executed in one cell of Jupyter Notebook Cell.
|
26 |
""")
|
27 |
|
28 |
def load_template(path: str) -> str:
|
requirements.txt
CHANGED
@@ -1,4 +1,4 @@
|
|
1 |
-
tinyagent-py[all]
|
2 |
cloudpickle
|
3 |
modal
|
4 |
jinja2
|
|
|
1 |
+
tinyagent-py[all]==0.0.7
|
2 |
cloudpickle
|
3 |
modal
|
4 |
jinja2
|