letta-nightly 0.6.1.dev20241205211219__py3-none-any.whl → 0.6.1.dev20241207104149__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.
Potentially problematic release.
This version of letta-nightly might be problematic. Click here for more details.
- letta/agent.py +54 -37
- letta/agent_store/db.py +1 -77
- letta/agent_store/storage.py +0 -5
- letta/chat_only_agent.py +103 -0
- letta/cli/cli.py +0 -1
- letta/client/client.py +3 -7
- letta/constants.py +1 -0
- letta/functions/function_sets/base.py +37 -9
- letta/main.py +2 -2
- letta/memory.py +4 -82
- letta/metadata.py +0 -35
- letta/o1_agent.py +7 -2
- letta/offline_memory_agent.py +180 -0
- letta/orm/__init__.py +3 -0
- letta/orm/file.py +1 -1
- letta/orm/message.py +66 -0
- letta/orm/mixins.py +16 -0
- letta/orm/organization.py +1 -0
- letta/orm/sqlalchemy_base.py +118 -26
- letta/orm/tool.py +22 -1
- letta/orm/tools_agents.py +32 -0
- letta/personas/examples/offline_memory_persona.txt +4 -0
- letta/prompts/system/memgpt_convo_only.txt +14 -0
- letta/prompts/system/memgpt_offline_memory.txt +23 -0
- letta/prompts/system/memgpt_offline_memory_chat.txt +35 -0
- letta/schemas/agent.py +3 -2
- letta/schemas/letta_base.py +7 -6
- letta/schemas/message.py +1 -7
- letta/schemas/tools_agents.py +32 -0
- letta/server/rest_api/app.py +11 -0
- letta/server/rest_api/routers/v1/agents.py +2 -2
- letta/server/rest_api/routers/v1/blocks.py +2 -2
- letta/server/server.py +63 -47
- letta/server/static_files/assets/index-43ab4d62.css +1 -0
- letta/server/static_files/assets/index-4848e3d7.js +40 -0
- letta/server/static_files/index.html +2 -2
- letta/services/block_manager.py +1 -1
- letta/services/message_manager.py +182 -0
- letta/services/organization_manager.py +6 -9
- letta/services/source_manager.py +1 -1
- letta/services/tool_manager.py +2 -2
- letta/services/tools_agents_manager.py +94 -0
- letta/services/user_manager.py +1 -1
- {letta_nightly-0.6.1.dev20241205211219.dist-info → letta_nightly-0.6.1.dev20241207104149.dist-info}/METADATA +2 -1
- {letta_nightly-0.6.1.dev20241205211219.dist-info → letta_nightly-0.6.1.dev20241207104149.dist-info}/RECORD +48 -39
- letta/agent_store/lancedb.py +0 -177
- letta/persistence_manager.py +0 -149
- letta/server/static_files/assets/index-3ab03d5b.css +0 -1
- letta/server/static_files/assets/index-9fa459a2.js +0 -271
- {letta_nightly-0.6.1.dev20241205211219.dist-info → letta_nightly-0.6.1.dev20241207104149.dist-info}/LICENSE +0 -0
- {letta_nightly-0.6.1.dev20241205211219.dist-info → letta_nightly-0.6.1.dev20241207104149.dist-info}/WHEEL +0 -0
- {letta_nightly-0.6.1.dev20241205211219.dist-info → letta_nightly-0.6.1.dev20241207104149.dist-info}/entry_points.txt +0 -0
|
@@ -30,19 +30,16 @@ class OrganizationManager:
|
|
|
30
30
|
def get_organization_by_id(self, org_id: str) -> Optional[PydanticOrganization]:
|
|
31
31
|
"""Fetch an organization by ID."""
|
|
32
32
|
with self.session_maker() as session:
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return organization.to_pydantic()
|
|
36
|
-
except NoResultFound:
|
|
37
|
-
return None
|
|
33
|
+
organization = OrganizationModel.read(db_session=session, identifier=org_id)
|
|
34
|
+
return organization.to_pydantic()
|
|
38
35
|
|
|
39
36
|
@enforce_types
|
|
40
37
|
def create_organization(self, pydantic_org: PydanticOrganization) -> PydanticOrganization:
|
|
41
|
-
"""Create a new organization.
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
"""Create a new organization."""
|
|
39
|
+
try:
|
|
40
|
+
org = self.get_organization_by_id(pydantic_org.id)
|
|
44
41
|
return org
|
|
45
|
-
|
|
42
|
+
except NoResultFound:
|
|
46
43
|
return self._create_organization(pydantic_org=pydantic_org)
|
|
47
44
|
|
|
48
45
|
@enforce_types
|
letta/services/source_manager.py
CHANGED
|
@@ -141,5 +141,5 @@ class SourceManager:
|
|
|
141
141
|
"""Delete a file by its ID."""
|
|
142
142
|
with self.session_maker() as session:
|
|
143
143
|
file = FileMetadataModel.read(db_session=session, identifier=file_id)
|
|
144
|
-
file.
|
|
144
|
+
file.hard_delete(db_session=session, actor=actor)
|
|
145
145
|
return file.to_pydantic()
|
letta/services/tool_manager.py
CHANGED
|
@@ -122,7 +122,7 @@ class ToolManager:
|
|
|
122
122
|
tool.json_schema = new_schema
|
|
123
123
|
|
|
124
124
|
# Save the updated tool to the database
|
|
125
|
-
return tool.update(db_session=session, actor=actor)
|
|
125
|
+
return tool.update(db_session=session, actor=actor).to_pydantic()
|
|
126
126
|
|
|
127
127
|
@enforce_types
|
|
128
128
|
def delete_tool_by_id(self, tool_id: str, actor: PydanticUser) -> None:
|
|
@@ -130,7 +130,7 @@ class ToolManager:
|
|
|
130
130
|
with self.session_maker() as session:
|
|
131
131
|
try:
|
|
132
132
|
tool = ToolModel.read(db_session=session, identifier=tool_id, actor=actor)
|
|
133
|
-
tool.
|
|
133
|
+
tool.hard_delete(db_session=session, actor=actor)
|
|
134
134
|
except NoResultFound:
|
|
135
135
|
raise ValueError(f"Tool with id {tool_id} not found.")
|
|
136
136
|
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
|
|
4
|
+
from sqlalchemy import select
|
|
5
|
+
from sqlalchemy.exc import IntegrityError
|
|
6
|
+
from sqlalchemy.orm import Session
|
|
7
|
+
|
|
8
|
+
from letta.orm.errors import NoResultFound
|
|
9
|
+
from letta.orm.organization import Organization
|
|
10
|
+
from letta.orm.tool import Tool
|
|
11
|
+
from letta.orm.tools_agents import ToolsAgents as ToolsAgentsModel
|
|
12
|
+
from letta.schemas.tools_agents import ToolsAgents as PydanticToolsAgents
|
|
13
|
+
|
|
14
|
+
class ToolsAgentsManager:
|
|
15
|
+
"""Manages the relationship between tools and agents."""
|
|
16
|
+
|
|
17
|
+
def __init__(self):
|
|
18
|
+
from letta.server.server import db_context
|
|
19
|
+
self.session_maker = db_context
|
|
20
|
+
|
|
21
|
+
def add_tool_to_agent(self, agent_id: str, tool_id: str, tool_name: str) -> PydanticToolsAgents:
|
|
22
|
+
"""Add a tool to an agent.
|
|
23
|
+
|
|
24
|
+
When a tool is added to an agent, it will be added to all agents in the same organization.
|
|
25
|
+
"""
|
|
26
|
+
with self.session_maker() as session:
|
|
27
|
+
try:
|
|
28
|
+
# Check if the tool-agent combination already exists for this agent
|
|
29
|
+
tools_agents_record = ToolsAgentsModel.read(db_session=session, agent_id=agent_id, tool_name=tool_name)
|
|
30
|
+
warnings.warn(f"Tool name '{tool_name}' already exists for agent '{agent_id}'.")
|
|
31
|
+
except NoResultFound:
|
|
32
|
+
tools_agents_record = PydanticToolsAgents(agent_id=agent_id, tool_id=tool_id, tool_name=tool_name)
|
|
33
|
+
tools_agents_record = ToolsAgentsModel(**tools_agents_record.model_dump(exclude_none=True))
|
|
34
|
+
tools_agents_record.create(session)
|
|
35
|
+
|
|
36
|
+
return tools_agents_record.to_pydantic()
|
|
37
|
+
|
|
38
|
+
def remove_tool_with_name_from_agent(self, agent_id: str, tool_name: str) -> None:
|
|
39
|
+
"""Remove a tool from an agent by its name.
|
|
40
|
+
|
|
41
|
+
When a tool is removed from an agent, it will be removed from all agents in the same organization.
|
|
42
|
+
"""
|
|
43
|
+
with self.session_maker() as session:
|
|
44
|
+
try:
|
|
45
|
+
# Find and delete the tool-agent association for the agent
|
|
46
|
+
tools_agents_record = ToolsAgentsModel.read(db_session=session, agent_id=agent_id, tool_name=tool_name)
|
|
47
|
+
tools_agents_record.hard_delete(session)
|
|
48
|
+
return tools_agents_record.to_pydantic()
|
|
49
|
+
except NoResultFound:
|
|
50
|
+
raise ValueError(f"Tool name '{tool_name}' not found for agent '{agent_id}'.")
|
|
51
|
+
|
|
52
|
+
def remove_tool_with_id_from_agent(self, agent_id: str, tool_id: str) -> PydanticToolsAgents:
|
|
53
|
+
"""Remove a tool with an ID from an agent."""
|
|
54
|
+
with self.session_maker() as session:
|
|
55
|
+
try:
|
|
56
|
+
tools_agents_record = ToolsAgentsModel.read(db_session=session, agent_id=agent_id, tool_id=tool_id)
|
|
57
|
+
tools_agents_record.hard_delete(session)
|
|
58
|
+
return tools_agents_record.to_pydantic()
|
|
59
|
+
except NoResultFound:
|
|
60
|
+
raise ValueError(f"Tool ID '{tool_id}' not found for agent '{agent_id}'.")
|
|
61
|
+
|
|
62
|
+
def list_tool_ids_for_agent(self, agent_id: str) -> List[str]:
|
|
63
|
+
"""List all tool IDs associated with a specific agent."""
|
|
64
|
+
with self.session_maker() as session:
|
|
65
|
+
tools_agents_record = ToolsAgentsModel.list(db_session=session, agent_id=agent_id)
|
|
66
|
+
return [record.tool_id for record in tools_agents_record]
|
|
67
|
+
|
|
68
|
+
def list_tool_names_for_agent(self, agent_id: str) -> List[str]:
|
|
69
|
+
"""List all tool names associated with a specific agent."""
|
|
70
|
+
with self.session_maker() as session:
|
|
71
|
+
tools_agents_record = ToolsAgentsModel.list(db_session=session, agent_id=agent_id)
|
|
72
|
+
return [record.tool_name for record in tools_agents_record]
|
|
73
|
+
|
|
74
|
+
def list_agent_ids_with_tool(self, tool_id: str) -> List[str]:
|
|
75
|
+
"""List all agents associated with a specific tool."""
|
|
76
|
+
with self.session_maker() as session:
|
|
77
|
+
tools_agents_record = ToolsAgentsModel.list(db_session=session, tool_id=tool_id)
|
|
78
|
+
return [record.agent_id for record in tools_agents_record]
|
|
79
|
+
|
|
80
|
+
def get_tool_id_for_name(self, agent_id: str, tool_name: str) -> str:
|
|
81
|
+
"""Get the tool ID for a specific tool name for an agent."""
|
|
82
|
+
with self.session_maker() as session:
|
|
83
|
+
try:
|
|
84
|
+
tools_agents_record = ToolsAgentsModel.read(db_session=session, agent_id=agent_id, tool_name=tool_name)
|
|
85
|
+
return tools_agents_record.tool_id
|
|
86
|
+
except NoResultFound:
|
|
87
|
+
raise ValueError(f"Tool name '{tool_name}' not found for agent '{agent_id}'.")
|
|
88
|
+
|
|
89
|
+
def remove_all_agent_tools(self, agent_id: str) -> None:
|
|
90
|
+
"""Remove all tools associated with an agent."""
|
|
91
|
+
with self.session_maker() as session:
|
|
92
|
+
tools_agents_records = ToolsAgentsModel.list(db_session=session, agent_id=agent_id)
|
|
93
|
+
for record in tools_agents_records:
|
|
94
|
+
record.hard_delete(session)
|
letta/services/user_manager.py
CHANGED
|
@@ -71,7 +71,7 @@ class UserManager:
|
|
|
71
71
|
with self.session_maker() as session:
|
|
72
72
|
# Delete from user table
|
|
73
73
|
user = UserModel.read(db_session=session, identifier=user_id)
|
|
74
|
-
user.
|
|
74
|
+
user.hard_delete(session)
|
|
75
75
|
|
|
76
76
|
# TODO: Integrate this via the ORM models for the Agent, Source, and AgentSourceMapping
|
|
77
77
|
# Cascade delete for related models: Agent, Source, AgentSourceMapping
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: letta-nightly
|
|
3
|
-
Version: 0.6.1.
|
|
3
|
+
Version: 0.6.1.dev20241207104149
|
|
4
4
|
Summary: Create LLM agents with long-term memory and custom tools
|
|
5
5
|
License: Apache License
|
|
6
6
|
Author: Letta Team
|
|
@@ -70,6 +70,7 @@ Requires-Dist: pytz (>=2023.3.post1,<2024.0)
|
|
|
70
70
|
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
|
|
71
71
|
Requires-Dist: qdrant-client (>=1.9.1,<2.0.0) ; extra == "qdrant"
|
|
72
72
|
Requires-Dist: questionary (>=2.0.1,<3.0.0)
|
|
73
|
+
Requires-Dist: sentry-sdk[fastapi] (==2.19.1)
|
|
73
74
|
Requires-Dist: setuptools (>=68.2.2,<69.0.0)
|
|
74
75
|
Requires-Dist: sqlalchemy (>=2.0.25,<3.0.0)
|
|
75
76
|
Requires-Dist: sqlalchemy-json (>=0.7.0,<0.8.0)
|
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
letta/__init__.py,sha256=1hJidwYqfS-iX2V3ZLC2ulm-PYX74k2EMIyzC4Z0pWc,1035
|
|
2
2
|
letta/__main__.py,sha256=6Hs2PV7EYc5Tid4g4OtcLXhqVHiNYTGzSBdoOnW2HXA,29
|
|
3
|
-
letta/agent.py,sha256=
|
|
3
|
+
letta/agent.py,sha256=Kr55vl085tf-FvSWBPD-1SZmOn2xaCd_tLtoV8SvDuU,79198
|
|
4
4
|
letta/agent_store/chroma.py,sha256=-kCEMBFKmqCyFeIETYf7RN-khGddsip2FAhSzNqaC7U,12537
|
|
5
|
-
letta/agent_store/db.py,sha256=
|
|
6
|
-
letta/agent_store/lancedb.py,sha256=i63d4VZwj9UIOTNs5f0JZ_r5yZD-jKWz4FAH4RMpXOE,5104
|
|
5
|
+
letta/agent_store/db.py,sha256=0AdN1-LpvIUhmiayTwzhKPaXTdlyOILtHGZ7zmS7pPs,20314
|
|
7
6
|
letta/agent_store/milvus.py,sha256=xUu-D9a6N10MuGJ-R-QWR2IHX77ueqAp88tV4gg9B4M,8470
|
|
8
7
|
letta/agent_store/qdrant.py,sha256=6_33V-FEDpT9LG5zmr6-3y9slw1YFLswxpahiyMkvHA,7880
|
|
9
|
-
letta/agent_store/storage.py,sha256=
|
|
8
|
+
letta/agent_store/storage.py,sha256=YDQTrfgPBa0cMiMuQatk9hcadIUMvA4zKZHx2VKjlak,6475
|
|
10
9
|
letta/benchmark/benchmark.py,sha256=ebvnwfp3yezaXOQyGXkYCDYpsmre-b9hvNtnyx4xkG0,3701
|
|
11
10
|
letta/benchmark/constants.py,sha256=aXc5gdpMGJT327VuxsT5FngbCK2J41PQYeICBO7g_RE,536
|
|
12
|
-
letta/
|
|
11
|
+
letta/chat_only_agent.py,sha256=606FQybmeN9s04rIFQlDkWOHirrT0p48_3pMKY8d5Ts,4740
|
|
12
|
+
letta/cli/cli.py,sha256=7DI6fHLCTgotP4jr6x4D07EaOjayi1vH-SZj9KiCOQQ,16834
|
|
13
13
|
letta/cli/cli_config.py,sha256=tB0Wgz3O9j6KiCsU1HWfsKmhNM9RqLsAxzxEDFQFGnM,8565
|
|
14
14
|
letta/cli/cli_load.py,sha256=x4L8s15GwIW13xrhKYFWHo_y-IVGtoPDHWWKcHDRP10,4587
|
|
15
15
|
letta/client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
16
|
-
letta/client/client.py,sha256=
|
|
16
|
+
letta/client/client.py,sha256=Oetmz1FwIs0n9bCRmzlPqxIjQK3zKrraQ2t3gq_pNg4,124015
|
|
17
17
|
letta/client/streaming.py,sha256=Hh5pjlyrdCuO2V75ZCxSSOCPd3BmHdKFGaIUJC6fBp0,4775
|
|
18
18
|
letta/client/utils.py,sha256=OJlAKWrldc4I6M1WpcTWNtPJ4wfxlzlZqWLfCozkFtI,2872
|
|
19
19
|
letta/config.py,sha256=AF4XY6grcu87OLjrWXh1ufnyKWsCL0qER-_9jQCAlU0,18947
|
|
20
|
-
letta/constants.py,sha256=
|
|
20
|
+
letta/constants.py,sha256=l2IyZpVG-d_raFFX5bN6mCbprnnc1IA-z-oCKPoyPSM,6902
|
|
21
21
|
letta/credentials.py,sha256=D9mlcPsdDWlIIXQQD8wSPE9M_QvsRrb0p3LB5i9OF5Q,5806
|
|
22
22
|
letta/data_sources/connectors.py,sha256=5VKxfeV-QyUlK1wexLlpgar99dGm6PHxFaEbSeByo_U,9923
|
|
23
23
|
letta/data_sources/connectors_helper.py,sha256=2TQjCt74fCgT5sw1AP8PalDEk06jPBbhrPG4HVr-WLs,3371
|
|
24
24
|
letta/embeddings.py,sha256=3vJaQ8RMLLp6yiYZGsthq6Xsu4keb9gp7DYN_2GPBFU,8459
|
|
25
25
|
letta/errors.py,sha256=mFeTpZP37otDMr68s9hyGOnafJPrWeblQOI79cgP4nQ,3209
|
|
26
26
|
letta/functions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
27
|
-
letta/functions/function_sets/base.py,sha256=
|
|
27
|
+
letta/functions/function_sets/base.py,sha256=anK6XJQlmTu9eC33700Eh7NWxQ0NTLUC2Vxpn6ihvnY,9034
|
|
28
28
|
letta/functions/function_sets/extras.py,sha256=Jik3UiDqYTm4Lam1XPTvuVjvgUHwIAhopsnbmVhGMBg,4732
|
|
29
29
|
letta/functions/functions.py,sha256=evH6GKnIJwVVre1Xre2gaSIqREv4eNM4DiWOhn8PMqg,3299
|
|
30
30
|
letta/functions/helpers.py,sha256=K84kqAN1RXZIhjb7-btS0C2p-SInYNv6FvSfo-16Y6g,8578
|
|
@@ -83,36 +83,39 @@ letta/local_llm/webui/legacy_api.py,sha256=k3H3y4qp2Fs-XmP24iSIEyvq6wjWFWBzklY3-
|
|
|
83
83
|
letta/local_llm/webui/legacy_settings.py,sha256=BLmd3TSx5StnY3ibjwaxYATPt_Lvq-o1rlcc_-Q1JcU,538
|
|
84
84
|
letta/local_llm/webui/settings.py,sha256=gmLHfiOl1u4JmlAZU2d2O8YKF9lafdakyjwR_ftVPh8,552
|
|
85
85
|
letta/log.py,sha256=FxkAk2f8Bl-u9dfImSj1DYnjAsmV6PL3tjTSnEiNP48,2218
|
|
86
|
-
letta/main.py,sha256=
|
|
87
|
-
letta/memory.py,sha256=
|
|
88
|
-
letta/metadata.py,sha256=
|
|
89
|
-
letta/o1_agent.py,sha256=
|
|
86
|
+
letta/main.py,sha256=M78MU-12bj-6qyoWz-yNIRsj8qMmwCZB4Ed8LTFfKrc,19135
|
|
87
|
+
letta/memory.py,sha256=R4Z_MYD5ve04FBe2yohux1pzp8MTjOSI1AZ5oLCdGRA,14568
|
|
88
|
+
letta/metadata.py,sha256=zwIe0Sr1Q2g5L2V6Yc5D_t_NG8nhdgleAGQEdaAi2Lw,15165
|
|
89
|
+
letta/o1_agent.py,sha256=aNuv70NmmtKQcfOcd0L4VxHzg7o7xoiU81j1LWok4bk,3164
|
|
90
|
+
letta/offline_memory_agent.py,sha256=369jMxqKMoex9JI269kpaO1Q_JPWLwn-BaiZ6YHc-Fw,7898
|
|
90
91
|
letta/openai_backcompat/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
91
92
|
letta/openai_backcompat/openai_object.py,sha256=Y1ZS1sATP60qxJiOsjOP3NbwSzuzvkNAvb3DeuhM5Uk,13490
|
|
92
93
|
letta/orm/__all__.py,sha256=2gh2MZTkA3Hw67VWVKK3JIStJOqTeLdpCvYSVYNeEDA,692
|
|
93
|
-
letta/orm/__init__.py,sha256=
|
|
94
|
+
letta/orm/__init__.py,sha256=HyH2suMD8-92bZ5paW8AC1o-639AQqwAc_HN8S7mjxI,542
|
|
94
95
|
letta/orm/agents_tags.py,sha256=Qa7Yt9imL8xbGP57fflccAMy7Z32CQiU_7eZKSSPngc,1119
|
|
95
96
|
letta/orm/base.py,sha256=K_LpNUURbsj44ycHbzvNXG_n8pBOjf1YvDaikIPDpQA,2716
|
|
96
97
|
letta/orm/block.py,sha256=xymYeCTJJFkzADW6wjfP2LXNZZN9yg4mCSybbvEEMMM,2356
|
|
97
98
|
letta/orm/blocks_agents.py,sha256=o6cfblODja7so4444npW0vusqKcvDPp8YJdsWsOePus,1164
|
|
98
99
|
letta/orm/enums.py,sha256=KfHcFt_fR6GUmSlmfsa-TetvmuRxGESNve8MStRYW64,145
|
|
99
100
|
letta/orm/errors.py,sha256=nv1HnF3z4-u9m_g7SO5TO5u2nmJN677_n8F0iIjluUI,460
|
|
100
|
-
letta/orm/file.py,sha256=
|
|
101
|
+
letta/orm/file.py,sha256=JafpJhooBtMrmkRG68jT8rFK9mRIQSlYKYjq3VXhTcc,1525
|
|
101
102
|
letta/orm/job.py,sha256=If-qSTJW4t5h-6Jolw3tS3-xMZEaPIbXe3S0GMf_FXI,1102
|
|
102
|
-
letta/orm/
|
|
103
|
-
letta/orm/
|
|
103
|
+
letta/orm/message.py,sha256=8x6zDFlnYqTL27JDaVcaHtIOkvTGVg_FxesSmOvH0kI,2677
|
|
104
|
+
letta/orm/mixins.py,sha256=TpP5dFAcGu2VvHZQSt8ymc0UjQhcVp5-Fc2C4v_nUTM,1508
|
|
105
|
+
letta/orm/organization.py,sha256=ZoHow3Tpdh9TXDvB4VZbArbUCgbErFTSQMriYAzulqA,2397
|
|
104
106
|
letta/orm/sandbox_config.py,sha256=PCMHE-eJPzBT-90OYtXjEMRF4f9JB8AJIGETE7bu-f0,2870
|
|
105
107
|
letta/orm/source.py,sha256=Ib0XHCMt345RjBSC30A398rZ21W5mA4PXX00XNXyd24,2021
|
|
106
|
-
letta/orm/sqlalchemy_base.py,sha256=
|
|
107
|
-
letta/orm/tool.py,sha256=
|
|
108
|
+
letta/orm/sqlalchemy_base.py,sha256=_uix_6bCC_rZYbTKL_OpldjTgrEv-9l6FL3ysKsgUZU,13877
|
|
109
|
+
letta/orm/tool.py,sha256=R1I3FGjt8xlW7DPkwV9zlliOcAB3vpphAZTQTsvDBXs,2982
|
|
110
|
+
letta/orm/tools_agents.py,sha256=mBMGQsTEx_ckfhZb2-2nqbxHBEMhvDXim6w6tFHHWBQ,1195
|
|
108
111
|
letta/orm/user.py,sha256=bUZzyBQXfR0w7mZAkThPAQE6kKx6W--Rw6uAiPEUW3s,1133
|
|
109
|
-
letta/persistence_manager.py,sha256=sEnNdNisK7StqIzG8eIY0YMag6S9hZFbkDfmY7L2Ikc,5268
|
|
110
112
|
letta/personas/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
111
113
|
letta/personas/examples/anna_pa.txt,sha256=zgiNdSNhy1HQy58cF_6RFPzcg2i37F9v38YuL1CW40A,1849
|
|
112
114
|
letta/personas/examples/google_search_persona.txt,sha256=RyObU80MIk2oeJJDWOK1aX5pHOtbHSSjIrbUpxov240,1194
|
|
113
115
|
letta/personas/examples/memgpt_doc.txt,sha256=_McafHuYkJYAnBFwvu_LVEaSEQGbs0flCgJIIJYlZgc,425
|
|
114
116
|
letta/personas/examples/memgpt_starter.txt,sha256=x-fEozRrfUVlCJUEjkwHDCGeBb2z50d0jd6QF78SHKQ,160
|
|
115
117
|
letta/personas/examples/o1_persona.txt,sha256=VKSDXuMaiOg-fnaiMFnEauYy85q88LJKW0y8N7V5j3g,339
|
|
118
|
+
letta/personas/examples/offline_memory_persona.txt,sha256=u2ZK9X72hxA7BbKRzkailEVisFaICdHhLi6hBNS4kC0,178
|
|
116
119
|
letta/personas/examples/sam.txt,sha256=V1-3-x9gud_opkeNL3XPXyCyJySCp4sYi-XTFD26gnc,1223
|
|
117
120
|
letta/personas/examples/sam_pov.txt,sha256=NUZOfkz91aBwnv2M3iDsPZYf8MlaGF0zQB0nFOUC56k,1171
|
|
118
121
|
letta/personas/examples/sam_simple_pov_gpt35.txt,sha256=vP6R5GxPeO0QuMartRs3DBfSs1LFWW8CHNqo7II0BuA,1053
|
|
@@ -124,14 +127,17 @@ letta/prompts/system/memgpt_base.txt,sha256=dOHdqibJIth9lHZMxl4hUGxKjT6DWXvvVBb1
|
|
|
124
127
|
letta/prompts/system/memgpt_chat.txt,sha256=2tOfLG89vOxBBD7vYOQhIWardJFJ4tO2VUFYcA0NAZo,5420
|
|
125
128
|
letta/prompts/system/memgpt_chat_compressed.txt,sha256=_gMDjc8tcigLfJ3fOXryz31_DJxSQM812T3J-aw7x0w,1056
|
|
126
129
|
letta/prompts/system/memgpt_chat_fstring.txt,sha256=N6KSRwu-dcnDBLpCeqCdgM9lI0CnR3uIVPFcrCCa0V0,4720
|
|
130
|
+
letta/prompts/system/memgpt_convo_only.txt,sha256=0cmlDNtjZ_YlUVElzM4gzwCh16uwVBN2miKgYIlozKg,1142
|
|
127
131
|
letta/prompts/system/memgpt_doc.txt,sha256=AsT55NOORoH-K-p0fxklrDRZ3qHs4MIKMuR-M4SSU4E,4768
|
|
128
132
|
letta/prompts/system/memgpt_gpt35_extralong.txt,sha256=FheNhYoIzNz6qnJKhVquZVSMj3HduC48reFaX7Pf7ig,5046
|
|
129
133
|
letta/prompts/system/memgpt_intuitive_knowledge.txt,sha256=sA7c3urYqREVnSBI81nTGImXAekqC0Fxc7RojFqud1g,2966
|
|
130
134
|
letta/prompts/system/memgpt_modified_chat.txt,sha256=HOaPVurEftD8KsuwsclDgE2afIfklMjxhuSO96q1-6I,4656
|
|
131
135
|
letta/prompts/system/memgpt_modified_o1.txt,sha256=AxxYVjYLZwpZ6yfifh1SuPtwlJGWTcTVzw53QbkN-Ao,5492
|
|
136
|
+
letta/prompts/system/memgpt_offline_memory.txt,sha256=rWEJeF-6aiinjkJM9hgLUYCmlEcC_HekYB1bjEUYq6M,2460
|
|
137
|
+
letta/prompts/system/memgpt_offline_memory_chat.txt,sha256=ituh7gDuio7nC2UKFB7GpBq6crxb8bYedQfJ0ADoPgg,3949
|
|
132
138
|
letta/providers.py,sha256=0j6WPRn70WNSOjWS7smhTI3ZZOlfVAVF0ZFcrdQDmMY,25321
|
|
133
139
|
letta/pytest.ini,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
134
|
-
letta/schemas/agent.py,sha256=
|
|
140
|
+
letta/schemas/agent.py,sha256=5nL4YSvuVp2RxJ5lbpTdKOFB-DntnFwncqcRWREbfkQ,8514
|
|
135
141
|
letta/schemas/agents_tags.py,sha256=9DGr8fN2DHYdWvZ_qcXmrKI0w7YKCGz2lfEcrX2KAkI,1130
|
|
136
142
|
letta/schemas/api_key.py,sha256=u07yzzMn-hBAHZIIKbWY16KsgiFjSNR8lAghpMUo3_4,682
|
|
137
143
|
letta/schemas/block.py,sha256=pVDH8jr5r-oxdX4cK9dX2wXyLBzgGKQOBWOzqZSeBog,5944
|
|
@@ -141,13 +147,13 @@ letta/schemas/enums.py,sha256=F396hXs57up4Jqj1vwWVknMpoVo7MkccVBALvKGHPpE,1032
|
|
|
141
147
|
letta/schemas/file.py,sha256=ChN2CWzLI2TT9WLItcfElEH0E8b7kzPylF2OQBr6Beg,1550
|
|
142
148
|
letta/schemas/health.py,sha256=zT6mYovvD17iJRuu2rcaQQzbEEYrkwvAE9TB7iU824c,139
|
|
143
149
|
letta/schemas/job.py,sha256=vRVVpMCHTxot9uaalLS8RARnqzJWvcLB1XP5XRBioPc,1398
|
|
144
|
-
letta/schemas/letta_base.py,sha256=
|
|
150
|
+
letta/schemas/letta_base.py,sha256=v3OvpVFVUfcuK1lIyTjM0x4fmWeWQw1DdlhKXHBUCz8,3608
|
|
145
151
|
letta/schemas/letta_message.py,sha256=RuVVtwFbi85yP3dXQxowofQ6cI2cO_CdGtgpHGQzgHc,6563
|
|
146
152
|
letta/schemas/letta_request.py,sha256=E6OwKiceNffpdGdQMI1qc0jEfpL_e7O9BTzklOkbt6Y,1019
|
|
147
153
|
letta/schemas/letta_response.py,sha256=vQV5uqe-kq9fc4wCo-sVB_PJt5yUk8DB2zOgHsrmN-k,6189
|
|
148
154
|
letta/schemas/llm_config.py,sha256=RbgnCaqYd_yl-Xs7t-DEI1NhpKD8WiVWjxcwq5mZd5M,4467
|
|
149
155
|
letta/schemas/memory.py,sha256=80Y7gqWQQndhNkJ-0j38d2m619gTlfes_qJNA6_ant8,10040
|
|
150
|
-
letta/schemas/message.py,sha256=
|
|
156
|
+
letta/schemas/message.py,sha256=KER04veCt-7FiZj3GU1x_QW38xnBC7jnnBDkRJuW3ak,33485
|
|
151
157
|
letta/schemas/openai/chat_completion_request.py,sha256=AOIwgbN3CZKVqkuXeMHeSa53u4h0wVq69t3T_LJ0vIE,3389
|
|
152
158
|
letta/schemas/openai/chat_completion_response.py,sha256=ub-oVSyLpuJd-5_yzCSIRR8tD3GM83IeDO1c1uAATa4,3970
|
|
153
159
|
letta/schemas/openai/chat_completions.py,sha256=V0ZPIIk-ds3O6MAkNHMz8zh1hqMFSPrTcYr88WDYzWE,3588
|
|
@@ -159,13 +165,14 @@ letta/schemas/sandbox_config.py,sha256=6om_uU2-cZaPxe6HLo3Kg9OuTzx_Hibk80UQKyGKf
|
|
|
159
165
|
letta/schemas/source.py,sha256=B1VbaDJV-EGPv1nQXwCx_RAzeAJd50UqP_1m1cIRT8c,2854
|
|
160
166
|
letta/schemas/tool.py,sha256=d88nXm9sH6xOH0d6DKiPehRFVUA5TsfkBBzOP7wmIY8,9715
|
|
161
167
|
letta/schemas/tool_rule.py,sha256=pLt-BzgFSrlVO6ipY4kygyvfoM0BWA-XdqhGxso9aKs,1192
|
|
168
|
+
letta/schemas/tools_agents.py,sha256=DGfmX7qXSBMCjykHyy0FRxgep2tJgYXf1rqDTmP6Tfo,1313
|
|
162
169
|
letta/schemas/usage.py,sha256=lvn1ooHwLEdv6gwQpw5PBUbcwn_gwdT6HA-fCiix6sY,817
|
|
163
170
|
letta/schemas/user.py,sha256=V32Tgl6oqB3KznkxUz12y7agkQicjzW7VocSpj78i6Q,1526
|
|
164
171
|
letta/server/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
165
172
|
letta/server/constants.py,sha256=yAdGbLkzlOU_dLTx0lKDmAnj0ZgRXCEaIcPJWO69eaE,92
|
|
166
173
|
letta/server/generate_openapi_schema.sh,sha256=0OtBhkC1g6CobVmNEd_m2B6sTdppjbJLXaM95icejvE,371
|
|
167
174
|
letta/server/rest_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
168
|
-
letta/server/rest_api/app.py,sha256=
|
|
175
|
+
letta/server/rest_api/app.py,sha256=Kv8luYrKIpI1__6AxjjVriZgDm6KeNWx9r1LO3Vgvbo,8032
|
|
169
176
|
letta/server/rest_api/auth/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
170
177
|
letta/server/rest_api/auth/index.py,sha256=fQBGyVylGSRfEMLQ17cZzrHd5Y1xiVylvPqH5Rl-lXQ,1378
|
|
171
178
|
letta/server/rest_api/auth_token.py,sha256=725EFEIiNj4dh70hrSd94UysmFD8vcJLrTRfNHkzxDo,774
|
|
@@ -179,8 +186,8 @@ letta/server/rest_api/routers/openai/assistants/threads.py,sha256=g8iu98__tQEMY9
|
|
|
179
186
|
letta/server/rest_api/routers/openai/chat_completions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
180
187
|
letta/server/rest_api/routers/openai/chat_completions/chat_completions.py,sha256=qFMpxfYIlJ-PW08IQt09RW44u6hwkssdsUT-h_GuOvE,4836
|
|
181
188
|
letta/server/rest_api/routers/v1/__init__.py,sha256=RZc0fIHNN4BGretjU6_TGK7q49RyV4jfYNudoiK_sUo,762
|
|
182
|
-
letta/server/rest_api/routers/v1/agents.py,sha256=
|
|
183
|
-
letta/server/rest_api/routers/v1/blocks.py,sha256=
|
|
189
|
+
letta/server/rest_api/routers/v1/agents.py,sha256=h6i_HJZ0kcM4p2cTZeh0Mi65PhBw08uzDDxsQkFRLt4,24891
|
|
190
|
+
letta/server/rest_api/routers/v1/blocks.py,sha256=hLGwm56xCA09KdEi8P0V3s__pD_yyl07p17cdSfDj8g,4878
|
|
184
191
|
letta/server/rest_api/routers/v1/health.py,sha256=pKCuVESlVOhGIb4VC4K-H82eZqfghmT6kvj2iOkkKuc,401
|
|
185
192
|
letta/server/rest_api/routers/v1/jobs.py,sha256=gnu__rjcd9SpKdQkSD_sci-xJYH0fw828PuHMcYwsCw,2678
|
|
186
193
|
letta/server/rest_api/routers/v1/llms.py,sha256=TcyvSx6MEM3je5F4DysL7ligmssL_pFlJaaO4uL95VY,877
|
|
@@ -191,12 +198,12 @@ letta/server/rest_api/routers/v1/tools.py,sha256=TP16cpuTF2HYLFZVmabExw9gziB-Ptk
|
|
|
191
198
|
letta/server/rest_api/routers/v1/users.py,sha256=M1wEr2IyHzuRwINYxLXTkrbAH3osLe_cWjzrWrzR1aw,3729
|
|
192
199
|
letta/server/rest_api/static_files.py,sha256=NG8sN4Z5EJ8JVQdj19tkFa9iQ1kBPTab9f_CUxd_u4Q,3143
|
|
193
200
|
letta/server/rest_api/utils.py,sha256=6c5a_-ZFTlwZ1IuzpRQtqxSG1eD56nNhKhWlrdgBYWk,3103
|
|
194
|
-
letta/server/server.py,sha256=
|
|
201
|
+
letta/server/server.py,sha256=jX1KQsSoLY9gtKFSwskxZjx7lduuQ0YLTovriKnM-9Q,81561
|
|
195
202
|
letta/server/startup.sh,sha256=wTOQOJJZw_Iec57WIu0UW0AVflk0ZMWYZWg8D3T_gSQ,698
|
|
196
|
-
letta/server/static_files/assets/index-
|
|
197
|
-
letta/server/static_files/assets/index-
|
|
203
|
+
letta/server/static_files/assets/index-43ab4d62.css,sha256=Q6tNYu7XNRgkTZau1dVwCQTT4YpLGLF7VgTNzLcMaQI,7613
|
|
204
|
+
letta/server/static_files/assets/index-4848e3d7.js,sha256=XkoX-NW0x1Hb7uTWslfpuPP73MnNDthOdJLHLID9EhM,146806
|
|
198
205
|
letta/server/static_files/favicon.ico,sha256=DezhLdFSbM8o81wCOZcV3riq7tFUOGQD4h6-vr-HuU0,342
|
|
199
|
-
letta/server/static_files/index.html,sha256=
|
|
206
|
+
letta/server/static_files/index.html,sha256=RF-Kt4CbTPJbsHtK30NaWIsdUiBpmJgQsKmE6WwqsBk,1198
|
|
200
207
|
letta/server/static_files/memgpt_logo_transparent.png,sha256=7l6niNb4MlUILxLlUZPxIE1TEHj_Z9f9XDxoST3d7Vw,85383
|
|
201
208
|
letta/server/utils.py,sha256=rRvW6L1lzau4u9boamiyZH54lf5tQ91ypXzUW9cfSPA,1667
|
|
202
209
|
letta/server/ws_api/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -206,24 +213,26 @@ letta/server/ws_api/protocol.py,sha256=M_-gM5iuDBwa1cuN2IGNCG5GxMJwU2d3XW93XALv9
|
|
|
206
213
|
letta/server/ws_api/server.py,sha256=C2Kv48PCwl46DQFb0ZP30s86KJLQ6dZk2AhWQEZn9pY,6004
|
|
207
214
|
letta/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
208
215
|
letta/services/agents_tags_manager.py,sha256=zNqeXDpaf4dQ77jrRHiQfITdk4FawBzcND-9tWrj8gw,3127
|
|
209
|
-
letta/services/block_manager.py,sha256=
|
|
216
|
+
letta/services/block_manager.py,sha256=BmuK0k3yl9byT703syGtZNfjUdM2FkOwlE6bQYIQtjI,5448
|
|
210
217
|
letta/services/blocks_agents_manager.py,sha256=mfO3EMW9os_E1_r4SRlC2wmBFFLpt8p-yhdOH_Iotaw,5627
|
|
211
218
|
letta/services/job_manager.py,sha256=FrkSXloke48CZKuzlYdysxM5gKWoTu7FRigPrs_YW4A,3645
|
|
212
|
-
letta/services/
|
|
219
|
+
letta/services/message_manager.py,sha256=pvRaV2GoW5EzRas5j2NSF75O_sTaHVUWwmPzTbHcfHw,6874
|
|
220
|
+
letta/services/organization_manager.py,sha256=B7BgHkZcAOP1fzbg2fFF8eTfKmqOiGvoojQ8ys7JVY4,3412
|
|
213
221
|
letta/services/per_agent_lock_manager.py,sha256=porM0cKKANQ1FvcGXOO_qM7ARk5Fgi1HVEAhXsAg9-4,546
|
|
214
222
|
letta/services/sandbox_config_manager.py,sha256=9BCu59nHR4nIMFXgFyEMOY2UTmZvBMS3GlDBWWCHB4I,12648
|
|
215
|
-
letta/services/source_manager.py,sha256=
|
|
223
|
+
letta/services/source_manager.py,sha256=8TILbVvJx1bopgDbIJCiIguZBw7uyYDFkasZxVos_G8,6560
|
|
216
224
|
letta/services/tool_execution_sandbox.py,sha256=GTWdfAKIMIuODEFbmReyEYkOnE62uzDF-3FHWee1s3A,21295
|
|
217
|
-
letta/services/tool_manager.py,sha256=
|
|
225
|
+
letta/services/tool_manager.py,sha256=BFwD9J6WOIXnYV6QmJFeCKRIiAiD0vO0haNfshkn2jI,7854
|
|
218
226
|
letta/services/tool_sandbox_env/.gitkeep,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
219
|
-
letta/services/
|
|
227
|
+
letta/services/tools_agents_manager.py,sha256=kF6yIsUO154_Q3l-cEeSU56QW-VUr_M6B-9csqhHBkg,4847
|
|
228
|
+
letta/services/user_manager.py,sha256=cfXgnVlnfqPCk7c-wYRsU3RegHs-4stksk186RW89Do,4403
|
|
220
229
|
letta/settings.py,sha256=ZcUcwvl7hStawZ0JOA0133jNk3j5qBd7qlFAAaIPsU8,3608
|
|
221
230
|
letta/streaming_interface.py,sha256=_FPUWy58j50evHcpXyd7zB1wWqeCc71NCFeWh_TBvnw,15736
|
|
222
231
|
letta/streaming_utils.py,sha256=329fsvj1ZN0r0LpQtmMPZ2vSxkDBIUUwvGHZFkjm2I8,11745
|
|
223
232
|
letta/system.py,sha256=buKYPqG5n2x41hVmWpu6JUpyd7vTWED9Km2_M7dLrvk,6960
|
|
224
233
|
letta/utils.py,sha256=7FGZYp8JCEtP0PBSfV03Zj4kW3pwV7qpNki4AOU3a94,32913
|
|
225
|
-
letta_nightly-0.6.1.
|
|
226
|
-
letta_nightly-0.6.1.
|
|
227
|
-
letta_nightly-0.6.1.
|
|
228
|
-
letta_nightly-0.6.1.
|
|
229
|
-
letta_nightly-0.6.1.
|
|
234
|
+
letta_nightly-0.6.1.dev20241207104149.dist-info/LICENSE,sha256=mExtuZ_GYJgDEI38GWdiEYZizZS4KkVt2SF1g_GPNhI,10759
|
|
235
|
+
letta_nightly-0.6.1.dev20241207104149.dist-info/METADATA,sha256=65Tw5JljqWDW7dJ2Qm-ZS-4hfPopKW9WAmstmTFOv3I,11459
|
|
236
|
+
letta_nightly-0.6.1.dev20241207104149.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
|
|
237
|
+
letta_nightly-0.6.1.dev20241207104149.dist-info/entry_points.txt,sha256=2zdiyGNEZGV5oYBuS-y2nAAgjDgcC9yM_mHJBFSRt5U,40
|
|
238
|
+
letta_nightly-0.6.1.dev20241207104149.dist-info/RECORD,,
|
letta/agent_store/lancedb.py
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
# type: ignore
|
|
2
|
-
|
|
3
|
-
import uuid
|
|
4
|
-
from datetime import datetime
|
|
5
|
-
from typing import Dict, Iterator, List, Optional
|
|
6
|
-
|
|
7
|
-
from lancedb.pydantic import LanceModel, Vector
|
|
8
|
-
|
|
9
|
-
from letta.agent_store.storage import StorageConnector, TableType
|
|
10
|
-
from letta.config import AgentConfig, LettaConfig
|
|
11
|
-
from letta.schemas.message import Message, Passage, Record
|
|
12
|
-
|
|
13
|
-
""" Initial implementation - not complete """
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def get_db_model(table_name: str, table_type: TableType):
|
|
17
|
-
config = LettaConfig.load()
|
|
18
|
-
|
|
19
|
-
if table_type == TableType.ARCHIVAL_MEMORY or table_type == TableType.PASSAGES:
|
|
20
|
-
# create schema for archival memory
|
|
21
|
-
class PassageModel(LanceModel):
|
|
22
|
-
"""Defines data model for storing Passages (consisting of text, embedding)"""
|
|
23
|
-
|
|
24
|
-
id: uuid.UUID
|
|
25
|
-
user_id: str
|
|
26
|
-
text: str
|
|
27
|
-
file_id: str
|
|
28
|
-
agent_id: str
|
|
29
|
-
data_source: str
|
|
30
|
-
embedding: Vector(config.default_embedding_config.embedding_dim)
|
|
31
|
-
metadata_: Dict
|
|
32
|
-
|
|
33
|
-
def __repr__(self):
|
|
34
|
-
return f"<Passage(passage_id='{self.id}', text='{self.text}', embedding='{self.embedding})>"
|
|
35
|
-
|
|
36
|
-
def to_record(self):
|
|
37
|
-
return Passage(
|
|
38
|
-
text=self.text,
|
|
39
|
-
embedding=self.embedding,
|
|
40
|
-
file_id=self.file_id,
|
|
41
|
-
user_id=self.user_id,
|
|
42
|
-
id=self.id,
|
|
43
|
-
data_source=self.data_source,
|
|
44
|
-
agent_id=self.agent_id,
|
|
45
|
-
metadata=self.metadata_,
|
|
46
|
-
)
|
|
47
|
-
|
|
48
|
-
return PassageModel
|
|
49
|
-
elif table_type == TableType.RECALL_MEMORY:
|
|
50
|
-
|
|
51
|
-
class MessageModel(LanceModel):
|
|
52
|
-
"""Defines data model for storing Message objects"""
|
|
53
|
-
|
|
54
|
-
__abstract__ = True # this line is necessary
|
|
55
|
-
|
|
56
|
-
# Assuming message_id is the primary key
|
|
57
|
-
id: uuid.UUID
|
|
58
|
-
user_id: str
|
|
59
|
-
agent_id: str
|
|
60
|
-
|
|
61
|
-
# openai info
|
|
62
|
-
role: str
|
|
63
|
-
name: str
|
|
64
|
-
text: str
|
|
65
|
-
model: str
|
|
66
|
-
user: str
|
|
67
|
-
|
|
68
|
-
# function info
|
|
69
|
-
function_name: str
|
|
70
|
-
function_args: str
|
|
71
|
-
function_response: str
|
|
72
|
-
|
|
73
|
-
embedding = Vector(config.default_embedding_config.embedding_dim)
|
|
74
|
-
|
|
75
|
-
# Add a datetime column, with default value as the current time
|
|
76
|
-
created_at = datetime
|
|
77
|
-
|
|
78
|
-
def __repr__(self):
|
|
79
|
-
return f"<Message(message_id='{self.id}', text='{self.text}', embedding='{self.embedding})>"
|
|
80
|
-
|
|
81
|
-
def to_record(self):
|
|
82
|
-
return Message(
|
|
83
|
-
user_id=self.user_id,
|
|
84
|
-
agent_id=self.agent_id,
|
|
85
|
-
role=self.role,
|
|
86
|
-
name=self.name,
|
|
87
|
-
text=self.text,
|
|
88
|
-
model=self.model,
|
|
89
|
-
function_name=self.function_name,
|
|
90
|
-
function_args=self.function_args,
|
|
91
|
-
function_response=self.function_response,
|
|
92
|
-
embedding=self.embedding,
|
|
93
|
-
created_at=self.created_at,
|
|
94
|
-
id=self.id,
|
|
95
|
-
)
|
|
96
|
-
|
|
97
|
-
"""Create database model for table_name"""
|
|
98
|
-
return MessageModel
|
|
99
|
-
|
|
100
|
-
else:
|
|
101
|
-
raise ValueError(f"Table type {table_type} not implemented")
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
class LanceDBConnector(StorageConnector):
|
|
105
|
-
"""Storage via LanceDB"""
|
|
106
|
-
|
|
107
|
-
# TODO: this should probably eventually be moved into a parent DB class
|
|
108
|
-
|
|
109
|
-
def __init__(self, name: Optional[str] = None, agent_config: Optional[AgentConfig] = None):
|
|
110
|
-
# TODO
|
|
111
|
-
pass
|
|
112
|
-
|
|
113
|
-
def generate_where_filter(self, filters: Dict) -> str:
|
|
114
|
-
where_filters = []
|
|
115
|
-
for key, value in filters.items():
|
|
116
|
-
where_filters.append(f"{key}={value}")
|
|
117
|
-
return where_filters.join(" AND ")
|
|
118
|
-
|
|
119
|
-
@abstractmethod
|
|
120
|
-
def get_all_paginated(self, filters: Optional[Dict] = {}, page_size: Optional[int] = 1000) -> Iterator[List[Record]]:
|
|
121
|
-
# TODO
|
|
122
|
-
pass
|
|
123
|
-
|
|
124
|
-
@abstractmethod
|
|
125
|
-
def get_all(self, filters: Optional[Dict] = {}, limit=10) -> List[Record]:
|
|
126
|
-
# TODO
|
|
127
|
-
pass
|
|
128
|
-
|
|
129
|
-
@abstractmethod
|
|
130
|
-
def get(self, id: uuid.UUID) -> Optional[Record]:
|
|
131
|
-
# TODO
|
|
132
|
-
pass
|
|
133
|
-
|
|
134
|
-
@abstractmethod
|
|
135
|
-
def size(self, filters: Optional[Dict] = {}) -> int:
|
|
136
|
-
# TODO
|
|
137
|
-
pass
|
|
138
|
-
|
|
139
|
-
@abstractmethod
|
|
140
|
-
def insert(self, record: Record):
|
|
141
|
-
# TODO
|
|
142
|
-
pass
|
|
143
|
-
|
|
144
|
-
@abstractmethod
|
|
145
|
-
def insert_many(self, records: List[Record], show_progress=False):
|
|
146
|
-
# TODO
|
|
147
|
-
pass
|
|
148
|
-
|
|
149
|
-
@abstractmethod
|
|
150
|
-
def query(self, query: str, query_vec: List[float], top_k: int = 10, filters: Optional[Dict] = {}) -> List[Record]:
|
|
151
|
-
# TODO
|
|
152
|
-
pass
|
|
153
|
-
|
|
154
|
-
@abstractmethod
|
|
155
|
-
def query_date(self, start_date, end_date):
|
|
156
|
-
# TODO
|
|
157
|
-
pass
|
|
158
|
-
|
|
159
|
-
@abstractmethod
|
|
160
|
-
def query_text(self, query):
|
|
161
|
-
# TODO
|
|
162
|
-
pass
|
|
163
|
-
|
|
164
|
-
@abstractmethod
|
|
165
|
-
def delete_table(self):
|
|
166
|
-
# TODO
|
|
167
|
-
pass
|
|
168
|
-
|
|
169
|
-
@abstractmethod
|
|
170
|
-
def delete(self, filters: Optional[Dict] = {}):
|
|
171
|
-
# TODO
|
|
172
|
-
pass
|
|
173
|
-
|
|
174
|
-
@abstractmethod
|
|
175
|
-
def save(self):
|
|
176
|
-
# TODO
|
|
177
|
-
pass
|