letta-nightly 0.1.7.dev20240924104148__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/__init__.py +24 -0
- letta/__main__.py +3 -0
- letta/agent.py +1427 -0
- letta/agent_store/chroma.py +295 -0
- letta/agent_store/db.py +546 -0
- letta/agent_store/lancedb.py +177 -0
- letta/agent_store/milvus.py +198 -0
- letta/agent_store/qdrant.py +201 -0
- letta/agent_store/storage.py +188 -0
- letta/benchmark/benchmark.py +96 -0
- letta/benchmark/constants.py +14 -0
- letta/cli/cli.py +689 -0
- letta/cli/cli_config.py +1282 -0
- letta/cli/cli_load.py +166 -0
- letta/client/__init__.py +0 -0
- letta/client/admin.py +171 -0
- letta/client/client.py +2360 -0
- letta/client/streaming.py +90 -0
- letta/client/utils.py +61 -0
- letta/config.py +484 -0
- letta/configs/anthropic.json +13 -0
- letta/configs/letta_hosted.json +11 -0
- letta/configs/openai.json +12 -0
- letta/constants.py +134 -0
- letta/credentials.py +140 -0
- letta/data_sources/connectors.py +247 -0
- letta/embeddings.py +218 -0
- letta/errors.py +26 -0
- letta/functions/__init__.py +0 -0
- letta/functions/function_sets/base.py +174 -0
- letta/functions/function_sets/extras.py +132 -0
- letta/functions/functions.py +105 -0
- letta/functions/schema_generator.py +205 -0
- letta/humans/__init__.py +0 -0
- letta/humans/examples/basic.txt +1 -0
- letta/humans/examples/cs_phd.txt +9 -0
- letta/interface.py +314 -0
- letta/llm_api/__init__.py +0 -0
- letta/llm_api/anthropic.py +383 -0
- letta/llm_api/azure_openai.py +155 -0
- letta/llm_api/cohere.py +396 -0
- letta/llm_api/google_ai.py +468 -0
- letta/llm_api/llm_api_tools.py +485 -0
- letta/llm_api/openai.py +470 -0
- letta/local_llm/README.md +3 -0
- letta/local_llm/__init__.py +0 -0
- letta/local_llm/chat_completion_proxy.py +279 -0
- letta/local_llm/constants.py +31 -0
- letta/local_llm/function_parser.py +68 -0
- letta/local_llm/grammars/__init__.py +0 -0
- letta/local_llm/grammars/gbnf_grammar_generator.py +1324 -0
- letta/local_llm/grammars/json.gbnf +26 -0
- letta/local_llm/grammars/json_func_calls_with_inner_thoughts.gbnf +32 -0
- letta/local_llm/groq/api.py +97 -0
- letta/local_llm/json_parser.py +202 -0
- letta/local_llm/koboldcpp/api.py +62 -0
- letta/local_llm/koboldcpp/settings.py +23 -0
- letta/local_llm/llamacpp/api.py +58 -0
- letta/local_llm/llamacpp/settings.py +22 -0
- letta/local_llm/llm_chat_completion_wrappers/__init__.py +0 -0
- letta/local_llm/llm_chat_completion_wrappers/airoboros.py +452 -0
- letta/local_llm/llm_chat_completion_wrappers/chatml.py +470 -0
- letta/local_llm/llm_chat_completion_wrappers/configurable_wrapper.py +387 -0
- letta/local_llm/llm_chat_completion_wrappers/dolphin.py +246 -0
- letta/local_llm/llm_chat_completion_wrappers/llama3.py +345 -0
- letta/local_llm/llm_chat_completion_wrappers/simple_summary_wrapper.py +156 -0
- letta/local_llm/llm_chat_completion_wrappers/wrapper_base.py +11 -0
- letta/local_llm/llm_chat_completion_wrappers/zephyr.py +345 -0
- letta/local_llm/lmstudio/api.py +100 -0
- letta/local_llm/lmstudio/settings.py +29 -0
- letta/local_llm/ollama/api.py +88 -0
- letta/local_llm/ollama/settings.py +32 -0
- letta/local_llm/settings/__init__.py +0 -0
- letta/local_llm/settings/deterministic_mirostat.py +45 -0
- letta/local_llm/settings/settings.py +72 -0
- letta/local_llm/settings/simple.py +28 -0
- letta/local_llm/utils.py +265 -0
- letta/local_llm/vllm/api.py +63 -0
- letta/local_llm/webui/api.py +60 -0
- letta/local_llm/webui/legacy_api.py +58 -0
- letta/local_llm/webui/legacy_settings.py +23 -0
- letta/local_llm/webui/settings.py +24 -0
- letta/log.py +76 -0
- letta/main.py +437 -0
- letta/memory.py +440 -0
- letta/metadata.py +884 -0
- letta/openai_backcompat/__init__.py +0 -0
- letta/openai_backcompat/openai_object.py +437 -0
- letta/persistence_manager.py +148 -0
- letta/personas/__init__.py +0 -0
- letta/personas/examples/anna_pa.txt +13 -0
- letta/personas/examples/google_search_persona.txt +15 -0
- letta/personas/examples/memgpt_doc.txt +6 -0
- letta/personas/examples/memgpt_starter.txt +4 -0
- letta/personas/examples/sam.txt +14 -0
- letta/personas/examples/sam_pov.txt +14 -0
- letta/personas/examples/sam_simple_pov_gpt35.txt +13 -0
- letta/personas/examples/sqldb/test.db +0 -0
- letta/prompts/__init__.py +0 -0
- letta/prompts/gpt_summarize.py +14 -0
- letta/prompts/gpt_system.py +26 -0
- letta/prompts/system/memgpt_base.txt +49 -0
- letta/prompts/system/memgpt_chat.txt +58 -0
- letta/prompts/system/memgpt_chat_compressed.txt +13 -0
- letta/prompts/system/memgpt_chat_fstring.txt +51 -0
- letta/prompts/system/memgpt_doc.txt +50 -0
- letta/prompts/system/memgpt_gpt35_extralong.txt +53 -0
- letta/prompts/system/memgpt_intuitive_knowledge.txt +31 -0
- letta/prompts/system/memgpt_modified_chat.txt +23 -0
- letta/pytest.ini +0 -0
- letta/schemas/agent.py +117 -0
- letta/schemas/api_key.py +21 -0
- letta/schemas/block.py +135 -0
- letta/schemas/document.py +21 -0
- letta/schemas/embedding_config.py +54 -0
- letta/schemas/enums.py +35 -0
- letta/schemas/job.py +38 -0
- letta/schemas/letta_base.py +80 -0
- letta/schemas/letta_message.py +175 -0
- letta/schemas/letta_request.py +23 -0
- letta/schemas/letta_response.py +28 -0
- letta/schemas/llm_config.py +54 -0
- letta/schemas/memory.py +224 -0
- letta/schemas/message.py +727 -0
- letta/schemas/openai/chat_completion_request.py +123 -0
- letta/schemas/openai/chat_completion_response.py +136 -0
- letta/schemas/openai/chat_completions.py +123 -0
- letta/schemas/openai/embedding_response.py +11 -0
- letta/schemas/openai/openai.py +157 -0
- letta/schemas/organization.py +20 -0
- letta/schemas/passage.py +80 -0
- letta/schemas/source.py +62 -0
- letta/schemas/tool.py +143 -0
- letta/schemas/usage.py +18 -0
- letta/schemas/user.py +33 -0
- letta/server/__init__.py +0 -0
- letta/server/constants.py +6 -0
- letta/server/rest_api/__init__.py +0 -0
- letta/server/rest_api/admin/__init__.py +0 -0
- letta/server/rest_api/admin/agents.py +21 -0
- letta/server/rest_api/admin/tools.py +83 -0
- letta/server/rest_api/admin/users.py +98 -0
- letta/server/rest_api/app.py +193 -0
- letta/server/rest_api/auth/__init__.py +0 -0
- letta/server/rest_api/auth/index.py +43 -0
- letta/server/rest_api/auth_token.py +22 -0
- letta/server/rest_api/interface.py +726 -0
- letta/server/rest_api/routers/__init__.py +0 -0
- letta/server/rest_api/routers/openai/__init__.py +0 -0
- letta/server/rest_api/routers/openai/assistants/__init__.py +0 -0
- letta/server/rest_api/routers/openai/assistants/assistants.py +115 -0
- letta/server/rest_api/routers/openai/assistants/schemas.py +121 -0
- letta/server/rest_api/routers/openai/assistants/threads.py +336 -0
- letta/server/rest_api/routers/openai/chat_completions/__init__.py +0 -0
- letta/server/rest_api/routers/openai/chat_completions/chat_completions.py +131 -0
- letta/server/rest_api/routers/v1/__init__.py +15 -0
- letta/server/rest_api/routers/v1/agents.py +543 -0
- letta/server/rest_api/routers/v1/blocks.py +73 -0
- letta/server/rest_api/routers/v1/jobs.py +46 -0
- letta/server/rest_api/routers/v1/llms.py +28 -0
- letta/server/rest_api/routers/v1/organizations.py +61 -0
- letta/server/rest_api/routers/v1/sources.py +199 -0
- letta/server/rest_api/routers/v1/tools.py +103 -0
- letta/server/rest_api/routers/v1/users.py +109 -0
- letta/server/rest_api/static_files.py +74 -0
- letta/server/rest_api/utils.py +69 -0
- letta/server/server.py +1995 -0
- letta/server/startup.sh +8 -0
- letta/server/static_files/assets/index-0cbf7ad5.js +274 -0
- letta/server/static_files/assets/index-156816da.css +1 -0
- letta/server/static_files/assets/index-486e3228.js +274 -0
- letta/server/static_files/favicon.ico +0 -0
- letta/server/static_files/index.html +39 -0
- letta/server/static_files/memgpt_logo_transparent.png +0 -0
- letta/server/utils.py +46 -0
- letta/server/ws_api/__init__.py +0 -0
- letta/server/ws_api/example_client.py +104 -0
- letta/server/ws_api/interface.py +108 -0
- letta/server/ws_api/protocol.py +100 -0
- letta/server/ws_api/server.py +145 -0
- letta/settings.py +165 -0
- letta/streaming_interface.py +396 -0
- letta/system.py +207 -0
- letta/utils.py +1065 -0
- letta_nightly-0.1.7.dev20240924104148.dist-info/LICENSE +190 -0
- letta_nightly-0.1.7.dev20240924104148.dist-info/METADATA +98 -0
- letta_nightly-0.1.7.dev20240924104148.dist-info/RECORD +189 -0
- letta_nightly-0.1.7.dev20240924104148.dist-info/WHEEL +4 -0
- letta_nightly-0.1.7.dev20240924104148.dist-info/entry_points.txt +3 -0
letta/system.py
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
import json
|
|
2
|
+
import uuid
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
5
|
+
from .constants import (
|
|
6
|
+
INITIAL_BOOT_MESSAGE,
|
|
7
|
+
INITIAL_BOOT_MESSAGE_SEND_MESSAGE_FIRST_MSG,
|
|
8
|
+
INITIAL_BOOT_MESSAGE_SEND_MESSAGE_THOUGHT,
|
|
9
|
+
MESSAGE_SUMMARY_WARNING_STR,
|
|
10
|
+
)
|
|
11
|
+
from .utils import get_local_time, json_dumps
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def get_initial_boot_messages(version="startup"):
|
|
15
|
+
if version == "startup":
|
|
16
|
+
initial_boot_message = INITIAL_BOOT_MESSAGE
|
|
17
|
+
messages = [
|
|
18
|
+
{"role": "assistant", "content": initial_boot_message},
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
elif version == "startup_with_send_message":
|
|
22
|
+
tool_call_id = str(uuid.uuid4())
|
|
23
|
+
messages = [
|
|
24
|
+
# first message includes both inner monologue and function call to send_message
|
|
25
|
+
{
|
|
26
|
+
"role": "assistant",
|
|
27
|
+
"content": INITIAL_BOOT_MESSAGE_SEND_MESSAGE_THOUGHT,
|
|
28
|
+
# "function_call": {
|
|
29
|
+
# "name": "send_message",
|
|
30
|
+
# "arguments": '{\n "message": "' + f"{INITIAL_BOOT_MESSAGE_SEND_MESSAGE_FIRST_MSG}" + '"\n}',
|
|
31
|
+
# },
|
|
32
|
+
"tool_calls": [
|
|
33
|
+
{
|
|
34
|
+
"id": tool_call_id,
|
|
35
|
+
"type": "function",
|
|
36
|
+
"function": {
|
|
37
|
+
"name": "send_message",
|
|
38
|
+
"arguments": '{\n "message": "' + f"{INITIAL_BOOT_MESSAGE_SEND_MESSAGE_FIRST_MSG}" + '"\n}',
|
|
39
|
+
},
|
|
40
|
+
}
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
# obligatory function return message
|
|
44
|
+
{
|
|
45
|
+
# "role": "function",
|
|
46
|
+
"role": "tool",
|
|
47
|
+
"name": "send_message", # NOTE: technically not up to spec, this is old functions style
|
|
48
|
+
"content": package_function_response(True, None),
|
|
49
|
+
"tool_call_id": tool_call_id,
|
|
50
|
+
},
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
elif version == "startup_with_send_message_gpt35":
|
|
54
|
+
tool_call_id = str(uuid.uuid4())
|
|
55
|
+
messages = [
|
|
56
|
+
# first message includes both inner monologue and function call to send_message
|
|
57
|
+
{
|
|
58
|
+
"role": "assistant",
|
|
59
|
+
"content": "*inner thoughts* Still waiting on the user. Sending a message with function.",
|
|
60
|
+
# "function_call": {"name": "send_message", "arguments": '{\n "message": "' + f"Hi, is anyone there?" + '"\n}'},
|
|
61
|
+
"tool_calls": [
|
|
62
|
+
{
|
|
63
|
+
"id": tool_call_id,
|
|
64
|
+
"type": "function",
|
|
65
|
+
"function": {
|
|
66
|
+
"name": "send_message",
|
|
67
|
+
"arguments": '{\n "message": "' + f"Hi, is anyone there?" + '"\n}',
|
|
68
|
+
},
|
|
69
|
+
}
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
# obligatory function return message
|
|
73
|
+
{
|
|
74
|
+
# "role": "function",
|
|
75
|
+
"role": "tool",
|
|
76
|
+
"name": "send_message",
|
|
77
|
+
"content": package_function_response(True, None),
|
|
78
|
+
"tool_call_id": tool_call_id,
|
|
79
|
+
},
|
|
80
|
+
]
|
|
81
|
+
|
|
82
|
+
else:
|
|
83
|
+
raise ValueError(version)
|
|
84
|
+
|
|
85
|
+
return messages
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def get_heartbeat(reason="Automated timer", include_location=False, location_name="San Francisco, CA, USA"):
|
|
89
|
+
# Package the message with time and location
|
|
90
|
+
formatted_time = get_local_time()
|
|
91
|
+
packaged_message = {
|
|
92
|
+
"type": "heartbeat",
|
|
93
|
+
"reason": reason,
|
|
94
|
+
"time": formatted_time,
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if include_location:
|
|
98
|
+
packaged_message["location"] = location_name
|
|
99
|
+
|
|
100
|
+
return json_dumps(packaged_message)
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
def get_login_event(last_login="Never (first login)", include_location=False, location_name="San Francisco, CA, USA"):
|
|
104
|
+
# Package the message with time and location
|
|
105
|
+
formatted_time = get_local_time()
|
|
106
|
+
packaged_message = {
|
|
107
|
+
"type": "login",
|
|
108
|
+
"last_login": last_login,
|
|
109
|
+
"time": formatted_time,
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if include_location:
|
|
113
|
+
packaged_message["location"] = location_name
|
|
114
|
+
|
|
115
|
+
return json_dumps(packaged_message)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def package_user_message(
|
|
119
|
+
user_message: str,
|
|
120
|
+
time: Optional[str] = None,
|
|
121
|
+
include_location: bool = False,
|
|
122
|
+
location_name: Optional[str] = "San Francisco, CA, USA",
|
|
123
|
+
name: Optional[str] = None,
|
|
124
|
+
):
|
|
125
|
+
# Package the message with time and location
|
|
126
|
+
formatted_time = time if time else get_local_time()
|
|
127
|
+
packaged_message = {
|
|
128
|
+
"type": "user_message",
|
|
129
|
+
"message": user_message,
|
|
130
|
+
"time": formatted_time,
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if include_location:
|
|
134
|
+
packaged_message["location"] = location_name
|
|
135
|
+
|
|
136
|
+
if name:
|
|
137
|
+
packaged_message["name"] = name
|
|
138
|
+
|
|
139
|
+
return json_dumps(packaged_message)
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
def package_function_response(was_success, response_string, timestamp=None):
|
|
143
|
+
formatted_time = get_local_time() if timestamp is None else timestamp
|
|
144
|
+
packaged_message = {
|
|
145
|
+
"status": "OK" if was_success else "Failed",
|
|
146
|
+
"message": response_string,
|
|
147
|
+
"time": formatted_time,
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return json_dumps(packaged_message)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
def package_system_message(system_message, message_type="system_alert", time=None):
|
|
154
|
+
formatted_time = time if time else get_local_time()
|
|
155
|
+
packaged_message = {
|
|
156
|
+
"type": message_type,
|
|
157
|
+
"message": system_message,
|
|
158
|
+
"time": formatted_time,
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
return json.dumps(packaged_message)
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
def package_summarize_message(summary, summary_length, hidden_message_count, total_message_count, timestamp=None):
|
|
165
|
+
context_message = (
|
|
166
|
+
f"Note: prior messages ({hidden_message_count} of {total_message_count} total messages) have been hidden from view due to conversation memory constraints.\n"
|
|
167
|
+
+ f"The following is a summary of the previous {summary_length} messages:\n {summary}"
|
|
168
|
+
)
|
|
169
|
+
|
|
170
|
+
formatted_time = get_local_time() if timestamp is None else timestamp
|
|
171
|
+
packaged_message = {
|
|
172
|
+
"type": "system_alert",
|
|
173
|
+
"message": context_message,
|
|
174
|
+
"time": formatted_time,
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return json_dumps(packaged_message)
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def package_summarize_message_no_summary(hidden_message_count, timestamp=None, message=None):
|
|
181
|
+
"""Add useful metadata to the summary message"""
|
|
182
|
+
|
|
183
|
+
# Package the message with time and location
|
|
184
|
+
formatted_time = get_local_time() if timestamp is None else timestamp
|
|
185
|
+
context_message = (
|
|
186
|
+
message
|
|
187
|
+
if message
|
|
188
|
+
else f"Note: {hidden_message_count} prior messages with the user have been hidden from view due to conversation memory constraints. Older messages are stored in Recall Memory and can be viewed using functions."
|
|
189
|
+
)
|
|
190
|
+
packaged_message = {
|
|
191
|
+
"type": "system_alert",
|
|
192
|
+
"message": context_message,
|
|
193
|
+
"time": formatted_time,
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return json_dumps(packaged_message)
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
def get_token_limit_warning():
|
|
200
|
+
formatted_time = get_local_time()
|
|
201
|
+
packaged_message = {
|
|
202
|
+
"type": "system_alert",
|
|
203
|
+
"message": MESSAGE_SUMMARY_WARNING_STR,
|
|
204
|
+
"time": formatted_time,
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
return json_dumps(packaged_message)
|