letta-nightly 0.10.0.dev20250801104513__py3-none-any.whl → 0.10.0.dev20250803104302__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.
@@ -1,7 +1,6 @@
1
1
  from typing import Literal
2
2
 
3
3
  import aiohttp
4
- import requests
5
4
  from pydantic import Field
6
5
 
7
6
  from letta.constants import DEFAULT_EMBEDDING_CHUNK_SIZE
@@ -43,7 +42,7 @@ class OllamaProvider(OpenAIProvider):
43
42
 
44
43
  configs = []
45
44
  for model in response_json["models"]:
46
- context_window = self.get_model_context_window(model["name"])
45
+ context_window = await self._get_model_context_window(model["name"])
47
46
  if context_window is None:
48
47
  print(f"Ollama model {model['name']} has no context window, using default 32000")
49
48
  context_window = 32000
@@ -75,7 +74,7 @@ class OllamaProvider(OpenAIProvider):
75
74
 
76
75
  configs = []
77
76
  for model in response_json["models"]:
78
- embedding_dim = await self._get_model_embedding_dim_async(model["name"])
77
+ embedding_dim = await self._get_model_embedding_dim(model["name"])
79
78
  if not embedding_dim:
80
79
  print(f"Ollama model {model['name']} has no embedding dimension, using default 1024")
81
80
  # continue
@@ -92,63 +91,50 @@ class OllamaProvider(OpenAIProvider):
92
91
  )
93
92
  return configs
94
93
 
95
- def get_model_context_window(self, model_name: str) -> int | None:
96
- """Gets model context window for Ollama. As this can look different based on models,
97
- we use the following for guidance:
98
-
99
- "llama.context_length": 8192,
100
- "llama.embedding_length": 4096,
101
- source: https://github.com/ollama/ollama/blob/main/docs/api.md#show-model-information
102
-
103
- FROM 2024-10-08
104
- Notes from vLLM around keys
105
- source: https://github.com/vllm-project/vllm/blob/72ad2735823e23b4e1cc79b7c73c3a5f3c093ab0/vllm/config.py#L3488
106
-
107
- possible_keys = [
108
- # OPT
109
- "max_position_embeddings",
110
- # GPT-2
111
- "n_positions",
112
- # MPT
113
- "max_seq_len",
114
- # ChatGLM2
115
- "seq_length",
116
- # Command-R
117
- "model_max_length",
118
- # Whisper
119
- "max_target_positions",
120
- # Others
121
- "max_sequence_length",
122
- "max_seq_length",
123
- "seq_len",
124
- ]
125
- max_position_embeddings
126
- parse model cards: nous, dolphon, llama
127
- """
94
+ async def _get_model_context_window(self, model_name: str) -> int | None:
128
95
  endpoint = f"{self.base_url}/api/show"
129
- payload = {"name": model_name, "verbose": True}
130
- response = requests.post(endpoint, json=payload)
131
- if response.status_code != 200:
132
- return None
96
+ payload = {"name": model_name}
133
97
 
134
98
  try:
135
- model_info = response.json()
136
- # Try to extract context window from model parameters
137
- if "model_info" in model_info and "llama.context_length" in model_info["model_info"]:
138
- return int(model_info["model_info"]["llama.context_length"])
139
- except Exception:
140
- pass
141
- logger.warning(f"Failed to get model context window for {model_name}")
99
+ async with aiohttp.ClientSession() as session:
100
+ async with session.post(endpoint, json=payload) as response:
101
+ if response.status != 200:
102
+ error_text = await response.text()
103
+ logger.warning(f"Failed to get model info for {model_name}: {response.status} - {error_text}")
104
+ return None
105
+
106
+ response_json = await response.json()
107
+ model_info = response_json.get("model_info", {})
108
+
109
+ if architecture := model_info.get("general.architecture"):
110
+ if context_length := model_info.get(f"{architecture}.context_length"):
111
+ return int(context_length)
112
+
113
+ except Exception as e:
114
+ logger.warning(f"Failed to get model context window for {model_name} with error: {e}")
115
+
142
116
  return None
143
117
 
144
- async def _get_model_embedding_dim_async(self, model_name: str):
145
- async with aiohttp.ClientSession() as session:
146
- async with session.post(f"{self.base_url}/api/show", json={"name": model_name, "verbose": True}) as response:
147
- response_json = await response.json()
118
+ async def _get_model_embedding_dim(self, model_name: str) -> int | None:
119
+ endpoint = f"{self.base_url}/api/show"
120
+ payload = {"name": model_name}
121
+
122
+ try:
123
+ async with aiohttp.ClientSession() as session:
124
+ async with session.post(endpoint, json=payload) as response:
125
+ if response.status != 200:
126
+ error_text = await response.text()
127
+ logger.warning(f"Failed to get model info for {model_name}: {response.status} - {error_text}")
128
+ return None
148
129
 
