agent-starter-pack 0.0.1b0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of agent-starter-pack might be problematic. Click here for more details.

Files changed (162) hide show
  1. agent_starter_pack-0.0.1b0.dist-info/METADATA +143 -0
  2. agent_starter_pack-0.0.1b0.dist-info/RECORD +162 -0
  3. agent_starter_pack-0.0.1b0.dist-info/WHEEL +4 -0
  4. agent_starter_pack-0.0.1b0.dist-info/entry_points.txt +2 -0
  5. agent_starter_pack-0.0.1b0.dist-info/licenses/LICENSE +201 -0
  6. agents/agentic_rag_vertexai_search/README.md +22 -0
  7. agents/agentic_rag_vertexai_search/app/agent.py +145 -0
  8. agents/agentic_rag_vertexai_search/app/retrievers.py +79 -0
  9. agents/agentic_rag_vertexai_search/app/templates.py +53 -0
  10. agents/agentic_rag_vertexai_search/notebooks/evaluating_langgraph_agent.ipynb +1561 -0
  11. agents/agentic_rag_vertexai_search/template/.templateconfig.yaml +14 -0
  12. agents/agentic_rag_vertexai_search/tests/integration/test_agent.py +57 -0
  13. agents/crewai_coding_crew/README.md +34 -0
  14. agents/crewai_coding_crew/app/agent.py +86 -0
  15. agents/crewai_coding_crew/app/crew/config/agents.yaml +39 -0
  16. agents/crewai_coding_crew/app/crew/config/tasks.yaml +37 -0
  17. agents/crewai_coding_crew/app/crew/crew.py +71 -0
  18. agents/crewai_coding_crew/notebooks/evaluating_crewai_agent.ipynb +1571 -0
  19. agents/crewai_coding_crew/notebooks/evaluating_langgraph_agent.ipynb +1561 -0
  20. agents/crewai_coding_crew/template/.templateconfig.yaml +12 -0
  21. agents/crewai_coding_crew/tests/integration/test_agent.py +47 -0
  22. agents/langgraph_base_react/README.md +9 -0
  23. agents/langgraph_base_react/app/agent.py +73 -0
  24. agents/langgraph_base_react/notebooks/evaluating_langgraph_agent.ipynb +1561 -0
  25. agents/langgraph_base_react/template/.templateconfig.yaml +13 -0
  26. agents/langgraph_base_react/tests/integration/test_agent.py +48 -0
  27. agents/multimodal_live_api/README.md +50 -0
  28. agents/multimodal_live_api/app/agent.py +86 -0
  29. agents/multimodal_live_api/app/server.py +193 -0
  30. agents/multimodal_live_api/app/templates.py +51 -0
  31. agents/multimodal_live_api/app/vector_store.py +55 -0
  32. agents/multimodal_live_api/template/.templateconfig.yaml +15 -0
  33. agents/multimodal_live_api/tests/integration/test_server_e2e.py +254 -0
  34. agents/multimodal_live_api/tests/load_test/load_test.py +40 -0
  35. agents/multimodal_live_api/tests/unit/test_server.py +143 -0
  36. src/base_template/.gitignore +197 -0
  37. src/base_template/Makefile +37 -0
  38. src/base_template/README.md +91 -0
  39. src/base_template/app/utils/tracing.py +143 -0
  40. src/base_template/app/utils/typing.py +115 -0
  41. src/base_template/deployment/README.md +123 -0
  42. src/base_template/deployment/cd/deploy-to-prod.yaml +98 -0
  43. src/base_template/deployment/cd/staging.yaml +215 -0
  44. src/base_template/deployment/ci/pr_checks.yaml +51 -0
  45. src/base_template/deployment/terraform/apis.tf +34 -0
  46. src/base_template/deployment/terraform/build_triggers.tf +122 -0
  47. src/base_template/deployment/terraform/dev/apis.tf +42 -0
  48. src/base_template/deployment/terraform/dev/iam.tf +90 -0
  49. src/base_template/deployment/terraform/dev/log_sinks.tf +66 -0
  50. src/base_template/deployment/terraform/dev/providers.tf +29 -0
  51. src/base_template/deployment/terraform/dev/storage.tf +76 -0
  52. src/base_template/deployment/terraform/dev/variables.tf +126 -0
  53. src/base_template/deployment/terraform/dev/vars/env.tfvars +21 -0
  54. src/base_template/deployment/terraform/iam.tf +130 -0
  55. src/base_template/deployment/terraform/locals.tf +50 -0
  56. src/base_template/deployment/terraform/log_sinks.tf +72 -0
  57. src/base_template/deployment/terraform/providers.tf +35 -0
  58. src/base_template/deployment/terraform/service_accounts.tf +42 -0
  59. src/base_template/deployment/terraform/storage.tf +100 -0
  60. src/base_template/deployment/terraform/variables.tf +202 -0
  61. src/base_template/deployment/terraform/vars/env.tfvars +43 -0
  62. src/base_template/pyproject.toml +113 -0
  63. src/base_template/tests/unit/test_utils/test_tracing_exporter.py +140 -0
  64. src/cli/commands/create.py +534 -0
  65. src/cli/commands/setup_cicd.py +730 -0
  66. src/cli/main.py +35 -0
  67. src/cli/utils/__init__.py +35 -0
  68. src/cli/utils/cicd.py +662 -0
  69. src/cli/utils/gcp.py +120 -0
  70. src/cli/utils/logging.py +51 -0
  71. src/cli/utils/template.py +644 -0
  72. src/data_ingestion/README.md +79 -0
  73. src/data_ingestion/data_ingestion_pipeline/components/ingest_data.py +175 -0
  74. src/data_ingestion/data_ingestion_pipeline/components/process_data.py +321 -0
  75. src/data_ingestion/data_ingestion_pipeline/pipeline.py +58 -0
  76. src/data_ingestion/data_ingestion_pipeline/submit_pipeline.py +184 -0
  77. src/data_ingestion/pyproject.toml +17 -0
  78. src/data_ingestion/uv.lock +999 -0
  79. src/deployment_targets/agent_engine/app/agent_engine_app.py +238 -0
  80. src/deployment_targets/agent_engine/app/utils/gcs.py +42 -0
  81. src/deployment_targets/agent_engine/deployment_metadata.json +4 -0
  82. src/deployment_targets/agent_engine/notebooks/intro_reasoning_engine.ipynb +869 -0
  83. src/deployment_targets/agent_engine/tests/integration/test_agent_engine_app.py +120 -0
  84. src/deployment_targets/agent_engine/tests/load_test/.results/.placeholder +0 -0
  85. src/deployment_targets/agent_engine/tests/load_test/.results/report.html +264 -0
  86. src/deployment_targets/agent_engine/tests/load_test/.results/results_exceptions.csv +1 -0
  87. src/deployment_targets/agent_engine/tests/load_test/.results/results_failures.csv +1 -0
  88. src/deployment_targets/agent_engine/tests/load_test/.results/results_stats.csv +3 -0
  89. src/deployment_targets/agent_engine/tests/load_test/.results/results_stats_history.csv +22 -0
  90. src/deployment_targets/agent_engine/tests/load_test/README.md +42 -0
  91. src/deployment_targets/agent_engine/tests/load_test/load_test.py +100 -0
  92. src/deployment_targets/agent_engine/tests/unit/test_dummy.py +22 -0
  93. src/deployment_targets/cloud_run/Dockerfile +29 -0
  94. src/deployment_targets/cloud_run/app/server.py +128 -0
  95. src/deployment_targets/cloud_run/deployment/terraform/artifact_registry.tf +22 -0
  96. src/deployment_targets/cloud_run/deployment/terraform/dev/service_accounts.tf +20 -0
  97. src/deployment_targets/cloud_run/tests/integration/test_server_e2e.py +192 -0
  98. src/deployment_targets/cloud_run/tests/load_test/.results/.placeholder +0 -0
  99. src/deployment_targets/cloud_run/tests/load_test/README.md +79 -0
  100. src/deployment_targets/cloud_run/tests/load_test/load_test.py +85 -0
  101. src/deployment_targets/cloud_run/tests/unit/test_server.py +142 -0
  102. src/deployment_targets/cloud_run/uv.lock +6952 -0
  103. src/frontends/live_api_react/frontend/package-lock.json +19405 -0
  104. src/frontends/live_api_react/frontend/package.json +56 -0
  105. src/frontends/live_api_react/frontend/public/favicon.ico +0 -0
  106. src/frontends/live_api_react/frontend/public/index.html +62 -0
  107. src/frontends/live_api_react/frontend/public/robots.txt +3 -0
  108. src/frontends/live_api_react/frontend/src/App.scss +189 -0
  109. src/frontends/live_api_react/frontend/src/App.test.tsx +25 -0
  110. src/frontends/live_api_react/frontend/src/App.tsx +205 -0
  111. src/frontends/live_api_react/frontend/src/components/audio-pulse/AudioPulse.tsx +64 -0
  112. src/frontends/live_api_react/frontend/src/components/audio-pulse/audio-pulse.scss +68 -0
  113. src/frontends/live_api_react/frontend/src/components/control-tray/ControlTray.tsx +217 -0
  114. src/frontends/live_api_react/frontend/src/components/control-tray/control-tray.scss +201 -0
  115. src/frontends/live_api_react/frontend/src/components/logger/Logger.tsx +241 -0
  116. src/frontends/live_api_react/frontend/src/components/logger/logger.scss +133 -0
  117. src/frontends/live_api_react/frontend/src/components/logger/mock-logs.ts +151 -0
  118. src/frontends/live_api_react/frontend/src/components/side-panel/SidePanel.tsx +161 -0
  119. src/frontends/live_api_react/frontend/src/components/side-panel/side-panel.scss +285 -0
  120. src/frontends/live_api_react/frontend/src/contexts/LiveAPIContext.tsx +48 -0
  121. src/frontends/live_api_react/frontend/src/hooks/use-live-api.ts +115 -0
  122. src/frontends/live_api_react/frontend/src/hooks/use-media-stream-mux.ts +23 -0
  123. src/frontends/live_api_react/frontend/src/hooks/use-screen-capture.ts +72 -0
  124. src/frontends/live_api_react/frontend/src/hooks/use-webcam.ts +69 -0
  125. src/frontends/live_api_react/frontend/src/index.css +28 -0
  126. src/frontends/live_api_react/frontend/src/index.tsx +35 -0
  127. src/frontends/live_api_react/frontend/src/multimodal-live-types.ts +242 -0
  128. src/frontends/live_api_react/frontend/src/react-app-env.d.ts +17 -0
  129. src/frontends/live_api_react/frontend/src/reportWebVitals.ts +31 -0
  130. src/frontends/live_api_react/frontend/src/setupTests.ts +21 -0
  131. src/frontends/live_api_react/frontend/src/utils/audio-recorder.ts +111 -0
  132. src/frontends/live_api_react/frontend/src/utils/audio-streamer.ts +270 -0
  133. src/frontends/live_api_react/frontend/src/utils/audioworklet-registry.ts +43 -0
  134. src/frontends/live_api_react/frontend/src/utils/multimodal-live-client.ts +329 -0
  135. src/frontends/live_api_react/frontend/src/utils/store-logger.ts +64 -0
  136. src/frontends/live_api_react/frontend/src/utils/utils.ts +86 -0
  137. src/frontends/live_api_react/frontend/src/utils/worklets/audio-processing.ts +73 -0
  138. src/frontends/live_api_react/frontend/src/utils/worklets/vol-meter.ts +65 -0
  139. src/frontends/live_api_react/frontend/tsconfig.json +25 -0
  140. src/frontends/streamlit/frontend/side_bar.py +213 -0
  141. src/frontends/streamlit/frontend/streamlit_app.py +263 -0
  142. src/frontends/streamlit/frontend/style/app_markdown.py +37 -0
  143. src/frontends/streamlit/frontend/utils/chat_utils.py +67 -0
  144. src/frontends/streamlit/frontend/utils/local_chat_history.py +125 -0
  145. src/frontends/streamlit/frontend/utils/message_editing.py +59 -0
  146. src/frontends/streamlit/frontend/utils/multimodal_utils.py +217 -0
  147. src/frontends/streamlit/frontend/utils/stream_handler.py +282 -0
  148. src/frontends/streamlit/frontend/utils/title_summary.py +77 -0
  149. src/resources/containers/data_processing/Dockerfile +25 -0
  150. src/resources/locks/uv-agentic_rag_vertexai_search-agent_engine.lock +4684 -0
  151. src/resources/locks/uv-agentic_rag_vertexai_search-cloud_run.lock +5799 -0
  152. src/resources/locks/uv-crewai_coding_crew-agent_engine.lock +5509 -0
  153. src/resources/locks/uv-crewai_coding_crew-cloud_run.lock +6688 -0
  154. src/resources/locks/uv-langgraph_base_react-agent_engine.lock +4595 -0
  155. src/resources/locks/uv-langgraph_base_react-cloud_run.lock +5710 -0
  156. src/resources/locks/uv-multimodal_live_api-cloud_run.lock +5665 -0
  157. src/resources/setup_cicd/cicd_variables.tf +36 -0
  158. src/resources/setup_cicd/github.tf +85 -0
  159. src/resources/setup_cicd/providers.tf +39 -0
  160. src/utils/generate_locks.py +135 -0
  161. src/utils/lock_utils.py +82 -0
  162. src/utils/watch_and_rebuild.py +190 -0
