Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dirkbrnd committed Feb 11, 2025
1 parent f1a99fe commit 1ab2875
Show file tree
Hide file tree
Showing 39 changed files with 102 additions and 64 deletions.
2 changes: 1 addition & 1 deletion cookbook/models/aws/bedrock/basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from agno.agent import Agent, RunResponse # noqa
from agno.models.aws.bedrock import AwsBedrock
from agno.models.aws import AwsBedrock

agent = Agent(model=AwsBedrock(id="mistral.mistral-small-2402-v1:0"), markdown=True)

Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/aws/bedrock/basic_stream.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Iterator # noqa
from agno.agent import Agent, RunResponse # noqa
from agno.models.aws.bedrock import AwsBedrock
from agno.models.aws import AwsBedrock

agent = Agent(model=AwsBedrock(id="mistral.mistral-small-2402-v1:0"), markdown=True)

Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/aws/bedrock/image_agent_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from agno.agent import Agent
from agno.media import Image
from agno.models.aws.bedrock import AwsBedrock
from agno.models.aws import AwsBedrock
from agno.tools.duckduckgo import DuckDuckGoTools

agent = Agent(
Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/aws/bedrock/structured_output.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import List

from agno.agent import Agent, RunResponse # noqa
from agno.models.aws.bedrock import AwsBedrock
from agno.models.aws import AwsBedrock
from pydantic import BaseModel, Field
from rich.pretty import pprint # noqa

Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/aws/bedrock/tool_use.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Run `pip install duckduckgo-search` to install dependencies."""

from agno.agent import Agent
from agno.models.aws.bedrock import AwsBedrock
from agno.models.aws import AwsBedrock
from agno.tools.duckduckgo import DuckDuckGoTools

agent = Agent(
Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/aws/bedrock/tool_use_stream.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Run `pip install duckduckgo-search` to install dependencies."""

from agno.agent import Agent
from agno.models.aws.bedrock import AwsBedrock
from agno.models.aws import AwsBedrock
from agno.tools.duckduckgo import DuckDuckGoTools

agent = Agent(
Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/aws/claude/async_basic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio

from agno.agent import Agent, RunResponse # noqa
from agno.models.aws.claude import Claude
from agno.models.aws import Claude

agent = Agent(
model=Claude(id="anthropic.claude-3-5-sonnet-20240620-v1:0"), markdown=True
Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/aws/claude/async_basic_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from typing import Iterator # noqa

from agno.agent import Agent, RunResponse # noqa
from agno.models.aws.claude import Claude
from agno.models.aws import Claude

agent = Agent(
model=Claude(id="anthropic.claude-3-5-sonnet-20240620-v1:0"), markdown=True
Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/aws/claude/async_tool_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import asyncio

from agno.agent import Agent
from agno.models.aws.claude import Claude
from agno.models.aws import Claude
from agno.tools.duckduckgo import DuckDuckGoTools

agent = Agent(
Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/aws/claude/basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from agno.agent import Agent, RunResponse # noqa
from agno.models.aws.claude import Claude
from agno.models.aws import Claude

agent = Agent(
model=Claude(id="anthropic.claude-3-5-sonnet-20240620-v1:0"), markdown=True
Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/aws/claude/basic_stream.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import Iterator # noqa
from agno.agent import Agent, RunResponse # noqa
from agno.models.aws.claude import Claude
from agno.models.aws import Claude

agent = Agent(
model=Claude(id="anthropic.claude-3-5-sonnet-20240620-v1:0"), markdown=True
Expand Down
20 changes: 20 additions & 0 deletions cookbook/models/aws/claude/image_agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
from agno.agent import Agent
from agno.media import Image
from agno.models.aws import Claude
from agno.tools.duckduckgo import DuckDuckGoTools

agent = Agent(
model=Claude(id="anthropic.claude-3-5-sonnet-20240620-v1:0"),
tools=[DuckDuckGoTools()],
markdown=True,
)

agent.print_response(
"Tell me about this image and search the web for more information.",
images=[
Image(
url="https://upload.wikimedia.org/wikipedia/commons/a/a7/Camponotus_flavomarginatus_ant.jpg"
),
],
stream=True,
)
2 changes: 1 addition & 1 deletion cookbook/models/aws/claude/knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from agno.agent import Agent
from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
from agno.models.aws.claude import Claude
from agno.models.aws import Claude
from agno.vectordb.pgvector import PgVector

db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/aws/claude/storage.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Run `pip install duckduckgo-search sqlalchemy anthropic` to install dependencies."""

from agno.agent import Agent
from agno.models.aws.claude import Claude
from agno.models.aws import Claude
from agno.storage.agent.postgres import PostgresAgentStorage
from agno.tools.duckduckgo import DuckDuckGoTools

Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/aws/claude/structured_output.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import List

from agno.agent import Agent, RunResponse # noqa
from agno.models.aws.claude import Claude
from agno.models.aws import Claude
from pydantic import BaseModel, Field
from rich.pretty import pprint # noqa

Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/aws/claude/tool_use.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Run `pip install duckduckgo-search` to install dependencies."""

from agno.agent import Agent
from agno.models.aws.claude import Claude
from agno.models.aws import Claude
from agno.tools.duckduckgo import DuckDuckGoTools

agent = Agent(
Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/azure/ai_foundry/async_basic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio

from agno.agent import Agent
from agno.models.azure.ai_foundry import AzureAIFoundry
from agno.models.azure import AzureAIFoundry

agent = Agent(
model=AzureAIFoundry(id="Phi-4"),
Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/azure/ai_foundry/async_basic_stream.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio

from agno.agent import Agent
from agno.models.azure.ai_foundry import AzureAIFoundry
from agno.models.azure import AzureAIFoundry

assistant = Agent(
model=AzureAIFoundry(id="Phi-4"),
Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/azure/ai_foundry/async_tool_use.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pprint import pprint

from agno.agent import Agent
from agno.models.azure.ai_foundry import AzureAIFoundry
from agno.models.azure import AzureAIFoundry
from agno.run.response import RunResponse
from agno.tools.duckduckgo import DuckDuckGoTools

Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/azure/ai_foundry/basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from agno.agent import Agent, RunResponse # noqa
from agno.models.azure.ai_foundry import AzureAIFoundry
from agno.models.azure import AzureAIFoundry

agent = Agent(model=AzureAIFoundry(id="Phi-4"), markdown=True)

Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/azure/ai_foundry/basic_stream.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import Iterator # noqa

from agno.agent import Agent, RunResponse # noqa
from agno.models.azure.ai_foundry import AzureAIFoundry
from agno.models.azure import AzureAIFoundry

agent = Agent(model=AzureAIFoundry(id="Phi-4"), markdown=True)

Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/azure/ai_foundry/demo_cohere.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from agno.agent import Agent, RunResponse # noqa
from agno.models.azure.ai_foundry import AzureAIFoundry
from agno.models.azure import AzureAIFoundry

agent = Agent(model=AzureAIFoundry(id="Cohere-command-r-08-2024"), markdown=True)

Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/azure/ai_foundry/demo_mistral.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from agno.agent import Agent, RunResponse # noqa
from agno.models.azure.ai_foundry import AzureAIFoundry
from agno.models.azure import AzureAIFoundry

agent = Agent(model=AzureAIFoundry(id="Mistral-Large-2411"), markdown=True)

Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/azure/ai_foundry/image_agent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from agno.agent import Agent
from agno.media import Image
from agno.models.azure.ai_foundry import AzureAIFoundry
from agno.models.azure import AzureAIFoundry

agent = Agent(
model=AzureAIFoundry(id="Llama-3.2-11B-Vision-Instruct"),
Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/azure/ai_foundry/image_agent_bytes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from agno.agent import Agent
from agno.media import Image
from agno.models.azure.ai_foundry import AzureAIFoundry
from agno.models.azure import AzureAIFoundry

agent = Agent(
model=AzureAIFoundry(id="Llama-3.2-11B-Vision-Instruct"),
Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/azure/ai_foundry/knowledge.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from agno.agent import Agent
from agno.embedder.azure_openai import AzureOpenAIEmbedder
from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
from agno.models.azure.ai_foundry import AzureAIFoundry
from agno.models.azure import AzureAIFoundry
from agno.vectordb.pgvector import PgVector

db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"
Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/azure/ai_foundry/storage.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Run `pip install duckduckgo-search sqlalchemy anthropic` to install dependencies."""

from agno.agent import Agent
from agno.models.azure.ai_foundry import AzureAIFoundry
from agno.models.azure import AzureAIFoundry
from agno.storage.agent.postgres import PostgresAgentStorage
from agno.tools.duckduckgo import DuckDuckGoTools

Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/azure/ai_foundry/structured_output.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from typing import List

from agno.agent import Agent, RunResponse # noqa
from agno.models.azure.ai_foundry import AzureAIFoundry
from agno.models.azure import AzureAIFoundry
from pydantic import BaseModel, Field
from rich.pretty import pprint # noqa

Expand Down
2 changes: 1 addition & 1 deletion cookbook/models/azure/ai_foundry/tool_use.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Run `pip install duckduckgo-search` to install dependencies."""

from agno.agent import Agent
from agno.models.azure.ai_foundry import AzureAIFoundry
from agno.models.azure import AzureAIFoundry
from agno.tools.duckduckgo import DuckDuckGoTools

agent = Agent(
Expand Down
13 changes: 13 additions & 0 deletions cookbook/models/google/gemini_openai/tool_use.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Run `pip install duckduckgo-search` to install dependencies."""

from agno.agent import Agent
from agno.models.google import GeminiOpenAI
from agno.tools.duckduckgo import DuckDuckGoTools

agent = Agent(
model=GeminiOpenAI(id="gemini-2.0-flash-exp"),
tools=[DuckDuckGoTools()],
show_tool_calls=True,
markdown=True,
)
agent.print_response("Whats happening in France?")
1 change: 0 additions & 1 deletion cookbook/models/mistral/image_bytes_input_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from agno.agent import Agent
from agno.media import Image
from agno.models.mistral.mistral import MistralChat
from agno.tools.duckduckgo import DuckDuckGoTools

agent = Agent(
model=MistralChat(id="pixtral-12b-2409"),
Expand Down
2 changes: 2 additions & 0 deletions libs/agno/agno/models/aws/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from agno.models.aws.bedrock import AwsBedrock
from agno.models.aws.claude import Claude
5 changes: 4 additions & 1 deletion libs/agno/agno/models/aws/bedrock.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class AwsBedrock(Model, ABC):
aws_access_key_id (Optional[str]): The AWS access key ID to use.
aws_secret_access_key (Optional[str]): The AWS secret access key to use.
"""
id: str = "mistral.mistral-small-2402-v1:0"
name: str = "AwsBedrock"
provider: str = "AwsBedrock"

aws_region: Optional[str] = None
aws_access_key_id: Optional[str] = None
Expand All @@ -47,7 +50,7 @@ class AwsBedrock(Model, ABC):
stop_sequences: Optional[List[str]] = None
request_params: Optional[Dict[str, Any]] = None

client: Optional[Any] = None
client: Optional[AwsClient] = None

def get_client(self) -> AwsClient:
if self.client is not None:
Expand Down
48 changes: 29 additions & 19 deletions libs/agno/agno/models/aws/claude.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,36 +54,46 @@ def to_dict(self) -> Dict[str, Any]:
_dict["stop_sequences"] = self.stop_sequences
return _dict

_client: Optional[AnthropicBedrock] = None
_async_client: Optional[AsyncAnthropicBedrock] = None
client: Optional[AnthropicBedrock] = None
async_client: Optional[AsyncAnthropicBedrock] = None

def get_client(self):
if self._client is not None:
return self._client
if self.client is not None:
return self.client

self.aws_access_key = self.aws_access_key or getenv("AWS_ACCESS_KEY")
self.aws_secret_key = self.aws_secret_key or getenv("AWS_SECRET_KEY")
self.aws_region = self.aws_region or getenv("AWS_REGION")

self._client = AnthropicBedrock(
aws_secret_key=self.aws_secret_key,
aws_access_key=self.aws_access_key,
aws_region=self.aws_region,
**self.client_params,
client_params = {
"aws_secret_key": self.aws_secret_key,
"aws_access_key": self.aws_access_key,
"aws_region": self.aws_region,
}
if self.client_params:
client_params.update(self.client_params)

self.client = AnthropicBedrock(
**client_params,
)
return self._client
return self.client

def get_async_client(self):
if self._async_client is not None:
return self._async_client

self._async_client = AsyncAnthropicBedrock(
aws_secret_key=self.aws_secret_key,
aws_access_key=self.aws_access_key,
aws_region=self.aws_region,
**self.client_params,
if self.async_client is not None:
return self.async_client

client_params = {
"aws_secret_key": self.aws_secret_key,
"aws_access_key": self.aws_access_key,
"aws_region": self.aws_region,
}
if self.client_params:
client_params.update(self.client_params)

self.async_client = AsyncAnthropicBedrock(
**client_params,
)
return self._async_client
return self.async_client

@property
def request_kwargs(self) -> Dict[str, Any]:
Expand Down
1 change: 1 addition & 0 deletions libs/agno/agno/models/azure/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from agno.models.azure.ai_foundry import AzureAIFoundry
from agno.models.azure.openai_chat import AzureOpenAI
4 changes: 2 additions & 2 deletions libs/agno/agno/models/azure/ai_foundry.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ class AzureAIFoundry(Model):
"""
A class for interacting with Azure AI Interface models.
- For Managed Compute, set the `api_key` to your Azure AI Foundry API key and the `azure_endpoint` to the endpoint URL in the format `https://<your-host-name>.<your-azure-region>.models.ai.azure.com`
- For Serverless API, set the `api_key` to your Azure AI Foundry API key and the `azure_endpoint` to the endpoint URL in the format `https://<your-host-name>.<your-azure-region>.models.ai.azure.com`
- For Managed Compute, set the `api_key` to your Azure AI Foundry API key and the `azure_endpoint` to the endpoint URL in the format `https://<your-host-name>.<your-azure-region>.models.ai.azure.com/models`
- For Serverless API, set the `api_key` to your Azure AI Foundry API key and the `azure_endpoint` to the endpoint URL in the format `https://<your-host-name>.<your-azure-region>.models.ai.azure.com/models`
- For Github Models, set the `api_key` to the Github Personal Access Token.
- For Azure OpenAI, set the `api_key` to your Azure AI Foundry API key, the `api_version` to `2024-06-01` and the `azure_endpoint` to the endpoint URL in the format `https://<your-resource-name>.openai.azure.com/openai/deployments/<your-deployment-name>`
Expand Down
2 changes: 1 addition & 1 deletion libs/agno/agno/models/azure/openai_chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def _get_client_params(self) -> Dict[str, Any]:

self.api_key = self.api_key or getenv("AZURE_OPENAI_API_KEY")
self.azure_endpoint = self.azure_endpoint or getenv("AZURE_OPENAI_ENDPOINT")
self.azure_deployment = self.azure_deployment or getenv("AZURE_DEPLOYMENT")
self.azure_deployment = self.azure_deployment or getenv("AZURE_OPENAI_DEPLOYMENT")
params_mapping = {
"api_key": self.api_key,
"api_version": self.api_version,
Expand Down
Loading

0 comments on commit 1ab2875

Please sign in to comment.