Spaces:
Sleeping
Sleeping
File size: 5,113 Bytes
23f2703 2bcb787 c9f0eeb 23f2703 7bf11dd 23f2703 2bcb787 c9f0eeb 2bcb787 c9f0eeb 2bcb787 c9f0eeb 2bcb787 c9f0eeb 2bcb787 c9f0eeb 2bcb787 c9f0eeb 2bcb787 c9f0eeb 23f2703 c9f0eeb |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
import streamlit as st
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel
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
"""
"""You're a helpful agent named '{name}'.
You have been submitted this task by your manager.
---
Task:
{task}
---
You're helping your manager solve a wider task: so make sure to not provide a one-line answer, but give as much information as possible to give them a clear understanding of the answer.
Your final_answer WILL HAVE to contain these parts:
### 1. Task outcome (short version):
### 2. Task outcome (extremely detailed version):
### 3. Additional context (if relevant):
Put all these in your final_answer tool, everything that you do not pass as an argument to final_answer will be lost.
And even if your task resolution is not successful, please return as much context as possible, so that your manager can act upon this feedback.
{{additional_prompting}}"""
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(),
max_steps=6,
)
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],
max_steps=6,
)
# 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 organizing reports")
# 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 the description of your patient visit:", 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 blog 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, "Blog Writing 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")
|