community[patch]: callback before yield for google palm (#26882)

**Description:** Moves yield to after callback for `_stream` function
for the google palm model in the community package
**Issue:** #16913
This commit is contained in:
Subhrajyoty Roy 2024-09-26 22:17:05 +05:30 committed by GitHub
parent 121e79b1f0
commit 11e703a97e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -215,13 +215,13 @@ class GooglePalm(BaseLLM, BaseModel):
**kwargs, **kwargs,
): ):
chunk = GenerationChunk(text=stream_resp.text) chunk = GenerationChunk(text=stream_resp.text)
yield chunk
if run_manager: if run_manager:
run_manager.on_llm_new_token( run_manager.on_llm_new_token(
stream_resp.text, stream_resp.text,
chunk=chunk, chunk=chunk,
verbose=self.verbose, verbose=self.verbose,
) )
yield chunk
@property @property
def _llm_type(self) -> str: def _llm_type(self) -> str: