Update app.py
#590
by Thanatos39 - opened
app.py
CHANGED
|
@@ -193,4 +193,46 @@ if __name__ == "__main__":
|
|
| 193 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
| 194 |
|
| 195 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
| 196 |
-
demo.launch(debug=True, share=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
print("-"*(60 + len(" App Starting ")) + "\n")
|
| 194 |
|
| 195 |
print("Launching Gradio Interface for Basic Agent Evaluation...")
|
| 196 |
+
demo.launch(debug=True, share=False)
|
| 197 |
+
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
# ==========================================
|
| 201 |
+
# SECTION 1: IMPORTS & TOOL DEFINITIONS
|
| 202 |
+
# ==========================================
|
| 203 |
+
from smolagents import CodeAgent, LiteLLMModel, tool
|
| 204 |
+
import pandas as pd
|
| 205 |
+
import requests
|
| 206 |
+
from bs4 import BeautifulSoup
|
| 207 |
+
|
| 208 |
+
# Paste your custom high-yield tools here
|
| 209 |
+
@tool
|
| 210 |
+
def inspect_dataframe(file_path: str, operation: str, query_code: str = None) -> str:
|
| 211 |
+
# (Your dataframe tool logic here...)
|
| 212 |
+
pass
|
| 213 |
+
|
| 214 |
+
@tool
|
| 215 |
+
def fetch_webpage_content(url: str) -> str:
|
| 216 |
+
# (Your scraper tool logic here...)
|
| 217 |
+
pass
|
| 218 |
+
|
| 219 |
+
# ==========================================
|
| 220 |
+
# SECTION 2: INITIALIZE THE INTENT ENGINE
|
| 221 |
+
# ==========================================
|
| 222 |
+
# Ensure you have set your HF_TOKEN secret in Space Settings!
|
| 223 |
+
model = LiteLLMModel(model_id="huggingface/Qwen/Qwen2.5-Coder-32B-Instruct")
|
| 224 |
+
|
| 225 |
+
# Instantiate your agent with the tools attached
|
| 226 |
+
agent = CodeAgent(
|
| 227 |
+
tools=[inspect_dataframe, fetch_webpage_content],
|
| 228 |
+
model=model,
|
| 229 |
+
additional_authorized_imports=["pandas", "numpy", "json", "datetime", "re", "bs4"]
|
| 230 |
+
)
|
| 231 |
+
|
| 232 |
+
# ==========================================
|
| 233 |
+
# SECTION 3: CONNECT TO THE TEMPLATE RUNNER
|
| 234 |
+
# ==========================================
|
| 235 |
+
# The original template space comes with a Gradio UI block or a loop
|
| 236 |
+
# that cycles through questions. Leave that layout block intact at the bottom.
|
| 237 |
+
# Inside that function block where it evaluates user questions, change it to call your agent:
|
| 238 |
+
# e.g., raw_output = agent.run(evaluation_question)
|