The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
community[patch]: Invoke callback prior to yielding token (#18452)
William De Venaeb04d0d3e20b
diff --git a/libs/community/langchain_community/llms/anthropic.py b/libs/community/langchain_community/llms/anthropic.pyindex f5674a0766..ad37bd9e4a 100644--- a/libs/community/langchain_community/llms/anthropic.py+++ b/libs/community/langchain_community/llms/anthropic.py@@ -309,9 +309,9 @@ class Anthropic(LLM, _AnthropicCommon):prompt=self._wrap_prompt(prompt), stop_sequences=stop, stream=True, **params):chunk = GenerationChunk(text=token.completion)- yield chunkif run_manager:run_manager.on_llm_new_token(chunk.text, chunk=chunk)+ yield chunkasync def _astream(self,@@ -345,9 +345,9 @@ class Anthropic(LLM, _AnthropicCommon):**params,):chunk = GenerationChunk(text=token.completion)- yield chunkif run_manager:await run_manager.on_llm_new_token(chunk.text, chunk=chunk)+ yield chunkdef get_num_tokens(self, text: str) -> int:"""Calculate number of tokens."""