@@ -0,0 +1,238 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import datetime
16
+ import json
17
+ import logging
18
+ import os
19
+ from collections.abc import Iterable, Mapping, Sequence
20
+ from typing import (
21
+ Any,
22
+ )
23
+
24
+ import google.auth
25
+ import vertexai
26
+ from google.cloud import logging as google_cloud_logging
27
+ from langchain_core.runnables import RunnableConfig
28
+ from traceloop.sdk import Instruments, Traceloop
29
+ from vertexai.preview import reasoning_engines
30
+
31
+ from app.utils.gcs import create_bucket_if_not_exists
32
+ from app.utils.tracing import CloudTraceLoggingSpanExporter
33
+ from app.utils.typing import Feedback, InputChat, dumpd, ensure_valid_config
34
+
35
+
36
+ logging.basicConfig(
37
+ level=logging.INFO,
38
+ )
39
+
40
+ class AgentEngineApp:
41
+ """Class for managing agent engine functionality."""
42
+
43
+ def __init__(self, project_id: str | None = None, env_vars: dict[str, str] | None = None) -> None:
44
+ """Initialize the AgentEngineApp variables"""
45
+ self.project_id = project_id
46
+ self.env_vars = env_vars if env_vars is not None else {}
47
+
48
+
49
+ def set_up(self) -> None:
50
+ """The set_up method is used to define application initialization logic"""
51
+ import os
52
+
53
+ for k, v in self.env_vars.items():
54
+ os.environ[k] = v
55
+
56
+ # Lazy import agent at setup time to avoid deployment dependencies
57
+ from app.agent import agent
58
+
59
+ logging_client = google_cloud_logging.Client(project=self.project_id)
60
+ self.logger = logging_client.logger(__name__)
61
+
62
+ # Initialize Telemetry
63
+ try:
64
+ Traceloop.init(
65
+ app_name="{{cookiecutter.project_name}}",
66
+ disable_batch=False,
67
+ exporter=CloudTraceLoggingSpanExporter(project_id=self.project_id),
68
+ instruments={Instruments.LANGCHAIN, Instruments.CREW},
69
+ )
70
+ except Exception as e:
71
+ logging.error("Failed to initialize Telemetry: %s", str(e))
72
+
73
+ self.runnable = agent
74
+
75
+ # Add any additional variables here that should be included in the tracing logs
76
+ def set_tracing_properties(self, config: RunnableConfig | None) -> None:
77
+ """Sets tracing association properties for the current request.
78
+
79
+ Args:
80
+ config: Optional RunnableConfig containing request metadata
81
+ """
82
+ config = ensure_valid_config(config)
83
+ Traceloop.set_association_properties(
84
+ {
85
+ "log_type": "tracing",
86
+ "run_id": str(config["run_id"]),
87
+ "user_id": config["metadata"].pop("user_id", "None"),
88
+ "session_id": config["metadata"].pop("session_id", "None"),
89
+ "commit_sha": os.environ.get("COMMIT_SHA", "None"),
90
+ }
91
+ )
92
+
93
+ def stream_query(
94
+ self,
95
+ *,
96
+ input: str | Mapping,
97
+ config: RunnableConfig | None = None,
98
+ **kwargs: Any,
99
+ ) -> Iterable[Any]:
100
+ """Stream responses from the agent for a given input."""
101
+
102
+ config = ensure_valid_config(config)
103
+ self.set_tracing_properties(config=config)
104
+ # Validate input. We assert the input is a list of messages
105
+ input_chat = InputChat.model_validate(input)
106
+
107
+ for chunk in self.runnable.stream(
108
+ input=input_chat, config=config, **kwargs, stream_mode="messages"
109
+ ):
110
+ dumped_chunk = dumpd(chunk)
111
+ yield dumped_chunk
112
+
113
+ def register_feedback(self, feedback: dict[str, Any]) -> None:
114
+ """Collect and log feedback."""
115
+ feedback_obj = Feedback.model_validate(feedback)
116
+ self.logger.log_struct(feedback_obj.model_dump(), severity="INFO")
117
+
118
+ def query(
119
+ self,
120
+ *,
121
+ input: str | Mapping,
122
+ config: RunnableConfig | None = None,
123
+ **kwargs: Any,
124
+ ) -> Any:
125
+ """Process a single input and return the agent's response."""
126
+ return dumpd(self.runnable.invoke(input=input, config=config, **kwargs))
127
+
128
+ def register_operations(self) -> Mapping[str, Sequence]:
129
+ """Registers the operations of the Agent.
130
+
131
+ This mapping defines how different operation modes (e.g., "", "stream")
132
+ are implemented by specific methods of the Agent. The "default" mode,
133
+ represented by the empty string ``, is associated with the `query` API,
134
+ while the "stream" mode is associated with the `stream_query` API.
135
+
136
+ Returns:
137
+ Mapping[str, Sequence[str]]: A mapping of operation modes to a list
138
+ of method names that implement those operation modes.
139
+ """
140
+ return {
141
+ "": ["query", "register_feedback"],
142
+ "stream": ["stream_query"],
143
+ }
144
+
145
+
146
+ def deploy_agent_engine_app(
147
+ project: str | None = None,
148
+ location: str | None = None,
149
+ agent_name: str | None = None,
150
+ requirements_file: str = ".requirements.txt",
151
+ extra_packages: list[str] = ["./app"],
152
+ env_vars: dict[str, str] | None = None,
153
+ ) -> reasoning_engines.ReasoningEngine:
154
+ """Deploy the agent engine app to Vertex AI."""
155
+
156
+ staging_bucket = f"gs://{project}-agent-engine"
157
+
158
+ create_bucket_if_not_exists(
159
+ bucket_name=staging_bucket, project=project, location=location
160
+ )
161
+ vertexai.init(project=project, location=location, staging_bucket=staging_bucket)
162
+
163
+ # Read requirements
164
+ with open(requirements_file) as f:
165
+ requirements = f.read().strip().split("\n")
166
+
167
+ agent = AgentEngineApp(project_id=project, env_vars=env_vars)
168
+
169
+ # Common configuration for both create and update operations
170
+ agent_config = {
171
+ "reasoning_engine": agent,
172
+ "requirements": requirements,
173
+ "display_name": agent_name,
174
+ "description": "This is a sample custom application in Reasoning Engine that uses LangGraph",
175
+ "extra_packages": extra_packages,
176
+ }
177
+
178
+ logging.info(f"Agent config: {agent_config}")
179
+
180
+ # Check if an agent with this name already exists
181
+ existing_agents = reasoning_engines.ReasoningEngine.list(
182
+ filter=f"display_name={agent_name}"
183
+ )
184
+
185
+ if existing_agents:
186
+ # Update the existing agent with new configuration
187
+ logging.info(f"Updating existing agent: {agent_name}")
188
+ remote_agent = existing_agents[0].update(**agent_config)
189
+ else:
190
+ # Create a new agent if none exists
191
+ logging.info(f"Creating new agent: {agent_name}")
192
+ remote_agent = reasoning_engines.ReasoningEngine.create(**agent_config)
193
+
194
+ config = {
195
+ "remote_agent_engine_id": remote_agent.resource_name,
196
+ "deployment_timestamp": datetime.datetime.now().isoformat(),
197
+ }
198
+ config_file = "deployment_metadata.json"
199
+
200
+ with open(config_file, "w") as f:
201
+ json.dump(config, f, indent=2)
202
+
203
+ logging.info(f"Agent Engine ID written to {config_file}")
204
+
205
+ return remote_agent
206
+
207
+
208
+ if __name__ == "__main__":
209
+ import argparse
210
+
211
+ parser = argparse.ArgumentParser(description="Deploy agent engine app to Vertex AI")
212
+ parser.add_argument("--project", default=None, help="GCP project ID (defaults to application default credentials)")
213
+ parser.add_argument("--location", default="us-central1", help="GCP region (defaults to us-central1)")
214
+ parser.add_argument("--agent-name", default="{{cookiecutter.project_name}}", help="Name for the agent engine")
215
+ parser.add_argument("--requirements-file", default=".requirements.txt", help="Path to requirements.txt file")
216
+ parser.add_argument("--extra-packages", nargs="+", default=["./app"], help="Additional packages to include")
217
+ parser.add_argument("--set-env-vars", help="Comma-separated list of environment variables in KEY=VALUE format")
218
+ args = parser.parse_args()
219
+
220
+ # Parse environment variables if provided
221
+ env_vars = None
222
+ if args.set_env_vars:
223
+ env_vars = {}
224
+ for pair in args.set_env_vars.split(","):
225
+ key, value = pair.split("=", 1)
226
+ env_vars[key] = value
227
+
228
+ if not args.project:
229
+ _, args.project = google.auth.default()
230
+
231
+ deploy_agent_engine_app(
232
+ project=args.project,
233
+ location=args.location,
234
+ agent_name=args.agent_name,
235
+ requirements_file=args.requirements_file,
236
+ extra_packages=args.extra_packages,
237
+ env_vars=env_vars
238
+ )
@@ -0,0 +1,42 @@
1
+ # Copyright 2025 Google LLC
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ import logging
16
+
17
+ from google.api_core import exceptions
18
+ from google.cloud import storage
19
+
20
+
21
+ def create_bucket_if_not_exists(bucket_name: str, project: str, location: str) -> None:
22
+ """Creates a new bucket if it doesn't already exist.
23
+
24
+ Args:
25
+ bucket_name: Name of the bucket to create
26
+ project: Google Cloud project ID
27
+ location: Location to create the bucket in (defaults to us-central1)
28
+ """
29
+ storage_client = storage.Client(project=project)
30
+
31
+ if bucket_name.startswith("gs://"):
32
+ bucket_name = bucket_name[5:]
33
+ try:
34
+ storage_client.get_bucket(bucket_name)
35
+ logging.info(f"Bucket {bucket_name} already exists")
36
+ except exceptions.NotFound:
37
+ bucket = storage_client.create_bucket(
38
+ bucket_name,
39
+ location=location,
40
+ project=project,
41
+ )
42
+ logging.info(f"Created bucket {bucket.name} in {bucket.location}")
@@ -0,0 +1,4 @@
1
+ {
2
+ "remote_agent_engine_id": "None",
3
+ "deployment_timestamp": "None"
4
+ }