Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions cookbook/agent_concepts/caching/async_cache_model_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
"""
Run this cookbook twice to see the difference in response time.
The first time should take a while to run.
The second time should be instant.
"""

import asyncio

from agno.agent.agent import Agent
from agno.models.openai.chat import OpenAIChat

agent = Agent(
model=OpenAIChat(id="o3-mini"), cache_model_response=True, debug_mode=True
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should cache_model_response not be a param of the model class instead?

)

# Should take a while to run the first time, then replay from cache
asyncio.run(
agent.aprint_response(
"Write me a short story about a cat that can talk and solve problems."
)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"""
Run this cookbook twice to see the difference in response time.

The first time should take a while to run.

The second time should be instant.
"""

import asyncio

from agno.agent.agent import Agent
from agno.models.openai.chat import OpenAIChat

agent = Agent(
model=OpenAIChat(id="o3-mini"), cache_model_response=True, debug_mode=True
)

# Should take a while to run the first time, then replay from cache
asyncio.run(
agent.aprint_response(
"Write me a short story about a dog that can talk and solve problems.",
stream=True,
)
)
19 changes: 19 additions & 0 deletions cookbook/agent_concepts/caching/cache_model_response.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
Run this cookbook twice to see the difference in response time.
The first time should take a while to run.
The second time should be instant.
"""

from agno.agent.agent import Agent
from agno.models.openai.chat import OpenAIChat

agent = Agent(
model=OpenAIChat(id="o3-mini"), cache_model_response=True, debug_mode=True
)

# Should take a while to run the first time, then replay from cache
agent.print_response(
"Write me a short story about a cat that can talk and solve problems."
)
19 changes: 19 additions & 0 deletions cookbook/agent_concepts/caching/cache_model_response_stream.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
Run this cookbook twice to see the difference in response time.
The first time should take a while to run.
The second time should be instant.
"""

from agno.agent.agent import Agent
from agno.models.openai.chat import OpenAIChat

agent = Agent(
model=OpenAIChat(id="o3-mini"), cache_model_response=True, debug_mode=True
)

# Should take a while to run the first time, then replay from cache
agent.print_response(
"Write me a short story about a cat that can talk and solve problems.", stream=True
)
4 changes: 2 additions & 2 deletions libs/agno/agno/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from importlib.metadata import version, PackageNotFoundError
from importlib.metadata import PackageNotFoundError, version

try:
__version__ = version("agno")
except PackageNotFoundError:
__version__ = "0.0.0"

__all__ = ["__version__"]
__all__ = ["__version__"]
Loading