agent-starter-pack 0.4.2__py3-none-any.whl → 0.4.3__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.
- {agent_starter_pack-0.4.2.dist-info → agent_starter_pack-0.4.3.dist-info}/METADATA +1 -1
- {agent_starter_pack-0.4.2.dist-info → agent_starter_pack-0.4.3.dist-info}/RECORD +8 -8
- agents/live_api/README.md +1 -1
- agents/live_api/app/agent.py +1 -2
- agents/live_api/app/server.py +13 -14
- {agent_starter_pack-0.4.2.dist-info → agent_starter_pack-0.4.3.dist-info}/WHEEL +0 -0
- {agent_starter_pack-0.4.2.dist-info → agent_starter_pack-0.4.3.dist-info}/entry_points.txt +0 -0
- {agent_starter_pack-0.4.2.dist-info → agent_starter_pack-0.4.3.dist-info}/licenses/LICENSE +0 -0
@@ -26,9 +26,9 @@ agents/langgraph_base_react/app/agent.py,sha256=srxiOT-NIM87WnUvP0PXuZGryEG9S33Z
|
|
26
26
|
agents/langgraph_base_react/notebooks/evaluating_langgraph_agent.ipynb,sha256=PlW41fL-ji9NKkimW6u25YRLGWN2pgoX2G8w5nzIEPE,58737
|
27
27
|
agents/langgraph_base_react/template/.templateconfig.yaml,sha256=NE_EJzZPtdbJRFdp5k9fovc6zUA6Wvm1MBUBvaZ6gV0,1050
|
28
28
|
agents/langgraph_base_react/tests/integration/test_agent.py,sha256=wg2Y8V4l7dh7rhWy7Z8zioDW5ILRsz7RZJ-mz0AhK3U,1619
|
29
|
-
agents/live_api/README.md,sha256=
|
30
|
-
agents/live_api/app/agent.py,sha256=
|
31
|
-
agents/live_api/app/server.py,sha256=
|
29
|
+
agents/live_api/README.md,sha256=c3lu5WguOUBc5hO_UtNZfVhfYxvSzMXuGFICn9M38mU,2897
|
30
|
+
agents/live_api/app/agent.py,sha256=FBsmCYI_dmBIbFD1uojcPxJfozGNc-0rg1fW2PhEyFw,2298
|
31
|
+
agents/live_api/app/server.py,sha256=A2frpeM-mHoRiUAlvJKZAdU_Q8-GOwcCh3iODdRmbr4,7652
|
32
32
|
agents/live_api/template/.templateconfig.yaml,sha256=xN4ZNa_-qoBWNh4oMh8WBu-KmxUAYtJdF7qlYbHg-FM,964
|
33
33
|
agents/live_api/tests/integration/test_server_e2e.py,sha256=D2VETDIyTD2fQyQ6DXwLr-POSYyVzzzcpIFLt5Ppyx4,8398
|
34
34
|
agents/live_api/tests/load_test/load_test.py,sha256=HHZyfC4gqiQtZVF_CbbxENGgWQccMLpwMv0IdoQ6cbQ,1275
|
@@ -169,8 +169,8 @@ src/resources/setup_cicd/providers.tf,sha256=Km4z6IJt7x7PLaa0kyZbBrO2m3lpuIJZFD5
|
|
169
169
|
src/utils/generate_locks.py,sha256=6V1B8V2BEuevWnXUsxZVTrLjXwFRII8UfsIGrQqZxVs,4320
|
170
170
|
src/utils/lock_utils.py,sha256=RSE6n3hBkH64xNm3Q5wrR0Pqbeo-oc7xaTOhA9yzHjk,2275
|
171
171
|
src/utils/watch_and_rebuild.py,sha256=vP4yIiA7E_lj5sfQdJUl8TXas6V7msDg8XWUutAC05Q,6679
|
172
|
-
agent_starter_pack-0.4.
|
173
|
-
agent_starter_pack-0.4.
|
174
|
-
agent_starter_pack-0.4.
|
175
|
-
agent_starter_pack-0.4.
|
176
|
-
agent_starter_pack-0.4.
|
172
|
+
agent_starter_pack-0.4.3.dist-info/METADATA,sha256=hRLsQG8-8zRQBkhkmzFxUU7FdmF4pyNmczu8YSUTrRk,10452
|
173
|
+
agent_starter_pack-0.4.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
174
|
+
agent_starter_pack-0.4.3.dist-info/entry_points.txt,sha256=U7uCxR7YulIhZ0L8R8Hui0Bsy6J7oyESBeDYJYMrQjA,56
|
175
|
+
agent_starter_pack-0.4.3.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
176
|
+
agent_starter_pack-0.4.3.dist-info/RECORD,,
|
agents/live_api/README.md
CHANGED
@@ -6,7 +6,7 @@ This pattern showcases a real-time conversational agent powered by Google Gemini
|
|
6
6
|
|
7
7
|
**Key components:**
|
8
8
|
|
9
|
-
- **Python Backend** (in `app/` folder): A production-ready server built with [FastAPI](https://fastapi.tiangolo.com/) and [google-genai](https://googleapis.github.io/python-
|
9
|
+
- **Python Backend** (in `app/` folder): A production-ready server built with [FastAPI](https://fastapi.tiangolo.com/) and [google-genai](https://googleapis.github.io/python-genai/) that features:
|
10
10
|
|
11
11
|
- **Real-time bidirectional communication** via WebSockets between the frontend and Gemini model
|
12
12
|
- **Integrated tool calling** with a weather information tool for demonstrating external data retrieval
|
agents/live_api/app/agent.py
CHANGED
@@ -22,8 +22,7 @@ from google.genai import types
|
|
22
22
|
# Constants
|
23
23
|
VERTEXAI = os.getenv("VERTEXAI", "true").lower() == "true"
|
24
24
|
LOCATION = "us-central1"
|
25
|
-
|
26
|
-
MODEL_ID = "gemini-2.0-flash-exp"
|
25
|
+
MODEL_ID = "gemini-2.0-flash-live-preview-04-09"
|
27
26
|
|
28
27
|
# Initialize Google Cloud clients
|
29
28
|
credentials, project_id = google.auth.default()
|
agents/live_api/app/server.py
CHANGED
@@ -70,6 +70,7 @@ class GeminiSession:
|
|
70
70
|
while True:
|
71
71
|
try:
|
72
72
|
data = await self.websocket.receive_json()
|
73
|
+
|
73
74
|
if isinstance(data, dict) and (
|
74
75
|
"realtimeInput" in data or "clientContent" in data
|
75
76
|
):
|
@@ -98,13 +99,7 @@ class GeminiSession:
|
|
98
99
|
async def _handle_tool_call(
|
99
100
|
self, session: Any, tool_call: LiveServerToolCall
|
100
101
|
) -> None:
|
101
|
-
"""Process tool calls from Gemini and send back responses.
|
102
|
-
|
103
|
-
Args:
|
104
|
-
session: The Gemini session
|
105
|
-
tool_call: Tool call request from Gemini
|
106
|
-
"""
|
107
|
-
# Handle case where function_calls might be None
|
102
|
+
"""Process tool calls from Gemini and send back responses."""
|
108
103
|
if tool_call.function_calls is None:
|
109
104
|
logging.debug("No function calls in tool_call")
|
110
105
|
return
|
@@ -116,7 +111,14 @@ class GeminiSession:
|
|
116
111
|
logging.error(f"Function {fc.name} not found")
|
117
112
|
continue
|
118
113
|
args = fc.args if fc.args is not None else {}
|
119
|
-
|
114
|
+
|
115
|
+
# Handle both async and sync functions appropriately
|
116
|
+
if asyncio.iscoroutinefunction(func):
|
117
|
+
# Function is already async
|
118
|
+
response = await func(**args)
|
119
|
+
else:
|
120
|
+
# Run sync function in a thread pool to avoid blocking
|
121
|
+
response = await asyncio.to_thread(func, **args)
|
120
122
|
|
121
123
|
tool_response = types.LiveClientToolResponse(
|
122
124
|
function_responses=[
|
@@ -127,18 +129,15 @@ class GeminiSession:
|
|
127
129
|
await session.send(input=tool_response)
|
128
130
|
|
129
131
|
async def receive_from_gemini(self) -> None:
|
130
|
-
"""Listen for and process messages from Gemini.
|
131
|
-
|
132
|
-
Continuously receives messages from Gemini, forwards them to the client,
|
133
|
-
and handles any tool calls. Handles connection errors gracefully.
|
134
|
-
"""
|
132
|
+
"""Listen for and process messages from Gemini without blocking."""
|
135
133
|
while result := await self.session._ws.recv(decode=False):
|
136
134
|
await self.websocket.send_bytes(result)
|
137
135
|
raw_message = json.loads(result)
|
138
136
|
if "toolCall" in raw_message:
|
139
137
|
message = types.LiveServerMessage.model_validate(raw_message)
|
140
138
|
tool_call = LiveServerToolCall.model_validate(message.tool_call)
|
141
|
-
|
139
|
+
# Create a separate task to handle the tool call without blocking
|
140
|
+
asyncio.create_task(self._handle_tool_call(self.session, tool_call))
|
142
141
|
|
143
142
|
|
144
143
|
def get_connect_and_run_callable(websocket: WebSocket) -> Callable:
|
File without changes
|
File without changes
|
File without changes
|