lm-deluge 0.0.83__py3-none-any.whl → 0.0.85__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.
Files changed (31) hide show
  1. lm_deluge/api_requests/anthropic.py +3 -0
  2. lm_deluge/api_requests/gemini.py +34 -2
  3. lm_deluge/api_requests/openai.py +1 -1
  4. lm_deluge/client.py +86 -0
  5. lm_deluge/models/google.py +14 -0
  6. lm_deluge/models/openai.py +28 -0
  7. lm_deluge/prompt.py +39 -11
  8. lm_deluge/tool/__init__.py +11 -4
  9. lm_deluge/tool/builtin/anthropic/__init__.py +300 -0
  10. lm_deluge/tool/builtin/gemini.py +59 -0
  11. lm_deluge/tool/builtin/openai.py +74 -0
  12. lm_deluge/tool/cua/__init__.py +173 -0
  13. lm_deluge/tool/cua/actions.py +148 -0
  14. lm_deluge/tool/cua/base.py +27 -0
  15. lm_deluge/tool/cua/batch.py +215 -0
  16. lm_deluge/tool/cua/converters.py +466 -0
  17. lm_deluge/tool/cua/kernel.py +702 -0
  18. lm_deluge/tool/cua/trycua.py +989 -0
  19. lm_deluge/tool/prefab/web_search.py +62 -69
  20. {lm_deluge-0.0.83.dist-info → lm_deluge-0.0.85.dist-info}/METADATA +1 -1
  21. {lm_deluge-0.0.83.dist-info → lm_deluge-0.0.85.dist-info}/RECORD +28 -21
  22. lm_deluge/built_in_tools/anthropic/__init__.py +0 -128
  23. lm_deluge/built_in_tools/openai.py +0 -28
  24. lm_deluge/llm_tools/__init__.py +0 -25
  25. /lm_deluge/{built_in_tools → tool/builtin}/anthropic/bash.py +0 -0
  26. /lm_deluge/{built_in_tools → tool/builtin}/anthropic/computer_use.py +0 -0
  27. /lm_deluge/{built_in_tools → tool/builtin}/anthropic/editor.py +0 -0
  28. /lm_deluge/{built_in_tools → tool/builtin}/base.py +0 -0
  29. {lm_deluge-0.0.83.dist-info → lm_deluge-0.0.85.dist-info}/WHEEL +0 -0
  30. {lm_deluge-0.0.83.dist-info → lm_deluge-0.0.85.dist-info}/licenses/LICENSE +0 -0
  31. {lm_deluge-0.0.83.dist-info → lm_deluge-0.0.85.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,6 @@
1
1
  """Web search prefab tool using Exa API."""
2
2
 
3
+ import abc
3
4
  import json
4
5
  import os
5
6
  from typing import Literal
@@ -9,7 +10,42 @@ from aiohttp import ClientSession, ClientTimeout
9
10
  from .. import Tool
10
11
 
11
12
 
12
- class WebSearchManager:
13
+ class AbstractWebSearchManager(abc.ABC):
14
+ def __init__(
15
+ self,
16
+ search_tool_name: str = "web_search",
17
+ fetch_tool_name: str = "web_fetch",
18
+ timeout: int = 30,
19
+ ):
20
+ self.search_tool_name = search_tool_name
21
+ self.fetch_tool_name = fetch_tool_name
22
+ self.timeout = ClientTimeout(total=timeout)
23
+ self._tools: list[Tool] | None = None
24
+
25
+ @abc.abstractmethod
26
+ async def _search(self, query: str, limit: int) -> list[dict]:
27
+ """Search the web and get results with content."""
28
+ pass
29
+
30
+ @abc.abstractmethod
31
+ async def _fetch(self, url: str) -> str:
32
+ """Get the contents of a specific URL as markdown."""
33
+ pass
34
+
35
+ def get_tools(self) -> list[Tool]:
36
+ """Return the web search tools."""
37
+ if self._tools is not None:
38
+ return self._tools
39
+
40
+ self._tools = [
41
+ Tool.from_function(self._search),
42
+ Tool.from_function(self._fetch),
43
+ ]
44
+
45
+ return self._tools
46
+
47
+
48
+ class ExaWebSearchManager(AbstractWebSearchManager):
13
49
  """
14
50
  Simple web search tools using the Exa API.
15
51
 
@@ -18,14 +54,16 @@ class WebSearchManager:
18
54
  - fetch: Get the contents of a specific URL as markdown
19
55
 
20
56
  Args:
21
- api_key: Exa API key. If not provided, uses EXA_API_KEY env variable.
22
57
  search_tool_name: Name for the search tool (default: "web_search")
23
58
  fetch_tool_name: Name for the fetch tool (default: "web_fetch")
24
59
  timeout: Request timeout in seconds (default: 30)
25
60
 
61
+ Environment variables:
62
+ EXA_API_KEY: Your Exa API key (required)
63
+
26
64
  Example:
27
65
  ```python
28
- manager = WebSearchManager()
66
+ manager = ExaWebSearchManager()
29
67
  tools = manager.get_tools()
30
68
  ```
31
69
  """
@@ -34,30 +72,20 @@ class WebSearchManager:
34
72
 
35
73
  def __init__(
36
74
  self,
37
- api_key: str | None = None,
38
75
  *,
39
76
  search_tool_name: str = "web_search",
40
77
  fetch_tool_name: str = "web_fetch",
41
78
  timeout: int = 30,
79
+ max_contents_chars: int = 20_000,
42
80
  ):
43
- self.search_tool_name = search_tool_name
44
- self.fetch_tool_name = fetch_tool_name
45
- self.timeout = ClientTimeout(total=timeout)
46
-
47
- if api_key is not None:
48
- self.api_key = api_key
49
- else:
50
- env_key = os.environ.get("EXA_API_KEY")
51
- if env_key:
52
- self.api_key = env_key
53
- else:
54
- raise ValueError(
55
- "No API key provided. Set api_key parameter or EXA_API_KEY env variable."
56
- )
57
-
58
- self._tools: list[Tool] | None = None
59
-
60
- async def _search(
81
+ super().__init__(
82
+ search_tool_name=search_tool_name,
83
+ fetch_tool_name=fetch_tool_name,
84
+ timeout=timeout,
85
+ )
86
+ self.max_contents_chars = max_contents_chars
87
+
88
+ async def _search( # type: ignore
61
89
  self,
62
90
  query: str,
63
91
  limit: int = 5,
@@ -65,6 +93,9 @@ class WebSearchManager:
65
93
  ) -> str:
66
94
  """Search the web and return results with content."""
67
95
  try:
96
+ key = os.getenv("EXA_API_KEY")
97
+ if not key:
98
+ raise ValueError("EXA_API_KEY environment variable not set")
68
99
  data = {
69
100
  "query": query,
70
101
  "numResults": limit,
@@ -74,7 +105,7 @@ class WebSearchManager:
74
105
 
75
106
  headers = {
76
107
  "Content-Type": "application/json",
77
- "x-api-key": self.api_key,
108
+ "x-api-key": key,
78
109
  }
79
110
 
80
111
  async with ClientSession() as session:
@@ -112,14 +143,19 @@ class WebSearchManager:
112
143
  async def _fetch(self, url: str) -> str:
113
144
  """Fetch the contents of a URL as markdown."""
114
145
  try:
146
+ key = os.getenv("EXA_API_KEY")
147
+ if not key:
148
+ raise ValueError("EXA_API_KEY environment variable not set")
115
149
  data = {
116
150
  "urls": [url],
117
- "text": True,
151
+ "text": {
152
+ "maxCharacters": self.max_contents_chars,
153
+ },
118
154
  }
119
155
 
120
156
  headers = {
121
157
  "Content-Type": "application/json",
122
- "x-api-key": self.api_key,
158
+ "x-api-key": key,
123
159
  }
124
160
 
125
161
  async with ClientSession() as session:
@@ -159,48 +195,5 @@ class WebSearchManager:
159
195
  except Exception as e:
160
196
  return json.dumps({"status": "error", "error": str(e)})
161
197
 
162
- def get_tools(self) -> list[Tool]:
163
- """Return the web search tools."""
164
- if self._tools is not None:
165
- return self._tools
166
-
167
- self._tools = [
168
- Tool(
169
- name=self.search_tool_name,
170
- description="Search the web and get results with their content.",
171
- run=self._search,
172
- parameters={
173
- "query": {
174
- "type": "string",
175
- "description": "The search query",
176
- },
177
- "limit": {
178
- "type": "integer",
179
- "description": "Number of results (default: 5, max: 10)",
180
- },
181
- "search_type": {
182
- "type": "string",
183
- "enum": ["auto", "deep"],
184
- "description": "Search type: 'auto' (default) or 'deep' for more thorough search",
185
- },
186
- },
187
- required=["query"],
188
- ),
189
- Tool(
190
- name=self.fetch_tool_name,
191
- description="Fetch the contents of a specific URL as text.",
192
- run=self._fetch,
193
- parameters={
194
- "url": {
195
- "type": "string",
196
- "description": "The URL to fetch content from",
197
- },
198
- },
199
- required=["url"],
200
- ),
201
- ]
202
-
203
- return self._tools
204
-
205
198
 
206
- __all__ = ["WebSearchManager"]
199
+ __all__ = ["ExaWebSearchManager", "AbstractWebSearchManager"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lm_deluge
3
- Version: 0.0.83
3
+ Version: 0.0.85
4
4
  Summary: Python utility for using LLM API models.
5
5
  Author-email: Benjamin Anderson <ben@trytaylor.ai>
6
6
  Requires-Python: >=3.10
@@ -2,41 +2,34 @@ lm_deluge/__init__.py,sha256=ye2mm-8r9bveEAMWyV13F6APAu2cNzHROU0LOULyPfY,792
2
2
  lm_deluge/batches.py,sha256=Km6QM5_7BlF2qEyo4WPlhkaZkpzrLqf50AaveHXQOoY,25127
3
3
  lm_deluge/cache.py,sha256=xO2AIYvP3tUpTMKQjwQQYfGRJSRi6e7sMlRhLjsS-u4,4873
4
4
  lm_deluge/cli.py,sha256=Ilww5gOw3J5v0NReq_Ra4hhxU4BCIJBl1oTGxJZKedc,12065
5
- lm_deluge/client.py,sha256=SD829zTZf1CjA_Yv0X6xuhI1QF4JJYZaK8oBaBIENs4,45715
5
+ lm_deluge/client.py,sha256=HZ_frrki94g65kMuy1RjRK_oBouCXoYvXLadTPXsQ-U,49216
6
6
  lm_deluge/config.py,sha256=C-_rVwAFL5sivLfKSkaa2ANMqqxKbyDCW86KfQB_Lck,1357
7
7
  lm_deluge/embed.py,sha256=CO-TOlC5kOTAM8lcnicoG4u4K664vCBwHF1vHa-nAGg,13382
8
8
  lm_deluge/errors.py,sha256=oHjt7YnxWbh-eXMScIzov4NvpJMo0-2r5J6Wh5DQ1tk,209
9
9
  lm_deluge/file.py,sha256=PTmlJQ-IaYcYUFun9V0bJ1NPVP84edJrR0hvCMWFylY,19697
10
10
  lm_deluge/image.py,sha256=5AMXmn2x47yXeYNfMSMAOWcnlrOxxOel-4L8QCJwU70,8928
11
11
  lm_deluge/mock_openai.py,sha256=-u4kxSzwoxDt_2fLh5LaiqETnu0Jg_VDL7TWAAYHGNw,21762
12
- lm_deluge/prompt.py,sha256=vgI4cvk5gl6-x4uLm4X67eSANyrolJbpF5HXTz88550,70365
12
+ lm_deluge/prompt.py,sha256=aOHNDGQv9UEpyxTLFkMvnpAOef_Yh1XDmgB__vQeH6Y,71763
13
13
  lm_deluge/request_context.py,sha256=CX15dT4Jxz77C-w5EKNyJCfYEa69wNKHbfNi47iG8W4,2771
14
14
  lm_deluge/rerank.py,sha256=-NBAJdHz9OB-SWWJnHzkFmeVO4wR6lFV7Vw-SxG7aVo,11457
15
15
  lm_deluge/tracker.py,sha256=B53KIsrK10L9L73cYbVB2pNSC0-FdvJGpIfw735CvaA,14808
16
16
  lm_deluge/usage.py,sha256=xz9tAw2hqaJvv9aAVhnQ6N1Arn7fS8Shb28VwCW26wI,5136
17
17
  lm_deluge/warnings.py,sha256=3_lWpR20b5WEfchqvbWVIc-vo8afU0Jg6S9FkbA5pZQ,2479
18
18
  lm_deluge/api_requests/__init__.py,sha256=AbpHGcgLb-kRsJGnwFEktk7uzpZOCcBY74-YBdrKVGs,1
19
- lm_deluge/api_requests/anthropic.py,sha256=KaIJAspFiTESuYy0uqzDTXXVhGN9raIjJBWF-YG2BOo,11594
19
+ lm_deluge/api_requests/anthropic.py,sha256=b9mr8oXJIX8AOYAOlOc0gTtmf2Ob_eVjWnuq4YvazUQ,11801
20
20
  lm_deluge/api_requests/base.py,sha256=05j5nrZhgNon2YRFXT_L-yVXKlvdodwOJan6Z6WpSp8,10911
21
21
  lm_deluge/api_requests/bedrock.py,sha256=mY1xTvgfCLyqLlfFFmu_baKgkVq1Df1_MJXeN_G1jWQ,15597
22
22
  lm_deluge/api_requests/chat_reasoning.py,sha256=sJvstvKFqsSBUjYcwxzGt2_FH4cEp3Z6gKcBPyPjGwk,236
23
23
  lm_deluge/api_requests/common.py,sha256=BZ3vRO5TB669_UsNKugkkuFSzoLHOYJIKt4nV4sf4vc,422
24
- lm_deluge/api_requests/gemini.py,sha256=q1Muf1LnWKxJA1x5braXSvAdtmxQrOkAaYYVh1K_EEM,11115
24
+ lm_deluge/api_requests/gemini.py,sha256=w42YdpBDcgPOCUwZT2voJbKLFV5GTT5skCX93RyYPLc,12388
25
25
  lm_deluge/api_requests/mistral.py,sha256=8JZP2CDf1XZfaPcTk0WS4q-VfYYj58ptpoH8LD3MQG4,4528
26
- lm_deluge/api_requests/openai.py,sha256=dhzFw-FCZ52ZsZ0dVwOdP0rX81YvyIDOK945wFfAOco,28898
26
+ lm_deluge/api_requests/openai.py,sha256=KjPu5z5rkinN0DHQs-_GczJZzHimLd7vADHKPYMeUzI,28891
27
27
  lm_deluge/api_requests/response.py,sha256=vG194gAH5p7ulpNy4qy5Pryfb1p3ZV21-YGoj__ru3E,7436
28
28
  lm_deluge/api_requests/deprecated/bedrock.py,sha256=WrcIShCoO8JCUSlFOCHxg6KQCNTZfw3TpYTvSpYk4mA,11320
29
29
  lm_deluge/api_requests/deprecated/cohere.py,sha256=KgDScD6_bWhAzOY5BHZQKSA3kurt4KGENqC4wLsGmcU,5142
30
30
  lm_deluge/api_requests/deprecated/deepseek.py,sha256=FEApI93VAWDwuaqTooIyKMgONYqRhdUmiAPBRme-IYs,4582
31
31
  lm_deluge/api_requests/deprecated/mistral.py,sha256=pOfOZUM4U35I3Plch84SnAFpDAzouHcSNNMtgxRvjy4,4709
32
32
  lm_deluge/api_requests/deprecated/vertex.py,sha256=ygXz2RjdXErPCSBbiHLEWbf5_sSTIi31WoX0UaoYzRI,15275
33
- lm_deluge/built_in_tools/base.py,sha256=FLYdKVAqlffA6WOu4j8wQVRd0iHMsyBW_T3vfl--aXo,276
34
- lm_deluge/built_in_tools/openai.py,sha256=aLuJdXbANvXVIU38Vo2zsir7zlwWgX0d8oDPT7Ql64A,721
35
- lm_deluge/built_in_tools/anthropic/__init__.py,sha256=Dxm8MJTUwMhyXT_78uIdRe8dJsLHZcHThJ9UEurTw18,4526
36
- lm_deluge/built_in_tools/anthropic/bash.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
37
- lm_deluge/built_in_tools/anthropic/computer_use.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
38
- lm_deluge/built_in_tools/anthropic/editor.py,sha256=DyC_DrHVTm1khU9QDL39vBuhu4tO5mS5H7xMRIT0Ng4,23327
39
- lm_deluge/llm_tools/__init__.py,sha256=c_S5wiBkSZcObPLYaMrsykKAJ302YF5QIoNUOQyDfsE,527
40
33
  lm_deluge/models/__init__.py,sha256=_c-gxqAaNO4xy4dtsqIwG1odpwcCa2J02_YQnuXYtc0,4669
41
34
  lm_deluge/models/anthropic.py,sha256=X92EYIapos-8LXnIYiypPJcFhI0tqmXja_w8e9H4CF8,6781
42
35
  lm_deluge/models/arcee.py,sha256=4OI8eA8RoA-zYww4fWwhVZDFWB2Kd4-KQTTPl9r3Ay4,465
@@ -45,14 +38,14 @@ lm_deluge/models/cerebras.py,sha256=u2FMXJF6xMr0euDRKLKMo_NVTOcvSrrEpehbHr8sSeE,
45
38
  lm_deluge/models/cohere.py,sha256=iXjYtM6jy_YL73Op8OfNsrMNopwae9y-Sw-4vF9cEBw,3406
46
39
  lm_deluge/models/deepseek.py,sha256=b5t_ep6fE-2cKD2mmImBaLcJUbYrfizYnjG96sfKNTk,2072
47
40
  lm_deluge/models/fireworks.py,sha256=yvt2Ggzye4aUqCqY74ta67Vu7FrQaLFjdFtN4P7D-dc,638
48
- lm_deluge/models/google.py,sha256=fARfBMHDwhPJ48SGcYg3sHQDQ0Mm0yPQ-9s6iVYne8M,6011
41
+ lm_deluge/models/google.py,sha256=IDePlNOvF0lvpv3UhkUD8g30TUJqoaJHQGzTglyGg80,6560
49
42
  lm_deluge/models/grok.py,sha256=TDzr8yfTaHbdJhwMA-Du6L-efaKFJhjTQViuVElCCHI,2566
50
43
  lm_deluge/models/groq.py,sha256=Mi5WE1xOBGoZlymD0UN6kzhH_NOmfJYU4N2l-TO0Z8Q,2552
51
44
  lm_deluge/models/kimi.py,sha256=B_ZL4_0q6hS1VVskBWlBR569nNSjC8RgA2lj1eCjRRE,1183
52
45
  lm_deluge/models/meta.py,sha256=BBgnscL1gMcIdPbRqrlDl_q9YAYGSrkw9JkAIabXtLs,1883
53
46
  lm_deluge/models/minimax.py,sha256=rwW9gNotAYfDVtMlqmSYegN6GoZM_9DSNNZU2yPOmaU,275
54
47
  lm_deluge/models/mistral.py,sha256=x67o5gckBGmPcIGdVbS26XZAYFKBYM4tsxEAahGp8bk,4323
55
- lm_deluge/models/openai.py,sha256=t6fcXo0YXgPQ6YiftZJP8gPw8FOBqoVapSavMVmtaOw,12411
48
+ lm_deluge/models/openai.py,sha256=UDmPqvMaBjqky2Z6yNV4bG4LqxUZmbWEJJO4pq0Mqzc,13329
56
49
  lm_deluge/models/openrouter.py,sha256=AHQTvnXM96_70XR0eqb3Wu2rAj2SHBZCWQeEKJ307LY,2816
57
50
  lm_deluge/models/together.py,sha256=wrGs4wO65on-dSlU9AARAA-rc4GDuWkidPjRQ7GScNg,4749
58
51
  lm_deluge/models/zai.py,sha256=BIde8TwjvmkfEi-6bSSBSFIh7KVnlJ7_aNdlqNZRGGI,16
@@ -63,7 +56,21 @@ lm_deluge/pipelines/locate.py,sha256=lYNbKTmy9dTvj0lEQkOQ7yrxyqsgYzjD0C_byJKI_4w
63
56
  lm_deluge/pipelines/ocr.py,sha256=7fDlvs6uUOvbxMasvGGNJx5Fj6biM6z3lijKZaGN26k,23
64
57
  lm_deluge/pipelines/score.py,sha256=hkLMroJMfQ92HPlTBNOHrDRtvdYUBWK0MBlhOfvFTMk,2582
65
58
  lm_deluge/pipelines/translate.py,sha256=v_OvBQA2RB-QcWf0aopKHpYc2PDmckxzJGSmSuUX3Sw,1461
66
- lm_deluge/tool/__init__.py,sha256=uEqutw31_XtzydvK1LB_yNnFOyQg5XPR7V8STxs6B5I,39889
59
+ lm_deluge/tool/__init__.py,sha256=_GD2RAK0wYnKsAPdrM2w8X4xKtugBEm-eSZTboGRL9s,40260
60
+ lm_deluge/tool/builtin/base.py,sha256=FLYdKVAqlffA6WOu4j8wQVRd0iHMsyBW_T3vfl--aXo,276
61
+ lm_deluge/tool/builtin/gemini.py,sha256=uKrzzEZ0RO5EHddYYFvRKoMk7O6YOSWFDojhzbpQSfs,1724
62
+ lm_deluge/tool/builtin/openai.py,sha256=a6Y4TX_iqghDTnbL-HeFeVGq1nRdBosYJcLZzfCTy9g,2499
63
+ lm_deluge/tool/builtin/anthropic/__init__.py,sha256=U-5VdcRS_ITjTBCoFoeABZOoG4nfBTgRvhT5eo1UY1g,10675
64
+ lm_deluge/tool/builtin/anthropic/bash.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
65
+ lm_deluge/tool/builtin/anthropic/computer_use.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
66
+ lm_deluge/tool/builtin/anthropic/editor.py,sha256=DyC_DrHVTm1khU9QDL39vBuhu4tO5mS5H7xMRIT0Ng4,23327
67
+ lm_deluge/tool/cua/__init__.py,sha256=HDXXwCqPRNm_-Wh6JCsIT89CYwioHdRSZcu2WQWYaCo,4756
68
+ lm_deluge/tool/cua/actions.py,sha256=ZeQheCJ9F5nHLu3teL14_qr8mr4UuaR78EhgrvYw_G8,3191
69
+ lm_deluge/tool/cua/base.py,sha256=DwOTHp8AGu5-ZRzg_6RdOu9Bh4cgAbK5EMPEusJlDrI,799
70
+ lm_deluge/tool/cua/batch.py,sha256=ddYHbg72y4e62G6-B6BMM1SNq5zI9WYsnC6jzKNJiOU,7312
71
+ lm_deluge/tool/cua/converters.py,sha256=O1wO4u_78ZZNBrXuyjh4vZreYckhh-e3J304C-d6uOA,13741
72
+ lm_deluge/tool/cua/kernel.py,sha256=8klzaCTBB-4yYvZTzroi-t5ABNX81jAjc5uCCKG3Kvc,25654
73
+ lm_deluge/tool/cua/trycua.py,sha256=SvdA5DkAVweegQ3r_SI_AbKKX242mFOxsBDf5CNiRkY,36954
67
74
  lm_deluge/tool/prefab/__init__.py,sha256=JXwyAkBvKqOYC8us80ClxZ31vKECAJ8FsrZKiEK_PT8,909
68
75
  lm_deluge/tool/prefab/batch_tool.py,sha256=VTMoW7ImQYmeDHrbB4BKSw3WeHXhsjp9XqFHz4ytjcc,5584
69
76
  lm_deluge/tool/prefab/docs.py,sha256=5X3EVUH4ws72og4TxDpgIjN3clroqUsR1Wx8fIuQWd0,41566
@@ -76,7 +83,7 @@ lm_deluge/tool/prefab/sheets.py,sha256=RhH4PgRI4E6WYKfJpScflT7HtAULvp88ZA94NmJyE
76
83
  lm_deluge/tool/prefab/subagents.py,sha256=srJ7On7YR0Y8WuNvf5TJl_7IUfEtG3zlxZeLgmn_-NI,8484
77
84
  lm_deluge/tool/prefab/todos.py,sha256=mrtv68uRc-grc0xKP6xKpfPSA2yXYU7FLNy6fDzEbG8,14902
78
85
  lm_deluge/tool/prefab/tool_search.py,sha256=EJL5R5BgnO6owspk7F01Yzr8C9q9oJqmfMrWBjLE_bA,6151
79
- lm_deluge/tool/prefab/web_search.py,sha256=oc1sQloAdybKlOJBPgbwPuBew0degyj9hqTK1dV9Woc,6615
86
+ lm_deluge/tool/prefab/web_search.py,sha256=i_FFBB2TAZwgN4-_9a6cD10Z9bgFGk4qNUbnOI3EnJA,6200
80
87
  lm_deluge/tool/prefab/otc/__init__.py,sha256=33AcwAt9ycECxonnvkcyh13w9Sr2Cbs6OOlBjzBvl54,6373
81
88
  lm_deluge/tool/prefab/otc/executor.py,sha256=4IROA_0un3HaV4GK7r4vQiVxJvcoHkqVii-4asGH-Cw,10508
82
89
  lm_deluge/tool/prefab/otc/parse.py,sha256=lSAtez-pBFcJVQMW2evRvV9KlduRtPevzGCEB1fmUMo,4517
@@ -87,8 +94,8 @@ lm_deluge/util/schema.py,sha256=q6uwhA4s1lM2dHT1Kwc46E7OY1VecMOtTEI0PTFn6tA,1320
87
94
  lm_deluge/util/spatial.py,sha256=BsF_UKhE-x0xBirc-bV1xSKZRTUhsOBdGqsMKme20C8,4099
88
95
  lm_deluge/util/validation.py,sha256=hz5dDb3ebvZrZhnaWxOxbNSVMI6nmaOODBkk0htAUhs,1575
89
96
  lm_deluge/util/xml.py,sha256=Ft4zajoYBJR3HHCt2oHwGfymGLdvp_gegVmJ-Wqk4Ck,10547
90
- lm_deluge-0.0.83.dist-info/licenses/LICENSE,sha256=uNNXGXPCw2TC7CUs7SEBkA-Mz6QBQFWUUEWDMgEs1dU,1058
91
- lm_deluge-0.0.83.dist-info/METADATA,sha256=TRA97JDBxqqO8DmVIZZ8p7FynREzdunRpCnaVK7A_oQ,13595
92
- lm_deluge-0.0.83.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
93
- lm_deluge-0.0.83.dist-info/top_level.txt,sha256=hqU-TJX93yBwpgkDtYcXyLr3t7TLSCCZ_reytJjwBaE,10
94
- lm_deluge-0.0.83.dist-info/RECORD,,
97
+ lm_deluge-0.0.85.dist-info/licenses/LICENSE,sha256=uNNXGXPCw2TC7CUs7SEBkA-Mz6QBQFWUUEWDMgEs1dU,1058
98
+ lm_deluge-0.0.85.dist-info/METADATA,sha256=MgU3mDxSvV_NBnmoacgJYXQZ-dAUdSI0JZHgXz7-BxY,13595
99
+ lm_deluge-0.0.85.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
100
+ lm_deluge-0.0.85.dist-info/top_level.txt,sha256=hqU-TJX93yBwpgkDtYcXyLr3t7TLSCCZ_reytJjwBaE,10
101
+ lm_deluge-0.0.85.dist-info/RECORD,,
@@ -1,128 +0,0 @@
1
- from typing import Literal
2
-
3
- # from lm_deluge.prompt import ToolCall
4
-
5
- ToolVersion = Literal["2024-10-22", "2025-01-24", "2025-04-29"]
6
- ToolType = Literal["bash", "computer", "editor"]
7
-
8
-
9
- def model_to_version(model: str) -> ToolVersion:
10
- if "opus" not in model and "sonnet" not in model:
11
- raise ValueError("cannot use computer tools with incompatible model")
12
- if "claude-4" in model:
13
- return "2025-04-29"
14
- elif "3.7" in model:
15
- return "2025-01-24"
16
- elif "3.6" in model:
17
- return "2024-10-22"
18
- else:
19
- raise ValueError("unsupported model for anthropic CUA")
20
-
21
-
22
- def get_anthropic_cu_tools(
23
- model: str,
24
- display_width: int = 1024,
25
- display_height: int = 768,
26
- exclude_tools: list[ToolType] | None = None,
27
- ):
28
- version = model_to_version(model)
29
- if version == "2024-10-22":
30
- result = [
31
- {
32
- "name": "computer",
33
- "type": "computer_20241022",
34
- "display_width_px": display_width,
35
- "display_height_px": display_height,
36
- "display_number": None,
37
- },
38
- {"name": "str_replace_editor", "type": "text_editor_20241022"},
39
- {"name": "bash", "type": "bash_20241022"},
40
- ]
41
- elif version == "2025-01-24":
42
- result = [
43
- {
44
- "name": "computer",
45
- "type": "computer_20250124",
46
- "display_width_px": display_width,
47
- "display_height_px": display_height,
48
- "display_number": None,
49
- },
50
- {"name": "str_replace_editor", "type": "text_editor_20250124"},
51
- {"type": "bash_20250124", "name": "bash"},
52
- ]
53
- elif version == "2025-04-29":
54
- result = [
55
- {
56
- "name": "computer",
57
- "type": "computer_20250124",
58
- "display_width_px": display_width,
59
- "display_height_px": display_height,
60
- "display_number": None,
61
- },
62
- {"name": "str_replace_based_edit_tool", "type": "text_editor_20250429"},
63
- {
64
- "name": "bash",
65
- "type": "bash_20250124",
66
- },
67
- ]
68
- else:
69
- raise ValueError("invalid tool version")
70
-
71
- if exclude_tools is None:
72
- return result
73
- if "bash" in exclude_tools:
74
- result = [x for x in result if x["name"] != "bash"]
75
- if "editor" in exclude_tools:
76
- result = [x for x in result if "edit" not in x["name"]]
77
- if "computer" in exclude_tools:
78
- result = [x for x in result if "computer" not in x["name"]]
79
- return result
80
-
81
-
82
- def bash_tool(model: str = "claude-4-sonnet"):
83
- # Claude Sonnet 3.5 requires the computer-use-2024-10-22 beta header when using the bash tool.
84
- # The bash tool is generally available in Claude 4 and Sonnet 3.7.
85
- if "claude-4" in model:
86
- return {"type": "text_editor_20250429", "name": "str_replace_based_edit_tool"}
87
- elif "3.7" in model:
88
- return {"type": "text_editor_20250124", "name": "str_replace_editor"}
89
- else:
90
- return {"type": "text_editor_20241022", "name": "str_replace_editor"}
91
-
92
-
93
- def text_editor_tool(model: str = "claude-4-sonnet"):
94
- if "claude-4" in model:
95
- return {"type": "bash_20250124", "name": "bash"}
96
- elif "3.7" in model:
97
- return {"type": "bash_20250124", "name": "bash"}
98
- else:
99
- return {"type": "bash_20241022", "name": "bash"}
100
-
101
-
102
- def web_search_tool(max_uses: int = 5):
103
- res = {
104
- "type": "web_search_20250305",
105
- "name": "web_search",
106
- # Optional: Limit the number of searches per request
107
- "max_uses": max_uses,
108
- # You can use either allowed_domains or blocked_domains, but not both in the same request.
109
- # Optional: Only include results from these domains
110
- # "allowed_domains": ["example.com", "trusteddomain.org"],
111
- # Optional: Never include results from these domains
112
- # "blocked_domains": ["untrustedsource.com"],
113
- # Optional: Localize search results
114
- # "user_location": {
115
- # "type": "approximate",
116
- # "city": "San Francisco",
117
- # "region": "California",
118
- # "country": "US",
119
- # "timezone": "America/Los_Angeles"
120
- # }
121
- }
122
- return res
123
-
124
-
125
- def code_execution_tool():
126
- # The code execution tool is currently in beta.
127
- # This feature requires the beta header: "anthropic-beta": "code-execution-2025-05-22"
128
- return {"type": "code_execution_20250522", "name": "code_execution"}
@@ -1,28 +0,0 @@
1
- def image_generation_openai():
2
- # TODO: handle result properly
3
- return {"type": "image_generation"}
4
-
5
-
6
- def code_interpreter_openai(container: dict | None = None):
7
- if container is None:
8
- container = {"type": "auto"}
9
- return {"type": "code_interpreter", "container": container}
10
-
11
-
12
- def local_shell_openai():
13
- return {"type": "local_shell"}
14
-
15
-
16
- def web_search_openai():
17
- return {"type": "web_search_preview"}
18
-
19
-
20
- def computer_use_openai(
21
- display_width: int = 1024, display_height: int = 768, environment: str = "browser"
22
- ):
23
- return {
24
- "type": "computer_use_preview",
25
- "display_width": display_width,
26
- "display_height": display_height,
27
- "environment": environment,
28
- }
@@ -1,25 +0,0 @@
1
- # Backward compatibility - re-export from new locations
2
- # Pipelines (workflow functions)
3
- from ..pipelines import extract, extract_async, score_llm, translate, translate_async
4
-
5
- # Prefab tools (Tool managers)
6
- from ..tool.prefab import (
7
- SubAgentManager,
8
- TodoItem,
9
- TodoManager,
10
- TodoPriority,
11
- TodoStatus,
12
- )
13
-
14
- __all__ = [
15
- "extract",
16
- "extract_async",
17
- "TodoItem",
18
- "TodoManager",
19
- "TodoPriority",
20
- "TodoStatus",
21
- "translate",
22
- "translate_async",
23
- "score_llm",
24
- "SubAgentManager",
25
- ]
File without changes