Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

chore: default to uvloop

Andy Li6debdeafba07
diff --git a/letta/server/rest_api/app.py b/letta/server/rest_api/app.py
index 759a0c46a..3c1cbdfb1 100644
--- a/letta/server/rest_api/app.py
+++ b/letta/server/rest_api/app.py
@@ -383,8 +383,8 @@ def start_server(
# Experimental UV Loop Support
try:
- if importlib.util.find_spec("uvloop") is not None and settings.use_uvloop:
- print("Running server on uvloop...")
+ if settings.use_uvloop:
+ print("Running server asyncio loop on uvloop...")
import asyncio
import uvloop
diff --git a/letta/settings.py b/letta/settings.py
index 74dce7592..b38071ca2 100644
--- a/letta/settings.py
+++ b/letta/settings.py
@@ -230,13 +230,13 @@ class Settings(BaseSettings):
track_errored_messages: bool = Field(default=True, description="Enable tracking for errored messages")
track_stop_reason: bool = Field(default=True, description="Enable tracking stop reason on steps.")
- # uvicorn settings
+ # FastAPI Application Settings
uvicorn_workers: int = 1
uvicorn_reload: bool = False
uvicorn_timeout_keep_alive: int = 5
- use_uvloop: bool = False
- use_granian: bool = False
+ use_uvloop: bool = Field(default=True, description="Enable uvloop as asyncio event loop.")
+ use_granian: bool = Field(default=False, description="Use Granian for workers")
sqlalchemy_tracing: bool = False
# event loop parallelism
@@ -278,7 +278,7 @@ class Settings(BaseSettings):
elif self.pg_db and self.pg_user and self.pg_password and self.pg_host and self.pg_port:
return f"postgresql+pg8000://{self.pg_user}:{self.pg_password}@{self.pg_host}:{self.pg_port}/{self.pg_db}"
else:
- return f"postgresql+pg8000://letta:letta@localhost:5432/letta"
+ return "postgresql+pg8000://letta:letta@localhost:5432/letta"
# add this property to avoid being returned the default
# reference: https://github.com/letta-ai/letta/issues/1362
diff --git a/poetry.lock b/poetry.lock
index e1a49e788..a6396dd1b 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -1,4 +1,4 @@
-# This file is automatically @generated by Poetry 2.1.2 and should not be changed by hand.
+# This file is automatically @generated by Poetry 2.1.3 and should not be changed by hand.
[[package]]
name = "aioboto3"
@@ -7394,10 +7394,9 @@ standard = ["colorama (>=0.4) ; sys_platform == \"win32\"", "httptools (>=0.5.0)
name = "uvloop"
version = "0.21.0"
description = "Fast implementation of asyncio event loop on top of libuv"
-optional = true
+optional = false
python-versions = ">=3.8.0"
groups = ["main"]
-markers = "extra == \"experimental\" or extra == \"all\""
files = [
{file = "uvloop-0.21.0-cp310-cp310-macosx_10_9_universal2.whl", hash = "sha256:ec7e6b09a6fdded42403182ab6b832b71f4edaf7f37a9a0e371a01db5f0cb45f"},
{file = "uvloop-0.21.0-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:196274f2adb9689a289ad7d65700d37df0c0930fd8e4e743fa4834e850d7719d"},
@@ -8112,12 +8111,12 @@ cffi = {version = ">=1.11", markers = "platform_python_implementation == \"PyPy\
cffi = ["cffi (>=1.11)"]
[extras]
-all = ["autoflake", "black", "docker", "fastapi", "granian", "isort", "langchain", "langchain-community", "locust", "pexpect", "pg8000", "pgvector", "pinecone", "pre-commit", "psycopg2", "psycopg2-binary", "pyright", "pytest-asyncio", "pytest-order", "redis", "uvicorn", "uvloop", "wikipedia"]
+all = ["autoflake", "black", "docker", "fastapi", "granian", "isort", "langchain", "langchain-community", "locust", "pexpect", "pg8000", "pgvector", "pinecone", "pre-commit", "psycopg2", "psycopg2-binary", "pyright", "pytest-asyncio", "pytest-order", "redis", "uvicorn", "wikipedia"]
bedrock = ["aioboto3", "boto3"]
cloud-tool-sandbox = ["e2b-code-interpreter"]
desktop = ["docker", "fastapi", "langchain", "langchain-community", "locust", "pg8000", "pgvector", "psycopg2", "psycopg2-binary", "pyright", "uvicorn", "wikipedia"]
dev = ["autoflake", "black", "isort", "locust", "pexpect", "pre-commit", "pyright", "pytest-asyncio", "pytest-order"]
-experimental = ["granian", "uvloop"]
+experimental = ["granian"]
external-tools = ["docker", "firecrawl-py", "langchain", "langchain-community", "wikipedia"]
google = ["google-genai"]
pinecone = ["pinecone"]
@@ -8129,4 +8128,4 @@ tests = ["wikipedia"]
[metadata]
lock-version = "2.1"
python-versions = "<3.14,>=3.10"
-content-hash = "03cb9e2fb78259e20c53617103da09ff9366315a72181d8306b10d73eb08a42d"
+content-hash = "ffe94b86dbab82c316b33fd384c5e45fed489ebb058d65e969f553eebd4402ed"
diff --git a/pyproject.toml b/pyproject.toml
index 02b367e25..18f6b2649 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -93,7 +93,7 @@ matplotlib = "^3.10.1"
asyncpg = {version = "^0.30.0", optional = true}
tavily-python = "^0.7.2"
mistralai = "^1.8.1"
-uvloop = {version = "^0.21.0", optional = true}
+uvloop = {version = "^0.21.0"}
granian = {version = "^2.3.2", extras = ["uvloop", "reload"], optional = true}
redis = {version = "^6.2.0", optional = true}
structlog = "^25.4.0"
@@ -107,7 +107,7 @@ postgres = ["pgvector", "pg8000", "psycopg2-binary", "psycopg2", "asyncpg"]
redis = ["redis"]
pinecone = ["pinecone"]
dev = ["pytest", "pytest-asyncio", "pexpect", "black", "pre-commit", "pyright", "pytest-order", "autoflake", "isort", "locust"]
-experimental = ["uvloop", "granian"]
+experimental = ["granian"]
server = ["websockets", "fastapi", "uvicorn"]
cloud-tool-sandbox = ["e2b-code-interpreter"]
external-tools = ["docker", "langchain", "wikipedia", "langchain-community", "firecrawl-py"]
@@ -115,7 +115,7 @@ tests = ["wikipedia"]
bedrock = ["boto3", "aioboto3"]
google = ["google-genai"]
desktop = ["pgvector", "pg8000", "psycopg2-binary", "psycopg2", "pyright", "websockets", "fastapi", "uvicorn", "docker", "langchain", "wikipedia", "langchain-community", "locust"]
-all = ["pgvector", "pg8000", "psycopg2-binary", "psycopg2", "pytest", "pytest-asyncio", "pexpect", "black", "pre-commit", "pyright", "pytest-order", "autoflake", "isort", "websockets", "fastapi", "uvicorn", "docker", "langchain", "wikipedia", "langchain-community", "locust", "uvloop", "granian", "redis", "pinecone"]
+all = ["pgvector", "pg8000", "psycopg2-binary", "psycopg2", "pytest", "pytest-asyncio", "pexpect", "black", "pre-commit", "pyright", "pytest-order", "autoflake", "isort", "websockets", "fastapi", "uvicorn", "docker", "langchain", "wikipedia", "langchain-community", "locust", "granian", "redis", "pinecone"]
[tool.poetry.group.dev.dependencies]
black = "^24.4.2"