mirror of
https://github.com/hwchase17/langchain.git
synced 2025-06-06 15:13:56 +00:00
langchain_groq[patch]: Invoke callback prior to yielding token (#18272)
## PR title langchain_groq[patch]: Invoke callback prior to yielding ## PR message **Description:**Invoke callback prior to yielding token in _stream and _astream methods for groq. Issue: https://github.com/langchain-ai/langchain/issues/16913 Dependencies: None Twitter handle: None
This commit is contained in:
parent
eb0c178d75
commit
5ee76fccd5
@ -274,9 +274,10 @@ class ChatGroq(BaseChatModel):
|
|||||||
chunk = ChatGenerationChunk(
|
chunk = ChatGenerationChunk(
|
||||||
message=chunk, generation_info=generation_info or None
|
message=chunk, generation_info=generation_info or None
|
||||||
)
|
)
|
||||||
yield chunk
|
|
||||||
if run_manager:
|
if run_manager:
|
||||||
run_manager.on_llm_new_token(chunk.text, chunk=chunk, logprobs=logprobs)
|
run_manager.on_llm_new_token(chunk.text, chunk=chunk, logprobs=logprobs)
|
||||||
|
yield chunk
|
||||||
|
|
||||||
async def _astream(
|
async def _astream(
|
||||||
self,
|
self,
|
||||||
@ -310,11 +311,12 @@ class ChatGroq(BaseChatModel):
|
|||||||
chunk = ChatGenerationChunk(
|
chunk = ChatGenerationChunk(
|
||||||
message=chunk, generation_info=generation_info or None
|
message=chunk, generation_info=generation_info or None
|
||||||
)
|
)
|
||||||
yield chunk
|
|
||||||
if run_manager:
|
if run_manager:
|
||||||
await run_manager.on_llm_new_token(
|
await run_manager.on_llm_new_token(
|
||||||
token=chunk.text, chunk=chunk, logprobs=logprobs
|
token=chunk.text, chunk=chunk, logprobs=logprobs
|
||||||
)
|
)
|
||||||
|
yield chunk
|
||||||
|
|
||||||
#
|
#
|
||||||
# Internal methods
|
# Internal methods
|
||||||
|
Loading…
Reference in New Issue
Block a user