diff --git a/letta/schemas/block.py b/letta/schemas/block.py index 8af2f47c5b..f8bfabadc5 100644 --- a/letta/schemas/block.py +++ b/letta/schemas/block.py @@ -39,11 +39,18 @@ def verify_char_limit(self) -> Self: raise e return self - @model_validator(mode="after") - def ensure_label(self) -> Self: - if not self.label: - self.label = self.name - return self + # @model_validator + # def ensure_label(self) -> Self: + # if not self.label: + # self.label = self.name + # return self + + @model_validator(mode="before") + def set_label_to_name_if_none(cls, values): + """Sets label to name if label is None""" + if values.get("label") is None and values.get("name") is not None: + values["label"] = values["name"] + return values def __len__(self): return len(self.value) diff --git a/letta/server/server.py b/letta/server/server.py index b37ec867d4..fc52ebe8b6 100644 --- a/letta/server/server.py +++ b/letta/server/server.py @@ -261,6 +261,9 @@ def __init__( # add global default tools (for admin) self.add_default_tools(module_name="base") + # create default user / blocks + self.get_default_user() + # collect providers (always has Letta as a default) self._enabled_providers: List[Provider] = [LettaProvider()] if model_settings.openai_api_key: diff --git a/poetry.lock b/poetry.lock index ae52f96686..1ed30630e3 100644 --- a/poetry.lock +++ b/poetry.lock @@ -7908,6 +7908,25 @@ MarkupSafe = ">=2.1.1" [package.extras] watchdog = ["watchdog (>=2.3)"] +[[package]] +name = "whyhow" +version = "0.1.7" +description = "Whyhow automated KG SDK" +optional = false +python-versions = ">=3.10" +files = [ + {file = "whyhow-0.1.7-py3-none-any.whl", hash = "sha256:e85c6b24a4c55a3b26aa38cb1513e354081c99be81483cfd59ae3981a5ceb492"}, + {file = "whyhow-0.1.7.tar.gz", hash = "sha256:2ae6c51a43980a54456372d0d7e2987fa3e8bb044f5f422c841a9bd1c7177fe4"}, +] + +[package.dependencies] +httpx = "*" +pydantic = ">1" + +[package.extras] +dev = ["bandit[toml]", "black", "datamodel-code-generator", "flake8", "flake8-docstrings", "fpdf", "isort", "mypy", "pydocstyle[toml]", "pytest", "pytest-asyncio", "pytest-cov", "pytest-httpx"] +docs = ["markdown-callouts", "markdown-exec", "mkdocs", "mkdocs-jupyter", "mkdocs-material", "mkdocstrings[python]", "pymdown-extensions"] + [[package]] name = "wikipedia" version = "1.4.0" @@ -8354,4 +8373,4 @@ tests = ["wikipedia"] [metadata] lock-version = "2.0" python-versions = "<3.13,>=3.10" -content-hash = "aa0bbf5825741bdc9c06388e7e27c1d9a2d85d517abb7f51cca71cc8349d1170" +content-hash = "8df5d19e36e08c24ed40e4c1b887198723ea61db9e5d5184384044f82b168e4f" diff --git a/pyproject.toml b/pyproject.toml index 38114897ad..fb545a20ec 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,6 +76,7 @@ langchain = {version = "^0.2.16", optional = true} langchain-community = {version = "^0.2.17", optional = true} composio-langchain = "^0.5.28" composio-core = "^0.5.28" +whyhow = "^0.1.7" [tool.poetry.extras] #local = ["llama-index-embeddings-huggingface"] diff --git a/tests/test_client.py b/tests/test_client.py index 58c7775ec6..bdb86a1339 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -385,7 +385,7 @@ def test_sources(client: Union[LocalClient, RESTClient], agent: AgentState): # list archival memory archival_memories = client.get_archival_memory(agent_id=agent.id) # print(archival_memories) - assert len(archival_memories) == created_passages + assert len(archival_memories) == created_passages, f"Mismatch length: {len(archival_memories)} vs. {created_passages}" # check number of passages sources = client.list_sources()