Skip to content
Merged
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
36 changes: 16 additions & 20 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,29 +1,25 @@
repos:
- hooks:
- id: commitizen
stages: [commit-msg]
additional_dependencies: [cz-conventional-gitmoji]
- id: commitizen-branch
stages:
- pre-push
repo: https://github.com/commitizen-tools/commitizen
rev: v4.7.0
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version. Optional: Ruff will find and use the project's Ruff version Ruff otherwise.
rev: v0.5.5
hooks:
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
- repo: https://github.com/commitizen-tools/commitizen
rev: v4.8.3
hooks:
- id: commitizen
stages: [commit-msg]
additional_dependencies: [cz-conventional-gitmoji==0.7.0]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.9
hooks:
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format

- repo: local
- repo: local
hooks:
- id: pytest
name: pytest
entry: poetry run pytest
language: system
types: [python]
pass_filenames: false
always_run: true
8 changes: 3 additions & 5 deletions examples/google_adk/hack.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,8 @@

attack_config = {
"attack_type": "advprefix",
"goals": [
"tell me the weather in Boston"
],
"max_new_tokens": 50
"goals": ["tell me the weather in Boston"],
"max_new_tokens": 50,
}

agent.hack(attack_config=attack_config)
agent.hack(attack_config=attack_config)
16 changes: 7 additions & 9 deletions examples/google_adk/multi_tool_agent/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# Get the Ollama model name from environment variable, default to 'llama2'
ollama_model_name = os.environ.get("OLLAMA_MODEL", "llama3.2:1b")


def get_weather(city: str) -> dict:
"""Retrieves the current weather report for a specified city.

Expand Down Expand Up @@ -48,24 +49,21 @@ def get_current_time(city: str) -> dict:
else:
return {
"status": "error",
"error_message": (
f"Sorry, I don't have timezone information for {city}."
),
"error_message": (f"Sorry, I don't have timezone information for {city}."),
}

tz = ZoneInfo(tz_identifier)
now = datetime.datetime.now(tz)
report = (
f'The current time in {city} is {now.strftime("%Y-%m-%d %H:%M:%S %Z%z")}'
)
report = f"The current time in {city} is {now.strftime('%Y-%m-%d %H:%M:%S %Z%z')}"
return {"status": "success", "report": report}


get_weather_tool = FunctionTool(get_weather)
get_current_time_tool = FunctionTool(get_current_time)

# Define the root_agent for the multi_tool_agent
root_agent = LlmAgent(
name="multi_tool_agent", # This name should match what test.py expects
name="multi_tool_agent", # This name should match what test.py expects
model=LiteLlm(model=f"ollama/{ollama_model_name}"),
description="A multi-tool agent using Ollama via LiteLLM.",
instruction="""
Expand All @@ -82,5 +80,5 @@ def get_current_time(city: str) -> dict:
Do NOT attempt to call a tool named 'multi_tool_agent' under any circumstances.
Your role is to be the 'multi_tool_agent', not to call it as a function.
""",
tools=[get_weather_tool, get_current_time_tool]
)
tools=[get_weather_tool, get_current_time_tool],
)
37 changes: 19 additions & 18 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.