Skip to content

Commit 9749bc9

Browse files
committed
Gemma Demo
1 parent b7f1f49 commit 9749bc9

File tree

8 files changed

+118
-15
lines changed

8 files changed

+118
-15
lines changed

cookbook/models/ollama/demo_gemma.py

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from pathlib import Path
2+
3+
from agno.agent import Agent
4+
from agno.media import Image
5+
from agno.models.ollama import Ollama
6+
7+
agent = Agent(model=Ollama(id="gemma3:12b"), markdown=True)
8+
9+
image_path = Path(__file__).parent.joinpath("super-agents.png")
10+
agent.print_response(
11+
"Write a 3 sentence fiction story about the image",
12+
images=[Image(filepath=image_path)],
13+
stream=True,
14+
)

evals/performance/other/autogen_instantiation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Run `pip install memory_profiler autogen-agentchat "autogen-ext[openai]"` to install dependencies."""
1+
"""Run `pip install autogen-agentchat "autogen-ext[openai]"` to install dependencies."""
22

33
from typing import Literal
44

evals/performance/other/crewai_instantiation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Run `pip install openai memory_profiler crewai crewai[tools]` to install dependencies."""
1+
"""Run `pip install openai crewai crewai[tools]` to install dependencies."""
22
from typing import Literal
33

44
from crewai.agent import Agent

evals/performance/other/langgraph_instantiation.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
"""Run `pip install memory_profiler langgraph langchain_openai` to install dependencies."""
1+
"""Run `pip install langgraph langchain_openai` to install dependencies."""
22

