[MLsys2026 Best Paper]: https://arxiv.org/abs/2506.08276. RAG on Everything with LEANN. Enjoy 97% storage savings while running a fast, accurate, and 100% private RAG application on your personal device.
Python aifaissgpt-osslangchainllama-indexllmlocalstorageoffline-firstollamaprivacypythonragretrieval-augmented-generationvector-databasevector-searchvectors
Add messages regarding the use of token during query (#147)
CelineNi228085f6f048f
diff --git a/packages/leann-core/src/leann/chat.py b/packages/leann-core/src/leann/chat.pyindex 1f870bf..9d874bf 100644--- a/packages/leann-core/src/leann/chat.py+++ b/packages/leann-core/src/leann/chat.py@@ -834,6 +834,11 @@ class OpenAIChat(LLMInterface):try:response = self.client.chat.completions.create(**params)+ print(+ f"Total tokens = {response.usage.total_tokens}, prompt tokens = {response.usage.prompt_tokens}, completion tokens = {response.usage.completion_tokens}"+ )+ if response.choices[0].finish_reason == "length":+ print("The query is exceeding the maximum allowed number of tokens")return response.choices[0].message.content.strip()except Exception as e:logger.error(f"Error communicating with OpenAI: {e}")