mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-04 10:42:55 +00:00
community[patch]: Invoke callback prior to yielding token (#17346)
**Description:** Invoke callback prior to yielding token in stream method for watsonx. **Issue:** [Callback for on_llm_new_token should be invoked before the token is yielded by the model #16913](https://github.com/langchain-ai/langchain/issues/16913) Co-authored-by: Robby <h0rv@users.noreply.github.com>
This commit is contained in:
parent
ce9a68791b
commit
0653aa469a
@ -397,7 +397,7 @@ class WatsonxLLM(BaseLLM):
|
|||||||
prompt=prompt, raw_response=True, params=params
|
prompt=prompt, raw_response=True, params=params
|
||||||
):
|
):
|
||||||
chunk = self._stream_response_to_generation_chunk(stream_resp)
|
chunk = self._stream_response_to_generation_chunk(stream_resp)
|
||||||
yield chunk
|
|
||||||
|
|
||||||
if run_manager:
|
if run_manager:
|
||||||
run_manager.on_llm_new_token(chunk.text, chunk=chunk)
|
run_manager.on_llm_new_token(chunk.text, chunk=chunk)
|
||||||
|
yield chunk
|
||||||
|
Loading…
Reference in New Issue
Block a user