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,145 @@
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
+ # mypy: disable-error-code="arg-type"
16
+ import os
17
+
18
+ import google
19
+ import vertexai
20
+ from langchain_core.documents import Document
21
+ from langchain_core.messages import BaseMessage
22
+ from langchain_core.runnables import RunnableConfig
23
+ from langchain_core.tools import tool
24
+ from langchain_google_vertexai import ChatVertexAI, VertexAIEmbeddings
25
+ from langgraph.graph import END, MessagesState, StateGraph
26
+ from langgraph.prebuilt import ToolNode
27
+
28
+ from app.retrievers import get_compressor, get_retriever
29
+ from app.templates import format_docs, inspect_conversation_template, rag_template
30
+
31
+ EMBEDDING_MODEL = "text-embedding-005"
32
+ LOCATION = "us-central1"
33
+ LLM = "gemini-2.0-flash-001"
34
+ EMBEDDING_COLUMN = "embedding"
35
+ TOP_K = 5
36
+
37
+ data_store_region = os.getenv("DATA_STORE_REGION", "us")
38
+ data_store_id = os.getenv("DATA_STORE_ID", "sample-datastore")
39
+
40
+ # Initialize Google Cloud and Vertex AI
41
+ credentials, project_id = google.auth.default()
42
+ vertexai.init(project=project_id, location=LOCATION)
43
+
44
+ embedding = VertexAIEmbeddings(
45
+ project=project_id, location=LOCATION, model_name=EMBEDDING_MODEL
46
+ )
47
+
48
+ retriever = get_retriever(
49
+ project_id=project_id,
50
+ data_store_id=data_store_id,
51
+ data_store_region=data_store_region,
52
+ embedding=embedding,
53
+ embedding_column=EMBEDDING_COLUMN,
54
+ max_documents=10,
55
+ )
56
+ compressor = get_compressor(
57
+ project_id=project_id,
58
+ )
59
+
60
+
61
+ @tool(response_format="content_and_artifact")
62
+ def retrieve_docs(query: str) -> tuple[str, list[Document]]:
63
+ """
64
+ Useful for retrieving relevant documents based on a query.
65
+ Use this when you need additional information to answer a question.
66
+
67
+ Args:
68
+ query (str): The user's question or search query.
69
+
70
+ Returns:
71
+ List[Document]: A list of the top-ranked Document objects, limited to TOP_K (5) results.
72
+ """
73
+ # Use the retriever to fetch relevant documents based on the query
74
+ retrieved_docs = retriever.invoke(query)
75
+ # Re-rank docs with Vertex AI Rank for better relevance
76
+ ranked_docs = compressor.compress_documents(documents=retrieved_docs, query=query)
77
+ # Format ranked documents into a consistent structure for LLM consumption
78
+ formatted_docs = format_docs.format(docs=ranked_docs)
79
+ return (formatted_docs, ranked_docs)
80
+
81
+
82
+ @tool
83
+ def should_continue() -> None:
84
+ """
85
+ Use this tool if you determine that you have enough context to respond to the questions of the user.
86
+ """
87
+ return None
88
+
89
+
90
+ tools = [retrieve_docs, should_continue]
91
+
92
+ llm = ChatVertexAI(model=LLM, temperature=0, max_tokens=1024, streaming=True)
93
+
94
+ # Set up conversation inspector
95
+ inspect_conversation = inspect_conversation_template | llm.bind_tools(
96
+ tools, tool_choice="any"
97
+ )
98
+
99
+ # Set up response chain
100
+ response_chain = rag_template | llm
101
+
102
+
103
+ def inspect_conversation_node(
104
+ state: MessagesState, config: RunnableConfig
105
+ ) -> dict[str, BaseMessage]:
106
+ """Inspects the conversation state and returns the next message using the conversation inspector."""
107
+ response = inspect_conversation.invoke(state, config)
108
+ return {"messages": response}
109
+
110
+
111
+ def generate_node(
112
+ state: MessagesState, config: RunnableConfig
113
+ ) -> dict[str, BaseMessage]:
114
+ """Generates a response using the RAG template and returns it as a message."""
115
+ response = response_chain.invoke(state, config)
116
+ return {"messages": response}
117
+
118
+
119
+ # Flow:
120
+ # 1. Start with agent node that inspects conversation using inspect_conversation_node
121
+ # 2. Agent node connects to tools node which can either:
122
+ # - Retrieve relevant docs using retrieve_docs tool
123
+ # - End tool usage with should_continue tool
124
+ # 3. Tools node connects to generate node which produces final response
125
+ # 4. Generate node connects to END to complete the workflow
126
+
127
+ workflow = StateGraph(MessagesState)
128
+ workflow.add_node("agent", inspect_conversation_node)
129
+ workflow.add_node("generate", generate_node)
130
+ workflow.set_entry_point("agent")
131
+
132
+ workflow.add_node(
133
+ "tools",
134
+ ToolNode(
135
+ tools=tools,
136
+ # With False, tool errors won't be caught by LangGraph
137
+ handle_tool_errors=False,
138
+ ),
139
+ )
140
+ workflow.add_edge("agent", "tools")
141
+ workflow.add_edge("tools", "generate")
142
+
143
+ workflow.add_edge("generate", END)
144
+
145
+ agent = workflow.compile()
@@ -0,0 +1,79 @@
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 os
16
+ from unittest.mock import MagicMock
17
+
18
+ from langchain_google_community import VertexAISearchRetriever
19
+ from langchain_google_community.vertex_rank import VertexAIRank
20
+ from langchain_google_vertexai import VertexAIEmbeddings
21
+
22
+
23
+ def get_retriever(
24
+ project_id: str,
25
+ data_store_id: str,
26
+ data_store_region: str,
27
+ embedding: VertexAIEmbeddings,
28
+ embedding_column: str = "embedding",
29
+ max_documents: int = 10,
30
+ custom_embedding_ratio: float = 0.5,
31
+ ) -> VertexAISearchRetriever:
32
+ """
33
+ Creates and returns an instance of the retriever service.
34
+
35
+ Uses mock service if the INTEGRATION_TEST environment variable is set to "TRUE",
36
+ otherwise initializes real Vertex AI retriever.
37
+ """
38
+ if os.getenv("INTEGRATION_TEST") == "TRUE":
39
+ retriever = MagicMock()
40
+ retriever.invoke = lambda x: []
41
+ return retriever
42
+
43
+ return VertexAISearchRetriever(
44
+ project_id=project_id,
45
+ data_store_id=data_store_id,
46
+ location_id=data_store_region,
47
+ engine_data_type=1,
48
+ # The following parameters are used when you want to search
49
+ # using custom embeddings in Agent Builder.
50
+ # The ratio is set to 0.5 by default to use a mix of custom
51
+ # embeddings but you can adapt the ratio as you need.
52
+ custom_embedding_ratio=custom_embedding_ratio,
53
+ custom_embedding=embedding,
54
+ custom_embedding_field_path=embedding_column,
55
+ # Extracting 20 documents before re-rank.
56
+ max_documents=max_documents,
57
+ beta=True,
58
+ )
59
+
60
+
61
+ def get_compressor(project_id: str, top_n: int = 5) -> VertexAIRank:
62
+ """
63
+ Creates and returns an instance of the compressor service.
64
+
65
+ Uses mock service if the INTEGRATION_TEST environment variable is set to "TRUE",
66
+ otherwise initializes real Vertex AI compressor.
67
+ """
68
+ if os.getenv("INTEGRATION_TEST") == "TRUE":
69
+ compressor = MagicMock()
70
+ compressor.compress_documents = lambda documents, query: []
71
+ return compressor
72
+
73
+ return VertexAIRank(
74
+ project_id=project_id,
75
+ location_id="global",
76
+ ranking_config="default_ranking_config",
77
+ title_field="id",
78
+ top_n=top_n,
79
+ )
@@ -0,0 +1,53 @@
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
+ from langchain_core.prompts import (
16
+ ChatPromptTemplate,
17
+ MessagesPlaceholder,
18
+ PromptTemplate,
19
+ )
20
+
21
+ format_docs = PromptTemplate.from_template(
22
+ """## Context provided:
23
+ {% for doc in docs%}
24
+ <Document {{ loop.index0 }}>
25
+ {{ doc.page_content | safe }}
26
+ </Document {{ loop.index0 }}>
27
+ {% endfor %}
28
+ """,
29
+ template_format="jinja2",
30
+ )
31
+
32
+ inspect_conversation_template = ChatPromptTemplate.from_messages(
33
+ [
34
+ (
35
+ "system",
36
+ """You are an AI assistant tasked with analyzing the conversation"""
37
+ """ and determining the best course of action.""",
38
+ ),
39
+ MessagesPlaceholder(variable_name="messages"),
40
+ ]
41
+ )
42
+
43
+ rag_template = ChatPromptTemplate.from_messages(
44
+ [
45
+ (
46
+ "system",
47
+ """You are an AI assistant for question-answering tasks."""
48
+ """ Answer to the best of your ability using the context provided."""
49
+ """ Leverage the Tools you are provided to answer questions.""",
50
+ ),
51
+ MessagesPlaceholder(variable_name="messages"),
52
+ ]
53
+ )