-
Notifications
You must be signed in to change notification settings - Fork 810
fix gemini live update chatcontext #2057
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
base: main
Are you sure you want to change the base?
Conversation
|
@@ -418,6 +434,15 @@ async def _main_task(self): | |||
async with self._session_lock: | |||
self._session = session | |||
|
|||
# for reconnect, send the updated chat context | |||
if self._chat_ctx: |
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.
if we're reconnecting while calling update_chat_ctx
we need to send updated context.
this will resend chat context once for normal cases.
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.
is there any synchronization if we're calling update_chat_ctx & the reconnection is happening? How do we know it'll not race and send two times?
if not gcp_project or not gcp_location: | ||
raise ValueError( | ||
"Project and location are required for VertexAI either via project and location or GOOGLE_CLOUD_PROJECT and GOOGLE_CLOUD_LOCATION environment variables" # noqa: E501 | ||
) | ||
gemini_api_key = None # VertexAI does not require an API key | ||
|
||
if not (gcp_project and gcp_location): | ||
raise ValueError("Project and location required for VertexAI") | ||
gemini_api_key = None | ||
else: | ||
if not gemini_api_key: | ||
raise ValueError("API key required for Google API") | ||
gcp_project = None | ||
gcp_location = None | ||
if not gemini_api_key: | ||
raise ValueError( | ||
"API key is required for Google API either via api_key or GOOGLE_API_KEY environment variable" # noqa: E501 | ||
) |
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.
I think the messages where better before?
diff = llm.utils.compute_chat_ctx_diff(self._chat_ctx, chat_ctx) | ||
if diff.to_remove: | ||
self._chat_ctx = chat_ctx | ||
self.reset_gemini_session() |
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.
I think it's OK to reconnect, but ideally, we use aiohttp with a connection pool
@@ -602,10 +625,14 @@ def _handle_go_away(self, go_away: LiveServerGoAway): | |||
) | |||
|
|||
def commit_audio(self) -> None: | |||
raise NotImplementedError("commit_audio_buffer is not supported yet") | |||
raise NotImplementedError("commit_audio is not supported yet") | |||
|
|||
def clear_audio(self) -> None: | |||
raise NotImplementedError("clear_audio is not supported yet") | |||
|
|||
def server_vad_enabled(self) -> bool: |
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.
it was there before, but I believe this fnc is unused
@@ -258,6 +255,11 @@ async def _close_gemini_session(self) -> None: | |||
finally: | |||
self._session = None | |||
|
|||
def reset_gemini_session(self) -> None: |
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.
make it private
No description provided.