fleet-python 0.2.20__tar.gz → 0.2.21__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 fleet-python might be problematic. Click here for more details.
- {fleet_python-0.2.20 → fleet_python-0.2.21}/PKG-INFO +1 -1
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/dsl_example.py +2 -1
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/__init__.py +2 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/client.py +5 -3
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/instance/client.py +10 -1
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/client.py +5 -3
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/instance/client.py +12 -1
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/verifiers/__init__.py +2 -1
- fleet_python-0.2.21/fleet/verifiers/parse.py +143 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet_python.egg-info/PKG-INFO +1 -1
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet_python.egg-info/SOURCES.txt +1 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/pyproject.toml +1 -1
- {fleet_python-0.2.20 → fleet_python-0.2.21}/LICENSE +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/README.md +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/diff_example.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/example.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/example_action_log.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/example_client.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/example_mcp_anthropic.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/example_mcp_openai.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/example_sync.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/example_task.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/example_verifier.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/gemini_example.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/json_tasks_example.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/nova_act_example.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/openai_example.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/openai_simple_example.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/query_builder_example.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/examples/quickstart.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/__init__.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/base.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/env/__init__.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/env/client.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/exceptions.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/instance/__init__.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/instance/base.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/resources/__init__.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/resources/base.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/resources/browser.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/resources/sqlite.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/tasks.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/verifiers/__init__.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/verifiers/bundler.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/_async/verifiers/verifier.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/base.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/config.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/env/__init__.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/env/client.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/exceptions.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/instance/__init__.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/instance/base.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/instance/models.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/models.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/resources/__init__.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/resources/base.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/resources/browser.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/resources/mcp.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/resources/sqlite.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/tasks.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/types.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/verifiers/bundler.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/verifiers/code.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/verifiers/db.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/verifiers/decorator.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/verifiers/sql_differ.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet/verifiers/verifier.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet_python.egg-info/dependency_links.txt +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet_python.egg-info/requires.txt +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/fleet_python.egg-info/top_level.txt +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/scripts/fix_sync_imports.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/scripts/unasync.py +0 -0
- {fleet_python-0.2.20 → fleet_python-0.2.21}/setup.cfg +0 -0
|
@@ -68,7 +68,7 @@ def validate_new_deal_creation(
|
|
|
68
68
|
async def main():
|
|
69
69
|
# Create a new instance
|
|
70
70
|
print("Creating new Hubspot instance...")
|
|
71
|
-
env = await flt.env.make_async("hubspot
|
|
71
|
+
env = await flt.env.make_async("hubspot")
|
|
72
72
|
print(f"New Instance: {env.instance_id}")
|
|
73
73
|
|
|
74
74
|
try:
|
|
@@ -85,6 +85,7 @@ async def main():
|
|
|
85
85
|
print(f"Message: {response.message}")
|
|
86
86
|
|
|
87
87
|
# Get the database resource
|
|
88
|
+
await env.instance.load()
|
|
88
89
|
db = env.db()
|
|
89
90
|
|
|
90
91
|
# Take a snapshot before insertion
|
|
@@ -34,6 +34,7 @@ from .verifiers import (
|
|
|
34
34
|
DatabaseSnapshot,
|
|
35
35
|
IgnoreConfig,
|
|
36
36
|
SnapshotDiff,
|
|
37
|
+
TASK_FAILED_SCORE,
|
|
37
38
|
TASK_SUCCESSFUL_SCORE,
|
|
38
39
|
)
|
|
39
40
|
|
|
@@ -80,6 +81,7 @@ __all__ = [
|
|
|
80
81
|
"DatabaseSnapshot",
|
|
81
82
|
"IgnoreConfig",
|
|
82
83
|
"SnapshotDiff",
|
|
84
|
+
"TASK_FAILED_SCORE",
|
|
83
85
|
"TASK_SUCCESSFUL_SCORE",
|
|
84
86
|
# Environment module
|
|
85
87
|
"env",
|
|
@@ -109,7 +109,7 @@ class AsyncEnv(EnvironmentBase):
|
|
|
109
109
|
return await self.instance.verify(validator)
|
|
110
110
|
|
|
111
111
|
async def verify_raw(
|
|
112
|
-
self, function_code: str, function_name: str
|
|
112
|
+
self, function_code: str, function_name: str | None = None
|
|
113
113
|
) -> ExecuteFunctionResponse:
|
|
114
114
|
return await self.instance.verify_raw(function_code, function_name)
|
|
115
115
|
|
|
@@ -152,12 +152,14 @@ class AsyncEnv(EnvironmentBase):
|
|
|
152
152
|
class AsyncFleet:
|
|
153
153
|
def __init__(
|
|
154
154
|
self,
|
|
155
|
-
api_key: Optional[str] =
|
|
155
|
+
api_key: Optional[str] = None,
|
|
156
156
|
base_url: Optional[str] = None,
|
|
157
157
|
httpx_client: Optional[httpx.AsyncClient] = None,
|
|
158
158
|
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
159
159
|
timeout: float = DEFAULT_TIMEOUT,
|
|
160
160
|
):
|
|
161
|
+
if api_key is None:
|
|
162
|
+
api_key = os.getenv("FLEET_API_KEY")
|
|
161
163
|
self._httpx_client = httpx_client or default_httpx_client(max_retries, timeout)
|
|
162
164
|
self.client = AsyncWrapper(
|
|
163
165
|
api_key=api_key,
|
|
@@ -182,7 +184,7 @@ class AsyncFleet:
|
|
|
182
184
|
) -> AsyncEnv:
|
|
183
185
|
if ":" in env_key:
|
|
184
186
|
env_key_part, version = env_key.split(":", 1)
|
|
185
|
-
if not version.startswith("v"):
|
|
187
|
+
if not version.startswith("v") and len(version) != 0 and version[0].isdigit():
|
|
186
188
|
version = f"v{version}"
|
|
187
189
|
else:
|
|
188
190
|
env_key_part = env_key
|
|
@@ -12,6 +12,7 @@ from ..resources.browser import AsyncBrowserResource
|
|
|
12
12
|
from ..resources.base import Resource
|
|
13
13
|
|
|
14
14
|
from fleet.verifiers import DatabaseSnapshot
|
|
15
|
+
from fleet.verifiers.parse import convert_verifier_string, extract_function_name
|
|
15
16
|
|
|
16
17
|
from ..exceptions import FleetEnvironmentError
|
|
17
18
|
from ...config import DEFAULT_MAX_RETRIES, DEFAULT_TIMEOUT
|
|
@@ -107,8 +108,16 @@ class AsyncInstanceClient:
|
|
|
107
108
|
return await self.verify_raw(function_code, function_name)
|
|
108
109
|
|
|
109
110
|
async def verify_raw(
|
|
110
|
-
self, function_code: str, function_name: str
|
|
111
|
+
self, function_code: str, function_name: str | None = None
|
|
111
112
|
) -> ExecuteFunctionResponse:
|
|
113
|
+
try:
|
|
114
|
+
function_code = convert_verifier_string(function_code)
|
|
115
|
+
except:
|
|
116
|
+
pass
|
|
117
|
+
|
|
118
|
+
if function_name is None:
|
|
119
|
+
function_name = extract_function_name(function_code)
|
|
120
|
+
|
|
112
121
|
response = await self.client.request(
|
|
113
122
|
"POST",
|
|
114
123
|
"/execute_verifier_function",
|
|
@@ -227,7 +227,7 @@ class Environment(EnvironmentBase):
|
|
|
227
227
|
return self.instance.verify(validator)
|
|
228
228
|
|
|
229
229
|
def verify_raw(
|
|
230
|
-
self, function_code: str, function_name: str
|
|
230
|
+
self, function_code: str, function_name: str | None = None
|
|
231
231
|
) -> ExecuteFunctionResponse:
|
|
232
232
|
return self.instance.verify_raw(function_code, function_name)
|
|
233
233
|
|
|
@@ -384,12 +384,14 @@ class Environment(EnvironmentBase):
|
|
|
384
384
|
class Fleet:
|
|
385
385
|
def __init__(
|
|
386
386
|
self,
|
|
387
|
-
api_key: Optional[str] =
|
|
387
|
+
api_key: Optional[str] = None,
|
|
388
388
|
base_url: Optional[str] = None,
|
|
389
389
|
httpx_client: Optional[httpx.Client] = None,
|
|
390
390
|
max_retries: int = DEFAULT_MAX_RETRIES,
|
|
391
391
|
timeout: float = DEFAULT_TIMEOUT,
|
|
392
392
|
):
|
|
393
|
+
if api_key is None:
|
|
394
|
+
api_key = os.getenv("FLEET_API_KEY")
|
|
393
395
|
self._httpx_client = httpx_client or default_httpx_client(max_retries, timeout)
|
|
394
396
|
self.client = SyncWrapper(
|
|
395
397
|
api_key=api_key,
|
|
@@ -417,7 +419,7 @@ class Fleet:
|
|
|
417
419
|
) -> Environment:
|
|
418
420
|
if ":" in env_key:
|
|
419
421
|
env_key_part, version = env_key.split(":", 1)
|
|
420
|
-
if not version.startswith("v"):
|
|
422
|
+
if not version.startswith("v") and len(version) != 0 and version[0].isdigit():
|
|
421
423
|
version = f"v{version}"
|
|
422
424
|
else:
|
|
423
425
|
env_key_part = env_key
|
|
@@ -7,6 +7,8 @@ import time
|
|
|
7
7
|
import logging
|
|
8
8
|
from urllib.parse import urlparse
|
|
9
9
|
|
|
10
|
+
from fleet.verifiers.parse import convert_verifier_string, extract_function_name
|
|
11
|
+
|
|
10
12
|
from ..resources.sqlite import SQLiteResource
|
|
11
13
|
from ..resources.browser import BrowserResource
|
|
12
14
|
from ..resources.base import Resource
|
|
@@ -116,8 +118,17 @@ class InstanceClient:
|
|
|
116
118
|
return self.verify_raw(function_code, function_name)
|
|
117
119
|
|
|
118
120
|
def verify_raw(
|
|
119
|
-
self, function_code: str, function_name: str
|
|
121
|
+
self, function_code: str, function_name: str | None = None
|
|
120
122
|
) -> ExecuteFunctionResponse:
|
|
123
|
+
try:
|
|
124
|
+
function_code = convert_verifier_string(function_code)
|
|
125
|
+
except:
|
|
126
|
+
pass
|
|
127
|
+
|
|
128
|
+
# Extract function name if not provided
|
|
129
|
+
if function_name is None:
|
|
130
|
+
function_name = extract_function_name(function_code)
|
|
131
|
+
|
|
121
132
|
response = self.client.request(
|
|
122
133
|
"POST",
|
|
123
134
|
"/execute_verifier_function",
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Fleet verifiers module - database snapshot validation utilities and verifier decorator."""
|
|
2
2
|
|
|
3
3
|
from fleet.verifiers.db import DatabaseSnapshot, IgnoreConfig, SnapshotDiff
|
|
4
|
-
from fleet.verifiers.code import TASK_SUCCESSFUL_SCORE
|
|
4
|
+
from fleet.verifiers.code import TASK_SUCCESSFUL_SCORE, TASK_FAILED_SCORE
|
|
5
5
|
from .decorator import (
|
|
6
6
|
verifier,
|
|
7
7
|
SyncVerifierFunction,
|
|
@@ -12,6 +12,7 @@ __all__ = [
|
|
|
12
12
|
"IgnoreConfig",
|
|
13
13
|
"SnapshotDiff",
|
|
14
14
|
"TASK_SUCCESSFUL_SCORE",
|
|
15
|
+
"TASK_FAILED_SCORE",
|
|
15
16
|
"verifier",
|
|
16
17
|
"SyncVerifierFunction",
|
|
17
18
|
]
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import re
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def extract_function_name(function_code: str) -> str | None:
|
|
5
|
+
"""
|
|
6
|
+
Extract function name from Python function code.
|
|
7
|
+
|
|
8
|
+
Handles both regular functions (def) and async functions (async def).
|
|
9
|
+
|
|
10
|
+
Args:
|
|
11
|
+
function_code: Python function code as a string
|
|
12
|
+
|
|
13
|
+
Returns:
|
|
14
|
+
The function name if found, None otherwise
|
|
15
|
+
"""
|
|
16
|
+
# Pattern to match both def and async def functions
|
|
17
|
+
# Handles various formatting styles and type annotations
|
|
18
|
+
pattern = r'(?:async\s+)?def\s+(\w+)\s*\('
|
|
19
|
+
|
|
20
|
+
match = re.search(pattern, function_code)
|
|
21
|
+
if match:
|
|
22
|
+
return match.group(1)
|
|
23
|
+
|
|
24
|
+
return None
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def convert_verifier_string(verifier_str: str) -> str:
|
|
28
|
+
"""
|
|
29
|
+
Convert a verifier function string from the old format (env: Environment)
|
|
30
|
+
to the new format (before: DatabaseSnapshot, after: DatabaseSnapshot).
|
|
31
|
+
|
|
32
|
+
Args:
|
|
33
|
+
verifier_str: The original verifier function as a string
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
The converted verifier function string
|
|
37
|
+
"""
|
|
38
|
+
# First, handle escaped newlines in the input
|
|
39
|
+
verifier_str = verifier_str.replace('\\n', '\n')
|
|
40
|
+
|
|
41
|
+
# Extract function name, docstring, and body
|
|
42
|
+
# More flexible pattern that accepts both int and float return types
|
|
43
|
+
func_pattern = r'def\s+(\w+)\s*\(\s*env(?:\s*:\s*Environment)?\s*,?\s*final_answer(?:\s*:\s*str\s*\|\s*None)?\s*(?:=\s*None)?\s*\)\s*->\s*(?:float|int):\s*\n((?:\s*""".*?"""\s*\n)?)(.*)'
|
|
44
|
+
match = re.match(func_pattern, verifier_str.strip(), re.DOTALL)
|
|
45
|
+
|
|
46
|
+
if not match:
|
|
47
|
+
# Try with multiline pattern
|
|
48
|
+
func_pattern_multiline = r'def\s+(\w+)\s*\(\s*\n?\s*env(?:\s*:\s*Environment)?\s*,?\s*\n?\s*final_answer(?:\s*:\s*str\s*\|\s*None)?\s*(?:=\s*None)?\s*\n?\s*\)\s*->\s*(?:float|int):\s*\n((?:\s*""".*?"""\s*\n)?)(.*)'
|
|
49
|
+
match = re.match(func_pattern_multiline, verifier_str.strip(), re.DOTALL)
|
|
50
|
+
|
|
51
|
+
if not match:
|
|
52
|
+
raise ValueError("Could not parse verifier function. Expected format: def function_name(env: Environment, final_answer: str | None = None) -> float/int:")
|
|
53
|
+
|
|
54
|
+
func_name = match.group(1)
|
|
55
|
+
docstring = match.group(2).strip()
|
|
56
|
+
body = match.group(3)
|
|
57
|
+
|
|
58
|
+
# Find all unique env.db() calls
|
|
59
|
+
db_calls = re.findall(r'env\.db\("(\w+)"\)', body)
|
|
60
|
+
unique_db_names = list(dict.fromkeys(db_calls)) # Remove duplicates while preserving order
|
|
61
|
+
|
|
62
|
+
# Build the new function
|
|
63
|
+
new_func = f'''def {func_name}(
|
|
64
|
+
before: DatabaseSnapshot, after: DatabaseSnapshot, transcript: str | None = None
|
|
65
|
+
) -> int:
|
|
66
|
+
class Environment:
|
|
67
|
+
def db(self, name: str) -> DatabaseSnapshot:'''
|
|
68
|
+
|
|
69
|
+
# Build the db method based on found database names
|
|
70
|
+
if unique_db_names:
|
|
71
|
+
conditions = []
|
|
72
|
+
for db_name in unique_db_names:
|
|
73
|
+
if db_name == "seed":
|
|
74
|
+
conditions.append('before if name == "seed"')
|
|
75
|
+
elif db_name == "current":
|
|
76
|
+
conditions.append('after')
|
|
77
|
+
else:
|
|
78
|
+
# Handle other database names if needed
|
|
79
|
+
conditions.append(f'None # Handle "{db_name}"')
|
|
80
|
+
|
|
81
|
+
if len(conditions) == 2 and "seed" in unique_db_names and "current" in unique_db_names:
|
|
82
|
+
new_func += f'''
|
|
83
|
+
return before if name == "seed" else after'''
|
|
84
|
+
else:
|
|
85
|
+
# More complex mapping if needed
|
|
86
|
+
new_func += f'''
|
|
87
|
+
if name == "seed":
|
|
88
|
+
return before
|
|
89
|
+
elif name == "current":
|
|
90
|
+
return after
|
|
91
|
+
else:
|
|
92
|
+
raise ValueError(f"Unknown database name: {{name}}")'''
|
|
93
|
+
else:
|
|
94
|
+
new_func += '''
|
|
95
|
+
return before if name == "seed" else after'''
|
|
96
|
+
|
|
97
|
+
new_func += '''
|
|
98
|
+
|
|
99
|
+
@property
|
|
100
|
+
def instance(self):
|
|
101
|
+
return self
|
|
102
|
+
|
|
103
|
+
def load(self):
|
|
104
|
+
pass
|
|
105
|
+
|
|
106
|
+
def verifier(env: Environment, final_answer: str | None = None) -> float:'''
|
|
107
|
+
|
|
108
|
+
if docstring:
|
|
109
|
+
new_func += f'\n {docstring}'
|
|
110
|
+
|
|
111
|
+
# First, find the minimum indentation in the body (excluding empty lines)
|
|
112
|
+
body_lines = body.splitlines()
|
|
113
|
+
min_indent = float('inf')
|
|
114
|
+
for line in body_lines:
|
|
115
|
+
if line.strip(): # Non-empty line
|
|
116
|
+
indent_len = len(line) - len(line.lstrip())
|
|
117
|
+
min_indent = min(min_indent, indent_len)
|
|
118
|
+
|
|
119
|
+
# If we didn't find any non-empty lines, set min_indent to 0
|
|
120
|
+
if min_indent == float('inf'):
|
|
121
|
+
min_indent = 0
|
|
122
|
+
|
|
123
|
+
# Now strip the minimum indentation and re-indent to 8 spaces
|
|
124
|
+
if body_lines:
|
|
125
|
+
indented_lines = []
|
|
126
|
+
for line in body_lines:
|
|
127
|
+
if line.strip(): # Non-empty line
|
|
128
|
+
# Remove the minimum indentation and add 8 spaces
|
|
129
|
+
stripped_line = line[min_indent:] if len(line) > min_indent else line.lstrip()
|
|
130
|
+
indented_lines.append(' ' + stripped_line)
|
|
131
|
+
else: # Empty line
|
|
132
|
+
indented_lines.append('')
|
|
133
|
+
|
|
134
|
+
indented_body = '\n'.join(indented_lines)
|
|
135
|
+
new_func += f'\n{indented_body}'
|
|
136
|
+
|
|
137
|
+
# Add the return statement
|
|
138
|
+
new_func += '\n\n return verifier(Environment(), transcript)'
|
|
139
|
+
|
|
140
|
+
# Replace TASK_FAILED_SCORE with 0 in the function string
|
|
141
|
+
new_func = new_func.replace('TASK_FAILED_SCORE', '0')
|
|
142
|
+
|
|
143
|
+
return new_func
|
|
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
|
|
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
|