diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index cf8ada22..40fc39a4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,24 +1,21 @@ 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 @@ -26,4 +23,3 @@ repos: language: system types: [python] pass_filenames: false - always_run: true diff --git a/examples/google_adk/hack.py b/examples/google_adk/hack.py index 3ed9a6ad..fae7bf20 100644 --- a/examples/google_adk/hack.py +++ b/examples/google_adk/hack.py @@ -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) \ No newline at end of file +agent.hack(attack_config=attack_config) diff --git a/examples/google_adk/multi_tool_agent/agent.py b/examples/google_adk/multi_tool_agent/agent.py index d6b9ac2c..709dee90 100644 --- a/examples/google_adk/multi_tool_agent/agent.py +++ b/examples/google_adk/multi_tool_agent/agent.py @@ -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. @@ -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=""" @@ -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] -) \ No newline at end of file + tools=[get_weather_tool, get_current_time_tool], +) diff --git a/poetry.lock b/poetry.lock index 2641f905..d2d26efe 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1,4 +1,4 @@ -# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand. +# This file is automatically @generated by Poetry 2.1.1 and should not be changed by hand. [[package]] name = "aiohappyeyeballs" @@ -188,7 +188,7 @@ description = "Timeout context manager for asyncio programs" optional = false python-versions = ">=3.8" groups = ["main"] -markers = "python_version == \"3.10\"" +markers = "python_version < \"3.11\"" files = [ {file = "async_timeout-5.0.1-py3-none-any.whl", hash = "sha256:39e3809566ff85354557ec2398b55e096c8364bacac9405a7a1fa429e77fe76c"}, {file = "async_timeout-5.0.1.tar.gz", hash = "sha256:d9321a7a3d5a6a5e187e824d2fa0793ce379a202935782d555d6e9d2735677d3"}, @@ -478,14 +478,14 @@ markers = {main = "platform_system == \"Windows\""} [[package]] name = "commitizen" -version = "4.8.0" +version = "4.8.3" description = "Python commitizen client tool" optional = false python-versions = "<4.0,>=3.9" groups = ["dev"] files = [ - {file = "commitizen-4.8.0-py3-none-any.whl", hash = "sha256:1cc1395010d3291b447c5d41f8201dde9cbe46e866f2a6b91ac4f599720f4516"}, - {file = "commitizen-4.8.0.tar.gz", hash = "sha256:488cb70afe18ff393a2ac18d32e82c3a18a81bf044dceeb33145ae5697ab832b"}, + {file = "commitizen-4.8.3-py3-none-any.whl", hash = "sha256:91f261387ca2bbb4ab6c79a1a6378dc1576ffb40e3b7dbee201724d95aceba38"}, + {file = "commitizen-4.8.3.tar.gz", hash = "sha256:303ebdc271217aadbb6a73a015612121291d180c8cdd05b5251c7923d4a14195"}, ] [package.dependencies] @@ -493,11 +493,12 @@ argcomplete = ">=1.12.1,<3.7" charset-normalizer = ">=2.1.0,<4" colorama = ">=0.4.1,<1.0" decli = ">=0.6.0,<1.0" +importlib-metadata = {version = ">=8.0.0,<9.0.0", markers = "python_version != \"3.9\""} jinja2 = ">=2.10.3" packaging = ">=19" pyyaml = ">=3.08" questionary = ">=2.0,<3.0" -termcolor = ">=1.1,<3" +termcolor = ">=1.1.0,<4.0.0" tomlkit = ">=0.5.3,<1.0.0" typing-extensions = {version = ">=4.0.1,<5.0.0", markers = "python_version < \"3.11\""} @@ -729,7 +730,7 @@ description = "Backport of PEP 654 (exception groups)" optional = false python-versions = ">=3.7" groups = ["main", "dev"] -markers = "python_version == \"3.10\"" +markers = "python_version < \"3.11\"" files = [ {file = "exceptiongroup-1.3.0-py3-none-any.whl", hash = "sha256:4d111e6e0c13d0644cad6ddaa7ed0261a0b36971f6d23e7ec9b4b9097da78a10"}, {file = "exceptiongroup-1.3.0.tar.gz", hash = "sha256:b241f5885f560bc56a59ee63ca4c6a8bfa46ae4ad651af316d4e81817bb9fd88"}, @@ -990,16 +991,16 @@ files = [ google-auth = ">=2.14.1,<3.0.0" googleapis-common-protos = ">=1.56.2,<2.0.0" grpcio = [ + {version = ">=1.33.2,<2.0dev", optional = true, markers = "extra == \"grpc\""}, {version = ">=1.49.1,<2.0dev", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""}, - {version = ">=1.33.2,<2.0dev", optional = true, markers = "python_version < \"3.11\" and extra == \"grpc\""}, ] grpcio-status = [ - {version = ">=1.49.1,<2.0.dev0", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""}, {version = ">=1.33.2,<2.0.dev0", optional = true, markers = "extra == \"grpc\""}, + {version = ">=1.49.1,<2.0.dev0", optional = true, markers = "python_version >= \"3.11\" and extra == \"grpc\""}, ] proto-plus = [ - {version = ">=1.25.0,<2.0.0", markers = "python_version >= \"3.13\""}, {version = ">=1.22.3,<2.0.0"}, + {version = ">=1.25.0,<2.0.0", markers = "python_version >= \"3.13\""}, ] protobuf = ">=3.19.5,<3.20.0 || >3.20.0,<3.20.1 || >3.20.1,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<7.0.0" requests = ">=2.18.0,<3.0.0" @@ -1196,8 +1197,8 @@ google-api-core = {version = ">=1.34.1,<2.0.dev0 || >=2.11.dev0,<3.0.0", extras google-auth = ">=2.14.1,<2.24.0 || >2.24.0,<2.25.0 || >2.25.0,<3.0.0" grpc-google-iam-v1 = ">=0.14.0,<1.0.0" proto-plus = [ - {version = ">=1.25.0,<2.0.0", markers = "python_version >= \"3.13\""}, {version = ">=1.22.3,<2.0.0"}, + {version = ">=1.25.0,<2.0.0", markers = "python_version >= \"3.13\""}, ] protobuf = ">=3.20.2,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<7.0.0" @@ -1218,8 +1219,8 @@ google-api-core = {version = ">=1.34.1,<2.0.dev0 || >=2.11.dev0,<3.0.0", extras google-auth = ">=2.14.1,<2.24.0 || >2.24.0,<2.25.0 || >2.25.0,<3.0.0" grpc-google-iam-v1 = ">=0.14.0,<1.0.0" proto-plus = [ - {version = ">=1.25.0,<2.0.0", markers = "python_version >= \"3.13\""}, {version = ">=1.22.3,<2.0.0"}, + {version = ">=1.25.0,<2.0.0", markers = "python_version >= \"3.13\""}, ] protobuf = ">=3.20.2,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<7.0.0" @@ -1239,8 +1240,8 @@ files = [ google-api-core = {version = ">=1.34.1,<2.0.dev0 || >=2.11.dev0,<3.0.0", extras = ["grpc"]} google-auth = ">=2.14.1,<2.24.0 || >2.24.0,<2.25.0 || >2.25.0,<3.0.0" proto-plus = [ - {version = ">=1.25.0,<2.0.0", markers = "python_version >= \"3.13\""}, {version = ">=1.22.3,<2.0.0"}, + {version = ">=1.25.0,<2.0.0", markers = "python_version >= \"3.13\""}, ] protobuf = ">=3.20.2,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<7.0.0" @@ -1284,8 +1285,8 @@ files = [ google-api-core = {version = ">=1.34.1,<2.0.dev0 || >=2.11.dev0,<3.0.0", extras = ["grpc"]} google-auth = ">=2.14.1,<2.24.0 || >2.24.0,<2.25.0 || >2.25.0,<3.0.0" proto-plus = [ - {version = ">=1.25.0,<2.0.0", markers = "python_version >= \"3.13\""}, {version = ">=1.22.3,<2.0.0"}, + {version = ">=1.25.0,<2.0.0", markers = "python_version >= \"3.13\""}, ] protobuf = ">=3.20.2,<4.21.0 || >4.21.0,<4.21.1 || >4.21.1,<4.21.2 || >4.21.2,<4.21.3 || >4.21.3,<4.21.4 || >4.21.4,<4.21.5 || >4.21.5,<7.0.0" @@ -1419,7 +1420,7 @@ description = "Lightweight in-process concurrent programming" optional = false python-versions = ">=3.9" groups = ["dev"] -markers = "(platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\") and python_version <= \"3.13\"" +markers = "python_version < \"3.14\" and (platform_machine == \"aarch64\" or platform_machine == \"ppc64le\" or platform_machine == \"x86_64\" or platform_machine == \"amd64\" or platform_machine == \"AMD64\" or platform_machine == \"win32\" or platform_machine == \"WIN32\")" files = [ {file = "greenlet-3.2.2-cp310-cp310-macosx_11_0_universal2.whl", hash = "sha256:c49e9f7c6f625507ed83a7485366b46cbe325717c60837f7244fc99ba16ba9d6"}, {file = "greenlet-3.2.2-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c3cc1a3ed00ecfea8932477f729a9f616ad7347a5e55d50929efa50a86cb7be7"}, @@ -2473,9 +2474,9 @@ files = [ [package.dependencies] numpy = [ - {version = ">=1.26.0", markers = "python_version >= \"3.12\""}, - {version = ">=1.23.2", markers = "python_version == \"3.11\""}, {version = ">=1.22.4", markers = "python_version < \"3.11\""}, + {version = ">=1.23.2", markers = "python_version == \"3.11\""}, + {version = ">=1.26.0", markers = "python_version >= \"3.12\""}, ] python-dateutil = ">=2.8.2" pytz = ">=2020.1" @@ -3878,7 +3879,7 @@ description = "A lil' TOML parser" optional = false python-versions = ">=3.8" groups = ["dev"] -markers = "python_version == \"3.10\"" +markers = "python_version < \"3.11\"" files = [ {file = "tomli-2.2.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:678e4fa69e4575eb77d103de3df8a895e1591b48e740211bd1067378c69e8249"}, {file = "tomli-2.2.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:023aa114dd824ade0100497eb2318602af309e5a55595f76b626d6d9f3b7b0a6"},