GhozlaneHadri commited on
Commit
9e93eef
·
verified ·
1 Parent(s): fb41e36

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -10
app.py CHANGED
@@ -1,22 +1,26 @@
1
  from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
2
  from tools.final_answer import FinalAnswerTool
3
- from Gradio_UI import GradioUI # assuming you created this file
4
 
5
- # You must define or import image_generator
6
- image_generator = HfApiModel("stabilityai/stable-diffusion-2") # Example model
7
 
8
- # Create the agent and register tools
 
 
 
9
  tools = [
10
  DuckDuckGoSearchTool(),
11
  FinalAnswerTool(),
12
- image_generator # This acts as a tool
13
  ]
14
 
15
- agent = CodeAgent(tools=tools)
 
16
 
17
  # Optional: You can run a test outside Gradio
18
- # image = image_generator(prompt="A high-quality, photorealistic image of a cat sleeping on a windowsill.")
19
- # final_answer(image)
20
 
21
- # Launch Gradio UI
22
- GradioUI(agent).launch()
 
1
  from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, load_tool, tool
2
  from tools.final_answer import FinalAnswerTool
3
+ from Gradio_UI import GradioUI
4
 
5
+ # Define your image generator tool
6
+ image_generator = HfApiModel("stabilityai/stable-diffusion-2")
7
 
8
+ # Example: Use Hugging Face API model as the LLM
9
+ llm_model = HfApiModel("mistralai/Mixtral-8x7B-Instruct-v0.1") # Example, you can use another model
10
+
11
+ # List of tools for the agent
12
  tools = [
13
  DuckDuckGoSearchTool(),
14
  FinalAnswerTool(),
15
+ image_generator
16
  ]
17
 
18
+ # Create the agent with model and tools
19
+ agent = CodeAgent(model=llm_model, tools=tools)
20
 
21
  # Optional: You can run a test outside Gradio
22
+ image = image_generator(prompt="A high-quality, photorealistic image of a cat sleeping on a windowsill.")
23
+ final_answer(image)
24
 
25
+ # Launch the Gradio UI
26
+ GradioUI(agent).launch()