Skip to content

Commit 29b7a8a

Browse files
committed
fix: gemini async client, events base class for start/finish
1 parent b559017 commit 29b7a8a

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

agents-core/vision_agents/core/agents/events.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from dataclasses import dataclass, field
2-
from vision_agents.core.events import PluginBaseEvent
2+
from vision_agents.core.events import PluginBaseEvent, BaseEvent
33
from typing import Optional, Any, Dict
44

55

plugins/gemini/vision_agents/plugins/gemini/gemini_llm.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
from typing import Optional, List, TYPE_CHECKING, Any, Dict
33

44
from google import genai
5-
from google.genai.client import AsyncClient
5+
from google.genai.client import AsyncClient, Client
66
from google.genai import types
77
from google.genai.types import GenerateContentResponse, GenerateContentConfig
88

@@ -55,7 +55,7 @@ def __init__(self, model: str, api_key: Optional[str] = None, client: Optional[A
5555
if client is not None:
5656
self.client = client
5757
else:
58-
self.client = AsyncClient(api_key=api_key)
58+
self.client = Client(api_key=api_key).aio
5959

6060
async def simple_response(self, text: str, processors: Optional[List[Processor]] = None, participant: Optional[Any] = None) -> LLMResponseEvent[Any]:
6161
"""
@@ -108,7 +108,8 @@ async def send_message(self, *args, **kwargs):
108108
# Gemini API does not have an item_id, we create it here and add it to all events
109109
item_id = str(uuid.uuid4())
110110

111-
for idx, chunk in enumerate(iterator):
111+
idx = 0
112+
async for chunk in iterator:
112113
response_chunk: GenerateContentResponse = chunk
113114
final_chunk = response_chunk
114115
self._standardize_and_emit_event(response_chunk, text_parts, item_id, idx)
@@ -120,6 +121,8 @@ async def send_message(self, *args, **kwargs):
120121
except Exception:
121122
pass # Ignore errors in chunk processing
122123

124+
idx += 1
125+
123126
# Check if there were function calls in the response
124127
if pending_calls:
125128
# Multi-hop tool calling loop

0 commit comments

Comments
 (0)