vision-agent 0.2.13__py3-none-any.whl → 0.2.15__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.
- vision_agent/agent/__init__.py +1 -0
- vision_agent/agent/agent_coder.py +33 -7
- vision_agent/agent/vision_agent.py +15 -13
- vision_agent/agent/vision_agent_prompts.py +3 -3
- vision_agent/agent/vision_agent_v2.py +300 -0
- vision_agent/agent/vision_agent_v2_prompt.py +170 -0
- vision_agent/llm/llm.py +11 -3
- vision_agent/tools/__init__.py +2 -2
- vision_agent/tools/tool_utils.py +1 -1
- vision_agent/tools/tools.py +4 -5
- vision_agent/tools/tools_v2.py +278 -17
- vision_agent/utils/__init__.py +3 -0
- vision_agent/utils/execute.py +104 -0
- vision_agent/utils/sim.py +70 -0
- {vision_agent-0.2.13.dist-info → vision_agent-0.2.15.dist-info}/METADATA +4 -2
- vision_agent-0.2.15.dist-info/RECORD +34 -0
- vision_agent/agent/execution.py +0 -287
- vision_agent-0.2.13.dist-info/RECORD +0 -30
- /vision_agent/{image_utils.py → utils/image_utils.py} +0 -0
- /vision_agent/{type_defs.py → utils/type_defs.py} +0 -0
- /vision_agent/{tools → utils}/video.py +0 -0
- {vision_agent-0.2.13.dist-info → vision_agent-0.2.15.dist-info}/LICENSE +0 -0
- {vision_agent-0.2.13.dist-info → vision_agent-0.2.15.dist-info}/WHEEL +0 -0
vision_agent/agent/execution.py
DELETED
@@ -1,287 +0,0 @@
|
|
1
|
-
"""This code is based off of code from CodeGeeX https://github.com/THUDM/CodeGeeX"""
|
2
|
-
|
3
|
-
import contextlib
|
4
|
-
import faulthandler
|
5
|
-
import io
|
6
|
-
import multiprocessing
|
7
|
-
import os
|
8
|
-
import platform
|
9
|
-
import signal
|
10
|
-
import tempfile
|
11
|
-
import traceback
|
12
|
-
import typing
|
13
|
-
from pathlib import Path
|
14
|
-
from typing import Dict, Generator, List, Optional, Union
|
15
|
-
|
16
|
-
IMPORT_HELPER = """
|
17
|
-
import math
|
18
|
-
import re
|
19
|
-
import sys
|
20
|
-
import copy
|
21
|
-
import datetime
|
22
|
-
import itertools
|
23
|
-
import collections
|
24
|
-
import heapq
|
25
|
-
import statistics
|
26
|
-
import functools
|
27
|
-
import hashlib
|
28
|
-
import numpy
|
29
|
-
import numpy as np
|
30
|
-
import string
|
31
|
-
from typing import *
|
32
|
-
from collections import *
|
33
|
-
from vision_agent.tools.tools_v2 import *
|
34
|
-
"""
|
35
|
-
|
36
|
-
|
37
|
-
def unsafe_execute(code: str, timeout: float, result: List) -> None:
|
38
|
-
with create_tempdir() as dir:
|
39
|
-
code_path = Path(dir) / "code.py"
|
40
|
-
with open(code_path, "w") as f:
|
41
|
-
f.write(code)
|
42
|
-
|
43
|
-
# These system calls are needed when cleaning up tempdir.
|
44
|
-
import os
|
45
|
-
import shutil
|
46
|
-
|
47
|
-
rmtree = shutil.rmtree
|
48
|
-
rmdir = os.rmdir
|
49
|
-
chdir = os.chdir
|
50
|
-
|
51
|
-
# Disable functionalities that can make destructive changes to the test.
|
52
|
-
reliability_guard()
|
53
|
-
|
54
|
-
try:
|
55
|
-
with swallow_io() as s:
|
56
|
-
with time_limit(timeout):
|
57
|
-
# WARNING
|
58
|
-
# This program exists to execute untrusted model-generated code. Although
|
59
|
-
# it is highly unlikely that model-generated code will do something overtly
|
60
|
-
# malicious in response to this test suite, model-generated code may act
|
61
|
-
# destructively due to a lack of model capability or alignment.
|
62
|
-
# Users are strongly encouraged to sandbox this evaluation suite so that it
|
63
|
-
# does not perform destructive actions on their host or network.
|
64
|
-
# Once you have read this disclaimer and taken appropriate precautions,
|
65
|
-
# uncomment the following line and proceed at your own risk:
|
66
|
-
code = compile(code, code_path, "exec") # type: ignore
|
67
|
-
exec(code)
|
68
|
-
result.append({"output": s.getvalue(), "passed": True})
|
69
|
-
except TimeoutError:
|
70
|
-
result.append({"output": "Timed out", "passed": False})
|
71
|
-
except AssertionError:
|
72
|
-
result.append({"output": f"{traceback.format_exc()}", "passed": False})
|
73
|
-
except BaseException:
|
74
|
-
result.append({"output": f"{traceback.format_exc()}", "passed": False})
|
75
|
-
|
76
|
-
# Needed for cleaning up.
|
77
|
-
shutil.rmtree = rmtree
|
78
|
-
os.rmdir = rmdir
|
79
|
-
os.chdir = chdir
|
80
|
-
|
81
|
-
code_path.unlink()
|
82
|
-
|
83
|
-
|
84
|
-
def check_correctness(
|
85
|
-
code: str,
|
86
|
-
timeout: float = 3.0,
|
87
|
-
) -> Dict[str, Union[str, bool]]:
|
88
|
-
"""Evaluates the functional correctness of a completion by running the test suite
|
89
|
-
provided in the problem.
|
90
|
-
"""
|
91
|
-
|
92
|
-
manager = multiprocessing.Manager()
|
93
|
-
result = manager.list()
|
94
|
-
|
95
|
-
# p = multiprocessing.Process(target=unsafe_execute, args=(tmp_dir,))
|
96
|
-
p = multiprocessing.Process(target=unsafe_execute, args=(code, timeout, result))
|
97
|
-
p.start()
|
98
|
-
p.join(timeout=timeout + 1)
|
99
|
-
if p.is_alive():
|
100
|
-
p.kill()
|
101
|
-
|
102
|
-
if not result:
|
103
|
-
result.append("timed out")
|
104
|
-
|
105
|
-
return {
|
106
|
-
"code": code,
|
107
|
-
"result": result[0]["output"],
|
108
|
-
"passed": result[0]["passed"],
|
109
|
-
}
|
110
|
-
|
111
|
-
|
112
|
-
# Copyright (c) OpenAI (https://openai.com)
|
113
|
-
|
114
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
115
|
-
# of this software and associated documentation files (the "Software"), to deal
|
116
|
-
# in the Software without restriction, including without limitation the rights
|
117
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
118
|
-
# copies of the Software, and to permit persons to whom the Software is
|
119
|
-
# furnished to do so, subject to the following conditions:
|
120
|
-
|
121
|
-
# The above copyright notice and this permission notice shall be included in
|
122
|
-
# all copies or substantial portions of the Software.
|
123
|
-
|
124
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
125
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
126
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
127
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
128
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
129
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
130
|
-
# THE SOFTWARE.
|
131
|
-
# ============================================================================
|
132
|
-
|
133
|
-
|
134
|
-
class redirect_stdin(contextlib._RedirectStream):
|
135
|
-
_stream = "stdin"
|
136
|
-
|
137
|
-
|
138
|
-
@contextlib.contextmanager
|
139
|
-
def chdir(root: str) -> Generator[None, None, None]:
|
140
|
-
if root == ".":
|
141
|
-
yield
|
142
|
-
return
|
143
|
-
cwd = os.getcwd()
|
144
|
-
os.chdir(root)
|
145
|
-
try:
|
146
|
-
yield
|
147
|
-
except BaseException as exc:
|
148
|
-
raise exc
|
149
|
-
finally:
|
150
|
-
os.chdir(cwd)
|
151
|
-
|
152
|
-
|
153
|
-
class WriteOnlyStringIO(io.StringIO):
|
154
|
-
"""StringIO that throws an exception when it's read from"""
|
155
|
-
|
156
|
-
def read(self, *args, **kwargs): # type: ignore
|
157
|
-
raise IOError
|
158
|
-
|
159
|
-
def readline(self, *args, **kwargs): # type: ignore
|
160
|
-
raise IOError
|
161
|
-
|
162
|
-
def readlines(self, *args, **kwargs): # type: ignore
|
163
|
-
raise IOError
|
164
|
-
|
165
|
-
def readable(self, *args, **kwargs): # type: ignore
|
166
|
-
"""Returns True if the IO object can be read."""
|
167
|
-
return False
|
168
|
-
|
169
|
-
|
170
|
-
@contextlib.contextmanager
|
171
|
-
def create_tempdir() -> Generator[str, None, None]:
|
172
|
-
with tempfile.TemporaryDirectory() as dirname:
|
173
|
-
with chdir(dirname):
|
174
|
-
yield dirname
|
175
|
-
|
176
|
-
|
177
|
-
@contextlib.contextmanager
|
178
|
-
def swallow_io() -> Generator[WriteOnlyStringIO, None, None]:
|
179
|
-
stream = WriteOnlyStringIO()
|
180
|
-
with contextlib.redirect_stdout(stream):
|
181
|
-
with contextlib.redirect_stderr(stream):
|
182
|
-
with redirect_stdin(stream):
|
183
|
-
yield stream
|
184
|
-
|
185
|
-
|
186
|
-
@typing.no_type_check
|
187
|
-
@contextlib.contextmanager
|
188
|
-
def time_limit(seconds: float) -> Generator[None, None, None]:
|
189
|
-
def signal_handler(signum, frame):
|
190
|
-
raise TimeoutError("Timed out!")
|
191
|
-
|
192
|
-
if platform.uname().system != "Windows":
|
193
|
-
signal.setitimer(signal.ITIMER_REAL, seconds)
|
194
|
-
signal.signal(signal.SIGALRM, signal_handler)
|
195
|
-
try:
|
196
|
-
yield
|
197
|
-
finally:
|
198
|
-
signal.setitimer(signal.ITIMER_REAL, 0)
|
199
|
-
|
200
|
-
|
201
|
-
@typing.no_type_check
|
202
|
-
def reliability_guard(maximum_memory_bytes: Optional[int] = None) -> None:
|
203
|
-
"""
|
204
|
-
This disables various destructive functions and prevents the generated code
|
205
|
-
from interfering with the test (e.g. fork bomb, killing other processes,
|
206
|
-
removing filesystem files, etc.)
|
207
|
-
|
208
|
-
WARNING
|
209
|
-
This function is NOT a security sandbox. Untrusted code, including, model-
|
210
|
-
generated code, should not be blindly executed outside of one. See the
|
211
|
-
Codex paper for more information about OpenAI's code sandbox, and proceed
|
212
|
-
with caution.
|
213
|
-
"""
|
214
|
-
|
215
|
-
if maximum_memory_bytes is not None:
|
216
|
-
if platform.uname().system != "Windows":
|
217
|
-
import resource
|
218
|
-
|
219
|
-
resource.setrlimit(
|
220
|
-
resource.RLIMIT_AS, (maximum_memory_bytes, maximum_memory_bytes)
|
221
|
-
)
|
222
|
-
resource.setrlimit(
|
223
|
-
resource.RLIMIT_DATA, (maximum_memory_bytes, maximum_memory_bytes)
|
224
|
-
)
|
225
|
-
if not platform.uname().system == "Darwin":
|
226
|
-
resource.setrlimit(
|
227
|
-
resource.RLIMIT_STACK, (maximum_memory_bytes, maximum_memory_bytes)
|
228
|
-
)
|
229
|
-
|
230
|
-
faulthandler.disable()
|
231
|
-
|
232
|
-
import builtins
|
233
|
-
|
234
|
-
builtins.exit = None
|
235
|
-
builtins.quit = None
|
236
|
-
|
237
|
-
import os
|
238
|
-
|
239
|
-
os.environ["OMP_NUM_THREADS"] = "1"
|
240
|
-
|
241
|
-
os.kill = None
|
242
|
-
os.system = None
|
243
|
-
# os.putenv = None # this causes numpy to fail on import
|
244
|
-
os.remove = None
|
245
|
-
os.removedirs = None
|
246
|
-
os.rmdir = None
|
247
|
-
os.fchdir = None
|
248
|
-
os.setuid = None
|
249
|
-
os.fork = None
|
250
|
-
os.forkpty = None
|
251
|
-
os.killpg = None
|
252
|
-
os.rename = None
|
253
|
-
os.renames = None
|
254
|
-
os.truncate = None
|
255
|
-
os.replace = None
|
256
|
-
os.unlink = None
|
257
|
-
os.fchmod = None
|
258
|
-
os.fchown = None
|
259
|
-
os.chmod = None
|
260
|
-
os.chown = None
|
261
|
-
os.chroot = None
|
262
|
-
os.fchdir = None
|
263
|
-
os.lchflags = None
|
264
|
-
os.lchmod = None
|
265
|
-
os.lchown = None
|
266
|
-
os.getcwd = None
|
267
|
-
os.chdir = None
|
268
|
-
|
269
|
-
import shutil
|
270
|
-
|
271
|
-
shutil.rmtree = None
|
272
|
-
shutil.move = None
|
273
|
-
shutil.chown = None
|
274
|
-
|
275
|
-
import subprocess
|
276
|
-
|
277
|
-
subprocess.Popen = None # type: ignore
|
278
|
-
|
279
|
-
__builtins__["help"] = None
|
280
|
-
|
281
|
-
import sys
|
282
|
-
|
283
|
-
sys.modules["ipdb"] = None
|
284
|
-
sys.modules["joblib"] = None
|
285
|
-
sys.modules["resource"] = None
|
286
|
-
sys.modules["psutil"] = None
|
287
|
-
sys.modules["tkinter"] = None
|
@@ -1,30 +0,0 @@
|
|
1
|
-
vision_agent/__init__.py,sha256=GVLHCeK_R-zgldpbcPmOzJat-BkadvkuRCMxDvTIcXs,108
|
2
|
-
vision_agent/agent/__init__.py,sha256=6AIN_lkqAz83dRN2WKpW7m1lQH1m-8BA2L-oUCFSKd4,163
|
3
|
-
vision_agent/agent/agent.py,sha256=X7kON-g9ePUKumCDaYfQNBX_MEFE-ax5PnRp7-Cc5Wo,529
|
4
|
-
vision_agent/agent/agent_coder.py,sha256=65ZEF3_K2aAG0vve-Q9xOPP9uw30_vVD2Li6NE6BFRY,6073
|
5
|
-
vision_agent/agent/agent_coder_prompts.py,sha256=CJe3v7xvHQ32u3RQAXQga_Tk_4UgU64RBAMHZ3S70KY,5538
|
6
|
-
vision_agent/agent/easytool.py,sha256=oMHnBg7YBtIPgqQUNcZgq7uMgpPThs99_UnO7ERkMVg,11511
|
7
|
-
vision_agent/agent/easytool_prompts.py,sha256=Bikw-PPLkm78dwywTlnv32Y1Tw6JMeC-R7oCnXWLcTk,4656
|
8
|
-
vision_agent/agent/execution.py,sha256=wX8LwXDq_0g_bTPikNiaW6nz5bUC7fUlNQsQHe_7Ww0,8582
|
9
|
-
vision_agent/agent/reflexion.py,sha256=4gz30BuFMeGxSsTzoDV4p91yE0R8LISXp28IaOI6wdM,10506
|
10
|
-
vision_agent/agent/reflexion_prompts.py,sha256=G7UAeNz_g2qCb2yN6OaIC7bQVUkda4m3z42EG8wAyfE,9342
|
11
|
-
vision_agent/agent/vision_agent.py,sha256=5W5Xr_h4yDMsFvIk2JWcfMlYoPYmTv3JZnrDDumuZgM,26842
|
12
|
-
vision_agent/agent/vision_agent_prompts.py,sha256=moihXFhEzFw8xnf2sUSgd_k9eoxQam3T6XUkB0fyp5o,8570
|
13
|
-
vision_agent/fonts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
14
|
-
vision_agent/fonts/default_font_ch_en.ttf,sha256=1YM0Z3XqLDjSNbF7ihQFSAIUdjF9m1rtHiNC_6QosTE,1594400
|
15
|
-
vision_agent/image_utils.py,sha256=1dggPBhW8_hUXDItCRLa23h-hdBwS50cjL4v1hsoUbg,7586
|
16
|
-
vision_agent/llm/__init__.py,sha256=BoUm_zSAKnLlE8s-gKTSQugXDqVZKPqYlWwlTLdhcz4,48
|
17
|
-
vision_agent/llm/llm.py,sha256=1BkrSVBWEClyqLc0Rmyw4heLhi_ZVm6JO7-i1wd1ziw,5383
|
18
|
-
vision_agent/lmm/__init__.py,sha256=nnNeKD1k7q_4vLb1x51O_EUTYaBgGfeiCx5F433gr3M,67
|
19
|
-
vision_agent/lmm/lmm.py,sha256=gK90vMxh0OcGSuIZQikBkDXm4pfkdFk1R2y7rtWDl84,10539
|
20
|
-
vision_agent/tools/__init__.py,sha256=uWySwcIeQMH57PVN6lVIknTx-SFmN_J0mvn_HbGlXcQ,451
|
21
|
-
vision_agent/tools/prompts.py,sha256=V1z4YJLXZuUl_iZ5rY0M5hHc_2tmMEUKr0WocXKGt4E,1430
|
22
|
-
vision_agent/tools/tool_utils.py,sha256=kY-hBDIrapI-030nZuasXU83P6X3GR0Y_gOR32bnedw,747
|
23
|
-
vision_agent/tools/tools.py,sha256=8JzNtn_uKTyc-bztjnaGCY7ctRnfW5dRS-ppxaP-1RE,46427
|
24
|
-
vision_agent/tools/tools_v2.py,sha256=RxeaBTTkhqvATQGuYKiopeU4L2m0GbpPo-ypDmQ9UfY,5407
|
25
|
-
vision_agent/tools/video.py,sha256=xTElFSFp1Jw4ulOMnk81Vxsh-9dTxcWUO6P9fzEi3AM,7653
|
26
|
-
vision_agent/type_defs.py,sha256=4LTnTL4HNsfYqCrDn9Ppjg9bSG2ZGcoKSSd9YeQf4Bw,1792
|
27
|
-
vision_agent-0.2.13.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
|
28
|
-
vision_agent-0.2.13.dist-info/METADATA,sha256=de1cx4IOvv_PK0XgFVdT0xzxejKweMug5xKAp3JwD24,9073
|
29
|
-
vision_agent-0.2.13.dist-info/WHEEL,sha256=7Z8_27uaHI_UZAc4Uox4PpBhQ9Y5_modZXWMxtUi4NU,88
|
30
|
-
vision_agent-0.2.13.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|