langroid 0.52.4__tar.gz → 0.52.6__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. {langroid-0.52.4 → langroid-0.52.6}/PKG-INFO +3 -6
  2. {langroid-0.52.4 → langroid-0.52.6}/README.md +2 -3
  3. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/chat_agent.py +8 -1
  4. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/doc_chat_agent.py +8 -2
  5. langroid-0.52.6/langroid/cachedb/__init__.py +8 -0
  6. {langroid-0.52.4 → langroid-0.52.6}/langroid/language_models/openai_gpt.py +2 -15
  7. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/configuration.py +1 -1
  8. {langroid-0.52.4 → langroid-0.52.6}/pyproject.toml +1 -5
  9. langroid-0.52.4/langroid/cachedb/__init__.py +0 -17
  10. langroid-0.52.4/langroid/cachedb/momento_cachedb.py +0 -108
  11. {langroid-0.52.4 → langroid-0.52.6}/.gitignore +0 -0
  12. {langroid-0.52.4 → langroid-0.52.6}/LICENSE +0 -0
  13. {langroid-0.52.4 → langroid-0.52.6}/langroid/__init__.py +0 -0
  14. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/__init__.py +0 -0
  15. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/base.py +0 -0
  16. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/batch.py +0 -0
  17. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/callbacks/__init__.py +0 -0
  18. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/callbacks/chainlit.py +0 -0
  19. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/chat_document.py +0 -0
  20. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/openai_assistant.py +0 -0
  21. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/__init__.py +0 -0
  22. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/arangodb/__init__.py +0 -0
  23. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/arangodb/arangodb_agent.py +0 -0
  24. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/arangodb/system_messages.py +0 -0
  25. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/arangodb/tools.py +0 -0
  26. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/arangodb/utils.py +0 -0
  27. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/doc_chat_task.py +0 -0
  28. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/lance_doc_chat_agent.py +0 -0
  29. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/lance_rag/__init__.py +0 -0
  30. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/lance_rag/critic_agent.py +0 -0
  31. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/lance_rag/lance_rag_task.py +0 -0
  32. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/lance_rag/query_planner_agent.py +0 -0
  33. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/lance_tools.py +0 -0
  34. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/neo4j/__init__.py +0 -0
  35. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/neo4j/csv_kg_chat.py +0 -0
  36. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/neo4j/neo4j_chat_agent.py +0 -0
  37. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/neo4j/system_messages.py +0 -0
  38. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/neo4j/tools.py +0 -0
  39. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/relevance_extractor_agent.py +0 -0
  40. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/retriever_agent.py +0 -0
  41. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/sql/__init__.py +0 -0
  42. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/sql/sql_chat_agent.py +0 -0
  43. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/sql/utils/__init__.py +0 -0
  44. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/sql/utils/description_extractors.py +0 -0
  45. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/sql/utils/populate_metadata.py +0 -0
  46. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/sql/utils/system_message.py +0 -0
  47. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/sql/utils/tools.py +0 -0
  48. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/special/table_chat_agent.py +0 -0
  49. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/task.py +0 -0
  50. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/tool_message.py +0 -0
  51. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/tools/__init__.py +0 -0
  52. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/tools/duckduckgo_search_tool.py +0 -0
  53. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/tools/exa_search_tool.py +0 -0
  54. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/tools/file_tools.py +0 -0
  55. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/tools/google_search_tool.py +0 -0
  56. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/tools/metaphor_search_tool.py +0 -0
  57. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/tools/orchestration.py +0 -0
  58. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/tools/recipient_tool.py +0 -0
  59. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/tools/retrieval_tool.py +0 -0
  60. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/tools/rewind_tool.py +0 -0
  61. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/tools/segment_extract_tool.py +0 -0
  62. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/tools/tavily_search_tool.py +0 -0
  63. {langroid-0.52.4 → langroid-0.52.6}/langroid/agent/xml_tool_message.py +0 -0
  64. {langroid-0.52.4 → langroid-0.52.6}/langroid/cachedb/base.py +0 -0
  65. {langroid-0.52.4 → langroid-0.52.6}/langroid/cachedb/redis_cachedb.py +0 -0
  66. {langroid-0.52.4 → langroid-0.52.6}/langroid/embedding_models/__init__.py +0 -0
  67. {langroid-0.52.4 → langroid-0.52.6}/langroid/embedding_models/base.py +0 -0
  68. {langroid-0.52.4 → langroid-0.52.6}/langroid/embedding_models/models.py +0 -0
  69. {langroid-0.52.4 → langroid-0.52.6}/langroid/embedding_models/protoc/__init__.py +0 -0
  70. {langroid-0.52.4 → langroid-0.52.6}/langroid/embedding_models/protoc/embeddings.proto +0 -0
  71. {langroid-0.52.4 → langroid-0.52.6}/langroid/embedding_models/protoc/embeddings_pb2.py +0 -0
  72. {langroid-0.52.4 → langroid-0.52.6}/langroid/embedding_models/protoc/embeddings_pb2.pyi +0 -0
  73. {langroid-0.52.4 → langroid-0.52.6}/langroid/embedding_models/protoc/embeddings_pb2_grpc.py +0 -0
  74. {langroid-0.52.4 → langroid-0.52.6}/langroid/embedding_models/remote_embeds.py +0 -0
  75. {langroid-0.52.4 → langroid-0.52.6}/langroid/exceptions.py +0 -0
  76. {langroid-0.52.4 → langroid-0.52.6}/langroid/language_models/__init__.py +0 -0
  77. {langroid-0.52.4 → langroid-0.52.6}/langroid/language_models/azure_openai.py +0 -0
  78. {langroid-0.52.4 → langroid-0.52.6}/langroid/language_models/base.py +0 -0
  79. {langroid-0.52.4 → langroid-0.52.6}/langroid/language_models/config.py +0 -0
  80. {langroid-0.52.4 → langroid-0.52.6}/langroid/language_models/mock_lm.py +0 -0
  81. {langroid-0.52.4 → langroid-0.52.6}/langroid/language_models/model_info.py +0 -0
  82. {langroid-0.52.4 → langroid-0.52.6}/langroid/language_models/prompt_formatter/__init__.py +0 -0
  83. {langroid-0.52.4 → langroid-0.52.6}/langroid/language_models/prompt_formatter/base.py +0 -0
  84. {langroid-0.52.4 → langroid-0.52.6}/langroid/language_models/prompt_formatter/hf_formatter.py +0 -0
  85. {langroid-0.52.4 → langroid-0.52.6}/langroid/language_models/prompt_formatter/llama2_formatter.py +0 -0
  86. {langroid-0.52.4 → langroid-0.52.6}/langroid/language_models/utils.py +0 -0
  87. {langroid-0.52.4 → langroid-0.52.6}/langroid/mytypes.py +0 -0
  88. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/__init__.py +0 -0
  89. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/agent_chats.py +0 -0
  90. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/code_parser.py +0 -0
  91. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/document_parser.py +0 -0
  92. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/file_attachment.py +0 -0
  93. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/md_parser.py +0 -0
  94. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/para_sentence_split.py +0 -0
  95. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/parse_json.py +0 -0
  96. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/parser.py +0 -0
  97. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/pdf_utils.py +0 -0
  98. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/repo_loader.py +0 -0
  99. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/routing.py +0 -0
  100. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/search.py +0 -0
  101. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/spider.py +0 -0
  102. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/table_loader.py +0 -0
  103. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/url_loader.py +0 -0
  104. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/urls.py +0 -0
  105. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/utils.py +0 -0
  106. {langroid-0.52.4 → langroid-0.52.6}/langroid/parsing/web_search.py +0 -0
  107. {langroid-0.52.4 → langroid-0.52.6}/langroid/prompts/__init__.py +0 -0
  108. {langroid-0.52.4 → langroid-0.52.6}/langroid/prompts/dialog.py +0 -0
  109. {langroid-0.52.4 → langroid-0.52.6}/langroid/prompts/prompts_config.py +0 -0
  110. {langroid-0.52.4 → langroid-0.52.6}/langroid/prompts/templates.py +0 -0
  111. {langroid-0.52.4 → langroid-0.52.6}/langroid/py.typed +0 -0
  112. {langroid-0.52.4 → langroid-0.52.6}/langroid/pydantic_v1/__init__.py +0 -0
  113. {langroid-0.52.4 → langroid-0.52.6}/langroid/pydantic_v1/main.py +0 -0
  114. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/__init__.py +0 -0
  115. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/algorithms/__init__.py +0 -0
  116. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/algorithms/graph.py +0 -0
  117. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/constants.py +0 -0
  118. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/git_utils.py +0 -0
  119. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/globals.py +0 -0
  120. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/logging.py +0 -0
  121. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/object_registry.py +0 -0
  122. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/output/__init__.py +0 -0
  123. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/output/citations.py +0 -0
  124. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/output/printing.py +0 -0
  125. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/output/status.py +0 -0
  126. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/pandas_utils.py +0 -0
  127. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/pydantic_utils.py +0 -0
  128. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/system.py +0 -0
  129. {langroid-0.52.4 → langroid-0.52.6}/langroid/utils/types.py +0 -0
  130. {langroid-0.52.4 → langroid-0.52.6}/langroid/vector_store/__init__.py +0 -0
  131. {langroid-0.52.4 → langroid-0.52.6}/langroid/vector_store/base.py +0 -0
  132. {langroid-0.52.4 → langroid-0.52.6}/langroid/vector_store/chromadb.py +0 -0
  133. {langroid-0.52.4 → langroid-0.52.6}/langroid/vector_store/lancedb.py +0 -0
  134. {langroid-0.52.4 → langroid-0.52.6}/langroid/vector_store/meilisearch.py +0 -0
  135. {langroid-0.52.4 → langroid-0.52.6}/langroid/vector_store/pineconedb.py +0 -0
  136. {langroid-0.52.4 → langroid-0.52.6}/langroid/vector_store/postgres.py +0 -0
  137. {langroid-0.52.4 → langroid-0.52.6}/langroid/vector_store/qdrantdb.py +0 -0
  138. {langroid-0.52.4 → langroid-0.52.6}/langroid/vector_store/weaviatedb.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: langroid
