langroid 0.1.226__py3-none-any.whl → 0.1.228__py3-none-any.whl

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.
@@ -8,6 +8,10 @@ from enum import Enum
8
8
  from typing import Any, Dict, List, Optional, Tuple, Type, cast, no_type_check
9
9
 
10
10
  from openai.types.beta import Assistant, Thread
11
+ from openai.types.beta.assistant_update_params import (
12
+ ToolResources,
13
+ ToolResourcesCodeInterpreter,
14
+ )
11
15
  from openai.types.beta.threads import Message, Run
12
16
  from openai.types.beta.threads.runs import RunStep
13
17
  from pydantic import BaseModel
@@ -29,7 +33,7 @@ logger = logging.getLogger(__name__)
29
33
 
30
34
 
31
35
  class ToolType(str, Enum):
32
- RETRIEVAL = "retrieval"
36
+ RETRIEVAL = "file_search"
33
37
  CODE_INTERPRETER = "code_interpreter"
34
38
  FUNCTION = "function"
35
39
 
@@ -127,7 +131,11 @@ class OpenAIAssistant(ChatAgent):
127
131
  self.config.files = list(set(self.config.files + files))
128
132
  self.assistant = self.assistants.update(
129
133
  self.assistant.id,
130
- file_ids=[f.id for f in self.files],
134
+ tool_resources=ToolResources(
135
+ code_interpreter=ToolResourcesCodeInterpreter(
136
+ file_ids=[f.id for f in self.files],
137
+ ),
138
+ ),
131
139
  )
132
140
 
133
141
  def add_assistant_tools(self, tools: List[AssistantTool]) -> None:
@@ -169,7 +169,8 @@ class DocChatAgentConfig(ChatAgentConfig):
169
169
  dims=1536,
170
170
  )
171
171
 
