mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-05 04:38:26 +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):
|
for chunk in self._client.stream(payload):
|
||||||
if chunk.choices:
|
if chunk.choices:
|
||||||
content = chunk.choices[0].delta.content
|
content = chunk.choices[0].delta.content
|
||||||
yield GenerationChunk(text=content)
|
|
||||||
if run_manager:
|
if run_manager:
|
||||||
run_manager.on_llm_new_token(content)
|
run_manager.on_llm_new_token(content)
|
||||||
|
yield GenerationChunk(text=content)
|
||||||
|
|
||||||
async def _astream(
|
async def _astream(
|
||||||
self,
|
self,
|
||||||
@ -327,9 +327,9 @@ class GigaChat(_BaseGigaChat, BaseLLM):
|
|||||||
async for chunk in self._client.astream(payload):
|
async for chunk in self._client.astream(payload):
|
||||||
if chunk.choices:
|
if chunk.choices:
|
||||||
content = chunk.choices[0].delta.content
|
content = chunk.choices[0].delta.content
|
||||||
yield GenerationChunk(text=content)
|
|
||||||
if run_manager:
|
if run_manager:
|
||||||
await run_manager.on_llm_new_token(content)
|
await run_manager.on_llm_new_token(content)
|
||||||
|
yield GenerationChunk(text=content)
|
||||||
|
|
||||||
model_config = ConfigDict(
|
model_config = ConfigDict(
|
||||||
extra="allow",
|
extra="allow",
|
||||||
|
Loading…
Reference in New Issue
Block a user