plancraft 0.3.6__py3-none-any.whl → 0.3.8__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.
- plancraft/environment/actions.py +5 -5
- plancraft/environment/search.py +1 -1
- plancraft/evaluator.py +10 -15
- {plancraft-0.3.6.dist-info → plancraft-0.3.8.dist-info}/METADATA +1 -1
- {plancraft-0.3.6.dist-info → plancraft-0.3.8.dist-info}/RECORD +7 -7
- {plancraft-0.3.6.dist-info → plancraft-0.3.8.dist-info}/WHEEL +0 -0
- {plancraft-0.3.6.dist-info → plancraft-0.3.8.dist-info}/licenses/LICENSE +0 -0
plancraft/environment/actions.py
CHANGED
@@ -70,7 +70,7 @@ class ActionHandlerBase(abc.ABC):
|
|
70
70
|
raise NotImplementedError()
|
71
71
|
|
72
72
|
@abc.abstractmethod
|
73
|
-
def match(self, generated_text: str):
|
73
|
+
def match(self, generated_text: str, **kwargs) -> Optional[BaseModel | str]:
|
74
74
|
"""
|
75
75
|
Match the generated text to the action/tool
|
76
76
|
"""
|
@@ -204,7 +204,7 @@ class MoveActionHandler(ActionHandlerBase):
|
|
204
204
|
def action_name(self) -> str:
|
205
205
|
return "move"
|
206
206
|
|
207
|
-
def match(self, generated_text: str) -> Optional[MoveAction | str]:
|
207
|
+
def match(self, generated_text: str, **kwargs) -> Optional[MoveAction | str]:
|
208
208
|
"""
|
209
209
|
Parse the raw model response to a MoveAction
|
210
210
|
"""
|
@@ -238,7 +238,7 @@ class SmeltActionHandler(ActionHandlerBase):
|
|
238
238
|
def action_name(self) -> str:
|
239
239
|
return "smelt"
|
240
240
|
|
241
|
-
def match(self, generated_text: str) -> Optional[SmeltAction | str]:
|
241
|
+
def match(self, generated_text: str, **kwargs) -> Optional[SmeltAction | str]:
|
242
242
|
"""
|
243
243
|
Parse the raw model response to a SmeltAction
|
244
244
|
"""
|
@@ -272,7 +272,7 @@ class ImpossibleActionHandler(ActionHandlerBase):
|
|
272
272
|
def action_name(self) -> str:
|
273
273
|
return "impossible"
|
274
274
|
|
275
|
-
def match(self, generated_text) -> Optional[StopAction]:
|
275
|
+
def match(self, generated_text, **kwargs) -> Optional[StopAction]:
|
276
276
|
"""
|
277
277
|
Parse the raw model response to a StopAction
|
278
278
|
"""
|
@@ -296,7 +296,7 @@ class ThinkActionHandler(ActionHandlerBase):
|
|
296
296
|
def action_name(self) -> str:
|
297
297
|
return "think"
|
298
298
|
|
299
|
-
def match(self, generated_text) -> Optional[str]:
|
299
|
+
def match(self, generated_text, **kwargs) -> Optional[str]:
|
300
300
|
"""
|
301
301
|
Parse the raw model response to a ThinkAction
|
302
302
|
"""
|
plancraft/environment/search.py
CHANGED
@@ -42,7 +42,7 @@ class GoldSearchActionHandler(ActionHandlerBase):
|
|
42
42
|
def action_name(self) -> str:
|
43
43
|
return "search"
|
44
44
|
|
45
|
-
def match(self, generated_text) -> Optional[str]:
|
45
|
+
def match(self, generated_text, **kwargs) -> Optional[str]:
|
46
46
|
"""
|
47
47
|
Parse the raw model response to a SearchAction
|
48
48
|
"""
|
plancraft/evaluator.py
CHANGED
@@ -142,13 +142,15 @@ class Evaluator:
|
|
142
142
|
return True
|
143
143
|
return False
|
144
144
|
|
145
|
-
def parse_raw_model_response(self, generated_text: str):
|
145
|
+
def parse_raw_model_response(self, generated_text: str, observation=None) -> str:
|
146
146
|
"""
|
147
147
|
Given a message and set of action handlers, parse the content to return the action
|
148
148
|
or a message if the action is not valid/requires message response
|
149
149
|
"""
|
150
150
|
for handler in self.actions:
|
151
|
-
match_output = handler.match(
|
151
|
+
match_output = handler.match(
|
152
|
+
generated_text, observation=observation, history=self.history
|
153
|
+
)
|
152
154
|
if match_output:
|
153
155
|
return match_output
|
154
156
|
action_names = [handler.action_name for handler in self.actions]
|
@@ -192,7 +194,6 @@ class Evaluator:
|
|
192
194
|
"""Given the loaded model and an example from Plancraft
|
193
195
|
run the episode until success or termination."""
|
194
196
|
success = False
|
195
|
-
num_non_env_actions = 0
|
196
197
|
self.reset(example)
|
197
198
|
action = None
|
198
199
|
|
@@ -207,24 +208,18 @@ class Evaluator:
|
|
207
208
|
success = example.impossible
|
208
209
|
break
|
209
210
|
# action is external tool then it is str
|
210
|
-
|
211
|
-
|
212
|
-
observation =
|
213
|
-
|
211
|
+
if isinstance(action, str):
|
212
|
+
observation = self.environment.step()
|
213
|
+
observation["target"] = example.target
|
214
|
+
observation["message"] = action
|
214
215
|
# action is environment action
|
215
216
|
else:
|
216
|
-
|
217
|
-
observation = self.environment.step()
|
218
|
-
else:
|
219
|
-
observation = self.environment.step(action)
|
220
|
-
|
217
|
+
observation = self.environment.step(action)
|
221
218
|
# convert inventory observation to text message
|
222
219
|
observation["target"] = example.target
|
223
220
|
observation["message"] = self.convert_observation_to_message(
|
224
221
|
observation
|
225
222
|
)
|
226
|
-
num_non_env_actions = 0
|
227
|
-
|
228
223
|
# check if the episode is done
|
229
224
|
success = self.check_done(observation["inventory"], example.target)
|
230
225
|
# exit if success
|
@@ -242,7 +237,7 @@ class Evaluator:
|
|
242
237
|
# add message to history
|
243
238
|
self.history.add_message_to_history(content=raw_action, role="assistant")
|
244
239
|
# parse the raw action
|
245
|
-
action = self.parse_raw_model_response(raw_action)
|
240
|
+
action = self.parse_raw_model_response(raw_action, observation=observation)
|
246
241
|
|
247
242
|
# save results and reset
|
248
243
|
return {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
plancraft/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
2
2
|
plancraft/config.py,sha256=Ppkps-E8xDNYEP9prOVxW2zEG9MpWVzcLJi4tmGLjuQ,4285
|
3
|
-
plancraft/evaluator.py,sha256=
|
3
|
+
plancraft/evaluator.py,sha256=FogXAjnldK2K1gD02f2WW1YWvjWokKGUOJxwtwzGNjk,10804
|
4
4
|
plancraft/generate_dataset.py,sha256=DlrU-PmvWqSNJD1g1-8Lpb8n3N-Ogw3rje1nrRzjGKs,2382
|
5
5
|
plancraft/utils.py,sha256=phaHzbIS85YZrBPaGG9TStHY8ZBKR1LKfuN1exfVy1U,6889
|
6
6
|
plancraft/data/test.json,sha256=4jWfYMAVuZCFmGB4iZJAjlh9_8jXECdaGp8xn7_tAM4,1317131
|
@@ -11,14 +11,14 @@ plancraft/data/val.json,sha256=IToAiaqUNQi_xhX1bzmInuskLaT7C2ryQjP-CZkzL24,13044
|
|
11
11
|
plancraft/data/val.small.easy.json,sha256=9zEmqepjXG2NIp88xnFqOCkwsUsku3HEwHoQGxgTr6U,190252
|
12
12
|
plancraft/data/val.small.json,sha256=76E9EFaljDQyAokg97e-IblvcOe6KbrdKkXvRxhhkgo,237653
|
13
13
|
plancraft/environment/__init__.py,sha256=XFsFny4lH195AwAmL-WeCaF9ZCMgc7IgXIwhQ8FTdgE,505
|
14
|
-
plancraft/environment/actions.py,sha256=
|
14
|
+
plancraft/environment/actions.py,sha256=AQxFaK4YW53mPwhuPhHrDF9wENSVjPHSWk0v77I1thw,9460
|
15
15
|
plancraft/environment/env.py,sha256=F5xo1eAJ9MeuoE2IpG_LtbaE0BGd66URPB_rehAWIiU,16372
|
16
16
|
plancraft/environment/items.py,sha256=Z9rhSyVDEoHF1pxRvhyiT94tyQJaWHi3wUHVcamz82o,221
|
17
17
|
plancraft/environment/planner.py,sha256=eJExz3OxSzurIEdH9LOtMwFH9ApqMQ3CokVhmbV6Px0,3953
|
18
18
|
plancraft/environment/prompts.py,sha256=8QXclX0ygpL02uZichE1AVkbdn_0HGteD5bzo0FZGOU,6947
|
19
19
|
plancraft/environment/recipes.py,sha256=0vwzOU86eZmGN2EpZVSIvzxpx0AOBWNPxTtAOFBN2A0,19570
|
20
20
|
plancraft/environment/sampler.py,sha256=IZT-XjmWSZrs0zDyRTMjYytXxewdwYf5YGGdKsR5ll4,7643
|
21
|
-
plancraft/environment/search.py,sha256=
|
21
|
+
plancraft/environment/search.py,sha256=Dmdvj04kMvPlwvoWSc2261LTXV8RbMpS4FODV1YoZKs,1847
|
22
22
|
plancraft/environment/assets/constants.json,sha256=kyOIOh82CTTMMGEIS60k5k6M-6fkEmYDoGAnvi3Zx5k,1379016
|
23
23
|
plancraft/environment/assets/minecraft_font.ttf,sha256=AzoK9cgggXwjFPHtIO7uz-YaDrminl3nvB-VsaTvTAk,60992
|
24
24
|
plancraft/environment/assets/table.png,sha256=IKIViZKAPyR4FWnS0JP9AZ19vIEO3qoS5-YRGAO1ow8,5430
|
@@ -1920,7 +1920,7 @@ plancraft/models/generators.py,sha256=F76_iPiqxUjDIrQwF58tzM0bLM91OkZJ0sBqBuki5w
|
|
1920
1920
|
plancraft/models/oracle.py,sha256=jDCE6zVFvbwFpDzQZTkHIlRwMud1yMJ4LVIdfpt5ddU,8449
|
1921
1921
|
plancraft/models/utils.py,sha256=E-sZohvolWgGbpHQKgAgkgIfUJoVnT5pMt6JP8xLHKg,4034
|
1922
1922
|
plancraft/train/dataset.py,sha256=oFqEd4LG9oEQ-71teh0Wf7-jJbtybT2ZibfM2bBdBkM,5474
|
1923
|
-
plancraft-0.3.
|
1924
|
-
plancraft-0.3.
|
1925
|
-
plancraft-0.3.
|
1926
|
-
plancraft-0.3.
|
1923
|
+
plancraft-0.3.8.dist-info/METADATA,sha256=H6H7LnIFSd-M-FyqlAtErJfzL4WxSDd0ku66P2YyTeQ,11147
|
1924
|
+
plancraft-0.3.8.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
1925
|
+
plancraft-0.3.8.dist-info/licenses/LICENSE,sha256=YGR8ehDB4t-T-lOQKMfKNR-2zsOU7E3E5NA8t25HKE0,1070
|
1926
|
+
plancraft-0.3.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|