pubmed_tools.py
"""
Pubmed Tools
=============================
Demonstrates pubmed tools.
"""
from agno.agent import Agent
from agno.tools.pubmed import PubmedTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
# Example 1: Enable all PubMed functions
agent_all = Agent(
tools=[
PubmedTools(
all=True, # Enable all PubMed search functions
)
],
markdown=True,
)
# Example 2: Enable specific PubMed functions only
agent_specific = Agent(
tools=[
PubmedTools(
enable_search_pubmed=True, # Only enable the main search function
)
],
markdown=True,
)
# Example 3: Default behavior with search enabled
agent = Agent(
tools=[
PubmedTools(
enable_search_pubmed=True,
)
],
markdown=True,
)
# Example usage with all functions enabled
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
print("=== Example 1: Using all PubMed functions ===")
agent_all.print_response(
"Tell me about ulcerative colitis and find the latest research."
)
# Example usage with specific functions only
print("\n=== Example 2: Using specific PubMed functions (search only) ===")
agent_specific.print_response("Search for recent studies on diabetes treatment.")
# Example usage with default configuration
print("\n=== Example 3: Default PubMed agent usage ===")
agent.print_response("Tell me about ulcerative colitis.")
agent.print_response("Find research papers on machine learning in healthcare.")
Run the Example
1
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
2
Install dependencies
uv pip install -U agno openai
3
Export your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
4
Run the example
Save the code above as
pubmed_tools.py, then run:python pubmed_tools.py