3
- Version: 0.52.4
3
+ Version: 0.52.6
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  Author-email: Prasad Chalasani <pchalasani@gmail.com>
6
6
  License: MIT
@@ -151,8 +151,6 @@ Provides-Extra: meilisearch
151
151
  Requires-Dist: meilisearch-python-sdk<3.0.0,>=2.2.3; extra == 'meilisearch'
152
152
  Provides-Extra: metaphor
153
153
  Requires-Dist: metaphor-python<0.2.0,>=0.1.23; extra == 'metaphor'
154
- Provides-Extra: momento
155
- Requires-Dist: momento<1.21.0,>=1.10.2; extra == 'momento'
156
154
  Provides-Extra: mysql
157
155
  Requires-Dist: pymysql<2.0.0,>=1.1.0; extra == 'mysql'
158
156
  Provides-Extra: neo4j
@@ -617,9 +615,8 @@ section above)
617
615
  providers ([local/open](https://langroid.github.io/langroid/tutorials/local-llm-setup/) or [remote/commercial](https://langroid.github.io/langroid/tutorials/non-openai-llms/)) via proxy libraries and local model servers
618
616
  such as [ollama](https://github.com/ollama), [oobabooga](https://github.com/oobabooga/text-generation-webui),
619
617
  [LiteLLM](https://docs.litellm.ai/docs/providers) that in effect mimic the OpenAI API. See the [supported LLMs](https://langroid.github.io/langroid/tutorials/supported-models/).
620
- - **Caching of LLM responses:** Langroid supports [Redis](https://redis.com/try-free/) and
621
- [Momento](https://www.gomomento.com/) to cache LLM responses.
622
- - **Vector-stores**: [LanceDB](https://github.com/lancedb/lancedb), [Qdrant](https://qdrant.tech/), [Chroma](https://www.trychroma.com/) are currently supported.
618
+ - **Caching of LLM responses:** Langroid supports [Redis](https://redis.com/try-free/) to cache LLM responses.
619
+ - **Vector-stores**: [Qdrant](https://qdrant.tech/), [Chroma](https://www.trychroma.com/), LanceDB, Pinecone, PostgresDB (PGVector), Weaviate are currently supported.
623
620
  Vector stores allow for Retrieval-Augmented-Generation (RAG).
624
621
  - **Grounding and source-citation:** Access to external documents via vector-stores
625
622
  allows for grounding and source-citation.
@@ -415,9 +415,8 @@ section above)
415
415
  providers ([local/open](https://langroid.github.io/langroid/tutorials/local-llm-setup/) or [remote/commercial](https://langroid.github.io/langroid/tutorials/non-openai-llms/)) via proxy libraries and local model servers
416
416
  such as [ollama](https://github.com/ollama), [oobabooga](https://github.com/oobabooga/text-generation-webui),
417
417
  [LiteLLM](https://docs.litellm.ai/docs/providers) that in effect mimic the OpenAI API. See the [supported LLMs](https://langroid.github.io/langroid/tutorials/supported-models/).
418
- - **Caching of LLM responses:** Langroid supports [Redis](https://redis.com/try-free/) and
419
- [Momento](https://www.gomomento.com/) to cache LLM responses.
420
- - **Vector-stores**: [LanceDB](https://github.com/lancedb/lancedb), [Qdrant](https://qdrant.tech/), [Chroma](https://www.trychroma.com/) are currently supported.
418
+ - **Caching of LLM responses:** Langroid supports [Redis](https://redis.com/try-free/) to cache LLM responses.
419
+ - **Vector-stores**: [Qdrant](https://qdrant.tech/), [Chroma](https://www.trychroma.com/), LanceDB, Pinecone, PostgresDB (PGVector), Weaviate are currently supported.
421
420
  Vector stores allow for Retrieval-Augmented-Generation (RAG).
422
421
  - **Grounding and source-citation:** Access to external documents via vector-stores
423
422
  allows for grounding and source-citation.
@@ -735,7 +735,11 @@ class ChatAgent(Agent):
735
735
  self.llm_tools_usable.discard(t)
736
736
  self.llm_functions_usable.discard(t)
737
737
 
738
- # Set tool instructions and JSON format instructions
738
+ self._update_tool_instructions()
739
+
740
+ def _update_tool_instructions(self) -> None:
741
+ # Set tool instructions and JSON format instructions,
742
+ # in case Tools have been enabled/disabled.
739
743
  if self.config.use_tools:
740
744
  self.system_tool_format_instructions = self.tool_format_rules()
741
745
  self.system_tool_instructions = self.tool_instructions()
@@ -977,6 +981,8 @@ class ChatAgent(Agent):
977
981
  self.llm_tools_usable.discard(t)
978
982
  self.llm_functions_usable.discard(t)
979
983
 
984
+ self._update_tool_instructions()
985
+
980
986
  def disable_message_use_except(self, message_class: Type[ToolMessage]) -> None:
981
987
  """
982
988
  Disable this agent from USING ALL messages EXCEPT a message class (Tool)
@@ -988,6 +994,7 @@ class ChatAgent(Agent):
988
994
  for r in to_remove:
989
995
  self.llm_tools_usable.discard(r)
990
996
  self.llm_functions_usable.discard(r)
997
+ self._update_tool_instructions()
991
998
 
992
999
  def _load_output_format(self, message: ChatDocument) -> None:
993
1000
  """
@@ -123,6 +123,9 @@ class DocChatAgentConfig(ChatAgentConfig):
123
123
  None # filter condition for various lexical/semantic search fns
124
124
  )
125
125
  conversation_mode: bool = True # accumulate message history?
126
+ # retain retrieved context? Setting to True increases token consumption, but
127
+ # helps LLM fix citation errors and improve accuracy of follow-up questions.
128
+ retain_context: bool = False
126
129
  # In assistant mode, DocChatAgent receives questions from another Agent,
127
130
  # and those will already be in stand-alone form, so in this mode
128
131
  # there is no need to convert them to stand-alone form.
@@ -861,8 +864,11 @@ class DocChatAgent(ChatAgent):
861
864
  # one for `final_prompt`, and one for the LLM response
862
865
 
863
866
  if self.config.conversation_mode:
864
- # respond with temporary context
865
- answer_doc = super()._llm_response_temp_context(question, final_prompt)
867
+ if self.config.retain_context:
868
+ answer_doc = super().llm_response(final_prompt)
869
+ else:
870
+ # respond with temporary context
871
+ answer_doc = super()._llm_response_temp_context(question, final_prompt)
866
872
  else:
867
873
  answer_doc = super().llm_response_forget(final_prompt)
868
874
 
@@ -0,0 +1,8 @@
1
+ from . import base
2
+
3
+ from . import redis_cachedb
4
+
5
+ __all__ = [
6
+ "base",
7
+ "redis_cachedb",
8
+ ]
@@ -627,20 +627,7 @@ class OpenAIGPT(LanguageModel):
627
627
 
628
628
  self.cache: CacheDB | None = None
629
629
  use_cache = self.config.cache_config is not None
630
- if settings.cache_type == "momento" and use_cache:
631
- from langroid.cachedb.momento_cachedb import (
632
- MomentoCache,
633
- MomentoCacheConfig,
634
- )
635
-
636
- if config.cache_config is None or not isinstance(
637
- config.cache_config,
638
- MomentoCacheConfig,
639
- ):
640
- # switch to fresh momento config if needed
641
- config.cache_config = MomentoCacheConfig()
642
- self.cache = MomentoCache(config.cache_config)
643
- elif "redis" in settings.cache_type and use_cache:
630
+ if "redis" in settings.cache_type and use_cache:
644
631
  if config.cache_config is None or not isinstance(
645
632
  config.cache_config,
646
633
  RedisCacheConfig,
@@ -656,7 +643,7 @@ class OpenAIGPT(LanguageModel):
656
643
  elif settings.cache_type != "none" and use_cache:
657
644
  raise ValueError(
658
645
  f"Invalid cache type {settings.cache_type}. "
659
- "Valid types are momento, redis, fakeredis, none"
646
+ "Valid types are redis, fakeredis, none"
660
647
  )
661
648
 
662
649
  self.config._validate_litellm()
@@ -17,7 +17,7 @@ class Settings(BaseSettings):
17
17
  progress: bool = False # show progress spinners/bars?
18
18
  stream: bool = True # stream output?
19
19
  cache: bool = True # use cache?
20
- cache_type: Literal["redis", "fakeredis", "momento", "none"] = "redis" # cache type
20
+ cache_type: Literal["redis", "fakeredis", "none"] = "redis" # cache type
21
21
  chat_model: str = "" # language model name, e.g. litellm/ollama/llama2
22
22
  quiet: bool = False # quiet mode (i.e. suppress all output)?
23
23
  notebook: bool = False # running in a notebook?
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "langroid"
3
- version = "0.52.4"
3
+ version = "0.52.6"
4
4
  authors = [
5
5
  {name = "Prasad Chalasani", email = "pchalasani@gmail.com"},
6
6
  ]
@@ -242,10 +242,6 @@ meilisearch = [
242
242
  "meilisearch-python-sdk<3.0.0,>=2.2.3",
243
243
  ]
244
244
 
245
- momento = [
246
- "momento<1.21.0,>=1.10.2",
247
- ]
248
-
249
245
  fastembed = [
250
246
  "fastembed<0.4.0,>=0.3.1",
251
247
  ]
@@ -1,17 +0,0 @@
1
- from . import base
2
-
3
- from . import redis_cachedb
4
-
5
- __all__ = [
6
- "base",
7
- "redis_cachedb",
8
- ]
9
-
10
-
11
- try:
12
- from . import momento_cachedb
13
-
14
- momento_cachedb
15
- __all__.append("momento_cachedb")
16
- except ImportError:
17
- pass
@@ -1,108 +0,0 @@
1
- import json
2
- import logging
3
- import os
4
- from datetime import timedelta
5
- from typing import Any, Dict, List
6
-
7
- from langroid.cachedb.base import CacheDBConfig
8
- from langroid.exceptions import LangroidImportError
9
-
10
- try:
11
- import momento
12
- from momento.responses import CacheGet
13
- except ImportError:
14
- raise LangroidImportError(package="momento", extra="momento")
15
-
16
- from dotenv import load_dotenv
17
-
18
- from langroid.cachedb.base import CacheDB
19
-
20
- logger = logging.getLogger(__name__)
21
-
22
-
23
- class MomentoCacheConfig(CacheDBConfig):
24
- """Configuration model for Momento Cache."""
25
-
26
- ttl: int = 60 * 60 * 24 * 7 # 1 week
27
- cachename: str = "langroid_momento_cache"
28
-
29
-
30
- class MomentoCache(CacheDB):
31
- """Momento implementation of the CacheDB."""
32
-
33
- def __init__(self, config: MomentoCacheConfig):
34
- """
35
- Initialize a MomentoCache with the given config.
36
-
37
- Args:
38
- config (MomentoCacheConfig): The configuration to use.
39
- """
40
- self.config = config
41
- load_dotenv()
42
-
43
- momento_token = os.getenv("MOMENTO_AUTH_TOKEN")
44
- if momento_token is None:
45
- raise ValueError("""MOMENTO_AUTH_TOKEN not set in .env file""")
46
- else:
47
- self.client = momento.CacheClient(
48
- configuration=momento.Configurations.Laptop.v1(),
49
- credential_provider=momento.CredentialProvider.from_environment_variable(
50
- "MOMENTO_AUTH_TOKEN"
51
- ),
52
- default_ttl=timedelta(seconds=self.config.ttl),
53
- )
54
- self.client.create_cache(self.config.cachename)
55
-
56
- def clear(self) -> None:
57
- """Clear keys from current db."""
58
- self.client.flush_cache(self.config.cachename)
59
-
60
- def store(self, key: str, value: Any) -> None:
61
- """
62
- Store a value associated with a key.
63
-
64
- Args:
65
- key (str): The key under which to store the value.
66
- value (Any): The value to store.
67
- """
68
- self.client.set(self.config.cachename, key, json.dumps(value))
69
-
70
- def retrieve(self, key: str) -> Dict[str, Any] | str | None:
71
- """
72
- Retrieve the value associated with a key.
73
-
74
- Args:
75
- key (str): The key to retrieve the value for.
76
-
77
- Returns:
78
- dict: The value associated with the key.
79
- """
80
- value = self.client.get(self.config.cachename, key)
81
- if isinstance(value, CacheGet.Hit):
82
- return json.loads(value.value_string) # type: ignore
83
- else:
84
- return None
85
-
86
- def delete_keys(self, keys: List[str]) -> None:
87
- """
88
- Delete the keys from the cache.
89
-
90
- Args:
91
- keys (List[str]): The keys to delete.
92
- """
93
- for key in keys:
94
- self.client.delete(self.config.cachename, key)
95
-
96
- def delete_keys_pattern(self, pattern: str) -> None:
97
- """
98
- Delete the keys from the cache with the given pattern.
99
-
100
- Args:
101
- prefix (str): The pattern to match.
102
- """
103
- raise NotImplementedError(
104
- """
105
- MomentoCache does not support delete_keys_pattern.
106
- Please use RedisCache instead.
107
- """
108
- )
File without changes
File without changes
File without changes
File without changes