LLM prompt formatted as a natural language
Browse files- tray_sim.py +8 -9
tray_sim.py
CHANGED
|
@@ -252,15 +252,14 @@ def run_tray_simulation(seed=0, num_objects=N_OBJECTS, azimuth=45, elevation=-25
|
|
| 252 |
with open(json_path, "w") as f:
|
| 253 |
json.dump(physics_state, f, indent=2)
|
| 254 |
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
#formatted = format_llm_prompt(physics_state)
|
| 258 |
-
#prompt = format_as_natural_language_prompt(
|
| 259 |
-
# formatted,
|
| 260 |
-
# task_description="Explain which objects are likely to fall if the tray is tilted slightly to the right."
|
| 261 |
-
#)
|
| 262 |
-
#print(prompt)
|
| 263 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 264 |
|
| 265 |
# Save to GIF
|
| 266 |
gif_path = os.path.join(tempfile.gettempdir(), f"tray_sim_{seed}.gif")
|
|
@@ -269,4 +268,4 @@ def run_tray_simulation(seed=0, num_objects=N_OBJECTS, azimuth=45, elevation=-25
|
|
| 269 |
#return gif_path
|
| 270 |
#return gif_path, stability_flags
|
| 271 |
#return gif_path, stability_flags, physics_state # optionally also return json_path
|
| 272 |
-
return gif_path, stability_flags, physics_state,
|
|
|
|
| 252 |
with open(json_path, "w") as f:
|
| 253 |
json.dump(physics_state, f, indent=2)
|
| 254 |
|
| 255 |
+
# LLM-friendly prompt output
|
| 256 |
+
#prompt = format_llm_prompt(physics_state)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 257 |
|
| 258 |
+
formatted = format_llm_prompt(physics_state)
|
| 259 |
+
prompt = format_as_natural_language_prompt(
|
| 260 |
+
formatted,
|
| 261 |
+
task_description="Explain which objects are likely to fall if the tray is tilted slightly to the right."
|
| 262 |
+
)
|
| 263 |
|
| 264 |
# Save to GIF
|
| 265 |
gif_path = os.path.join(tempfile.gettempdir(), f"tray_sim_{seed}.gif")
|
|
|
|
| 268 |
#return gif_path
|
| 269 |
#return gif_path, stability_flags
|
| 270 |
#return gif_path, stability_flags, physics_state # optionally also return json_path
|
| 271 |
+
return gif_path, stability_flags, physics_state, prompt, json_path # optionally also return json_path
|