Update app.py
Browse files
app.py
CHANGED
@@ -387,18 +387,21 @@ if st.button("Generate"):
|
|
387 |
|
388 |
with tab4:
|
389 |
st.header("Agentic RAG Party ๐ (Party Like Itโs 2099!)")
|
390 |
-
st.write("This demo uses
|
391 |
|
392 |
if st.button("Run Agentic RAG Demo ๐"):
|
393 |
try:
|
394 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool
|
|
|
395 |
|
396 |
-
tokenizer
|
397 |
-
|
|
|
|
|
398 |
|
|
|
399 |
agent = CodeAgent(
|
400 |
model=model,
|
401 |
-
tokenizer=tokenizer,
|
402 |
tools=[DuckDuckGoSearchTool(), VisitWebpageTool(), calculate_cargo_travel_time],
|
403 |
additional_authorized_imports=["pandas"],
|
404 |
planning_interval=5,
|
@@ -415,10 +418,12 @@ Add a random superhero catchphrase to each entry for fun!
|
|
415 |
"""
|
416 |
with st.spinner("Planning the ultimate superhero bash... โณ (Calling all caped crusaders!)"):
|
417 |
result = agent.run(task)
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
except ImportError:
|
422 |
-
st.error("Please install required packages: `pip install smolagents pandas`")
|
|
|
|
|
423 |
except Exception as e:
|
424 |
st.error(f"Error running demo: {str(e)} (Even Batman has off days!)")
|
|
|
387 |
|
388 |
with tab4:
|
389 |
st.header("Agentic RAG Party ๐ (Party Like Itโs 2099!)")
|
390 |
+
st.write("This demo uses Tiny Titans with Agentic RAG to plan a superhero party, powered by DuckDuckGo retrieval!")
|
391 |
|
392 |
if st.button("Run Agentic RAG Demo ๐"):
|
393 |
try:
|
394 |
from smolagents import CodeAgent, DuckDuckGoSearchTool, VisitWebpageTool
|
395 |
+
from transformers import AutoModelForCausalLM
|
396 |
|
397 |
+
# Load the model without separate tokenizer for agent
|
398 |
+
with st.spinner("Loading SmolLM-135M... โณ (Titanโs suiting up!)"):
|
399 |
+
model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM-135M")
|
400 |
+
st.write("Model loaded! ๐ฆธโโ๏ธ (Ready to party!)")
|
401 |
|
402 |
+
# Initialize agent without tokenizer argument
|
403 |
agent = CodeAgent(
|
404 |
model=model,
|
|
|
405 |
tools=[DuckDuckGoSearchTool(), VisitWebpageTool(), calculate_cargo_travel_time],
|
406 |
additional_authorized_imports=["pandas"],
|
407 |
planning_interval=5,
|
|
|
418 |
"""
|
419 |
with st.spinner("Planning the ultimate superhero bash... โณ (Calling all caped crusaders!)"):
|
420 |
result = agent.run(task)
|
421 |
+
st.write("Agentic RAG Party Plan:")
|
422 |
+
st.write(result)
|
423 |
+
st.write("Party on, Wayne! ๐ฆธโโ๏ธ๐")
|
424 |
except ImportError:
|
425 |
+
st.error("Please install required packages: `pip install smolagents pandas transformers`")
|
426 |
+
except TypeError as e:
|
427 |
+
st.error(f"Agent setup failed: {str(e)} (Looks like the Titans need a tune-up!)")
|
428 |
except Exception as e:
|
429 |
st.error(f"Error running demo: {str(e)} (Even Batman has off days!)")
|