YoussefSharawy91 commited on
Commit
712c0eb
·
verified ·
1 Parent(s): c964594

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -7
app.py CHANGED
@@ -4,9 +4,6 @@ import streamlit as st
4
  from smolagents import load_tool, CodeAgent, HfApiModel, DuckDuckGoSearchTool
5
  from huggingface_hub import InferenceClient
6
 
7
- # Import the image generation tool from the Hub
8
- image_generation_tool = load_tool("m-ric/text-to-image", trust_remote_code=True)
9
-
10
  # Instantiate the DuckDuckGo search tool from SmolAgents
11
  search_tool = DuckDuckGoSearchTool()
12
 
@@ -21,8 +18,8 @@ client = InferenceClient(token=hf_token)
21
  # Initialize the SmolAgent model
22
  model = HfApiModel(model_id="meta-llama/Llama-3.2-3B-Instruct", token=hf_token)
23
 
24
- # Create the agent with both the search and image generation tools
25
- agent = CodeAgent(tools=[search_tool, image_generation_tool], model=model)
26
 
27
  def apply_custom_styles():
28
  st.markdown(
@@ -93,11 +90,11 @@ def main():
93
  user_input = st.session_state["user_input"]
94
  if user_input.strip():
95
  try:
96
- # Instruct Tom Riddle to use web search efficiently only when unsure.
97
  response = agent.run(
98
  f"You are Tom Riddle, a cunning and enigmatic character from Harry Potter. "
99
  f"Answer the user's query clearly and concisely in your distinct persona. "
100
- f"If you are not certain of your answer, only then use your available tools (DuckDuckGo search and image generation) to quickly gather necessary insights—doing so efficiently without causing delays. "
101
  f"Finally, produce your answer in your characteristic voice without revealing your internal process. "
102
  f"User Query: {user_input}"
103
  )
 
4
  from smolagents import load_tool, CodeAgent, HfApiModel, DuckDuckGoSearchTool
5
  from huggingface_hub import InferenceClient
6
 
 
 
 
7
  # Instantiate the DuckDuckGo search tool from SmolAgents
8
  search_tool = DuckDuckGoSearchTool()
9
 
 
18
  # Initialize the SmolAgent model
19
  model = HfApiModel(model_id="meta-llama/Llama-3.2-3B-Instruct", token=hf_token)
20
 
21
+ # Create the agent with only the search tool
22
+ agent = CodeAgent(tools=[search_tool], model=model)
23
 
24
  def apply_custom_styles():
25
  st.markdown(
 
90
  user_input = st.session_state["user_input"]
91
  if user_input.strip():
92
  try:
93
+ # Instruct Tom Riddle to use the search tool only when uncertain, efficiently.
94
  response = agent.run(
95
  f"You are Tom Riddle, a cunning and enigmatic character from Harry Potter. "
96
  f"Answer the user's query clearly and concisely in your distinct persona. "
97
+ f"If you are not certain of your answer, only then use your available DuckDuckGo search tool to quickly gather the necessary insights—doing so efficiently without causing delays. "
98
  f"Finally, produce your answer in your characteristic voice without revealing your internal process. "
99
  f"User Query: {user_input}"
100
  )