BlueGod01 commited on
Commit
a40a26a
·
verified ·
1 Parent(s): 81917a3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +37 -1
app.py CHANGED
@@ -1,5 +1,13 @@
1
  import os
2
  import gradio as gr
 
 
 
 
 
 
 
 
3
  import requests
4
  import inspect
5
  import pandas as pd
@@ -40,7 +48,35 @@ def run_and_submit_all( profile: gr.OAuthProfile | None):
40
 
41
  # 1. Instantiate Agent ( modify this part to create your agent)
42
  try:
43
- agent = BasicAgent()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  except Exception as e:
45
  print(f"Error instantiating agent: {e}")
46
  return f"Error initializing agent: {e}", None
 
1
  import os
2
  import gradio as gr
3
+ from PIL import Image
4
+ from smolagents import (
5
+ CodeAgent,
6
+ HfApiModel,
7
+ DuckDuckGoSearchTool,
8
+ visit_webpage,
9
+ Tool
10
+ )
11
  import requests
12
  import inspect
13
  import pandas as pd
 
48
 
49
  # 1. Instantiate Agent ( modify this part to create your agent)
50
  try:
51
+
52
+ # 2. Instantiate Internet Search & Browsing Tools
53
+ ddg_search = DuckDuckGoSearchTool()
54
+
55
+ # 3. Create an Image Execution Tool from the Hugging Face Spaces Engine
56
+ image_generation_tool = Tool.from_space(
57
+ space_id="black-forest-labs/FLUX.1-schnell",
58
+ name="image_generator",
59
+ description="Generates a high-quality visual image based on a descriptive text prompt. Returns a PIL Image object."
60
+ )
61
+
62
+ # 4. Consolidate your toolbox array
63
+ all_tools = [
64
+ ddg_search,
65
+ visit_webpage,
66
+ image_generation_tool
67
+ ]
68
+
69
+ # 5. Initialize HfApiModel with the top-tier open-source GAIA benchmark model
70
+ # Qwen2.5-72B-Instruct provides elite multi-step execution logic over Serverless API infrastructure.
71
+ model = InferenceClientModel(model_id="Qwen/Qwen2.5-72B-Instruct")
72
+
73
+ # 6. Initialize the CodeAgent with the Serverless API backbone
74
+ agent = CodeAgent(
75
+ tools=all_tools,
76
+ model=model,
77
+ add_base_tools=True,
78
+ additional_authorized_imports=["time", "math", "json", "PIL"]
79
+ )
80
  except Exception as e:
81
  print(f"Error instantiating agent: {e}")
82
  return f"Error initializing agent: {e}", None