lm-deluge 0.0.67__py3-none-any.whl → 0.0.90__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 lm-deluge might be problematic. Click here for more details.
- lm_deluge/__init__.py +1 -2
- lm_deluge/api_requests/anthropic.py +117 -22
- lm_deluge/api_requests/base.py +84 -11
- lm_deluge/api_requests/bedrock.py +30 -6
- lm_deluge/api_requests/chat_reasoning.py +4 -0
- lm_deluge/api_requests/gemini.py +166 -20
- lm_deluge/api_requests/openai.py +145 -25
- lm_deluge/batches.py +15 -45
- lm_deluge/client.py +309 -50
- lm_deluge/config.py +15 -3
- lm_deluge/models/__init__.py +14 -1
- lm_deluge/models/anthropic.py +29 -14
- lm_deluge/models/arcee.py +16 -0
- lm_deluge/models/deepseek.py +36 -4
- lm_deluge/models/google.py +42 -0
- lm_deluge/models/grok.py +24 -0
- lm_deluge/models/kimi.py +36 -0
- lm_deluge/models/minimax.py +18 -0
- lm_deluge/models/openai.py +100 -0
- lm_deluge/models/openrouter.py +133 -7
- lm_deluge/models/together.py +11 -0
- lm_deluge/models/zai.py +50 -0
- lm_deluge/pipelines/gepa/__init__.py +95 -0
- lm_deluge/pipelines/gepa/core.py +354 -0
- lm_deluge/pipelines/gepa/docs/samples.py +705 -0
- lm_deluge/pipelines/gepa/examples/01_synthetic_keywords.py +140 -0
- lm_deluge/pipelines/gepa/examples/02_gsm8k_math.py +261 -0
- lm_deluge/pipelines/gepa/examples/03_hotpotqa_multihop.py +300 -0
- lm_deluge/pipelines/gepa/examples/04_batch_classification.py +271 -0
- lm_deluge/pipelines/gepa/examples/simple_qa.py +129 -0
- lm_deluge/pipelines/gepa/optimizer.py +435 -0
- lm_deluge/pipelines/gepa/proposer.py +235 -0
- lm_deluge/pipelines/gepa/util.py +165 -0
- lm_deluge/{llm_tools → pipelines}/score.py +2 -2
- lm_deluge/{llm_tools → pipelines}/translate.py +5 -3
- lm_deluge/prompt.py +537 -88
- lm_deluge/request_context.py +7 -2
- lm_deluge/server/__init__.py +24 -0
- lm_deluge/server/__main__.py +144 -0
- lm_deluge/server/adapters.py +369 -0
- lm_deluge/server/app.py +388 -0
- lm_deluge/server/auth.py +71 -0
- lm_deluge/server/model_policy.py +215 -0
- lm_deluge/server/models_anthropic.py +172 -0
- lm_deluge/server/models_openai.py +175 -0
- lm_deluge/tool/__init__.py +1130 -0
- lm_deluge/tool/builtin/anthropic/__init__.py +300 -0
- lm_deluge/tool/builtin/anthropic/bash.py +0 -0
- lm_deluge/tool/builtin/anthropic/computer_use.py +0 -0
- lm_deluge/tool/builtin/gemini.py +59 -0
- lm_deluge/tool/builtin/openai.py +74 -0
- lm_deluge/tool/cua/__init__.py +173 -0
- lm_deluge/tool/cua/actions.py +148 -0
- lm_deluge/tool/cua/base.py +27 -0
- lm_deluge/tool/cua/batch.py +215 -0
- lm_deluge/tool/cua/converters.py +466 -0
- lm_deluge/tool/cua/kernel.py +702 -0
- lm_deluge/tool/cua/trycua.py +989 -0
- lm_deluge/tool/prefab/__init__.py +45 -0
- lm_deluge/tool/prefab/batch_tool.py +156 -0
- lm_deluge/tool/prefab/docs.py +1119 -0
- lm_deluge/tool/prefab/email.py +294 -0
- lm_deluge/tool/prefab/filesystem.py +1711 -0
- lm_deluge/tool/prefab/full_text_search/__init__.py +285 -0
- lm_deluge/tool/prefab/full_text_search/tantivy_index.py +396 -0
- lm_deluge/tool/prefab/memory.py +458 -0
- lm_deluge/tool/prefab/otc/__init__.py +165 -0
- lm_deluge/tool/prefab/otc/executor.py +281 -0
- lm_deluge/tool/prefab/otc/parse.py +188 -0
- lm_deluge/tool/prefab/random.py +212 -0
- lm_deluge/tool/prefab/rlm/__init__.py +296 -0
- lm_deluge/tool/prefab/rlm/executor.py +349 -0
- lm_deluge/tool/prefab/rlm/parse.py +144 -0
- lm_deluge/tool/prefab/sandbox/__init__.py +19 -0
- lm_deluge/tool/prefab/sandbox/daytona_sandbox.py +483 -0
- lm_deluge/tool/prefab/sandbox/docker_sandbox.py +609 -0
- lm_deluge/tool/prefab/sandbox/fargate_sandbox.py +546 -0
- lm_deluge/tool/prefab/sandbox/modal_sandbox.py +469 -0
- lm_deluge/tool/prefab/sandbox/seatbelt_sandbox.py +827 -0
- lm_deluge/tool/prefab/sheets.py +385 -0
- lm_deluge/tool/prefab/skills.py +0 -0
- lm_deluge/tool/prefab/subagents.py +233 -0
- lm_deluge/tool/prefab/todos.py +342 -0
- lm_deluge/tool/prefab/tool_search.py +169 -0
- lm_deluge/tool/prefab/web_search.py +199 -0
- lm_deluge/tracker.py +16 -13
- lm_deluge/util/schema.py +412 -0
- lm_deluge/warnings.py +8 -0
- {lm_deluge-0.0.67.dist-info → lm_deluge-0.0.90.dist-info}/METADATA +23 -9
- lm_deluge-0.0.90.dist-info/RECORD +132 -0
- lm_deluge/built_in_tools/anthropic/__init__.py +0 -128
- lm_deluge/built_in_tools/openai.py +0 -28
- lm_deluge/presets/cerebras.py +0 -17
- lm_deluge/presets/meta.py +0 -13
- lm_deluge/tool.py +0 -849
- lm_deluge-0.0.67.dist-info/RECORD +0 -72
- lm_deluge/{llm_tools → pipelines}/__init__.py +1 -1
- /lm_deluge/{llm_tools → pipelines}/classify.py +0 -0
- /lm_deluge/{llm_tools → pipelines}/extract.py +0 -0
- /lm_deluge/{llm_tools → pipelines}/locate.py +0 -0
- /lm_deluge/{llm_tools → pipelines}/ocr.py +0 -0
- /lm_deluge/{built_in_tools/anthropic/bash.py → skills/anthropic.py} +0 -0
- /lm_deluge/{built_in_tools/anthropic/computer_use.py → skills/compat.py} +0 -0
- /lm_deluge/{built_in_tools → tool/builtin}/anthropic/editor.py +0 -0
- /lm_deluge/{built_in_tools → tool/builtin}/base.py +0 -0
- {lm_deluge-0.0.67.dist-info → lm_deluge-0.0.90.dist-info}/WHEEL +0 -0
- {lm_deluge-0.0.67.dist-info → lm_deluge-0.0.90.dist-info}/licenses/LICENSE +0 -0
- {lm_deluge-0.0.67.dist-info → lm_deluge-0.0.90.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from .filesystem import (
|
|
2
|
+
FilesystemManager,
|
|
3
|
+
FilesystemParams,
|
|
4
|
+
InMemoryWorkspaceBackend,
|
|
5
|
+
WorkspaceBackend,
|
|
6
|
+
)
|
|
7
|
+
from .batch_tool import BatchTool
|
|
8
|
+
from .tool_search import ToolSearchTool
|
|
9
|
+
from .otc import ToolComposer
|
|
10
|
+
from .rlm import RLMManager, RLMPipeline, RLMResult
|
|
11
|
+
from .sandbox import DaytonaSandbox, DockerSandbox, FargateSandbox, ModalSandbox
|
|
12
|
+
from .docs import DocsManager
|
|
13
|
+
from .sheets import SheetsManager
|
|
14
|
+
from .random import RandomTools
|
|
15
|
+
from .subagents import SubAgentManager
|
|
16
|
+
from .todos import TodoItem, TodoManager, TodoPriority, TodoStatus
|
|
17
|
+
from .email import EmailManager
|
|
18
|
+
from .full_text_search import FullTextSearchManager
|
|
19
|
+
|
|
20
|
+
__all__ = [
|
|
21
|
+
"BatchTool",
|
|
22
|
+
"ToolSearchTool",
|
|
23
|
+
"ToolComposer",
|
|
24
|
+
"RLMManager",
|
|
25
|
+
"RLMPipeline",
|
|
26
|
+
"RLMResult",
|
|
27
|
+
"TodoItem",
|
|
28
|
+
"TodoManager",
|
|
29
|
+
"TodoPriority",
|
|
30
|
+
"TodoStatus",
|
|
31
|
+
"SubAgentManager",
|
|
32
|
+
"FilesystemManager",
|
|
33
|
+
"FilesystemParams",
|
|
34
|
+
"InMemoryWorkspaceBackend",
|
|
35
|
+
"WorkspaceBackend",
|
|
36
|
+
"ModalSandbox",
|
|
37
|
+
"DaytonaSandbox",
|
|
38
|
+
"DockerSandbox",
|
|
39
|
+
"FargateSandbox",
|
|
40
|
+
"DocsManager",
|
|
41
|
+
"SheetsManager",
|
|
42
|
+
"RandomTools",
|
|
43
|
+
"EmailManager",
|
|
44
|
+
"FullTextSearchManager",
|
|
45
|
+
]
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"""Batch tool for issuing multiple tool calls in a single roundtrip."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import json
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from .. import Tool
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BatchTool:
|
|
12
|
+
"""Expose a single tool that runs multiple other tools in one request."""
|
|
13
|
+
|
|
14
|
+
def __init__(
|
|
15
|
+
self,
|
|
16
|
+
tools: list[Tool],
|
|
17
|
+
*,
|
|
18
|
+
batch_tool_name: str = "batch",
|
|
19
|
+
include_tools_in_prompt: bool = True,
|
|
20
|
+
):
|
|
21
|
+
self.tools = tools
|
|
22
|
+
self.batch_tool_name = batch_tool_name
|
|
23
|
+
self.include_tools_in_prompt = include_tools_in_prompt
|
|
24
|
+
self._tool_index = {tool.name: tool for tool in tools}
|
|
25
|
+
|
|
26
|
+
def _arguments_schema(self, tool: Tool) -> dict[str, Any]:
|
|
27
|
+
"""Build JSON Schema for a single tool's arguments."""
|
|
28
|
+
schema: dict[str, Any] = {
|
|
29
|
+
"type": "object",
|
|
30
|
+
"properties": tool.parameters or {},
|
|
31
|
+
"required": tool.required or [],
|
|
32
|
+
}
|
|
33
|
+
if tool.additionalProperties is not None:
|
|
34
|
+
schema["additionalProperties"] = tool.additionalProperties
|
|
35
|
+
return schema
|
|
36
|
+
|
|
37
|
+
def _build_definitions(self) -> dict[str, Any]:
|
|
38
|
+
"""Create $defs entries for each wrapped tool."""
|
|
39
|
+
definitions: dict[str, Any] = {}
|
|
40
|
+
for tool in self.tools:
|
|
41
|
+
definition_name = f"{tool.name}_call"
|
|
42
|
+
definitions[definition_name] = {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"description": tool.description or "",
|
|
45
|
+
"properties": {
|
|
46
|
+
"tool": {"type": "string", "enum": [tool.name]},
|
|
47
|
+
"arguments": self._arguments_schema(tool),
|
|
48
|
+
},
|
|
49
|
+
"required": ["tool", "arguments"],
|
|
50
|
+
"additionalProperties": False,
|
|
51
|
+
}
|
|
52
|
+
return definitions
|
|
53
|
+
|
|
54
|
+
def _build_parameters(self) -> tuple[dict[str, Any], dict[str, Any]]:
|
|
55
|
+
"""Create parameters and $defs for the batch tool."""
|
|
56
|
+
definitions = self._build_definitions()
|
|
57
|
+
if definitions:
|
|
58
|
+
items_schema: dict[str, Any] = {
|
|
59
|
+
"anyOf": [
|
|
60
|
+
{"$ref": f"#/$defs/{name}"} for name in sorted(definitions.keys())
|
|
61
|
+
]
|
|
62
|
+
}
|
|
63
|
+
else:
|
|
64
|
+
items_schema = {
|
|
65
|
+
"type": "object",
|
|
66
|
+
"properties": {
|
|
67
|
+
"tool": {"type": "string"},
|
|
68
|
+
"arguments": {"type": "object"},
|
|
69
|
+
},
|
|
70
|
+
"required": ["tool", "arguments"],
|
|
71
|
+
"additionalProperties": False,
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
parameters: dict[str, Any] = {
|
|
75
|
+
"calls": {
|
|
76
|
+
"type": "array",
|
|
77
|
+
"description": "List of tool calls to execute in order. "
|
|
78
|
+
"Each item selects a tool and provides its arguments.",
|
|
79
|
+
"items": items_schema,
|
|
80
|
+
"minItems": 1,
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return parameters, definitions
|
|
85
|
+
|
|
86
|
+
def _tool_summary(self, tool: Tool) -> str:
|
|
87
|
+
"""Render a short signature for the batch tool description."""
|
|
88
|
+
params = []
|
|
89
|
+
for name, schema in (tool.parameters or {}).items():
|
|
90
|
+
json_type = schema.get("type", "any")
|
|
91
|
+
params.append(f"{name}: {json_type}")
|
|
92
|
+
signature = f"{tool.name}({', '.join(params)})" if params else f"{tool.name}()"
|
|
93
|
+
desc = tool.description or "No description provided."
|
|
94
|
+
return f"- {signature}: {desc}"
|
|
95
|
+
|
|
96
|
+
def _build_description(self) -> str:
|
|
97
|
+
header = (
|
|
98
|
+
"Submit several tool calls at once to reduce roundtrips. "
|
|
99
|
+
"Provide `calls` as an array of objects with `tool` and `arguments`. "
|
|
100
|
+
"Calls run sequentially and results are returned in order."
|
|
101
|
+
)
|
|
102
|
+
if not self.include_tools_in_prompt:
|
|
103
|
+
return header
|
|
104
|
+
|
|
105
|
+
summaries = "\n".join(self._tool_summary(tool) for tool in self.tools)
|
|
106
|
+
return f"{header}\n\nAvailable tools:\n{summaries}"
|
|
107
|
+
|
|
108
|
+
async def _run(self, calls: list[dict[str, Any]]) -> str:
|
|
109
|
+
"""Execute each requested tool and return ordered results as JSON."""
|
|
110
|
+
results: list[dict[str, Any]] = []
|
|
111
|
+
|
|
112
|
+
for call in calls:
|
|
113
|
+
tool_name = call.get("tool", "")
|
|
114
|
+
|
|
115
|
+
arguments = call.get("arguments") or {}
|
|
116
|
+
tool = self._tool_index.get(tool_name)
|
|
117
|
+
if tool is None:
|
|
118
|
+
results.append(
|
|
119
|
+
{
|
|
120
|
+
"tool": tool_name or "",
|
|
121
|
+
"status": "error",
|
|
122
|
+
"error": f"Unknown tool '{tool_name}'",
|
|
123
|
+
}
|
|
124
|
+
)
|
|
125
|
+
continue
|
|
126
|
+
|
|
127
|
+
try:
|
|
128
|
+
output = await tool.acall(**arguments)
|
|
129
|
+
results.append({"tool": tool.name, "status": "ok", "result": output})
|
|
130
|
+
except Exception as exc: # pragma: no cover - defensive
|
|
131
|
+
results.append(
|
|
132
|
+
{
|
|
133
|
+
"tool": tool.name,
|
|
134
|
+
"status": "error",
|
|
135
|
+
"error": f"{type(exc).__name__}: {exc}",
|
|
136
|
+
}
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
return json.dumps(results)
|
|
140
|
+
|
|
141
|
+
def get_tool(self) -> Tool:
|
|
142
|
+
"""Return the batch tool definition."""
|
|
143
|
+
parameters, definitions = self._build_parameters()
|
|
144
|
+
|
|
145
|
+
return Tool(
|
|
146
|
+
name=self.batch_tool_name,
|
|
147
|
+
description=self._build_description(),
|
|
148
|
+
run=self._run,
|
|
149
|
+
parameters=parameters,
|
|
150
|
+
required=["calls"],
|
|
151
|
+
definitions=definitions or None,
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
def get_tools(self) -> list[Tool]:
|
|
155
|
+
"""Convenience helper to match other prefab managers."""
|
|
156
|
+
return [self.get_tool()]
|