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>
pull/17348/head^2
Robby 5 months ago committed by GitHub
parent ce9a68791b
commit 0653aa469a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -397,7 +397,7 @@ class WatsonxLLM(BaseLLM):
prompt=prompt, raw_response=True, params=params
):
chunk = self._stream_response_to_generation_chunk(stream_resp)
yield chunk
if run_manager:
run_manager.on_llm_new_token(chunk.text, chunk=chunk)
yield chunk

Loading…
Cancel
Save