matterattetatte's picture
Update app.py
384493e verified
import streamlit as st
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, ManagedAgent
examples = """
Here are a few examples:
Task: Today, I had an appointment with Bella, a 5-year-old Golden Retriever owned by John Smith. She came in for her annual check-up. Bella weighs 25 kilograms and is in great condition overall.
During the exam, I checked her vital signs: her temperature was 38.5°C, her heart rate was 80 bpm, and her respiratory rate was 20 breaths per minute—all perfectly normal. Her coat was shiny and free of any abnormalities, her eyes were clear with no discharge, and her ears showed no signs of infection. I did notice some mild tartar on her teeth, which I mentioned to John, and her skin was healthy with no rashes or lesions.
As part of her routine care, I administered her rabies vaccine, which was due, and confirmed that her distemper vaccination is up to date. We also performed a fecal test and a heartworm test, both of which came back negative.
For prevention, I prescribed her a monthly heartworm medication and provided her with flea and tick prevention. I told John that Bella is healthy and has no current health concerns. I recommended he continue her balanced diet, keep up her regular exercise, and return in a year for her next check-up.
It was a pleasure to see Bella, and I look forward to her next visit. – Dr. Emily Carter
Final answer:
Date of Visit January 9, 2025
Pet's Name Bella
Species Dog
Breed Golden Retriever
Age 5 years
Weight 25 kg
Owner's Name John Smith
Reason for Visit Annual Check-up
Vital Signs - Temperature: 38.5°C
- Heart Rate: 80 bpm
- Respiratory Rate: 20/min
Physical Exam - Coat: Shiny, no abnormalities
- Eyes: Clear, no discharge
- Ears: No signs of infection
- Teeth: Mild tartar
- Skin: No rashes or lesions
Vaccinations - Rabies Vaccine: Administered
- Distemper: Up to date
Tests Performed - Fecal Test: Negative
- Heartworm Test: Negative
Medications - Monthly Heartworm Prevention prescribed
- Flea and Tick prevention given
Diagnosis Healthy; No concerns detected
Recommendations - Continue balanced diet
- Regular exercise
- Return in 1 year for next annual check-up
Veterinarian Dr. Emily Carter
"""
sys_admin_prompt = f"""
You are a systems admin at a veterinary clinic. It is your job to organize my reports.
Here is my report:
{{task}}
Here are a few examples of previous tasks
{{additional_prompting}}
"""
admin_agent = CodeAgent(
tools=[],
model=HfApiModel(),
)
managed_admin_agent = ManagedAgent(
agent=admin_agent,
name="system admin",
managed_agent_prompt=sys_admin_prompt,
additional_prompting=examples,
description="Returns a rough draft of an organized report",
)
manager_agent = CodeAgent(
tools=[],
model=HfApiModel(),
managed_agents=[managed_admin_agent],
)
# Function to log agent actions
def log_agent_action(prompt, result, agent_name):
st.write(f"### Agent Activity ({agent_name}):")
st.write("**Prompt Sent to Agent:**")
st.code(prompt, language="text")
st.write("**Agent Output:**")
st.code(result, language="text")
# Streamlit app title
st.title("AI Veterinary Assistant Agent that summarizes reports in an organized way.")
# App description
st.write("Generate reports enriched with real-time insights using the AI Veterinary Report Writing Agent powered by SmolAgents and DuckDuckGo.")
# Input blog topic or prompt
prompt = st.text_area("Enter your search", placeholder="E.g., Today, I helped Max, a 5 year old Chihuahua")
# Button to generate blog content
if st.button("Generate Report"):
if prompt:
with st.spinner("Generating content..."):
try:
# Run the blog agent with the given prompt
result = manager_agent.run(prompt)
# Display the generated blog content
st.subheader("Generated Report:")
st.write(result)
# Log backend activity
log_agent_action(prompt, result, "Research Agent with DuckDuckGo")
except Exception as e:
st.error(f"An error occurred: {e}")
else:
st.warning("Please enter a blog topic or prompt to proceed.")
# Footer
st.markdown("---")
st.caption("Powered by SmolAgents, DuckDuckGo, and Streamlit")