mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-03 19:57:51 +00:00
community[patch]: callback before yield for gigachat (#26881)
**Description:** Moves yield to after callback for `_stream` and `_astream` function for the gigachat model in the community llm package **Issue:** #16913
This commit is contained in:
parent
11e703a97e
commit
ba467f1a36
@ -311,9 +311,9 @@ class GigaChat(_BaseGigaChat, BaseLLM):
|
||||
for chunk in self._client.stream(payload):
|
||||
if chunk.choices:
|
||||
content = chunk.choices[0].delta.content
|
||||
yield GenerationChunk(text=content)
|
||||
if run_manager:
|
||||
run_manager.on_llm_new_token(content)
|
||||
yield GenerationChunk(text=content)
|
||||
|
||||
async def _astream(
|
||||
self,
|
||||
@ -327,9 +327,9 @@ class GigaChat(_BaseGigaChat, BaseLLM):
|
||||
async for chunk in self._client.astream(payload):
|
||||
if chunk.choices:
|
||||
content = chunk.choices[0].delta.content
|
||||
yield GenerationChunk(text=content)
|
||||
if run_manager:
|
||||
await run_manager.on_llm_new_token(content)
|
||||
yield GenerationChunk(text=content)
|
||||
|
||||
model_config = ConfigDict(
|
||||
extra="allow",
|
||||
|
Loading…
Reference in New Issue
Block a user