The agent engineering platform.
Python agentsaiai-agentsanthropicchatgptdeepagentsenterpriseframeworkgeminigenerative-ailangchainlanggraphllmmultiagentopen-sourceopenaipydanticpythonragtypescript
community[patch]: invoke callback prior to yielding token (llama.cpp) (#19392)
aditya thomas4856a872616f
diff --git a/libs/community/langchain_community/llms/llamacpp.py b/libs/community/langchain_community/llms/llamacpp.pyindex 85acfb999e..b06e6d8cf7 100644--- a/libs/community/langchain_community/llms/llamacpp.py+++ b/libs/community/langchain_community/llms/llamacpp.py@@ -344,11 +344,11 @@ class LlamaCpp(LLM):text=part["choices"][0]["text"],generation_info={"logprobs": logprobs},)- yield chunkif run_manager:run_manager.on_llm_new_token(token=chunk.text, verbose=self.verbose, log_probs=logprobs)+ yield chunkdef get_num_tokens(self, text: str) -> int:tokenized_text = self.client.tokenize(text.encode("utf-8"))