mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-14 00:47:27 +00:00
google-genai[patch]: Invoke callback prior to yielding token (#17092)
- **Description:** Invoke callback prior to yielding token in stream and astream methods for Google-genai, - **Issue:** the issue # 16913, - **Twitter handle:** Sparsh10649446 --------- Co-authored-by: Eugene Yurtsev <eyurtsev@gmail.com>
This commit is contained in:
parent
7306600e2f
commit
a2167614b7
@ -624,9 +624,9 @@ class ChatGoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseChatModel):
|
||||
generation_t=ChatGenerationChunk,
|
||||
)
|
||||
gen = cast(ChatGenerationChunk, _chat_result.generations[0])
|
||||
yield gen
|
||||
if run_manager:
|
||||
run_manager.on_llm_new_token(gen.text)
|
||||
yield gen
|
||||
|
||||
async def _astream(
|
||||
self,
|
||||
@ -654,9 +654,9 @@ class ChatGoogleGenerativeAI(_BaseGoogleGenerativeAI, BaseChatModel):
|
||||
generation_t=ChatGenerationChunk,
|
||||
)
|
||||
gen = cast(ChatGenerationChunk, _chat_result.generations[0])
|
||||
yield gen
|
||||
if run_manager:
|
||||
await run_manager.on_llm_new_token(gen.text)
|
||||
yield gen
|
||||
|
||||
def _prepare_chat(
|
||||
self,
|
||||
|
Loading…
Reference in New Issue
Block a user