Oranblock commited on
Commit
ab1f532
·
verified ·
1 Parent(s): cbed036

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -5
app.py CHANGED
@@ -1,6 +1,6 @@
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,7 +285,11 @@ def get_user_input(config):
285
  }
286
 
287
  def generate_lua_script(params, api_key):
288
- client = Groq(api_key=api_key)
 
 
 
 
289
 
290
  if params["custom_prompt"]:
291
  prompt = params["custom_prompt"]
@@ -362,9 +366,13 @@ def generate_lua_script(params, api_key):
362
  if params["particle_texture"]:
363
  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"
364
 
365
- # Request the script generation from Groq
366
- response = client.create_lua_script(prompt=prompt)
367
- return response['script']
 
 
 
 
368
 
369
  def main():
370
  config = load_config()
 
1
  import streamlit as st
2
  import json
3
+ import requests
4
 
5
  def load_config():
6
  with open('config.json', 'r') as f:
 
285
  }
286
 
287
  def generate_lua_script(params, api_key):
288
+ url = "https://api.groq.com/v1/lua_script" # Example URL, replace with actual API endpoint
289
+ headers = {
290
+ "Authorization": f"Bearer {api_key}",
291
+ "Content-Type": "application/json"
292
+ }
293
 
294
  if params["custom_prompt"]:
295
  prompt = params["custom_prompt"]
 
366
  if params["particle_texture"]:
367
  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"
368
 
369
+ data = {
370
+ "prompt": prompt
371
+ }
372
+
373
+ response = requests.post(url, headers=headers, json=data)
374
+ response.raise_for_status() # Raise an exception for HTTP errors
375
+ return response.json()['script']
376
 
377
  def main():
378
  config = load_config()