-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Migrate high-volume-document-analyzer recipe to contrib/python and upgrade model references #2623
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
happyhuman
wants to merge
4
commits into
main
Choose a base branch
from
agent/update-doc-analyzer-sample
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
56edddf
Upgrade region, dependencies, and lockfile for high-volume-document-a…
happyhuman 14937aa
Remove hardcoded fallback location defaults from environment variable…
happyhuman c0a4599
Migrate high-volume-document-analyzer recipe to contrib/python and up…
happyhuman 17f3d1e
Load dotenv before agent import and remove hardcoded fallback model d…
happyhuman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
contrib/python/high-volume-document-analyzer/high_volume_document_analyzer/__init__.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """High-Volume Document Analyzer Agent: query and synthesize information from documents.""" | ||
|
|
||
| import os | ||
| from pathlib import Path | ||
|
|
||
| import google.auth | ||
| from dotenv import load_dotenv | ||
|
|
||
| # Environment bootstrap for the whole package. Real values come from .env | ||
| # (gitignored) or the ambient environment. The committed .env.example is the | ||
| # fallback so the unit tests and the runnability test import cleanly with no | ||
| # .env present. override=False throughout, so a real environment variable wins. | ||
| _ROOT = Path(__file__).resolve().parent.parent | ||
| load_dotenv(_ROOT / ".env", override=False) | ||
| load_dotenv(_ROOT / ".env.example", override=False) | ||
|
|
||
| try: | ||
| _, project_id = google.auth.default() | ||
| if project_id and ( | ||
| not os.environ.get("GOOGLE_CLOUD_PROJECT") | ||
| or os.environ.get("GOOGLE_CLOUD_PROJECT", "").startswith("<") | ||
| ): | ||
| os.environ["GOOGLE_CLOUD_PROJECT"] = project_id | ||
| except Exception: | ||
| pass | ||
|
|
||
| os.environ.setdefault("GOOGLE_CLOUD_LOCATION", "global") | ||
| os.environ.setdefault("GOOGLE_GENAI_USE_VERTEXAI", "True") | ||
|
|
||
| from . import agent # noqa: E402 -- must come after load_dotenv() | ||
|
|
||
| __all__ = ["agent"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
contrib/python/high-volume-document-analyzer/manifest.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| type: "standalone" # Options: [standalone | module] | ||
| status: "active" # Options: [active | inactive] | ||
| language: "python" # Options: [python | java | go | kotlin | typescript] | ||
| description: "The High-Volume Document Analyzer Agent queries and synthesizes information from a large corpus of internal documents (legal statutes, process manuals, etc.)" | ||
|
|
||
| # deployable: true # (optional) one-command deploy, no manual steps; omit if false (default) | ||
| # large: true # (optional) opt into the relaxed size tier; see .github/policy.yml (recipe_size_limits) for the exact numbers; omit if false (default) | ||
|
|
||
| architecture: # (optional) omit the whole block if nothing below can be inferred from code | ||
| agent: "single" # Options: [single | multi] | ||
| stateful: false # Options: [true | false] | ||
| datasources: # Options: [hardcoded | local | external] | ||
| - "external" | ||
|
|
||
| # dependencies: (optional) uncomment and fill in with canonical names | ||
| # libraries: | ||
| # - "ADK" | ||
| # - "pandas" # example — replace with actual libraries used | ||
| # services: | ||
| # - "GCP Project" | ||
| # - "Cloud Run" # example — replace with actual GCP/external services used | ||
|
|
||
| ownership: | ||
| team: "DEE" | ||
| poc: "happyhuman" | ||
| # contributors: (optional) uncomment and add GitHub IDs of additional contributors | ||
| # - "github-id-1" | ||
|
|
||
| # tags: (optional) uncomment and replace with meaningful labels | ||
| # - "rag" | ||
| # - "document-processing" | ||
|
|
||
| license: "Apache-2.0" # (optional) SPDX identifier; only set if explicitly declared — see https://spdx.org/licenses/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
contrib/python/high-volume-document-analyzer/tests/test_runnability.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # https://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| """Runnability tests for the recipe.""" | ||
|
|
||
| import os | ||
| from unittest.mock import MagicMock, patch | ||
|
|
||
|
|
||
| def test_agent_runnability() -> None: | ||
| """Verify agent.py imports and defines the expected globals.""" | ||
| # provide a dummy GCP project and patch google.auth.default() so import-time | ||
| # credential lookups don't need ADC — the setup must happen before the import. | ||
| os.environ.setdefault("GOOGLE_CLOUD_PROJECT", "test-project") | ||
|
|
||
| with patch( | ||
| "google.auth.default", return_value=(MagicMock(), "test-project") | ||
| ): | ||
| import high_volume_document_analyzer.agent | ||
|
|
||
| assert high_volume_document_analyzer.agent.root_agent is not None | ||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[MINOR] env read carries a hardcoded default (second argument is a hardcoded default); 20 occurrence(s) across 6 file(s). Defaults belong in .env.example, not in the code (contrib/python/high-volume-document-analyzer/tests/test_runnability.py:24; and 5 more)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Standardized placeholder strings in
.env.exampleusing<TODO: update-this-value>and removed hardcoded fallback defaults on runtime environment reads.