Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,10 +19,9 @@ HF_TOKEN = os.getenv("HF_TOKEN")
|
|
| 19 |
# PART 1: LLAMAINDEX AGENT
|
| 20 |
# ==========================================
|
| 21 |
li_llm = HuggingFaceInferenceAPI(
|
| 22 |
-
# Explicitly using a model-id that is supported by Inference Providers
|
| 23 |
model_name="Qwen/Qwen2.5-7B-Instruct",
|
| 24 |
token=HF_TOKEN,
|
| 25 |
-
provider="together" #
|
| 26 |
)
|
| 27 |
|
| 28 |
def get_tokyo_time() -> str:
|
|
@@ -50,7 +49,7 @@ async def chat_llama(message, history):
|
|
| 50 |
smol_model = InferenceClientModel(
|
| 51 |
model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 52 |
token=HF_TOKEN,
|
| 53 |
-
provider="together"
|
| 54 |
)
|
| 55 |
|
| 56 |
@tool
|
|
@@ -61,6 +60,7 @@ def weather_tool(location: str) -> str:
|
|
| 61 |
"""
|
| 62 |
return f"The weather in {location} is currently sunny and 22°C."
|
| 63 |
|
|
|
|
| 64 |
smol_agent = CodeAgent(
|
| 65 |
model=smol_model,
|
| 66 |
tools=[weather_tool, DuckDuckGoSearchTool()]
|
|
@@ -74,11 +74,10 @@ def chat_smol(message, history):
|
|
| 74 |
return f"Smolagents Error: {str(e)}"
|
| 75 |
|
| 76 |
# ==========================================
|
| 77 |
-
# PART 3:
|
| 78 |
# ==========================================
|
| 79 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 80 |
-
gr.Markdown("# 🤖 Dual-Agent
|
| 81 |
-
gr.Markdown("Comparing **Event-Driven Workflows** (LlamaIndex) vs **Code Execution** (smolagents).")
|
| 82 |
|
| 83 |
with gr.Tab("LlamaIndex (Workflow)"):
|
| 84 |
gr.ChatInterface(fn=chat_llama)
|
|
|
|
| 19 |
# PART 1: LLAMAINDEX AGENT
|
| 20 |
# ==========================================
|
| 21 |
li_llm = HuggingFaceInferenceAPI(
|
|
|
|
| 22 |
model_name="Qwen/Qwen2.5-7B-Instruct",
|
| 23 |
token=HF_TOKEN,
|
| 24 |
+
provider="together" # Routing through a stable provider
|
| 25 |
)
|
| 26 |
|
| 27 |
def get_tokyo_time() -> str:
|
|
|
|
| 49 |
smol_model = InferenceClientModel(
|
| 50 |
model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
|
| 51 |
token=HF_TOKEN,
|
| 52 |
+
provider="together"
|
| 53 |
)
|
| 54 |
|
| 55 |
@tool
|
|
|
|
| 60 |
"""
|
| 61 |
return f"The weather in {location} is currently sunny and 22°C."
|
| 62 |
|
| 63 |
+
# Ensure ddgs is installed via requirements.txt for this to work
|
| 64 |
smol_agent = CodeAgent(
|
| 65 |
model=smol_model,
|
| 66 |
tools=[weather_tool, DuckDuckGoSearchTool()]
|
|
|
|
| 74 |
return f"Smolagents Error: {str(e)}"
|
| 75 |
|
| 76 |
# ==========================================
|
| 77 |
+
# PART 3: GRADIO UI
|
| 78 |
# ==========================================
|
| 79 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 80 |
+
gr.Markdown("# 🤖 Dual-Agent Framework Comparison")
|
|
|
|
| 81 |
|
| 82 |
with gr.Tab("LlamaIndex (Workflow)"):
|
| 83 |
gr.ChatInterface(fn=chat_llama)
|