149
- if "model_info" not in response_json:
150
- if "error" in response_json:
151
- logger.warning("Ollama fetch model info error for %s: %s", model_name, response_json["error"])
152
- return None
130
+ response_json = await response.json()
131
+ model_info = response_json.get("model_info", {})
153
132
 
154
- return response_json["model_info"].get("embedding_length")
133
+ if architecture := model_info.get("general.architecture"):
134
+ if embedding_length := model_info.get(f"{architecture}.embedding_length"):
135
+ return int(embedding_length)
136
+
137
+ except Exception as e:
138
+ logger.warning(f"Failed to get model embedding dimension for {model_name} with error: {e}")
139
+
140
+ return None
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: letta-nightly
3
- Version: 0.10.0.dev20250801104513
3
+ Version: 0.10.0.dev20250803104302
4
4
  Summary: Create LLM agents with long-term memory and custom tools
5
5
  License: Apache License
6
6
  Author: Letta Team
@@ -287,7 +287,7 @@ letta/schemas/providers/groq.py,sha256=AquJQH-Y5-s75Nj2_X7xavuWUu5F2bSvHjAZ1Gfpe
287
287
  letta/schemas/providers/letta.py,sha256=DD42qaJoR7YvaWIB0Y1oMFGQgcI3BDe0X6--5DB1px4,1585
288
288
  letta/schemas/providers/lmstudio.py,sha256=fx1lfLG4K1x6RUeHEXr9pMnQ1IgMpK1XmW_Y23riwgw,4303
289
289
  letta/schemas/providers/mistral.py,sha256=EjFF6YcfN5jBjCfnZw3ECv_3qYuG0HVb7B0VoYk-jKU,1866
290
- letta/schemas/providers/ollama.py,sha256=IMnlVUrwvJeuIMAgD6buJq5Ccows2R4KZzFJ9QF8VNU,6452
290
+ letta/schemas/providers/ollama.py,sha256=iVx9xxrulG9ohbhk4kMtfryCnMgmynWg_NL4SesGX5U,6253
291
291
  letta/schemas/providers/openai.py,sha256=Et2NoOPWQ4xIn_WMP2ingZM_heLFM7SCtY6kHxCi9Tw,11042
292
292
  letta/schemas/providers/together.py,sha256=2zFca6Jy08r1ANrdvtlSIduyDr8ek9Tt1yYiz1S-5g8,3422
293
293
  letta/schemas/providers/vllm.py,sha256=OK98JyUXsI5Ygr1xSG9WDH6JqQXDifVSccdGwRW_gUQ,2482
@@ -451,8 +451,8 @@ letta/templates/summary_request_text.j2,sha256=ZttQwXonW2lk4pJLYzLK0pmo4EO4EtUUI
451
451
  letta/templates/template_helper.py,sha256=CzkLA-n_BCyvguP4c0V-O_YjQY1vl059MAQwbjt198s,1364
452
452
  letta/types/__init__.py,sha256=hokKjCVFGEfR7SLMrtZsRsBfsC7yTIbgKPLdGg4K1eY,147
453
453
  letta/utils.py,sha256=Fwwe2imHRamc_kucAATo8NXhwDG5NBoOIYmBaERXUhM,38384
454
- letta_nightly-0.10.0.dev20250801104513.dist-info/LICENSE,sha256=mExtuZ_GYJgDEI38GWdiEYZizZS4KkVt2SF1g_GPNhI,10759
455
- letta_nightly-0.10.0.dev20250801104513.dist-info/METADATA,sha256=M1XrCufQlCD86lBxCDTFfzhSgSwzjjVv2bWm0dfOv8s,23310
456
- letta_nightly-0.10.0.dev20250801104513.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
457
- letta_nightly-0.10.0.dev20250801104513.dist-info/entry_points.txt,sha256=2zdiyGNEZGV5oYBuS-y2nAAgjDgcC9yM_mHJBFSRt5U,40
458
- letta_nightly-0.10.0.dev20250801104513.dist-info/RECORD,,
454
+ letta_nightly-0.10.0.dev20250803104302.dist-info/LICENSE,sha256=mExtuZ_GYJgDEI38GWdiEYZizZS4KkVt2SF1g_GPNhI,10759
455
+ letta_nightly-0.10.0.dev20250803104302.dist-info/METADATA,sha256=TAeoC6ldtB2IKgkZit5y6R6Cw-ysxstQ36nGz7QUI2U,23310
456
+ letta_nightly-0.10.0.dev20250803104302.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
457
+ letta_nightly-0.10.0.dev20250803104302.dist-info/entry_points.txt,sha256=2zdiyGNEZGV5oYBuS-y2nAAgjDgcC9yM_mHJBFSRt5U,40
458
+ letta_nightly-0.10.0.dev20250803104302.dist-info/RECORD,,