synth-ai 0.1.0.dev38__py3-none-any.whl → 0.1.0.dev49__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.
- synth_ai/__init__.py +3 -1
- {synth_ai-0.1.0.dev38.dist-info → synth_ai-0.1.0.dev49.dist-info}/METADATA +12 -11
- synth_ai-0.1.0.dev49.dist-info/RECORD +6 -0
- {synth_ai-0.1.0.dev38.dist-info → synth_ai-0.1.0.dev49.dist-info}/WHEEL +1 -1
- synth_ai-0.1.0.dev49.dist-info/top_level.txt +1 -0
- private_tests/try_synth_sdk.py +0 -1
- public_tests/test_agent.py +0 -538
- public_tests/test_all_structured_outputs.py +0 -196
- public_tests/test_anthropic_structured_outputs.py +0 -0
- public_tests/test_deepseek_structured_outputs.py +0 -0
- public_tests/test_deepseek_tools.py +0 -64
- public_tests/test_gemini_output.py +0 -188
- public_tests/test_gemini_structured_outputs.py +0 -106
- public_tests/test_models.py +0 -183
- public_tests/test_openai_structured_outputs.py +0 -106
- public_tests/test_reasoning_effort.py +0 -75
- public_tests/test_reasoning_models.py +0 -92
- public_tests/test_recursive_structured_outputs.py +0 -180
- public_tests/test_structured.py +0 -137
- public_tests/test_structured_outputs.py +0 -109
- public_tests/test_synth_sdk.py +0 -384
- public_tests/test_text.py +0 -160
- public_tests/test_tools.py +0 -319
- synth_ai/zyk/__init__.py +0 -3
- synth_ai/zyk/lms/__init__.py +0 -0
- synth_ai/zyk/lms/caching/__init__.py +0 -0
- synth_ai/zyk/lms/caching/constants.py +0 -1
- synth_ai/zyk/lms/caching/dbs.py +0 -0
- synth_ai/zyk/lms/caching/ephemeral.py +0 -72
- synth_ai/zyk/lms/caching/handler.py +0 -142
- synth_ai/zyk/lms/caching/initialize.py +0 -13
- synth_ai/zyk/lms/caching/persistent.py +0 -83
- synth_ai/zyk/lms/config.py +0 -8
- synth_ai/zyk/lms/core/__init__.py +0 -0
- synth_ai/zyk/lms/core/all.py +0 -47
- synth_ai/zyk/lms/core/exceptions.py +0 -9
- synth_ai/zyk/lms/core/main.py +0 -314
- synth_ai/zyk/lms/core/vendor_clients.py +0 -85
- synth_ai/zyk/lms/cost/__init__.py +0 -0
- synth_ai/zyk/lms/cost/monitor.py +0 -1
- synth_ai/zyk/lms/cost/statefulness.py +0 -1
- synth_ai/zyk/lms/structured_outputs/__init__.py +0 -0
- synth_ai/zyk/lms/structured_outputs/handler.py +0 -442
- synth_ai/zyk/lms/structured_outputs/inject.py +0 -314
- synth_ai/zyk/lms/structured_outputs/rehabilitate.py +0 -187
- synth_ai/zyk/lms/tools/base.py +0 -104
- synth_ai/zyk/lms/vendors/__init__.py +0 -0
- synth_ai/zyk/lms/vendors/base.py +0 -31
- synth_ai/zyk/lms/vendors/constants.py +0 -22
- synth_ai/zyk/lms/vendors/core/__init__.py +0 -0
- synth_ai/zyk/lms/vendors/core/anthropic_api.py +0 -413
- synth_ai/zyk/lms/vendors/core/gemini_api.py +0 -306
- synth_ai/zyk/lms/vendors/core/mistral_api.py +0 -327
- synth_ai/zyk/lms/vendors/core/openai_api.py +0 -185
- synth_ai/zyk/lms/vendors/local/__init__.py +0 -0
- synth_ai/zyk/lms/vendors/local/ollama.py +0 -0
- synth_ai/zyk/lms/vendors/openai_standard.py +0 -375
- synth_ai/zyk/lms/vendors/retries.py +0 -3
- synth_ai/zyk/lms/vendors/supported/__init__.py +0 -0
- synth_ai/zyk/lms/vendors/supported/deepseek.py +0 -73
- synth_ai/zyk/lms/vendors/supported/groq.py +0 -16
- synth_ai/zyk/lms/vendors/supported/ollama.py +0 -14
- synth_ai/zyk/lms/vendors/supported/together.py +0 -11
- synth_ai-0.1.0.dev38.dist-info/RECORD +0 -67
- synth_ai-0.1.0.dev38.dist-info/top_level.txt +0 -4
- tests/test_agent.py +0 -538
- tests/test_recursive_structured_outputs.py +0 -180
- tests/test_structured_outputs.py +0 -100
- {synth_ai-0.1.0.dev38.dist-info → synth_ai-0.1.0.dev49.dist-info}/licenses/LICENSE +0 -0
@@ -1,67 +0,0 @@
|
|
1
|
-
private_tests/try_synth_sdk.py,sha256=vk4lUEfpQfLACFl6Qw468t_lsuYxuoIIr05WRgWKGKY,24
|
2
|
-
public_tests/test_agent.py,sha256=OGmUsd-f0ZRL0xIwJ0MO_dPYQOshNdnmmESxfTSytDM,22552
|
3
|
-
public_tests/test_all_structured_outputs.py,sha256=bIcchimaVkq8q8D-GKO25d1_SauTFh4a0c3OEKh3_8o,6524
|
4
|
-
public_tests/test_anthropic_structured_outputs.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
5
|
-
public_tests/test_deepseek_structured_outputs.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
6
|
-
public_tests/test_deepseek_tools.py,sha256=MxEaiT_zinuMPeylqfNMsD11zRaMEwY0Fi28bg5op0A,1895
|
7
|
-
public_tests/test_gemini_output.py,sha256=704NCnxNepYjUxJj3eEms6zHRCps2PSaR8A-lcsQxb4,6062
|
8
|
-
public_tests/test_gemini_structured_outputs.py,sha256=yKa3CDVJxE_Vb2BbVROje83Pb35MBusF0Nb-ttWbqS8,4001
|
9
|
-
public_tests/test_models.py,sha256=QGevBfBuQzwyKw1ez34igDyJpMTBVOc3meW6yqFE-bM,5853
|
10
|
-
public_tests/test_openai_structured_outputs.py,sha256=oIhdZ2QVLmn0LaqBpCP3Qhbn2KHJv633DGn6u9Ousak,3999
|
11
|
-
public_tests/test_reasoning_effort.py,sha256=w4dIiEaEU8gnfAmjrpCC5y-c9w-eH9NzFjwUHe2deyg,3089
|
12
|
-
public_tests/test_reasoning_models.py,sha256=Vr4sFRYcrYOBAZMFz2a0fZQqa-WjRwbtwc6lXy6bF4I,2897
|
13
|
-
public_tests/test_recursive_structured_outputs.py,sha256=rrqzsU5ExNt-m_wu9j_fkbHiEsAtbKEK66uK5Ub2ojs,6296
|
14
|
-
public_tests/test_structured.py,sha256=rftVwvYgMSHkRZM1WUJzga5Uvl9hmc5OpXzBshEXNF0,3740
|
15
|
-
public_tests/test_structured_outputs.py,sha256=9SFpH4RQ6nRcphBVmELRNSvhRjYaJBu_z-r6xqKAYpg,4213
|
16
|
-
public_tests/test_synth_sdk.py,sha256=jqJHKpvBn9qj21P76z9onXfPg88jyUmBTKmdvCsQMk8,14885
|
17
|
-
public_tests/test_text.py,sha256=UyPZ0ci-XBjK35tAeV0kN1X8Njf-0pHfEPZhsWDZ0-c,4072
|
18
|
-
public_tests/test_tools.py,sha256=QBwJ70dmPCm27BEwbNaZXXAf8DJxObsfwFX1rlBcYME,10904
|
19
|
-
synth_ai/__init__.py,sha256=tX_fcK8u64BoPEboRa3dIKK_WpLy5KAxL2Ucl-l0xVg,147
|
20
|
-
synth_ai/zyk/__init__.py,sha256=kGMD-drlBVdsyT-QFODMwaZUtxPCJ9mg58GKQUvFqo0,134
|
21
|
-
synth_ai/zyk/lms/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
22
|
-
synth_ai/zyk/lms/config.py,sha256=CcN5NL99j0UZubyGo-MUfbPD3pWosAMju_sqgfvqLVY,201
|
23
|
-
synth_ai/zyk/lms/caching/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
24
|
-
synth_ai/zyk/lms/caching/constants.py,sha256=fPi3x9p-yRdvixMSIyclvmwmwCRliXLXQjEm6dRnG8s,52
|
25
|
-
synth_ai/zyk/lms/caching/dbs.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
26
|
-
synth_ai/zyk/lms/caching/ephemeral.py,sha256=pNMG5Rzzp2m0Ln1UYmWxz1qbXwq3iNIrhjYAS0yO3ZE,2370
|
27
|
-
synth_ai/zyk/lms/caching/handler.py,sha256=4h4Kywf0_-WohE1RxBt4cqPo-kHRjZv-2K50WWO91V4,5050
|
28
|
-
synth_ai/zyk/lms/caching/initialize.py,sha256=zZls6RKAax6Z-8oJInGaSg_RPN_fEZ6e_RCX64lMLJw,416
|
29
|
-
synth_ai/zyk/lms/caching/persistent.py,sha256=ZaY1A9qhvfNKzcAI9FnwbIrgMKvVeIfb_yCyl3M8dxE,2860
|
30
|
-
synth_ai/zyk/lms/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
31
|
-
synth_ai/zyk/lms/core/all.py,sha256=wakK0HhvYRuaQZmxClURyNf3vUkTbm3OABw3TgpMjOQ,1185
|
32
|
-
synth_ai/zyk/lms/core/exceptions.py,sha256=K0BVdAzxVIchsvYZAaHEH1GAWBZvpxhFi-SPcJOjyPQ,205
|
33
|
-
synth_ai/zyk/lms/core/main.py,sha256=NNPd4wwpgscFtCCrVPgz6gcrg7kOTSKsBFhldV0kwv0,12502
|
34
|
-
synth_ai/zyk/lms/core/vendor_clients.py,sha256=C4ICuczCG2yRpDbrraT0LUoaPFYytuetfJLqhgvGn8A,2785
|
35
|
-
synth_ai/zyk/lms/cost/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
36
|
-
synth_ai/zyk/lms/cost/monitor.py,sha256=cSKIvw6WdPZIRubADWxQoh1MdB40T8-jjgfNUeUHIn0,5
|
37
|
-
synth_ai/zyk/lms/cost/statefulness.py,sha256=TOsuXL8IjtKOYJ2aJQF8TwJVqn_wQ7AIwJJmdhMye7U,36
|
38
|
-
synth_ai/zyk/lms/structured_outputs/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
39
|
-
synth_ai/zyk/lms/structured_outputs/handler.py,sha256=Y7qQ8VReofLKDX6M7L5OXBUmTyHw6bWEfYz0jqvQIZ0,16969
|
40
|
-
synth_ai/zyk/lms/structured_outputs/inject.py,sha256=Fy-zDeleRxOZ8ZRM6IuZ6CP2XZnMe4K2PEn4Q9c_KPY,11777
|
41
|
-
synth_ai/zyk/lms/structured_outputs/rehabilitate.py,sha256=GuIhzsb7rTvwgn7f9I9omNnXBz5Me_qrtNYcTWzw5_U,7909
|
42
|
-
synth_ai/zyk/lms/tools/base.py,sha256=j7wYb1xAvaAm3qVrINphgUhGS-UjZmRpbouseQYgh7A,3228
|
43
|
-
synth_ai/zyk/lms/vendors/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
44
|
-
synth_ai/zyk/lms/vendors/base.py,sha256=aK4PEtkMLt_o3qD22kW-x3HJUEKdIk06zlH4kX0VkAE,760
|
45
|
-
synth_ai/zyk/lms/vendors/constants.py,sha256=3CCq45otD80yaLts5sFHvPgLCQNkcjHkc9cqOQ0zH4Y,320
|
46
|
-
synth_ai/zyk/lms/vendors/openai_standard.py,sha256=A8fRaazdaccFW24De2dDyiH2kdjhf9SAlQhLmAQuZjA,12934
|
47
|
-
synth_ai/zyk/lms/vendors/retries.py,sha256=m-WvAiPix9ovnO2S-m53Td5VZDWBVBFuHuSK9--OVxw,38
|
48
|
-
synth_ai/zyk/lms/vendors/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
49
|
-
synth_ai/zyk/lms/vendors/core/anthropic_api.py,sha256=cgSPFgR9YM8eO1if92fch6pVv0Dxk3xigSXExGSdu-4,15329
|
50
|
-
synth_ai/zyk/lms/vendors/core/gemini_api.py,sha256=gsWudX1RP2a4mjuyWZXT3LUek-UMUYhCfE5TMYxp0nA,11530
|
51
|
-
synth_ai/zyk/lms/vendors/core/mistral_api.py,sha256=-EMPBEIoYxxDMxukmcmKL8AGAHPNYe4w-76gsPtmrhk,11860
|
52
|
-
synth_ai/zyk/lms/vendors/core/openai_api.py,sha256=GDCHIc0kpCnNPj2oW8RE3Cj2U_HcbXzzA5JV1ArAQlE,6600
|
53
|
-
synth_ai/zyk/lms/vendors/local/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
54
|
-
synth_ai/zyk/lms/vendors/local/ollama.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
55
|
-
synth_ai/zyk/lms/vendors/supported/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
56
|
-
synth_ai/zyk/lms/vendors/supported/deepseek.py,sha256=BElW0NGpkSA62wOqzzMtDw8XR36rSNXK5LldeHJkQrc,2430
|
57
|
-
synth_ai/zyk/lms/vendors/supported/groq.py,sha256=Fbi7QvhdLx0F-VHO5PY-uIQlPR0bo3C9h1MvIOx8nz0,388
|
58
|
-
synth_ai/zyk/lms/vendors/supported/ollama.py,sha256=K30VBFRTd7NYyPmyBVRZS2sm0UB651AHp9i3wd55W64,469
|
59
|
-
synth_ai/zyk/lms/vendors/supported/together.py,sha256=Ni_jBqqGPN0PkkY-Ew64s3gNKk51k3FCpLSwlNhKbf0,342
|
60
|
-
synth_ai-0.1.0.dev38.dist-info/licenses/LICENSE,sha256=ynhjRQUfqA_RdGRATApfFA_fBAy9cno04sLtLUqxVFM,1069
|
61
|
-
tests/test_agent.py,sha256=CjPPWuMWC_TzX1DkDald-bbAxgjXE-HPQvFhq2B--5k,22363
|
62
|
-
tests/test_recursive_structured_outputs.py,sha256=Ne-9XwnOxN7eSpGbNHOpegR-sRj589I84T6y8Z_4QnA,5781
|
63
|
-
tests/test_structured_outputs.py,sha256=J7sfbGZ7OeB5ONIKpcCTymyayNyAdFfGokC1bcUrSx0,3651
|
64
|
-
synth_ai-0.1.0.dev38.dist-info/METADATA,sha256=JHm6Ol6dT8wqnCf-Iq3dQJFxII1oFAMFHDkJY9tDm4o,2702
|
65
|
-
synth_ai-0.1.0.dev38.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
|
66
|
-
synth_ai-0.1.0.dev38.dist-info/top_level.txt,sha256=5GzJO9j-KbJ_4ppxhmCUa_qdhHM4-9cHHNU76yAI8do,42
|
67
|
-
synth_ai-0.1.0.dev38.dist-info/RECORD,,
|
tests/test_agent.py
DELETED
@@ -1,538 +0,0 @@
|
|
1
|
-
import unittest
|
2
|
-
from typing import List, Union
|
3
|
-
|
4
|
-
from pydantic import BaseModel
|
5
|
-
|
6
|
-
from synth_ai.zyk.lms.core.main import LM
|
7
|
-
|
8
|
-
|
9
|
-
class UnitTestDict(BaseModel):
|
10
|
-
test_description: str
|
11
|
-
input_names: List[str]
|
12
|
-
input_types: List[str]
|
13
|
-
stringified_input_values: List[str]
|
14
|
-
assertion_condition: str
|
15
|
-
assertion_type: str # Consider using Literal for specific assertion types
|
16
|
-
|
17
|
-
|
18
|
-
class ActionArgument(BaseModel):
|
19
|
-
key: str
|
20
|
-
value: Union[str, int, float, bool, UnitTestDict]
|
21
|
-
|
22
|
-
|
23
|
-
class ReAct(BaseModel):
|
24
|
-
reasoning: str
|
25
|
-
action_name: str
|
26
|
-
action_args: List[ActionArgument] # Dict#[str, Dict]
|
27
|
-
|
28
|
-
|
29
|
-
system = """
|
30
|
-
<System Message>
|
31
|
-
# Premise
|
32
|
-
You are a software engineer
|
33
|
-
Here is some information about this setting
|
34
|
-
<Setting Information>
|
35
|
-
You are working to solve a computer science problem. You will need to submit a solution to the problem, which will be tested against a suite of hidden unit tests.
|
36
|
-
</Setting Information>
|
37
|
-
<Actions Available>
|
38
|
-
<edit_submission>
|
39
|
-
<action_context>
|
40
|
-
Edit the submission code. Use this when you want to make changes to the current solution.
|
41
|
-
</action_context>
|
42
|
-
<action_arg_spec>
|
43
|
-
{'first_line': <class 'int'>, 'last_line': <class 'int'>, 'new_code': <class 'str'>}
|
44
|
-
</action_arg_spec>
|
45
|
-
<action_description>
|
46
|
-
Edit the submission code
|
47
|
-
</action_description>
|
48
|
-
|
49
|
-
</edit_submission>
|
50
|
-
<add_submission>
|
51
|
-
<action_context>
|
52
|
-
Add the submission code. Use this when you want to start from scratch with a new solution.
|
53
|
-
</action_context>
|
54
|
-
<action_arg_spec>
|
55
|
-
{'submission': <class 'str'>}
|
56
|
-
</action_arg_spec>
|
57
|
-
<action_description>
|
58
|
-
Add the submission code
|
59
|
-
</action_description>
|
60
|
-
|
61
|
-
</add_submission>
|
62
|
-
<add_unit_test>
|
63
|
-
<action_context>
|
64
|
-
Add a unit test. The unit test information you submit must be in the format of a BCBUnitTest:
|
65
|
-
|
66
|
-
class BCBUnitTest(BaseModel):
|
67
|
-
test_description: str
|
68
|
-
input_names: List[str]
|
69
|
-
input_types: List[str]
|
70
|
-
input_values: List[Any]
|
71
|
-
assertion_condition: str
|
72
|
-
assertion_type: Literal["assertTrue", "assertRaises"] = "assertTrue"
|
73
|
-
|
74
|
-
|
75
|
-
It will be parsed via BCBUnitTest(**unit_test_dict)
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
# Some various notes:
|
80
|
-
1. If an input should be of a type defined by a specific package, add the package name/alias to the type. E.g. "np.ndarray" or "pd.DataFrame". You still should fully define the value for the input_value field e.g. "pd.DataFrame({'a': [1, 2, 3]})"
|
81
|
-
|
82
|
-
2. Unit tests will be compiled from the BCBUnitTest class as follows:
|
83
|
-
A. For AssertTrue type tests, the test will be compiled as follows:
|
84
|
-
```python
|
85
|
-
def test_case(self):
|
86
|
-
# {{self.test_description}}
|
87
|
-
|
88
|
-
{{defs}}
|
89
|
-
result = {{function_name}}(**{{{{args}}}}})
|
90
|
-
self.{{self.assertion_type}}({{self.assertion_condition}})
|
91
|
-
```
|
92
|
-
B. For AssertRaises type tests, the test will be compiled as follows:
|
93
|
-
|
94
|
-
```python
|
95
|
-
def test_case(self):
|
96
|
-
# {{self.test_description}}
|
97
|
-
{{defs}}
|
98
|
-
with self.{{self.assertion_type}}({{self.assertion_condition}}):
|
99
|
-
{{function_name}}(**{{{{args}}}}})
|
100
|
-
```
|
101
|
-
|
102
|
-
Provide information accordingly.
|
103
|
-
|
104
|
-
</action_context>
|
105
|
-
<action_arg_spec>
|
106
|
-
{'unit_test_name': <class 'str'>, 'unit_test_dict': typing.Dict}
|
107
|
-
</action_arg_spec>
|
108
|
-
<action_description>
|
109
|
-
Add a unit test
|
110
|
-
</action_description>
|
111
|
-
|
112
|
-
</add_unit_test>
|
113
|
-
<remove_unit_test>
|
114
|
-
<action_context>
|
115
|
-
Remove a unit test
|
116
|
-
</action_context>
|
117
|
-
<action_arg_spec>
|
118
|
-
{'unit_test_name': <class 'str'>}
|
119
|
-
</action_arg_spec>
|
120
|
-
<action_description>
|
121
|
-
Remove a unit test
|
122
|
-
</action_description>
|
123
|
-
|
124
|
-
</remove_unit_test>
|
125
|
-
<test_submission>
|
126
|
-
<action_context>
|
127
|
-
Test the submission
|
128
|
-
</action_context>
|
129
|
-
<action_arg_spec>
|
130
|
-
{}
|
131
|
-
</action_arg_spec>
|
132
|
-
<action_description>
|
133
|
-
Test the submission
|
134
|
-
</action_description>
|
135
|
-
|
136
|
-
</test_submission>
|
137
|
-
<submit_solution>
|
138
|
-
<action_context>
|
139
|
-
Submit the solution
|
140
|
-
</action_context>
|
141
|
-
<action_arg_spec>
|
142
|
-
{}
|
143
|
-
</action_arg_spec>
|
144
|
-
<action_description>
|
145
|
-
Submit the solution
|
146
|
-
</action_description>
|
147
|
-
|
148
|
-
</submit_solution>
|
149
|
-
|
150
|
-
</Actions Available>
|
151
|
-
You'll be given your past actions/thoughts, along with recent raw observations from the environment
|
152
|
-
The environment one step in the past is your current environment.
|
153
|
-
|
154
|
-
# Objective
|
155
|
-
Please complete the problem by drafting a solution, creating unit tests, improving the solution, and submitting the solution.
|
156
|
-
|
157
|
-
# Constraints
|
158
|
-
You will be given a code_prompt_for_answer, which contains imports and the function signature. Your solution must comprise code that can be appended to code_prompt_for_answer and run as a single script.
|
159
|
-
|
160
|
-
"""
|
161
|
-
|
162
|
-
user = """
|
163
|
-
<User Message>
|
164
|
-
# Recent Actions / Thoughts
|
165
|
-
|
166
|
-
# Recent Observations
|
167
|
-
<1 environment step(s) in the past>{'action_result': None, 'environment_state': {'question': 'import pandas as pd\nimport numpy as np\n\n# Constants\nCOLUMNS = [\'column1\', \'column2\', \'column3\', \'column4\', \'column5\']\n\ndef task_func(df, dct):\n '''\n Replace certain values in a DataFrame with a dictionary mapping and calculate the Pearson correlation coefficient between each pair of columns.\n\n Parameters:\n df (DataFrame): The input DataFrame, containing numeric or categorical data.\n dct (dict): A dictionary for replacing values in df, where keys are existing values and values are new values.\n\n Returns:\n DataFrame: A DataFrame with the correlation coefficients between each pair of columns. The format of the DataFrame is a square matrix with column and index labels matching the columns of the input DataFrame.\n \n Requirements:\n - pandas\n - numpy\n \n Note:\n - This function operates on DataFrames containing numeric or categorical data that can be replaced with numeric values, as correlation calculations require numeric data.\n - This function using pearson method to calculate the correlation matrix.\n \n Raises:\n - This function will raise a ValueError is input df is not a DataFrame.\n \n Example:\n >>> df = pd.DataFrame({\'A\': [1, 2, 3], \'B\': [4, 5, 6]})\n >>> dct = {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}\n >>> correlation_matrix = task_func(df, dct)\n >>> correlation_matrix.shape == (2, 2)\n True\n >>> np.allclose(correlation_matrix, np.array([[1.0, 1.0], [1.0, 1.0]]))\n True\n '''\n', 'code_prompt_for_answer': "import pandas as pd\nimport numpy as np\n# Constants\nCOLUMNS = ['column1', 'column2', 'column3', 'column4', 'column5']\ndef task_func(df, dct):\n", 'unit_tests_you_have_written': {}, 'current_solution': ''}}</1 environment step(s) in the past>
|
168
|
-
|
169
|
-
Your next actions / thought:
|
170
|
-
"""
|
171
|
-
|
172
|
-
|
173
|
-
###
|
174
|
-
|
175
|
-
hard_system = """
|
176
|
-
# Premise
|
177
|
-
You are a software engineer
|
178
|
-
Here is some information about this setting
|
179
|
-
<Setting Information>
|
180
|
-
You are working to solve a computer science problem. You will need to submit a solution to the problem, which will be tested against a suite of hidden unit tests.
|
181
|
-
</Setting Information>
|
182
|
-
<Actions Available>
|
183
|
-
<edit_submission>
|
184
|
-
<action_context>
|
185
|
-
Edit the submission code. Use this when you want to make changes to the current solution.
|
186
|
-
</action_context>
|
187
|
-
<action_arg_spec>
|
188
|
-
{'first_line': <class 'int'>, 'last_line': <class 'int'>, 'new_code': <class 'str'>}
|
189
|
-
</action_arg_spec>
|
190
|
-
<action_description>
|
191
|
-
Edit the submission code
|
192
|
-
</action_description>
|
193
|
-
|
194
|
-
</edit_submission>
|
195
|
-
<add_submission>
|
196
|
-
<action_context>
|
197
|
-
Add the submission code. Use this when you want to start from scratch with a new solution.
|
198
|
-
</action_context>
|
199
|
-
<action_arg_spec>
|
200
|
-
{'submission': <class 'str'>}
|
201
|
-
</action_arg_spec>
|
202
|
-
<action_description>
|
203
|
-
Add the submission code
|
204
|
-
</action_description>
|
205
|
-
|
206
|
-
</add_submission>
|
207
|
-
<add_unit_test>
|
208
|
-
<action_context>
|
209
|
-
Add a unit test. The unit test information you submit must be in the format of a BCBUnitTest:
|
210
|
-
|
211
|
-
class BCBUnitTest(BaseModel):
|
212
|
-
test_description: str
|
213
|
-
input_names: List[str]
|
214
|
-
input_types: List[str]
|
215
|
-
input_values: List[Any]
|
216
|
-
assertion_condition: str
|
217
|
-
assertion_type: Literal["assertTrue", "assertRaises"] = "assertTrue"
|
218
|
-
|
219
|
-
|
220
|
-
It will be parsed via BCBUnitTest(**unit_test_dict)
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
# Some various notes:
|
225
|
-
1. If an input should be of a type defined by a specific package, add the package name/alias to the type. E.g. "np.ndarray" or "pd.DataFrame". You still should fully define the value for the input_value field e.g. "pd.DataFrame({'a': [1, 2, 3]})"
|
226
|
-
|
227
|
-
2. Unit tests will be compiled from the BCBUnitTest class as follows:
|
228
|
-
A. For AssertTrue type tests, the test will be compiled as follows:
|
229
|
-
```python
|
230
|
-
def test_case(self):
|
231
|
-
# {{self.test_description}}
|
232
|
-
|
233
|
-
{{defs}}
|
234
|
-
result = {{function_name}}(**{{{{args}}}}})
|
235
|
-
self.{{self.assertion_type}}({{self.assertion_condition}})
|
236
|
-
```
|
237
|
-
B. For AssertRaises type tests, the test will be compiled as follows:
|
238
|
-
|
239
|
-
```python
|
240
|
-
def test_case(self):
|
241
|
-
# {{self.test_description}}
|
242
|
-
{{defs}}
|
243
|
-
with self.{{self.assertion_type}}({{self.assertion_condition}}):
|
244
|
-
{{function_name}}(**{{{{args}}}}})
|
245
|
-
```
|
246
|
-
|
247
|
-
Provide information accordingly.
|
248
|
-
|
249
|
-
</action_context>
|
250
|
-
<action_arg_spec>
|
251
|
-
{'unit_test_name': <class 'str'>, 'unit_test_dict': typing.Dict}
|
252
|
-
</action_arg_spec>
|
253
|
-
<action_description>
|
254
|
-
Add a unit test
|
255
|
-
</action_description>
|
256
|
-
|
257
|
-
</add_unit_test>
|
258
|
-
<remove_unit_test>
|
259
|
-
<action_context>
|
260
|
-
Remove a unit test
|
261
|
-
</action_context>
|
262
|
-
<action_arg_spec>
|
263
|
-
{'unit_test_name': <class 'str'>}
|
264
|
-
</action_arg_spec>
|
265
|
-
<action_description>
|
266
|
-
Remove a unit test
|
267
|
-
</action_description>
|
268
|
-
|
269
|
-
</remove_unit_test>
|
270
|
-
<test_submission>
|
271
|
-
<action_context>
|
272
|
-
Test the submission
|
273
|
-
</action_context>
|
274
|
-
<action_arg_spec>
|
275
|
-
{}
|
276
|
-
</action_arg_spec>
|
277
|
-
<action_description>
|
278
|
-
Test the submission
|
279
|
-
</action_description>
|
280
|
-
|
281
|
-
</test_submission>
|
282
|
-
<submit_solution>
|
283
|
-
<action_context>
|
284
|
-
Submit the solution
|
285
|
-
</action_context>
|
286
|
-
<action_arg_spec>
|
287
|
-
{}
|
288
|
-
</action_arg_spec>
|
289
|
-
<action_description>
|
290
|
-
Submit the solution
|
291
|
-
</action_description>
|
292
|
-
|
293
|
-
</submit_solution>
|
294
|
-
|
295
|
-
</Actions Available>
|
296
|
-
You'll be given your past actions/thoughts, along with recent raw observations from the environment
|
297
|
-
The environment one step in the past is your current environment.
|
298
|
-
|
299
|
-
# Objective
|
300
|
-
Please complete the problem by drafting a solution, creating unit tests, improving the solution, and submitting the solution.
|
301
|
-
|
302
|
-
# Constraints
|
303
|
-
You will be given a code_prompt_for_answer, which contains imports and the function signature. Your solution must comprise code that can be appended to code_prompt_for_answer and run as a single script.
|
304
|
-
|
305
|
-
|
306
|
-
<User Message>
|
307
|
-
# Recent Actions / Thoughts
|
308
|
-
|
309
|
-
# Recent Observations
|
310
|
-
<1 environment step(s) in the past>{'action_result': None, 'environment_state': {'question': 'import pandas as pd\nimport numpy as np\n\n# Constants\nCOLUMNS = [\'column1\', \'column2\', \'column3\', \'column4\', \'column5\']\n\ndef task_func(df, dct):\n '''\n Replace certain values in a DataFrame with a dictionary mapping and calculate the Pearson correlation coefficient between each pair of columns.\n\n Parameters:\n df (DataFrame): The input DataFrame, containing numeric or categorical data.\n dct (dict): A dictionary for replacing values in df, where keys are existing values and values are new values.\n\n Returns:\n DataFrame: A DataFrame with the correlation coefficients between each pair of columns. The format of the DataFrame is a square matrix with column and index labels matching the columns of the input DataFrame.\n \n Requirements:\n - pandas\n - numpy\n \n Note:\n - This function operates on DataFrames containing numeric or categorical data that can be replaced with numeric values, as correlation calculations require numeric data.\n - This function using pearson method to calculate the correlation matrix.\n \n Raises:\n - This function will raise a ValueError is input df is not a DataFrame.\n \n Example:\n >>> df = pd.DataFrame({\'A\': [1, 2, 3], \'B\': [4, 5, 6]})\n >>> dct = {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}\n >>> correlation_matrix = task_func(df, dct)\n >>> correlation_matrix.shape == (2, 2)\n True\n >>> np.allclose(correlation_matrix, np.array([[1.0, 1.0], [1.0, 1.0]]))\n True\n '''\n', 'code_prompt_for_answer': "import pandas as pd\nimport numpy as np\n# Constants\nCOLUMNS = ['column1', 'column2', 'column3', 'column4', 'column5']\ndef task_func(df, dct):\n", 'unit_tests_you_have_written': {}, 'current_solution': ''}}</1 environment step(s) in the past>
|
311
|
-
|
312
|
-
Your next actions / thought:
|
313
|
-
|
314
|
-
Structured output: reasoning="I need to implement the function 'task_func' that replaces values in a DataFrame based on a dictionary and calculates the Pearson correlation coefficient between the columns. I will also ensure to handle the case where the input is not a DataFrame by raising a ValueError." action_name='edit_submission' action_args=[ActionArgument(key='first_line', value=4), ActionArgument(key='last_line', value=4), ActionArgument(key='new_code', value=" if not isinstance(df, pd.DataFrame):\n raise ValueError('Input must be a DataFrame')\n df.replace(dct, inplace=True)\n return df.corr(method='pearson')")]
|
315
|
-
<System Message>
|
316
|
-
# Premise
|
317
|
-
You are a software engineer
|
318
|
-
Here is some information about this setting
|
319
|
-
<Setting Information>
|
320
|
-
You are working to solve a computer science problem. You will need to submit a solution to the problem, which will be tested against a suite of hidden unit tests.
|
321
|
-
</Setting Information>
|
322
|
-
<Actions Available>
|
323
|
-
<edit_submission>
|
324
|
-
<action_context>
|
325
|
-
Edit the submission code. Use this when you want to make changes to the current solution.
|
326
|
-
</action_context>
|
327
|
-
<action_arg_spec>
|
328
|
-
{'first_line': <class 'int'>, 'last_line': <class 'int'>, 'new_code': <class 'str'>}
|
329
|
-
</action_arg_spec>
|
330
|
-
<action_description>
|
331
|
-
Edit the submission code
|
332
|
-
</action_description>
|
333
|
-
|
334
|
-
</edit_submission>
|
335
|
-
<add_submission>
|
336
|
-
<action_context>
|
337
|
-
Add the submission code. Use this when you want to start from scratch with a new solution.
|
338
|
-
</action_context>
|
339
|
-
<action_arg_spec>
|
340
|
-
{'submission': <class 'str'>}
|
341
|
-
</action_arg_spec>
|
342
|
-
<action_description>
|
343
|
-
Add the submission code
|
344
|
-
</action_description>
|
345
|
-
|
346
|
-
</add_submission>
|
347
|
-
<add_unit_test>
|
348
|
-
<action_context>
|
349
|
-
Add a unit test. The unit test information you submit must be in the format of a BCBUnitTest:
|
350
|
-
|
351
|
-
class BCBUnitTest(BaseModel):
|
352
|
-
test_description: str
|
353
|
-
input_names: List[str]
|
354
|
-
input_types: List[str]
|
355
|
-
input_values: List[Any]
|
356
|
-
assertion_condition: str
|
357
|
-
assertion_type: Literal["assertTrue", "assertRaises"] = "assertTrue"
|
358
|
-
|
359
|
-
|
360
|
-
It will be parsed via BCBUnitTest(**unit_test_dict)
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
# Some various notes:
|
365
|
-
1. If an input should be of a type defined by a specific package, add the package name/alias to the type. E.g. "np.ndarray" or "pd.DataFrame". You still should fully define the value for the input_value field e.g. "pd.DataFrame({'a': [1, 2, 3]})"
|
366
|
-
|
367
|
-
2. Unit tests will be compiled from the BCBUnitTest class as follows:
|
368
|
-
A. For AssertTrue type tests, the test will be compiled as follows:
|
369
|
-
```python
|
370
|
-
def test_case(self):
|
371
|
-
# {{self.test_description}}
|
372
|
-
|
373
|
-
{{defs}}
|
374
|
-
result = {{function_name}}(**{{{{args}}}}})
|
375
|
-
self.{{self.assertion_type}}({{self.assertion_condition}})
|
376
|
-
```
|
377
|
-
B. For AssertRaises type tests, the test will be compiled as follows:
|
378
|
-
|
379
|
-
```python
|
380
|
-
def test_case(self):
|
381
|
-
# {{self.test_description}}
|
382
|
-
{{defs}}
|
383
|
-
with self.{{self.assertion_type}}({{self.assertion_condition}}):
|
384
|
-
{{function_name}}(**{{{{args}}}}})
|
385
|
-
```
|
386
|
-
|
387
|
-
Provide information accordingly.
|
388
|
-
|
389
|
-
</action_context>
|
390
|
-
<action_arg_spec>
|
391
|
-
{'unit_test_name': <class 'str'>, 'unit_test_dict': typing.Dict}
|
392
|
-
</action_arg_spec>
|
393
|
-
<action_description>
|
394
|
-
Add a unit test
|
395
|
-
</action_description>
|
396
|
-
|
397
|
-
</add_unit_test>
|
398
|
-
<remove_unit_test>
|
399
|
-
<action_context>
|
400
|
-
Remove a unit test
|
401
|
-
</action_context>
|
402
|
-
<action_arg_spec>
|
403
|
-
{'unit_test_name': <class 'str'>}
|
404
|
-
</action_arg_spec>
|
405
|
-
<action_description>
|
406
|
-
Remove a unit test
|
407
|
-
</action_description>
|
408
|
-
|
409
|
-
</remove_unit_test>
|
410
|
-
<test_submission>
|
411
|
-
<action_context>
|
412
|
-
Test the submission
|
413
|
-
</action_context>
|
414
|
-
<action_arg_spec>
|
415
|
-
{}
|
416
|
-
</action_arg_spec>
|
417
|
-
<action_description>
|
418
|
-
Test the submission
|
419
|
-
</action_description>
|
420
|
-
|
421
|
-
</test_submission>
|
422
|
-
<submit_solution>
|
423
|
-
<action_context>
|
424
|
-
Submit the solution
|
425
|
-
</action_context>
|
426
|
-
<action_arg_spec>
|
427
|
-
{}
|
428
|
-
</action_arg_spec>
|
429
|
-
<action_description>
|
430
|
-
Submit the solution
|
431
|
-
</action_description>
|
432
|
-
|
433
|
-
</submit_solution>
|
434
|
-
|
435
|
-
</Actions Available>
|
436
|
-
You'll be given your past actions/thoughts, along with recent raw observations from the environment
|
437
|
-
The environment one step in the past is your current environment.
|
438
|
-
|
439
|
-
# Objective
|
440
|
-
Please complete the problem by drafting a solution, creating unit tests, improving the solution, and submitting the solution.
|
441
|
-
|
442
|
-
# Constraints
|
443
|
-
You will be given a code_prompt_for_answer, which contains imports and the function signature. Your solution must comprise code that can be appended to code_prompt_for_answer and run as a single script.
|
444
|
-
"""
|
445
|
-
|
446
|
-
hard_user = """
|
447
|
-
# Recent Actions / Thoughts
|
448
|
-
<1 reasoning step(s) in the past>reasoning="I need to implement the function 'task_func' that replaces values in a DataFrame based on a dictionary and calculates the Pearson correlation coefficient between the columns. I will also ensure to handle the case where the input is not a DataFrame by raising a ValueError." action_name='edit_submission' action_args=[ActionArgument(key='first_line', value=4), ActionArgument(key='last_line', value=4), ActionArgument(key='new_code', value=" if not isinstance(df, pd.DataFrame):\n raise ValueError('Input must be a DataFrame')\n df.replace(dct, inplace=True)\n return df.corr(method='pearson')")]</1 reasoning step(s) in the past>
|
449
|
-
# Recent Observations
|
450
|
-
<1 environment step(s) in the past>success=True result='Edited submission successfully'</1 environment step(s) in the past>
|
451
|
-
<2 environment step(s) in the past>{'action_result': None, 'environment_state': {'question': 'import pandas as pd\nimport numpy as np\n\n# Constants\nCOLUMNS = [\'column1\', \'column2\', \'column3\', \'column4\', \'column5\']\n\ndef task_func(df, dct):\n '''\n Replace certain values in a DataFrame with a dictionary mapping and calculate the Pearson correlation coefficient between each pair of columns.\n\n Parameters:\n df (DataFrame): The input DataFrame, containing numeric or categorical data.\n dct (dict): A dictionary for replacing values in df, where keys are existing values and values are new values.\n\n Returns:\n DataFrame: A DataFrame with the correlation coefficients between each pair of columns. The format of the DataFrame is a square matrix with column and index labels matching the columns of the input DataFrame.\n \n Requirements:\n - pandas\n - numpy\n \n Note:\n - This function operates on DataFrames containing numeric or categorical data that can be replaced with numeric values, as correlation calculations require numeric data.\n - This function using pearson method to calculate the correlation matrix.\n \n Raises:\n - This function will raise a ValueError is input df is not a DataFrame.\n \n Example:\n >>> df = pd.DataFrame({\'A\': [1, 2, 3], \'B\': [4, 5, 6]})\n >>> dct = {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}\n >>> correlation_matrix = task_func(df, dct)\n >>> correlation_matrix.shape == (2, 2)\n True\n >>> np.allclose(correlation_matrix, np.array([[1.0, 1.0], [1.0, 1.0]]))\n True\n '''\n', 'code_prompt_for_answer': "import pandas as pd\nimport numpy as np\n# Constants\nCOLUMNS = ['column1', 'column2', 'column3', 'column4', 'column5']\ndef task_func(df, dct):\n", 'unit_tests_you_have_written': {}, 'current_solution': ''}}</2 environment step(s) in the past>
|
452
|
-
|
453
|
-
Your next actions / thought:
|
454
|
-
"""
|
455
|
-
|
456
|
-
|
457
|
-
class TestLMStructuredOutputs(unittest.TestCase):
|
458
|
-
# ... existing code ...
|
459
|
-
|
460
|
-
@classmethod
|
461
|
-
def setUpClass(cls):
|
462
|
-
# Initialize LMs for both forced_json and stringified_json modes
|
463
|
-
cls.lm_forced_json = LM(
|
464
|
-
model_name="gpt-4o-mini",
|
465
|
-
formatting_model_name="gpt-4o-mini",
|
466
|
-
temperature=0.0,
|
467
|
-
max_retries="Few",
|
468
|
-
structured_output_mode="forced_json",
|
469
|
-
)
|
470
|
-
cls.lm_stringified_json = LM(
|
471
|
-
model_name="gpt-4o-mini",
|
472
|
-
formatting_model_name="gpt-4o-mini",
|
473
|
-
temperature=0.0,
|
474
|
-
max_retries="Few",
|
475
|
-
structured_output_mode="stringified_json",
|
476
|
-
)
|
477
|
-
|
478
|
-
def test_sync_react_response_content(self):
|
479
|
-
system_message = system
|
480
|
-
|
481
|
-
user_message = user
|
482
|
-
|
483
|
-
for lm in [self.lm_forced_json, self.lm_stringified_json]:
|
484
|
-
with self.subTest(
|
485
|
-
mode=lm.structured_output_handler.handler.structured_output_mode
|
486
|
-
):
|
487
|
-
result = lm.respond_sync(
|
488
|
-
system_message=system_message,
|
489
|
-
user_message=user_message,
|
490
|
-
response_model=ReAct,
|
491
|
-
)
|
492
|
-
self.assertIsInstance(result, ReAct)
|
493
|
-
self.assertIsInstance(result.reasoning, str)
|
494
|
-
self.assertIsInstance(result.action_name, str)
|
495
|
-
self.assertIsInstance(result.action_args, list)
|
496
|
-
for arg in result.action_args:
|
497
|
-
self.assertIsInstance(arg, ActionArgument)
|
498
|
-
self.assertIsInstance(arg.key, str)
|
499
|
-
# self.assertIsInstance(arg.value, str)
|
500
|
-
|
501
|
-
def test_sync_react_response_hard_content(self):
|
502
|
-
system_message = hard_system
|
503
|
-
|
504
|
-
user_message = hard_user
|
505
|
-
|
506
|
-
for lm in [self.lm_forced_json, self.lm_stringified_json]:
|
507
|
-
with self.subTest(
|
508
|
-
mode=lm.structured_output_handler.handler.structured_output_mode
|
509
|
-
):
|
510
|
-
result = lm.respond_sync(
|
511
|
-
system_message=system_message,
|
512
|
-
user_message=user_message,
|
513
|
-
response_model=ReAct,
|
514
|
-
)
|
515
|
-
self.assertIsInstance(result, ReAct)
|
516
|
-
self.assertIsInstance(result.reasoning, str)
|
517
|
-
self.assertIsInstance(result.action_name, str)
|
518
|
-
self.assertIsInstance(result.action_args, list)
|
519
|
-
for arg in result.action_args:
|
520
|
-
self.assertIsInstance(arg, ActionArgument)
|
521
|
-
self.assertIsInstance(arg.key, str)
|
522
|
-
# self.assertIsInstance(arg.value, str)
|
523
|
-
|
524
|
-
|
525
|
-
# use non-trivial fallback?
|
526
|
-
|
527
|
-
if __name__ == "__main__":
|
528
|
-
# Create an instance of the test class
|
529
|
-
test_instance = TestLMStructuredOutputs()
|
530
|
-
|
531
|
-
# Set up the class (this would normally be done by unittest)
|
532
|
-
test_instance.setUpClass()
|
533
|
-
|
534
|
-
# Run the test methods
|
535
|
-
test_instance.test_sync_react_response_content()
|
536
|
-
test_instance.test_sync_react_response_hard_content()
|
537
|
-
|
538
|
-
print("All tests completed.")
|