33
from typing import Literal
44

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""Run `pip install langgraph langchain_openai` to install dependencies."""
2+
3+
from typing import Literal
4+
from agents import Agent, function_tool
5+
from agno.eval.perf import PerfEval
6+
7+
def get_weather(city: Literal["nyc", "sf"]):
8+
"""Use this to get weather information."""
9+
if city == "nyc":
10+
return "It might be cloudy in nyc"
11+
elif city == "sf":
12+
return "It's always sunny in sf"
13+
else:
14+
raise AssertionError("Unknown city")
15+
16+
def instantiate_agent():
17+
return Agent(
18+
name="Haiku agent",
19+
instructions="Always respond in haiku form",
20+
model="o3-mini",
21+
tools=[function_tool(get_weather)],
22+
)
23+
24+
25+
openai_agents_instantiation = PerfEval(func=instantiate_agent, num_iterations=1000)
26+
27+
if __name__ == "__main__":
28+
openai_agents_instantiation.run(print_results=True)

evals/performance/other/smolagents_instantiation.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
"""Run `pip install memory_profiler smolagents` to install dependencies."""
2-
from typing import Literal
3-
1+
"""Run `pip install smolagents` to install dependencies."""
42
from agno.eval.perf import PerfEval
53
from smolagents import ToolCallingAgent, HfApiModel, Tool
64

libs/agno/agno/workspace/settings.py

+71-8
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
from __future__ import annotations
22

33
from pathlib import Path
4-
from typing import Optional
4+
from typing import List, Optional
55

6+
from pydantic import field_validator, ValidationInfo
67
from pydantic_settings import BaseSettings, SettingsConfigDict
78

89
from agno.api.schemas.workspace import WorkspaceSchema
@@ -11,18 +12,27 @@
1112
class WorkspaceSettings(BaseSettings):
1213
"""Workspace settings that can be used by any resource in the workspace."""
1314

14-
# Workspace name: only used for naming cloud resources
15+
# Workspace name
1516
ws_name: str
1617
# Path to the workspace root
1718
ws_root: Path
1819
# Workspace git repo url
1920
ws_repo: Optional[str] = None
20-
# default env for agno ws commands
21+
22+
# -*- Workspace Environments
23+
dev_env: str = "dev"
24+
dev_key: Optional[str] = None
25+
stg_env: str = "stg"
26+
stg_key: Optional[str] = None
27+
prd_env: str = "prd"
28+
prd_key: Optional[str] = None
29+
30+
# default env for `agno ws` commands
2131
default_env: Optional[str] = "dev"
22-
# default infra for agno ws commands
32+
# default infra for `agno ws` commands
2333
default_infra: Optional[str] = None
2434

25-
# Image Settings
35+
# -*- Image Settings
2636
# Repository for images
2737
image_repo: str = "agnohq"
2838
# 'Name:tag' for the image
@@ -36,7 +46,7 @@ class WorkspaceSettings(BaseSettings):
3646
# Force pull images in FROM
3747
force_pull_images: bool = False
3848

39-
# ag cli settings
49+
# -*- `ag` cli settings
4050
# Set to True if Agno should continue creating
4151
# resources after a resource creation has failed
4252
continue_on_create_failure: bool = False
@@ -48,16 +58,69 @@ class WorkspaceSettings(BaseSettings):
4858
# resources after a resource patch has failed
4959
continue_on_patch_failure: bool = False
5060

51-
# AWS settings
61+
# -*- AWS settings
5262
# Region for AWS resources
5363
aws_region: Optional[str] = None
5464
# Profile for AWS resources
5565
aws_profile: Optional[str] = None
66+
# Availability Zones for AWS resources
67+
aws_az1: Optional[str] = None
68+
aws_az2: Optional[str] = None
69+
aws_az3: Optional[str] = None
70+
# Subnets for AWS resources
71+
aws_subnet_ids: Optional[List[str]] = None
72+
# Security Groups for AWS resources
73+
aws_security_group_ids: Optional[List[str]] = None
5674

57-
# Other Settings
75+
# -*- Other Settings
5876
# Use cached resource if available, i.e. skip resource creation if the resource already exists
5977
use_cache: bool = True
6078
# WorkspaceSchema provided by the api
6179
ws_schema: Optional[WorkspaceSchema] = None
6280

6381
model_config = SettingsConfigDict(extra="allow")
82+
83+
@field_validator("dev_key", mode="before")
84+
def set_dev_key(cls, dev_key, info: ValidationInfo):
85+
if dev_key is not None:
86+
return dev_key
87+
88+
ws_name = info.data.get("ws_name")
89+
if ws_name is None:
90+
raise ValueError("ws_name invalid")
91+
92+
dev_env = info.data.get("dev_env")
93+
if dev_env is None:
94+
raise ValueError("dev_env invalid")
95+
96+
return f"{ws_name}-{dev_env}"
97+
98+
@field_validator("stg_key", mode="before")
99+
def set_stg_key(cls, stg_key, info: ValidationInfo):
100+
if stg_key is not None:
101+
return stg_key
102+
103+
ws_name = info.data.get("ws_name")
104+
if ws_name is None:
105+
raise ValueError("ws_name invalid")
106+
107+
stg_env = info.data.get("stg_env")
108+
if stg_env is None:
109+
raise ValueError("stg_env invalid")
110+
111+
return f"{ws_name}-{stg_env}"
112+
113+
@field_validator("prd_key", mode="before")
114+
def set_prd_key(cls, prd_key, info: ValidationInfo):
115+
if prd_key is not None:
116+
return prd_key
117+
118+
ws_name = info.data.get("ws_name")
119+
if ws_name is None:
120+
raise ValueError("ws_name invalid")
121+
122+
prd_env = info.data.get("prd_env")
123+
if prd_env is None:
124+
raise ValueError("prd_env invalid")
125+
126+
return f"{ws_name}-{prd_env}"

scripts/perf_setup.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ print_info "uv venv --python 3.12 ${VENV_DIR}"
2727
uv venv --python 3.12 ${VENV_DIR}
2828

2929
print_heading "Installing libraries"
30-
VIRTUAL_ENV=${VENV_DIR} uv pip install -U agno langgraph langchain_openai crewai pydantic_ai smolagents autogen-agentchat "autogen-ext[openai]"
30+
VIRTUAL_ENV=${VENV_DIR} uv pip install -U agno langgraph langchain_openai openai-agents crewai pydantic_ai smolagents autogen-agentchat "autogen-ext[openai]"
3131

3232
print_heading "uv pip list"
3333
VIRTUAL_ENV=${VENV_DIR} uv pip list

0 commit comments

Comments
 (0)