-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathref.diff
More file actions
292 lines (267 loc) · 9.09 KB
/
ref.diff
File metadata and controls
292 lines (267 loc) · 9.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
diff --git a/python/agents/financial-advisor/README.md b/python/agents/financial-advisor/README.md
index 9a7b949ae..84f39a10b 100644
--- a/python/agents/financial-advisor/README.md
+++ b/python/agents/financial-advisor/README.md
@@ -48,14 +48,14 @@ to implement this workflow.
1. **Prerequisites**
- * Python 3.11+
- * Poetry
+ * Python 3.10+
+ * uv
* For dependency management and packaging. Please follow the
instructions on the official
- [Poetry website](https://python-poetry.org/docs/) for installation.
+ [uv website](https://docs.astral.sh/uv/) for installation.
```bash
- pip install poetry
+ curl -LsSf https://astral.sh/uv/install.sh | sh
```
* A project on Google Cloud Platform
@@ -70,10 +70,7 @@ to implement this workflow.
git clone https://github.com/google/adk-samples.git
cd adk-samples/python/agents/financial_advisor
# Install the package and dependencies.
- # Note for Linux users: If you get an error related to `keyring` during the installation, you can disable it by running the following command:
- # poetry config keyring.enabled false
- # This is a one-time setup.
- poetry install
+ uv sync
```
3. **Configuration**
@@ -703,15 +700,15 @@ Thank you!
For running tests and evaluation, install the extra dependencies:
```bash
-poetry install --with dev
+uv sync --dev
```
Then the tests and evaluation can be run from the `financial-advisor` directory using
the `pytest` module:
```bash
-python3 -m pytest tests
-python3 -m pytest eval
+uv run pytest tests
+uv run pytest eval
```
`tests` runs the agent on a sample request, and makes sure that every component
@@ -726,8 +723,8 @@ The Financial Advisor can be deployed to Vertex AI Agent Engine using the follow
commands:
```bash
-poetry install --with deployment
-python3 deployment/deploy.py --create
+uv sync --group deployment
+uv run deployment/deploy.py --create
```
When the deployment finishes, it will print a line like this:
@@ -739,7 +736,7 @@ Created remote agent: projects/<PROJECT_NUMBER>/locations/<PROJECT_LOCATION>/rea
If you forgot the AGENT_ENGINE_ID, you can list existing agents using:
```bash
-python3 deployment/deploy.py --list
+uv run deployment/deploy.py --list
```
The output will be like:
@@ -755,7 +752,7 @@ All remote agents:
You may interact with the deployed agent using the `test_deployment.py` script
```bash
$ export USER_ID=<any string>
-$ python3 deployment/test_deployment.py --resource_id=${AGENT_ENGINE_ID} --user_id=${USER_ID}
+$ uv run deployment/test_deployment.py --resource_id=${AGENT_ENGINE_ID} --user_id=${USER_ID}
Found agent with resource ID: ...
Created session for user ID: ...
Type 'quit' to exit.
@@ -773,9 +770,35 @@ Would you like to begin by providing a market ticker symbol for analysis?
To delete the deployed agent, you may run the following command:
```bash
-python3 deployment/deploy.py --delete --resource_id=${AGENT_ENGINE_ID}
+uv run deployment/deploy.py --delete --resource_id=${AGENT_ENGINE_ID}
```
+### Alternative: Using Agent Starter Pack
+
+You can also use the [Agent Starter Pack](https://goo.gle/agent-starter-pack) to create a production-ready version of this agent with additional deployment options:
+
+```bash
+# Create and activate a virtual environment
+python -m venv .venv && source .venv/bin/activate # On Windows: .venv\Scripts\activate
+
+# Install the starter pack and create your project
+pip install --upgrade agent-starter-pack
+agent-starter-pack create my-financial-advisor -a adk@financial-advisor
+```
+
+<details>
+<summary>⚡️ Alternative: Using uv</summary>
+
+If you have [`uv`](https://github.com/astral-sh/uv) installed, you can create and set up your project with a single command:
+```bash
+uvx agent-starter-pack create my-financial-advisor -a adk@financial-advisor
+```
+This command handles creating the project without needing to pre-install the package into a virtual environment.
+
+</details>
+
+The starter pack will prompt you to select deployment options and provides additional production-ready features including automated CI/CD deployment scripts.
+
## Customization
1. Enhance Data_Analyst Module Search Capabilities with Specialized Stock Repositories:
diff --git a/python/agents/financial-advisor/financial_advisor/__init__.py b/python/agents/financial-advisor/financial_advisor/__init__.py
index fbb2f3108..c20ba73eb 100644
--- a/python/agents/financial-advisor/financial_advisor/__init__.py
+++ b/python/agents/financial-advisor/financial_advisor/__init__.py
@@ -14,4 +14,13 @@
"""Financial coordinator: provide reasonable investment strategies"""
+import os
+
+import google.auth
+
+_, project_id = google.auth.default()
+os.environ.setdefault("GOOGLE_CLOUD_PROJECT", project_id)
+os.environ.setdefault("GOOGLE_CLOUD_LOCATION", "global")
+os.environ.setdefault("GOOGLE_GENAI_USE_VERTEXAI", "True")
+
from . import agent
diff --git a/python/agents/financial-advisor/financial_advisor/agent.py b/python/agents/financial-advisor/financial_advisor/agent.py
index 8580f4c62..781adf3cf 100644
--- a/python/agents/financial-advisor/financial_advisor/agent.py
+++ b/python/agents/financial-advisor/financial_advisor/agent.py
@@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-"""Financial coordinator: provide reasonable investment strategies"""
+"""Financial coordinator: provide reasonable investment strategies."""
from google.adk.agents import LlmAgent
from google.adk.tools.agent_tool import AgentTool
@@ -23,6 +23,7 @@
from .sub_agents.risk_analyst import risk_analyst_agent
from .sub_agents.trading_analyst import trading_analyst_agent
+
MODEL = "gemini-2.5-pro"
diff --git a/python/agents/financial-advisor/pyproject.toml b/python/agents/financial-advisor/pyproject.toml
index b76be4a9d..387163938 100644
--- a/python/agents/financial-advisor/pyproject.toml
+++ b/python/agents/financial-advisor/pyproject.toml
@@ -1,36 +1,100 @@
[project]
name = "financial-advisor"
-version = "0.1"
+version = "0.1.0"
description = "AI-driven agent designed to facilitate the exploration of the financial advisor landscape"
authors = [{ name = "Antonio Gulli", email = "gulli@google.com" }]
-license = "Apache License 2.0"
+license = "Apache-2.0"
readme = "README.md"
+dependencies = [
+ "google-cloud-aiplatform[adk,agent-engines]>=1.93.0",
+ "google-genai>=1.9.0",
+ "pydantic>=2.10.6",
+ "python-dotenv>=1.0.1",
+ "google-adk>=1.0.0",
+]
-[tool.poetry.dependencies]
-google-cloud-aiplatform = { version = "^1.93.0", extras = [
- "adk",
- "agent-engines",
-] }
-python = "^3.9"
-google-genai = "^1.9.0"
-pydantic = "^2.10.6"
-python-dotenv = "^1.0.1"
-google-adk = "^1.0.0"
-[tool.poetry.group.dev]
-optional = true
-
-[tool.poetry.group.dev.dependencies]
-pytest = "^8.3.5"
-black = "^25.1.0"
-google-adk = { version = "^1.0.0", extras = ["eval"] }
-pytest-asyncio = "^0.26.0"
-
-[tool.poetry.group.deployment]
-optional = true
-
-[tool.poetry.group.deployment.dependencies]
-absl-py = "^2.2.1"
+requires-python = ">=3.10,<3.13"
+
+[dependency-groups]
+dev = [
+ "pytest>=8.3.2",
+ "pytest-asyncio>=0.23.7",
+ "google-adk[eval]>=1.0.0",
+ "nest-asyncio>=1.6.0",
+ "agent-starter-pack>=0.14.1",
+]
+
+deployment = [
+ "absl-py>=2.2.1",
+]
+
+[project.optional-dependencies]
+
+lint = [
+ "ruff>=0.4.6",
+ "mypy>=1.15.0",
+ "codespell>=2.2.0",
+ "types-pyyaml>=6.0.12.20240917",
+ "types-requests>=2.32.0.20240914",
+]
+
+[tool.ruff]
+line-length = 88
+target-version = "py310"
+
+[tool.ruff.lint]
+select = [
+ "E", # pycodestyle
+ "F", # pyflakes
+ "W", # pycodestyle warnings
+ "I", # isort
+ "C", # flake8-comprehensions
+ "B", # flake8-bugbear
+ "UP", # pyupgrade
+ "RUF", # ruff specific rules
+]
+ignore = ["E501", "C901"] # ignore line too long, too complex
+
+[tool.ruff.lint.isort]
+known-first-party = ["financial_advisor"]
+
+[tool.mypy]
+disallow_untyped_calls = true
+disallow_untyped_defs = true
+disallow_incomplete_defs = true
+no_implicit_optional = true
+check_untyped_defs = true
+disallow_subclassing_any = true
+warn_incomplete_stub = true
+warn_redundant_casts = true
+warn_unused_ignores = true
+warn_unreachable = true
+follow_imports = "silent"
+ignore_missing_imports = true
+explicit_package_bases = true
+disable_error_code = ["misc", "no-untyped-call", "no-any-return"]
+
+exclude = [".venv"]
+
+[tool.codespell]
+ignore-words-list = "rouge"
+skip = "./locust_env/*,uv.lock,.venv,./frontend,**/*.ipynb"
+
+[tool.pytest.ini_options]
+pythonpath = "."
+asyncio_default_fixture_loop_scope = "function"
[build-system]
-requires = ["poetry-core>=2.0.0,<3.0.0"]
-build-backend = "poetry.core.masonry.api"
+requires = ["uv_build>=0.8.14,<0.9.0"]
+build-backend = "uv_build"
+
+[tool.uv.build-backend]
+module-root = ""
+
+# This configuration file is used by goo.gle/agent-starter-pack to power remote templating.
+# It defines the template's properties and settings.
+[tool.agent-starter-pack]
+example_question = "Analyze AAPL"
+
+[tool.agent-starter-pack.settings]
+agent_directory = "financial_advisor"