plancraft 0.3.20__py3-none-any.whl → 0.3.22__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.
@@ -61,6 +61,14 @@ class ActionHandlerBase(abc.ABC):
61
61
  """
62
62
  raise NotImplementedError()
63
63
 
64
+ @property
65
+ @abc.abstractmethod
66
+ def regex_pattern(self) -> str:
67
+ """
68
+ Return the regex pattern for the model
69
+ """
70
+ raise NotImplementedError()
71
+
64
72
  @property
65
73
  @abc.abstractmethod
66
74
  def action_name(self) -> str:
@@ -97,7 +105,7 @@ class MoveAction(BaseModel):
97
105
  return convert_to_slot_index(value)
98
106
  except ValueError:
99
107
  raise AttributeError(
100
- "slot_from and slot_to must be [0] or [A1] to [C3] or [I1] to [I36]"
108
+ "[Source] and [Target] must be [0] or [A1] to [C3] or [I1] to [I36]"
101
109
  )
102
110
  return value
103
111
 
@@ -113,11 +121,11 @@ class MoveAction(BaseModel):
113
121
  @model_validator(mode="after")
114
122
  def validate(self):
115
123
  if self.slot_from == self.slot_to:
116
- raise AttributeError("slot_from and slot_to must be different")
124
+ raise AttributeError("[Source] and [Target] must be different")
117
125
  if self.slot_from < 0 or self.slot_from > 45:
118
- raise AttributeError("slot_from must be between 0 and 45")
126
+ raise AttributeError("[Source] must be between 0 and 45")
119
127
  if self.slot_to < 1 or self.slot_to > 45:
120
- raise AttributeError("slot_to must be between 1 and 45")
128
+ raise AttributeError("[Target] must be between 1 and 45")
121
129
  if self.quantity < 1 or self.quantity > 64:
122
130
  raise AttributeError("quantity must be between 1 and 64")
123
131
  return self
@@ -146,7 +154,7 @@ class SmeltAction(BaseModel):
146
154
  return convert_to_slot_index(value)
147
155
  except ValueError:
148
156
  raise AttributeError(
149
- "slot_from and slot_to must be [0] or [A1] to [C3] or [I1] to [I36]"
157
+ "[Source] and [Target] must be [0] or [A1] to [C3] or [I1] to [I36]"
150
158
  )
151
159
  return value
152
160
 
@@ -162,11 +170,11 @@ class SmeltAction(BaseModel):
162
170
  @model_validator(mode="after")
163
171
  def validate(self):
164
172
  if self.slot_from == self.slot_to:
165
- raise AttributeError("slot_from and slot_to must be different")
173
+ raise AttributeError("[Source] and [Target] must be different")
166
174
  if self.slot_from < 0 or self.slot_from > 45:
167
- raise AttributeError("slot_from must be between 0 and 45")
175
+ raise AttributeError("[Source] must be between 0 and 45")
168
176
  if self.slot_to < 1 or self.slot_to > 45:
169
- raise AttributeError("slot_to must be between 1 and 45")
177
+ raise AttributeError("[Target] must be between 1 and 45")
170
178
  if self.quantity < 1 or self.quantity > 64:
171
179
  raise AttributeError("quantity must be between 1 and 64")
172
180
  return self
@@ -200,6 +208,12 @@ class MoveActionHandler(ActionHandlerBase):
200
208
  def prompt_format_example(self) -> str:
201
209
  return "`move: from [Source] to [Target] with quantity N`"
202
210
 
211
+ @property
212
+ def regex_pattern(self) -> str:
213
+ return (
214
+ r"move: from \[(0|[ABCI][0-9])\] to \[(0|[ABCI][0-9])\] with quantity \d+"
215
+ )
216
+
203
217
  @property
204
218
  def action_name(self) -> str:
205
219
  return "move"
@@ -221,10 +235,8 @@ class MoveActionHandler(ActionHandlerBase):
221
235
  quantity=quantity,
222
236
  )
223
237
  return action
224
- except AttributeError:
225
- return (
226
- f"Format Error. Action be in the format: {self.prompt_format_example}"
227
- )
238
+ except AttributeError as e:
239
+ return f"Format Error: {e}. Correct format: {self.prompt_format_example}"
228
240
 
229
241
 
230
242
  class SmeltActionHandler(ActionHandlerBase):
@@ -236,6 +248,12 @@ class SmeltActionHandler(ActionHandlerBase):
236
248
  def prompt_format_example(self) -> str:
237
249
  return "`smelt: from [Source] to [Target] with quantity N`"
238
250
 
251
+ @property
252
+ def regex_pattern(self) -> str:
253
+ return (
254
+ r"smelt: from \[(0|[ABCI][0-9])\] to \[(0|[ABCI][0-9])\] with quantity \d+"
255
+ )
256
+
239
257
  @property
240
258
  def action_name(self) -> str:
241
259
  return "smelt"
@@ -258,10 +276,8 @@ class SmeltActionHandler(ActionHandlerBase):
258
276
  quantity=quantity,
259
277
  )
260
278
  return action
261
- except AttributeError:
262
- return (
263
- f"Format Error. Action be in the format: {self.prompt_format_example}"
264
- )
279
+ except AttributeError as e:
280
+ return f"Format Error: {e}. Correct format: {self.prompt_format_example}"
265
281
 
266
282
 
267
283
  class ImpossibleActionHandler(ActionHandlerBase):
@@ -273,6 +289,10 @@ class ImpossibleActionHandler(ActionHandlerBase):
273
289
  def prompt_format_example(self) -> str:
274
290
  return "`impossible: <reason>`"
275
291
 
292
+ @property
293
+ def regex_pattern(self) -> str:
294
+ return r"impossible: .+"
295
+
276
296
  @property
277
297
  def action_name(self) -> str:
278
298
  return "impossible"
@@ -287,10 +307,8 @@ class ImpossibleActionHandler(ActionHandlerBase):
287
307
  return
288
308
  reason = re.search(r"impossible: (.*)", generated_text).group(1)
289
309
  return StopAction(reason=reason)
290
- except AttributeError:
291
- return (
292
- f"Format Error. Action be in the format: {self.prompt_format_example}"
293
- )
310
+ except AttributeError as e:
311
+ return f"Format Error: {e}. Correct format: {self.prompt_format_example}"
294
312
 
295
313
 
296
314
  class ThinkActionHandler(ActionHandlerBase):
@@ -302,6 +320,10 @@ class ThinkActionHandler(ActionHandlerBase):
302
320
  def prompt_format_example(self) -> str:
303
321
  return "`think: <thought message>`"
304
322
 
323
+ @property
324
+ def regex_pattern(self) -> str:
325
+ return r"think: .+"
326
+
305
327
  @property
306
328
  def action_name(self) -> str:
307
329
  return "think"
@@ -315,7 +337,5 @@ class ThinkActionHandler(ActionHandlerBase):
315
337
  if not action_match:
316
338
  return
317
339
  return "Ok"
318
- except AttributeError:
319
- return (
320
- f"Format Error. Action be in the format: {self.prompt_format_example}"
321
- )
340
+ except AttributeError as e:
341
+ return f"Format Error: {e}. Correct format: {self.prompt_format_example}"
@@ -38,6 +38,10 @@ class GoldSearchActionHandler(ActionHandlerBase):
38
38
  def prompt_format_example(self) -> str:
39
39
  return "`search: <recipe name>`"
40
40
 
41
+ @property
42
+ def regex_pattern(self) -> str:
43
+ return r"search: \w+"
44
+
41
45
  @property
42
46
  def action_name(self) -> str:
43
47
  return "search"
@@ -53,7 +57,5 @@ class GoldSearchActionHandler(ActionHandlerBase):
53
57
 
54
58
  search_target = re.search(r"search: *(\w+)", generated_text).group(1)
55
59
  return gold_search_recipe(search_target)
56
- except AttributeError:
57
- return (
58
- f"Format Error. Action be in the format: {self.prompt_format_example}"
59
- )
60
+ except AttributeError as e:
61
+ return f"Format Error: {e}. Correct format: {self.prompt_format_example}"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: plancraft
3
- Version: 0.3.20
3
+ Version: 0.3.22
4
4
  Summary: Plancraft: an evaluation dataset for planning with LLM agents
5
5
  License: MIT License
6
6
 
@@ -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=VhPSRr0b1ySxb106TcBFdb3MdycxWwQGzqDnWQagm-8,10007
14
+ plancraft/environment/actions.py,sha256=Ve3SHwg0o2NcMBVM8O-IRjsvcdO2dH8kqvweWm6euo8,10559
15
15
  plancraft/environment/env.py,sha256=A4532st7JFBYBF_Nh0CEEi3ZTLJAeaB3t9PAIVSemj0,16390
16
16
  plancraft/environment/items.py,sha256=Z9rhSyVDEoHF1pxRvhyiT94tyQJaWHi3wUHVcamz82o,221
17
17
  plancraft/environment/planner.py,sha256=uIOJjIoyT_4pxeWeTKb8BkLJyKZG0-AMoEOkZs6Ua9A,19340
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=79hLpTU0ajvMPoBsvSe8tE88x31c8Vlczb3tJZJcau0,7441
21
- plancraft/environment/search.py,sha256=kk6t-MkpFGTL7I38GQ6H21BjW9qJLSNGMbJqvZhr1LE,2035
21
+ plancraft/environment/search.py,sha256=z31eEwQBY7WJaYVBEEwulFS8P3h1Nwo1Th9BaCTxk5M,2085
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=f-0KWlBuHy6wcxmDsxM3MQ_QwfBstzfbA26mlk1MgLA,1657
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.20.dist-info/METADATA,sha256=7Gs3Txfw2YCBVDAstW7K69fho4vktcYp6sw6g2nQOYE,11148
1924
- plancraft-0.3.20.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
1925
- plancraft-0.3.20.dist-info/licenses/LICENSE,sha256=YGR8ehDB4t-T-lOQKMfKNR-2zsOU7E3E5NA8t25HKE0,1070
1926
- plancraft-0.3.20.dist-info/RECORD,,
1923
+ plancraft-0.3.22.dist-info/METADATA,sha256=jTX0TZZxJRldUDDFuJ6AhuN1Bf5Jc2DuDooPVwCBkAQ,11148
1924
+ plancraft-0.3.22.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
1925
+ plancraft-0.3.22.dist-info/licenses/LICENSE,sha256=YGR8ehDB4t-T-lOQKMfKNR-2zsOU7E3E5NA8t25HKE0,1070
1926
+ plancraft-0.3.22.dist-info/RECORD,,