Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import json
|
| 3 |
-
import
|
| 4 |
|
| 5 |
def load_config():
|
| 6 |
with open('config.json', 'r') as f:
|
|
@@ -285,94 +285,100 @@ def get_user_input(config):
|
|
| 285 |
}
|
| 286 |
|
| 287 |
def generate_lua_script(params, api_key):
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
"Authorization": f"Bearer {api_key}",
|
| 291 |
-
"Content-Type": "application/json"
|
| 292 |
-
}
|
| 293 |
|
| 294 |
-
if params["
|
| 295 |
-
prompt
|
| 296 |
-
|
| 297 |
-
prompt
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
| 365 |
-
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
|
| 371 |
-
|
| 372 |
-
|
| 373 |
-
|
| 374 |
-
|
| 375 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 376 |
|
| 377 |
def main():
|
| 378 |
config = load_config()
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import json
|
| 3 |
+
from groq import Groq
|
| 4 |
|
| 5 |
def load_config():
|
| 6 |
with open('config.json', 'r') as f:
|
|
|
|
| 285 |
}
|
| 286 |
|
| 287 |
def generate_lua_script(params, api_key):
|
| 288 |
+
client = Groq(api_key=api_key)
|
| 289 |
+
prompt = params["custom_prompt"] if params["custom_prompt"] else "Create a Lua script for Roblox that:\n"
|
|
|
|
|
|
|
|
|
|
| 290 |
|
| 291 |
+
if params["color"]:
|
| 292 |
+
prompt += f"1. Creates a {params['shape']} with the specified color {params['color']}.\n"
|
| 293 |
+
if params["size"]:
|
| 294 |
+
prompt += f"2. Specifies the size {params['size']}.\n"
|
| 295 |
+
if params["position"]:
|
| 296 |
+
prompt += f"3. Positions it at {params['position']}.\n"
|
| 297 |
+
if params["part_cframe"]:
|
| 298 |
+
prompt += f"4. Sets its CFrame to {params['part_cframe']}.\n"
|
| 299 |
+
if params["material"]:
|
| 300 |
+
prompt += f"5. Sets the material to {params['material']}.\n"
|
| 301 |
+
if params["transparency"]:
|
| 302 |
+
prompt += f"6. Sets the transparency to {params['transparency']}.\n"
|
| 303 |
+
if params["reflectance"]:
|
| 304 |
+
prompt += f"7. Sets the reflectance to {params['reflectance']}.\n"
|
| 305 |
+
if params["rotation_speed"]:
|
| 306 |
+
prompt += f"8. Rotates the {params['shape']} at a speed of {params['rotation_speed']}.\n"
|
| 307 |
+
if params["bounce_height"]:
|
| 308 |
+
prompt += f"9. Sets the bounce height to {params['bounce_height']}.\n"
|
| 309 |
+
if params["collision"]:
|
| 310 |
+
prompt += f"10. Sets collision to {params['collision']}.\n"
|
| 311 |
+
if params["surface"]:
|
| 312 |
+
prompt += f"11. Sets the surface type to {params['surface']}.\n"
|
| 313 |
+
if params["anchor"]:
|
| 314 |
+
prompt += f"12. Sets anchor to {params['anchor']}.\n"
|
| 315 |
+
if params["collision_group"]:
|
| 316 |
+
prompt += f"13. Sets the collision group to {params['collision_group']}.\n"
|
| 317 |
+
if params["angular_velocity"] and params["linear_velocity"]:
|
| 318 |
+
prompt += f"14. Sets the angular velocity to {params['angular_velocity']} and linear velocity to {params['linear_velocity']}.\n"
|
| 319 |
+
if params["density"]:
|
| 320 |
+
prompt += f"15. Sets the density to {params['density']}.\n"
|
| 321 |
+
if params["camera_type"]:
|
| 322 |
+
prompt += f"16. Sets the camera type to {params['camera_type']}.\n"
|
| 323 |
+
if params["camera_position"]:
|
| 324 |
+
prompt += f"17. Sets the camera position to {params['camera_position']}.\n"
|
| 325 |
+
if params["field_of_view"]:
|
| 326 |
+
prompt += f"18. Sets the field of view to {params['field_of_view']}.\n"
|
| 327 |
+
if params["camera_interpolation"]:
|
| 328 |
+
prompt += f"19. Enables camera interpolation.\n"
|
| 329 |
+
if params["ambient_light"]:
|
| 330 |
+
prompt += f"20. Sets the ambient light to {params['ambient_light']}.\n"
|
| 331 |
+
if params["brightness"]:
|
| 332 |
+
prompt += f"21. Sets the brightness to {params['brightness']}.\n"
|
| 333 |
+
if params["time_of_day"]:
|
| 334 |
+
prompt += f"22. Sets the time of day to {params['time_of_day']}.\n"
|
| 335 |
+
if params["shadow_softness"]:
|
| 336 |
+
prompt += f"23. Sets the shadow softness to {params['shadow_softness']}.\n"
|
| 337 |
+
if params["shadow_color"]:
|
| 338 |
+
prompt += f"24. Sets the shadow color to {params['shadow_color']}.\n"
|
| 339 |
+
if params["fog_start"] and params["fog_end"] and params["fog_color"]:
|
| 340 |
+
prompt += f"25. Sets fog with start distance {params['fog_start']}, end distance {params['fog_end']}, and color {params['fog_color']}.\n"
|
| 341 |
+
if params["walk_speed"]:
|
| 342 |
+
prompt += f"26. Sets the player's walk speed to {params['walk_speed']}.\n"
|
| 343 |
+
if params["jump_power"]:
|
| 344 |
+
prompt += f"27. Sets the player's jump power to {params['jump_power']}.\n"
|
| 345 |
+
if params["health"]:
|
| 346 |
+
prompt += f"28. Sets the player's health to {params['health']}.\n"
|
| 347 |
+
if params["respawn_time"]:
|
| 348 |
+
prompt += f"29. Sets the respawn time to {params['respawn_time']}.\n"
|
| 349 |
+
if params["background_music"]:
|
| 350 |
+
prompt += f"30. Adds background music with ID {params['background_music']} and sets volume to {params['sound_volume']}.\n"
|
| 351 |
+
if params["sound_effects"]:
|
| 352 |
+
prompt += f"31. Adds sound effects with ID {params['sound_effects']}.\n"
|
| 353 |
+
if params["environmental_sounds"]:
|
| 354 |
+
prompt += f"32. Adds environmental sounds with ID {params['environmental_sounds']}.\n"
|
| 355 |
+
if params["ui_text"]:
|
| 356 |
+
prompt += f"33. Adds UI text '{params['ui_text']}' at position {params['ui_position']} with size {params['ui_size']} and color {params['ui_color']} using font {params['ui_font']} and text size {params['ui_text_size']}.\n"
|
| 357 |
+
if params["texture_id"] and params["decal_position"]:
|
| 358 |
+
prompt += f"34. Adds a decal with texture ID {params['texture_id']} at position {params['decal_position']}.\n"
|
| 359 |
+
if params["particle_texture"]:
|
| 360 |
+
prompt += f"35. Adds particle effects with texture ID {params['particle_texture']}, lifetime {params['particle_lifetime']}, rate {params['particle_rate']}, speed {params['particle_speed']}, size {params['particle_size']}, acceleration {params['particle_acceleration']}, rotation speed {params['particle_rot_speed']}, and color {params['particle_color']}.\n"
|
| 361 |
+
|
| 362 |
+
completion = client.chat.completions.create(
|
| 363 |
+
model="llama3-8b-8192",
|
| 364 |
+
messages=[
|
| 365 |
+
{
|
| 366 |
+
"role": "user",
|
| 367 |
+
"content": prompt
|
| 368 |
+
}
|
| 369 |
+
],
|
| 370 |
+
temperature=1,
|
| 371 |
+
max_tokens=1024,
|
| 372 |
+
top_p=1,
|
| 373 |
+
stream=True,
|
| 374 |
+
stop=None,
|
| 375 |
+
)
|
| 376 |
+
|
| 377 |
+
lua_script = ""
|
| 378 |
+
for chunk in completion:
|
| 379 |
+
lua_script += chunk.choices[0].delta.content or ""
|
| 380 |
+
|
| 381 |
+
return lua_script
|
| 382 |
|
| 383 |
def main():
|
| 384 |
config = load_config()
|