172
- vecdb: VectorStoreConfig = LanceDBConfig(
172
+ # Allow vecdb to be None in case we want to explicitly set it later
173
+ vecdb: Optional[VectorStoreConfig] = LanceDBConfig(
173
174
  collection_name="doc-chat-lancedb",
174
175
  replace_collection=True,
175
176
  storage_path=".lancedb/data/",
@@ -209,12 +210,13 @@ class DocChatAgent(ChatAgent):
209
210
 
210
211
  def clear(self) -> None:
211
212
  """Clear the document collection and the specific collection in vecdb"""
212
- if self.vecdb is None:
213
- raise ValueError("VecDB not set")
214
213
  self.original_docs = []
215
214
  self.original_docs_length = 0
216
215
  self.chunked_docs = []
217
216
  self.chunked_docs_clean = []
217
+ if self.vecdb is None:
218
+ logger.warning("Attempting to clear VecDB, but VecDB not set.")
219
+ return
218
220
  collection_name = self.vecdb.config.collection_name
219
221
  if collection_name is None:
220
222
  return
@@ -69,7 +69,7 @@ class OpenAIChatModel(str, Enum):
69
69
  GPT3_5_TURBO = "gpt-3.5-turbo-1106"
70
70
  GPT4 = "gpt-4"
71
71
  GPT4_32K = "gpt-4-32k"
72
- GPT4_TURBO = "gpt-4-turbo-preview"
72
+ GPT4_TURBO = "gpt-4-turbo"
73
73
 
74
74
 
75
75
  class OpenAICompletionModel(str, Enum):
@@ -192,8 +192,7 @@ class QdrantDB(VectorStore):
192
192
  with the same name. Defaults to False.
193
193
  """
194
194
  self.config.collection_name = collection_name
195
- collections = self.list_collections()
196
- if collection_name in collections:
195
+ if self.client.collection_exists(collection_name=collection_name):
197
196
  coll = self.client.get_collection(collection_name=collection_name)
198
197
  if (
199
198
  coll.status == CollectionStatus.GREEN
@@ -205,7 +204,8 @@ class QdrantDB(VectorStore):
205
204
  return
206
205
  else:
207
206
  logger.warning("Recreating fresh collection")
208
- self.client.recreate_collection(
207
+ self.client.delete_collection(collection_name=collection_name)
208
+ self.client.create_collection(
209
209
  collection_name=collection_name,
210
210
  vectors_config=VectorParams(
211
211
  size=self.embedding_dim,
@@ -214,7 +214,7 @@ class QdrantDB(VectorStore):
214
214
  )
215
215
  collection_info = self.client.get_collection(collection_name=collection_name)
216
216
  assert collection_info.status == CollectionStatus.GREEN
217
- assert collection_info.vectors_count == 0
217
+ assert collection_info.vectors_count in [0, None]
218
218
  if settings.debug:
219
219
  level = logger.getEffectiveLevel()
220
220
  logger.setLevel(logging.INFO)
@@ -1,14 +1,13 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: langroid
3
- Version: 0.1.226
3
+ Version: 0.1.228
4
4
  Summary: Harness LLMs with Multi-Agent Programming
5
5
  License: MIT
6
6
  Author: Prasad Chalasani
7
7
  Author-email: pchalasani@gmail.com
8
- Requires-Python: >=3.9.1,<3.12
8
+ Requires-Python: >=3.11,<3.12
9
9
  Classifier: License :: OSI Approved :: MIT License
10
10
  Classifier: Programming Language :: Python :: 3
11
- Classifier: Programming Language :: Python :: 3.10
12
11
  Classifier: Programming Language :: Python :: 3.11
13
12
  Provides-Extra: chainlit
14
13
  Provides-Extra: chromadb
@@ -19,10 +18,8 @@ Provides-Extra: mkdocs
19
18
  Provides-Extra: mysql
20
19
  Provides-Extra: neo4j
21
20
  Provides-Extra: postgres
22
- Provides-Extra: sciphi
23
21
  Provides-Extra: transformers
24
22
  Provides-Extra: unstructured
25
- Requires-Dist: agent-search (>=0.0.7,<0.0.8) ; extra == "sciphi"
26
23
  Requires-Dist: aiohttp (>=3.9.1,<4.0.0)
27
24
  Requires-Dist: async-generator (>=1.10,<2.0)
28
25
  Requires-Dist: autopep8 (>=2.0.2,<3.0.0)
@@ -8,9 +8,9 @@ langroid/agent/chat_agent.py,sha256=X5uVMm9qdw3j-FRf4hbN8k8ByaSdtQCTuU8olKE0sbs,
8
8
  langroid/agent/chat_document.py,sha256=PL8iA1ZYjXNFVa3kMO8T4sbbM3rzHWpRAY6PN_7n5LQ,7969
9
9
  langroid/agent/helpers.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
10
10
  langroid/agent/junk,sha256=LxfuuW7Cijsg0szAzT81OjWWv1PMNI-6w_-DspVIO2s,339
11
- langroid/agent/openai_assistant.py,sha256=QTLBgnH6Btf2GWzN-WApvra-vPQWvYcXcAOULuIy4Ig,32702
11
+ langroid/agent/openai_assistant.py,sha256=xWSDR4SyMcZhCUkgaM4-mu77rbEDF_xpt7N8m8CkiA4,32962
12
12
  langroid/agent/special/__init__.py,sha256=XPE076zD-roskxNBn-A1hnh4AHoMiQN9gk1UDjPaBaU,1201
13
- langroid/agent/special/doc_chat_agent.py,sha256=OpPWLFHBi3C5V6H0xRgmXUubmvy80EJRTgS6YkYfBJA,53242
13
+ langroid/agent/special/doc_chat_agent.py,sha256=Ur57J3xolTaoTgzr2DfP8TY7BViIMNFGNEmmRfHbkL4,53373
14
14
  langroid/agent/special/lance_doc_chat_agent.py,sha256=USp0U3eTaJzwF_3bdqE7CedSLbaqAi2tm-VzygcyLaA,10175
15
15
  langroid/agent/special/lance_rag/__init__.py,sha256=QTbs0IVE2ZgDg8JJy1zN97rUUg4uEPH7SLGctFNumk4,174
16
16
  langroid/agent/special/lance_rag/critic_agent.py,sha256=pi_9eMBxEycbWTddtq_yz-mOb2V4SgGm3zfsOH1HU-Q,5775
@@ -42,7 +42,6 @@ langroid/agent/tools/google_search_tool.py,sha256=cQxcNtb8XCNpOo_yCeYRwG_y-OATjP
42
42
  langroid/agent/tools/metaphor_search_tool.py,sha256=NKHss-AkI942_XhfMgUctAwHjIHpqp5NfYIebKV4UcE,2454
43
43
  langroid/agent/tools/recipient_tool.py,sha256=61vdKv06qgVdtnE3gxjzV8RvUEy8JhbC9eWa0J0BPdw,9171
44
44
  langroid/agent/tools/run_python_code.py,sha256=V3mHdHQYn0M0PAtyoHxjNvk6KvWWcQ4ugo0TOKc8HyI,1752
45
- langroid/agent/tools/sciphi_search_rag_tool.py,sha256=IAEgZY5-euQh8MndMzZnn1XVxaItvWYB2VF9-YHfunk,2496
46
45
  langroid/agent/tools/segment_extract_tool.py,sha256=W39poS7Av2EuJ34tGKhLhzgj3zEyZnBplpSt2goRAp4,1285
47
46
  langroid/agent_config.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
48
47
  langroid/cachedb/__init__.py,sha256=ygx42MS7fvh2UwRMjukTk3dWBkzv_rACebTBRYa_MkU,148
@@ -63,7 +62,7 @@ langroid/language_models/azure_openai.py,sha256=ncRCbKooqLVOY-PWQUIo9C3yTuKEFbAw
63
62
  langroid/language_models/base.py,sha256=4ybrbvOnoWzEVzVuZ3AStsl8ELoljiKtgtdykUzRSxg,21014
64
63
  langroid/language_models/config.py,sha256=5UF3DzO1a-Dfsc3vghE0XGq7g9t_xDsRCsuRiU4dgBg,366
65
64
  langroid/language_models/openai_assistants.py,sha256=9K-DEAL2aSWHeXj2hwCo2RAlK9_1oCPtqX2u1wISCj8,36
66
- langroid/language_models/openai_gpt.py,sha256=6CE6I_hmnHfRIMJMh4qhVeKijgKEm_LNcWNn3vLMLlM,49680
65
+ langroid/language_models/openai_gpt.py,sha256=3W0gi7_Ja0c0vuT8SDv8ioOWXyUKs7zJORx8BV-QT2g,49672
67
66
  langroid/language_models/prompt_formatter/__init__.py,sha256=9JXFF22QNMmbQV1q4nrIeQVTtA3Tx8tEZABLtLBdFyc,352
68
67
  langroid/language_models/prompt_formatter/base.py,sha256=eDS1sgRNZVnoajwV_ZIha6cba5Dt8xjgzdRbPITwx3Q,1221
69
68
  langroid/language_models/prompt_formatter/hf_formatter.py,sha256=TFL6ppmeQWnzr6CKQzRZFYY810zE1mr8DZnhw6i85ok,5217
@@ -120,8 +119,8 @@ langroid/vector_store/lancedb.py,sha256=lbl8wZuV6GNw0LnIwOSriSNwoMEba90umQTcQHtM
120
119
  langroid/vector_store/meilisearch.py,sha256=d2huA9P-NoYRuAQ9ZeXJmMKr7ry8u90RUSR28k2ecQg,11340
121
120
  langroid/vector_store/momento.py,sha256=9cui31TTrILid2KIzUpBkN2Ey3g_CZWOQVdaFsA4Ors,10045
122
121
  langroid/vector_store/qdrant_cloud.py,sha256=3im4Mip0QXLkR6wiqVsjV1QvhSElfxdFSuDKddBDQ-4,188
123
- langroid/vector_store/qdrantdb.py,sha256=_egbsP9SWBwmI827EDYSSOqfIQSmwNsmJfFTxrLpWYE,13457
124
- langroid-0.1.226.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
125
- langroid-0.1.226.dist-info/METADATA,sha256=Dssqa7k6VMEBWxwulUiub5XM9TyreczBTC-xrNGXeK4,48003
126
- langroid-0.1.226.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
127
- langroid-0.1.226.dist-info/RECORD,,
122
+ langroid/vector_store/qdrantdb.py,sha256=foKRxRv0BBony6S4Vt0Vav9Rn9HMxZvcIh1cE7nosFE,13524
123
+ langroid-0.1.228.dist-info/LICENSE,sha256=EgVbvA6VSYgUlvC3RvPKehSg7MFaxWDsFuzLOsPPfJg,1065
124
+ langroid-0.1.228.dist-info/METADATA,sha256=ZineIvSkpCMJ-NqtqT_24P8Y3pbBZwP1ntP5myCKaBU,47863
125
+ langroid-0.1.228.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
126
+ langroid-0.1.228.dist-info/RECORD,,
@@ -1,79 +0,0 @@
1
- """
2
- A tool which returns a Search RAG response from the SciPhi API.
3
- their titles, links, summaries. Since the tool is stateless (i.e. does not need
4
- access to agent state), it can be enabled for any agent, without having to define a
5
- special method inside the agent: `agent.enable_message(SciPhiSearchRAGTool)`
6
-
7
- Example return output appears as follows below:
8
-
9
- <-- Query -->
10
- ```
11
- Find 3 results on the internet about the LK-99 superconducting material.
12
- ``
13
-
14
- <-- Response (compressed for this example)-->
15
- ```
16
- [ result1 ]
17
-
18
- [ result2 ]
19
-
20
- [ result3 ]
21
-
22
- ```
23
-
24
- NOTE: Using this tool requires getting an API key from sciphi.ai.
25
- Setup is as simple as shown below
26
- # Get a free API key at https://www.sciphi.ai/account
27
- # export SCIPHI_API_KEY=$MY_SCIPHI_API_KEY before running the agent
28
- # OR add SCIPHI_API_KEY=$MY_SCIPHI_API_KEY to your .env file
29
-
30
- This tool requires installing langroid with the `sciphi` extra, e.g.
31
- `pip install langroid[sciphi]` or `poetry add langroid[sciphi]`
32
- (it installs the `agent-search` package from pypi).
33
-
34
- For more information, please refer to the official docs:
35
- https://agent-search.readthedocs.io/en/latest/
36
- """
37
-
38
- from typing import List
39
-
40
- try:
41
- from agent_search import SciPhi
42
- except ImportError:
43
- raise ImportError(
44
- "You are attempting to use the `agent-search` library;"
45
- "To use it, please install langroid with the `sciphi` extra, e.g. "
46
- "`pip install langroid[sciphi]` or `poetry add langroid[sciphi]` "
47
- "(it installs the `agent-search` package from pypi)."
48
- )
49
-
50
- from langroid.agent.tool_message import ToolMessage
51
-
52
-
53
- class SciPhiSearchRAGTool(ToolMessage):
54
- request: str = "web_search_rag"
55
- purpose: str = """
56
- To search the web with provider <search_provider> and
57
- return a response summary with llm model <llm_model> the given <query>.
58
- """
59
- query: str
60
-
61
- def handle(self) -> str:
62
- rag_response = SciPhi().get_search_rag_response(
63
- query=self.query, search_provider="bing", llm_model="SciPhi/Sensei-7B-V1"
64
- )
65
- result = rag_response["response"]
66
- result = (
67
- f"### RAG Response:\n{result}\n\n"
68
- + "### Related Queries:\n"
69
- + "\n".join(rag_response["related_queries"])
70
- )
71
- return result # type: ignore
72
-
73
- @classmethod
74
- def examples(cls) -> List["ToolMessage"]:
75
- return [
76
- cls(
77
- query="When was the Llama2 Large Language Model (LLM) released?",
78
- ),
79
- ]