File size: 2,429 Bytes
23f2703
b970e0d
23f2703
2bcb787
af2f617
b970e0d
2bcb787
 
 
af2f617
 
 
 
2bcb787
 
 
 
af2f617
 
 
 
c9f0eeb
23f2703
7bf11dd
 
 
 
 
 
 
 
23f2703
af2f617
c9f0eeb
 
2bcb787
c9f0eeb
 
2bcb787
c9f0eeb
 
2bcb787
 
 
c9f0eeb
 
2bcb787
c9f0eeb
2bcb787
 
c9f0eeb
 
af2f617
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
import streamlit as st
from smolagents import CodeAgent, DuckDuckGoSearchTool, HfApiModel, ToolCallingAgent, ManagedAgent, VisitWebpageTool


web_agent = ToolCallingAgent(
    tools=[DuckDuckGoSearchTool(max_results=10), VisitWebpageTool()],
    model=HfApiModel(),
)

managed_web_agent = ManagedAgent(
    agent=web_agent,
    name="search",
    description="Runs veterinarian web searches. Give it your query as an argument. Also, this agent should link to the sources you are using. If any specific sites are provided, this agent will only those sources.",
)

manager_agent = CodeAgent(
    tools=[],
    model=HfApiModel(model_id = "Qwen/Qwen2.5-Coder-32B-Instruct"),
    managed_agents=[managed_web_agent],
    additional_authorized_imports=['pyparsing', 'matplotlib', 'datetime', 'statistics', 'bs4', 'request', 'unicodedata', 'queue', 'time', 'collections', 're', 'math', 'stat', 'random', 
'itertools'],
)

# 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 researching your query and summarizing it")

# 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, "Veterinary 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")