Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -14,14 +14,16 @@ from smolagents import CodeAgent, DuckDuckGoSearchTool, tool, InferenceClientMod
|
|
| 14 |
|
| 15 |
# 0. SHARED CONFIG
|
| 16 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
|
|
|
|
|
|
| 17 |
|
| 18 |
# ==========================================
|
| 19 |
# PART 1: LLAMAINDEX AGENT
|
| 20 |
# ==========================================
|
| 21 |
li_llm = HuggingFaceInferenceAPI(
|
| 22 |
-
model_name=
|
| 23 |
token=HF_TOKEN,
|
| 24 |
-
provider="together"
|
| 25 |
)
|
| 26 |
|
| 27 |
def get_tokyo_time() -> str:
|
|
@@ -47,7 +49,7 @@ async def chat_llama(message, history):
|
|
| 47 |
# PART 2: SMOLAGENTS
|
| 48 |
# ==========================================
|
| 49 |
smol_model = InferenceClientModel(
|
| 50 |
-
model_id=
|
| 51 |
token=HF_TOKEN,
|
| 52 |
provider="together"
|
| 53 |
)
|
|
@@ -60,7 +62,6 @@ def weather_tool(location: str) -> str:
|
|
| 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,10 +75,11 @@ def chat_smol(message, history):
|
|
| 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("# 🤖
|
|
|
|
| 81 |
|
| 82 |
with gr.Tab("LlamaIndex (Workflow)"):
|
| 83 |
gr.ChatInterface(fn=chat_llama)
|
|
|
|
| 14 |
|
| 15 |
# 0. SHARED CONFIG
|
| 16 |
HF_TOKEN = os.getenv("HF_TOKEN")
|
| 17 |
+
# 7B is the sweet spot for free serverless inference in 2026
|
| 18 |
+
MODEL_ID = "Qwen/Qwen2.5-7B-Instruct"
|
| 19 |
|
| 20 |
# ==========================================
|
| 21 |
# PART 1: LLAMAINDEX AGENT
|
| 22 |
# ==========================================
|
| 23 |
li_llm = HuggingFaceInferenceAPI(
|
| 24 |
+
model_name=MODEL_ID,
|
| 25 |
token=HF_TOKEN,
|
| 26 |
+
provider="together"
|
| 27 |
)
|
| 28 |
|
| 29 |
def get_tokyo_time() -> str:
|
|
|
|
| 49 |
# PART 2: SMOLAGENTS
|
| 50 |
# ==========================================
|
| 51 |
smol_model = InferenceClientModel(
|
| 52 |
+
model_id=MODEL_ID,
|
| 53 |
token=HF_TOKEN,
|
| 54 |
provider="together"
|
| 55 |
)
|
|
|
|
| 62 |
"""
|
| 63 |
return f"The weather in {location} is currently sunny and 22°C."
|
| 64 |
|
|
|
|
| 65 |
smol_agent = CodeAgent(
|
| 66 |
model=smol_model,
|
| 67 |
tools=[weather_tool, DuckDuckGoSearchTool()]
|
|
|
|
| 75 |
return f"Smolagents Error: {str(e)}"
|
| 76 |
|
| 77 |
# ==========================================
|
| 78 |
+
# PART 3: UNIFIED GRADIO UI
|
| 79 |
# ==========================================
|
| 80 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
| 81 |
+
gr.Markdown("# 🤖 Consolidated AI Agent Space")
|
| 82 |
+
gr.Markdown(f"Currently using **{MODEL_ID}** via Together AI Provider.")
|
| 83 |
|
| 84 |
with gr.Tab("LlamaIndex (Workflow)"):
|
| 85 |
gr.ChatInterface(fn=chat_llama)
|