lm-deluge 0.0.24__tar.gz → 0.0.26__tar.gz
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 lm-deluge might be problematic. Click here for more details.
- {lm_deluge-0.0.24/src/lm_deluge.egg-info → lm_deluge-0.0.26}/PKG-INFO +1 -1
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/pyproject.toml +1 -1
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/batches.py +131 -42
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/file.py +3 -2
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/request_context.py +11 -6
- {lm_deluge-0.0.24 → lm_deluge-0.0.26/src/lm_deluge.egg-info}/PKG-INFO +1 -1
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/LICENSE +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/README.md +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/setup.cfg +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/__init__.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/agent.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/api_requests/__init__.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/api_requests/anthropic.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/api_requests/base.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/api_requests/bedrock.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/api_requests/common.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/api_requests/deprecated/bedrock.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/api_requests/deprecated/cohere.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/api_requests/deprecated/deepseek.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/api_requests/deprecated/mistral.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/api_requests/deprecated/vertex.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/api_requests/gemini.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/api_requests/mistral.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/api_requests/openai.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/api_requests/response.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/built_in_tools/anthropic/__init__.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/built_in_tools/anthropic/bash.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/built_in_tools/anthropic/computer_use.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/built_in_tools/anthropic/editor.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/built_in_tools/base.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/built_in_tools/openai.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/cache.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/client.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/config.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/embed.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/errors.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/gemini_limits.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/image.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/llm_tools/__init__.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/llm_tools/classify.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/llm_tools/extract.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/llm_tools/locate.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/llm_tools/ocr.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/llm_tools/score.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/llm_tools/translate.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/models.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/prompt.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/rerank.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/tool.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/tracker.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/usage.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/util/json.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/util/logprobs.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/util/spatial.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/util/validation.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/util/xml.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge.egg-info/SOURCES.txt +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge.egg-info/dependency_links.txt +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge.egg-info/requires.txt +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge.egg-info/top_level.txt +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/tests/test_builtin_tools.py +0 -0
- {lm_deluge-0.0.24 → lm_deluge-0.0.26}/tests/test_native_mcp_server.py +0 -0
|
@@ -169,7 +169,8 @@ async def submit_batches_oa(
|
|
|
169
169
|
batch_size: int = 50_000,
|
|
170
170
|
):
|
|
171
171
|
"""Write OpenAI batch requests to a file and submit."""
|
|
172
|
-
|
|
172
|
+
MAX_BATCH_SIZE_BYTES = 200 * 1024 * 1024 # 200MB
|
|
173
|
+
MAX_BATCH_SIZE_ITEMS = batch_size
|
|
173
174
|
|
|
174
175
|
prompts = prompts_to_conversations(prompts)
|
|
175
176
|
if any(p is None for p in prompts):
|
|
@@ -178,29 +179,71 @@ async def submit_batches_oa(
|
|
|
178
179
|
model_obj = APIModel.from_registry(model)
|
|
179
180
|
|
|
180
181
|
tasks = []
|
|
182
|
+
current_batch = []
|
|
183
|
+
current_batch_size = 0
|
|
184
|
+
# current_batch_start_idx = 0
|
|
185
|
+
|
|
186
|
+
for idx, prompt in enumerate(prompts):
|
|
187
|
+
assert isinstance(prompt, Conversation)
|
|
188
|
+
context = RequestContext(
|
|
189
|
+
task_id=idx,
|
|
190
|
+
model_name=model,
|
|
191
|
+
prompt=prompt,
|
|
192
|
+
sampling_params=sampling_params,
|
|
193
|
+
)
|
|
194
|
+
request = {
|
|
195
|
+
"custom_id": str(idx),
|
|
196
|
+
"method": "POST",
|
|
197
|
+
"url": "/v1/chat/completions",
|
|
198
|
+
"body": await _build_oa_chat_request(model_obj, context),
|
|
199
|
+
}
|
|
181
200
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
"
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
file_path =
|
|
203
|
-
|
|
201
|
+
# Calculate size of this request
|
|
202
|
+
request_json = json.dumps(request) + "\n"
|
|
203
|
+
request_size = len(request_json.encode("utf-8"))
|
|
204
|
+
|
|
205
|
+
# Check if adding this request would exceed limits
|
|
206
|
+
would_exceed_size = current_batch_size + request_size > MAX_BATCH_SIZE_BYTES
|
|
207
|
+
would_exceed_items = len(current_batch) >= MAX_BATCH_SIZE_ITEMS
|
|
208
|
+
|
|
209
|
+
if current_batch and (would_exceed_size or would_exceed_items):
|
|
210
|
+
# Submit current batch
|
|
211
|
+
def write_batch_file():
|
|
212
|
+
with tempfile.NamedTemporaryFile(
|
|
213
|
+
mode="w+", suffix=".jsonl", delete=False
|
|
214
|
+
) as f:
|
|
215
|
+
for batch_request in current_batch:
|
|
216
|
+
json.dump(batch_request, f)
|
|
217
|
+
f.write("\n")
|
|
218
|
+
print("wrote", len(current_batch), "items")
|
|
219
|
+
return f.name
|
|
220
|
+
|
|
221
|
+
file_path = await asyncio.to_thread(write_batch_file)
|
|
222
|
+
tasks.append(asyncio.create_task(submit_batch_oa(file_path)))
|
|
223
|
+
|
|
224
|
+
# Start new batch
|
|
225
|
+
current_batch = []
|
|
226
|
+
current_batch_size = 0
|
|
227
|
+
# current_batch_start_idx = idx
|
|
228
|
+
|
|
229
|
+
# Add request to current batch
|
|
230
|
+
current_batch.append(request)
|
|
231
|
+
current_batch_size += request_size
|
|
232
|
+
|
|
233
|
+
# Submit final batch if it has items
|
|
234
|
+
if current_batch:
|
|
235
|
+
|
|
236
|
+
def write_final_batch_file():
|
|
237
|
+
with tempfile.NamedTemporaryFile(
|
|
238
|
+
mode="w+", suffix=".jsonl", delete=False
|
|
239
|
+
) as f:
|
|
240
|
+
for batch_request in current_batch:
|
|
241
|
+
json.dump(batch_request, f)
|
|
242
|
+
f.write("\n")
|
|
243
|
+
print("wrote", len(current_batch), "items")
|
|
244
|
+
return f.name
|
|
245
|
+
|
|
246
|
+
file_path = await asyncio.to_thread(write_final_batch_file)
|
|
204
247
|
tasks.append(asyncio.create_task(submit_batch_oa(file_path)))
|
|
205
248
|
|
|
206
249
|
batch_ids = await asyncio.gather(*tasks)
|
|
@@ -229,34 +272,80 @@ async def submit_batches_anthropic(
|
|
|
229
272
|
|
|
230
273
|
Returns: batch_ids (list[str])
|
|
231
274
|
"""
|
|
275
|
+
MAX_BATCH_SIZE_BYTES = 200 * 1024 * 1024 # 200MB
|
|
276
|
+
MAX_BATCH_SIZE_ITEMS = batch_size
|
|
232
277
|
|
|
233
278
|
# Convert prompts to Conversations
|
|
234
279
|
prompts = prompts_to_conversations(prompts)
|
|
235
280
|
|
|
236
281
|
request_headers = None
|
|
237
|
-
BATCH_SIZE = batch_size
|
|
238
282
|
batch_tasks = []
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
283
|
+
current_batch = []
|
|
284
|
+
current_batch_size = 0
|
|
285
|
+
|
|
286
|
+
for idx, prompt in enumerate(prompts):
|
|
287
|
+
assert isinstance(prompt, Conversation)
|
|
288
|
+
context = RequestContext(
|
|
289
|
+
task_id=idx,
|
|
290
|
+
model_name=model,
|
|
291
|
+
prompt=prompt,
|
|
292
|
+
sampling_params=sampling_params,
|
|
293
|
+
cache=cache,
|
|
294
|
+
)
|
|
295
|
+
request_body, request_headers = _build_anthropic_request(
|
|
296
|
+
APIModel.from_registry(model), context
|
|
297
|
+
)
|
|
298
|
+
request = {"custom_id": str(idx), "params": request_body}
|
|
299
|
+
|
|
300
|
+
# Calculate size of this request
|
|
301
|
+
request_json = json.dumps(request) + "\n"
|
|
302
|
+
request_size = len(request_json.encode("utf-8"))
|
|
303
|
+
|
|
304
|
+
# Check if adding this request would exceed limits
|
|
305
|
+
would_exceed_size = current_batch_size + request_size > MAX_BATCH_SIZE_BYTES
|
|
306
|
+
would_exceed_items = len(current_batch) >= MAX_BATCH_SIZE_ITEMS
|
|
307
|
+
|
|
308
|
+
if current_batch and (would_exceed_size or would_exceed_items):
|
|
309
|
+
# Submit current batch
|
|
310
|
+
def write_batch_file():
|
|
311
|
+
with tempfile.NamedTemporaryFile(
|
|
312
|
+
mode="w+", suffix=".jsonl", delete=False
|
|
313
|
+
) as f:
|
|
314
|
+
for batch_request in current_batch:
|
|
315
|
+
json.dump(batch_request, f)
|
|
316
|
+
f.write("\n")
|
|
317
|
+
print("wrote", len(current_batch), "items")
|
|
318
|
+
return f.name
|
|
319
|
+
|
|
320
|
+
file_path = await asyncio.to_thread(write_batch_file)
|
|
321
|
+
batch_tasks.append(
|
|
322
|
+
asyncio.create_task(
|
|
323
|
+
_submit_anthropic_batch(file_path, request_headers, model) # type: ignore
|
|
254
324
|
)
|
|
255
|
-
|
|
256
|
-
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
# Start new batch
|
|
328
|
+
current_batch = []
|
|
329
|
+
current_batch_size = 0
|
|
330
|
+
|
|
331
|
+
# Add request to current batch
|
|
332
|
+
current_batch.append(request)
|
|
333
|
+
current_batch_size += request_size
|
|
334
|
+
|
|
335
|
+
# Submit final batch if it has items
|
|
336
|
+
if current_batch:
|
|
257
337
|
|
|
258
|
-
|
|
338
|
+
def write_final_batch_file():
|
|
339
|
+
with tempfile.NamedTemporaryFile(
|
|
340
|
+
mode="w+", suffix=".jsonl", delete=False
|
|
341
|
+
) as f:
|
|
342
|
+
for batch_request in current_batch:
|
|
343
|
+
json.dump(batch_request, f)
|
|
344
|
+
f.write("\n")
|
|
345
|
+
print("wrote", len(current_batch), "items")
|
|
346
|
+
return f.name
|
|
259
347
|
|
|
348
|
+
file_path = await asyncio.to_thread(write_final_batch_file)
|
|
260
349
|
batch_tasks.append(
|
|
261
350
|
asyncio.create_task(
|
|
262
351
|
_submit_anthropic_batch(file_path, request_headers, model) # type: ignore
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
from functools import cached_property
|
|
1
2
|
import os
|
|
2
3
|
import io
|
|
3
4
|
import requests
|
|
@@ -68,13 +69,13 @@ class File:
|
|
|
68
69
|
return encoded
|
|
69
70
|
return f"data:{self._mime()};base64,{encoded}"
|
|
70
71
|
|
|
71
|
-
@
|
|
72
|
+
@cached_property
|
|
72
73
|
def fingerprint(self) -> str:
|
|
73
74
|
# Hash the file contents for fingerprinting
|
|
74
75
|
file_bytes = self._bytes()
|
|
75
76
|
return xxhash.xxh64(file_bytes).hexdigest()
|
|
76
77
|
|
|
77
|
-
@
|
|
78
|
+
@cached_property
|
|
78
79
|
def size(self) -> int:
|
|
79
80
|
"""Return file size in bytes."""
|
|
80
81
|
return len(self._bytes())
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
from dataclasses import dataclass, field
|
|
2
|
+
from functools import cached_property
|
|
2
3
|
from typing import Any, Callable
|
|
3
4
|
|
|
4
5
|
from .config import SamplingParams
|
|
@@ -39,14 +40,18 @@ class RequestContext:
|
|
|
39
40
|
|
|
40
41
|
# Computed properties
|
|
41
42
|
cache_key: str = field(init=False)
|
|
42
|
-
num_tokens: int = field(init=False)
|
|
43
|
+
# num_tokens: int = field(init=False)
|
|
43
44
|
|
|
44
|
-
def __post_init__(self):
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
# def __post_init__(self):
|
|
46
|
+
# # Compute cache key from prompt fingerprint
|
|
47
|
+
# # self.cache_key = self.prompt.fingerprint
|
|
47
48
|
|
|
48
|
-
|
|
49
|
-
|
|
49
|
+
# # Compute token count
|
|
50
|
+
# self.num_tokens =
|
|
51
|
+
|
|
52
|
+
@cached_property
|
|
53
|
+
def num_tokens(self):
|
|
54
|
+
return self.prompt.count_tokens(self.sampling_params.max_new_tokens)
|
|
50
55
|
|
|
51
56
|
def maybe_callback(self, response, tracker):
|
|
52
57
|
if not self.callback:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{lm_deluge-0.0.24 → lm_deluge-0.0.26}/src/lm_deluge/built_in_tools/anthropic/computer_use.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|