Mahdiyar commited on
Commit
445de55
·
1 Parent(s): 9ce16b5

Switch Back to GPT 4.1 Mini. QWEN overthinked stuff:D

Browse files
Files changed (2) hide show
  1. app.py +10 -4
  2. helper.py +2 -1
app.py CHANGED
@@ -263,7 +263,11 @@ async def run_example():
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
@@ -287,13 +291,14 @@ async def run_example():
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-235B-A22B", 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,pip_packages=["tinyagent-py[all]","requests","cloudpickle"])
 
297
  agent.add_tool(python_interpreter.run_python)
298
 
299
 
@@ -343,6 +348,7 @@ async def run_example():
343
  share=False,
344
  prevent_thread_lock=True, # Critical to not block our event loop
345
  show_error=True,
 
346
  )
347
  ui_logger.info("Gradio interface launched (non-blocking).")
348
 
 
263
  ui_logger.info("--- Starting GradioCallback Example ---")
264
  # --- End Logging Setup ---
265
 
266
+ #api_key = os.environ.get("NEBIUS_API_KEY")
267
+ #model = "openai/Qwen/Qwen3-235B-A22B"
268
+ #model = "openai/Qwen/Qwen3-30B-A3B-fast"
269
+ model = "gpt-4.1-mini"
270
+ api_key = os.environ.get("OPENAI_API_KEY")
271
  if not api_key:
272
  ui_logger.error("NEBIUS_API_KEY environment variable not set.")
273
  return
 
291
  tools_meta_data[metadata["name"]] = metadata
292
  template_str = load_template("./prompts/code_agent.yaml")
293
  system_prompt = render_system_prompt(template_str, tools_meta_data, {}, ["tinyagent","gradio","requests","asyncio"]) + prompt_code_example + prompt_qwen_helper
294
+ agent = TinyAgent(model=model, api_key=api_key,
295
+ #model_kwargs=dict(base_url="https://api.studio.nebius.com/v1/"),
296
  logger=agent_logger,
297
  system_prompt=system_prompt,
298
 
299
  )
300
+ python_interpreter = PythonCodeInterpreter(log_manager=log_manager,code_tools=tools,pip_packages=["tinyagent-py[all]","requests","cloudpickle"],
301
+ default_python_codes=["import random","import requests","import cloudpickle","import tempfile","import shutil","import asyncio","import logging","import time"])
302
  agent.add_tool(python_interpreter.run_python)
303
 
304
 
 
348
  share=False,
349
  prevent_thread_lock=True, # Critical to not block our event loop
350
  show_error=True,
351
+ mcp_server=True,
352
  )
353
  ui_logger.info("Gradio interface launched (non-blocking).")
354
 
helper.py CHANGED
@@ -24,7 +24,8 @@ prompt_qwen_helper = dedent("""
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
  - When Task is not resolvable using functions available in your python enviroment, first think about creating a new function to solve the task, then ask the user about your approach and your code, if user allowed you to use it, then define and execute your custom made function. [It is your super power, you can create functions to solve the task.]
27
- """)
 
28
 
29
  def load_template(path: str) -> str:
30
  """
 
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
  - When Task is not resolvable using functions available in your python enviroment, first think about creating a new function to solve the task, then ask the user about your approach and your code, if user allowed you to use it, then define and execute your custom made function. [It is your super power, you can create functions to solve the task.]
27
+ - When you are defining a new function, you need to add any needed imports inside the function.
28
+ """)
29
 
30
  def load_template(path: str) -> str:
31
  """