awacke1 commited on
Commit
2702048
ยท
verified ยท
1 Parent(s): 5858718

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
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 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
 
396
- tokenizer = AutoTokenizer.from_pretrained("HuggingFaceTB/SmolLM-135M")
397
- model = AutoModelForCausalLM.from_pretrained("HuggingFaceTB/SmolLM-135M")
 
 
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
- st.write("Agentic RAG Party Plan:")
419
- st.write(result)
420
- st.write("Party on, Wayne! ๐Ÿฆธโ€โ™‚๏ธ๐ŸŽ‰")
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!)")