py-adtools 0.1.9__tar.gz → 0.1.10__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 py-adtools might be problematic. Click here for more details.
- {py_adtools-0.1.9 → py_adtools-0.1.10}/PKG-INFO +1 -1
- {py_adtools-0.1.9 → py_adtools-0.1.10}/adtools/evaluator.py +7 -4
- {py_adtools-0.1.9 → py_adtools-0.1.10}/adtools/lm/openai_api.py +3 -3
- {py_adtools-0.1.9 → py_adtools-0.1.10}/adtools/lm/vllm_server.py +1 -0
- {py_adtools-0.1.9 → py_adtools-0.1.10}/adtools/py_code.py +8 -5
- {py_adtools-0.1.9 → py_adtools-0.1.10}/py_adtools.egg-info/PKG-INFO +1 -1
- {py_adtools-0.1.9 → py_adtools-0.1.10}/setup.py +1 -1
- {py_adtools-0.1.9 → py_adtools-0.1.10}/LICENSE +0 -0
- {py_adtools-0.1.9 → py_adtools-0.1.10}/README.md +0 -0
- {py_adtools-0.1.9 → py_adtools-0.1.10}/adtools/__init__.py +0 -0
- {py_adtools-0.1.9 → py_adtools-0.1.10}/adtools/evaluator_pool.py +0 -0
- {py_adtools-0.1.9 → py_adtools-0.1.10}/adtools/lm/__init__.py +0 -0
- {py_adtools-0.1.9 → py_adtools-0.1.10}/adtools/lm/lm_base.py +0 -0
- {py_adtools-0.1.9 → py_adtools-0.1.10}/py_adtools.egg-info/SOURCES.txt +0 -0
- {py_adtools-0.1.9 → py_adtools-0.1.10}/py_adtools.egg-info/dependency_links.txt +0 -0
- {py_adtools-0.1.9 → py_adtools-0.1.10}/py_adtools.egg-info/requires.txt +0 -0
- {py_adtools-0.1.9 → py_adtools-0.1.10}/py_adtools.egg-info/top_level.txt +0 -0
- {py_adtools-0.1.9 → py_adtools-0.1.10}/setup.cfg +0 -0
|
@@ -160,10 +160,13 @@ class PyEvaluator(ABC):
|
|
|
160
160
|
with open(os.devnull, 'w') as devnull:
|
|
161
161
|
os.dup2(devnull.fileno(), sys.stdout.fileno())
|
|
162
162
|
os.dup2(devnull.fileno(), sys.stderr.fileno())
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
try:
|
|
164
|
+
# Evaluate and put the results to the queue
|
|
165
|
+
res = self.evaluate(program_str, **kwargs)
|
|
166
|
+
result_queue.put(res)
|
|
167
|
+
except:
|
|
168
|
+
traceback.print_exc()
|
|
169
|
+
result_queue.put(None)
|
|
167
170
|
|
|
168
171
|
def secure_evaluate(
|
|
169
172
|
self,
|
|
@@ -6,7 +6,7 @@ Commercial use of this software or its derivatives requires prior written permis
|
|
|
6
6
|
"""
|
|
7
7
|
|
|
8
8
|
import os
|
|
9
|
-
from typing import List
|
|
9
|
+
from typing import List, Optional
|
|
10
10
|
|
|
11
11
|
import openai.types.chat
|
|
12
12
|
|
|
@@ -46,8 +46,8 @@ class OpenAIAPI(LanguageModel):
|
|
|
46
46
|
def chat_completion(
|
|
47
47
|
self,
|
|
48
48
|
message: str | List[openai.types.chat.ChatCompletionMessageParam],
|
|
49
|
-
max_tokens: int,
|
|
50
|
-
timeout_seconds: float,
|
|
49
|
+
max_tokens: Optional[int] = None,
|
|
50
|
+
timeout_seconds: Optional[float] = None,
|
|
51
51
|
*args,
|
|
52
52
|
**kwargs
|
|
53
53
|
):
|
|
@@ -75,6 +75,7 @@ class VLLMServer(LanguageModel):
|
|
|
75
75
|
env_variable_dict: Environment variables to use for vLLM server, e.g., {'KEY': 'VALUE'}.
|
|
76
76
|
vllm_serve_args: Arguments to pass to vLLM server, e.g., ['--enable-reasoning'].
|
|
77
77
|
vllm_serve_kwargs: Keyword arguments to pass to vLLM server, e.g., {'--reasoning-parser': 'deepseek-r1'}.
|
|
78
|
+
chat_template_kwargs: Keyword arguments to pass to chat template, e.g., {'enable_thinking': False}.
|
|
78
79
|
|
|
79
80
|
Example:
|
|
80
81
|
# deploy a model on GPU 0 and 1
|
|
@@ -163,11 +163,14 @@ class PyProgram:
|
|
|
163
163
|
return program
|
|
164
164
|
|
|
165
165
|
@classmethod
|
|
166
|
-
def from_text(cls, text: str) -> 'PyProgram':
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
def from_text(cls, text: str) -> Optional['PyProgram']:
|
|
167
|
+
try:
|
|
168
|
+
tree = ast.parse(text)
|
|
169
|
+
visitor = _ProgramVisitor(text)
|
|
170
|
+
visitor.visit(tree)
|
|
171
|
+
return visitor.return_program()
|
|
172
|
+
except:
|
|
173
|
+
return None
|
|
171
174
|
|
|
172
175
|
|
|
173
176
|
class _ProgramVisitor(ast.NodeVisitor):
|
|
@@ -5,7 +5,7 @@ with open('README.md', 'r', encoding='utf-8') as fh:
|
|
|
5
5
|
|
|
6
6
|
setup(
|
|
7
7
|
name='py-adtools',
|
|
8
|
-
version='0.1.
|
|
8
|
+
version='0.1.10',
|
|
9
9
|
author='Rui Zhang',
|
|
10
10
|
author_email='rzhang.cs@gmail.com',
|
|
11
11
|
description='Useful tools for parsing and evaluating Python programs for LLM-based algorithm design.',
|
|
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
|