Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,30 +1,23 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import
|
| 3 |
-
import
|
| 4 |
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
You are a professional game developer.
|
| 8 |
-
Generate a COMPLETE HTML5 game.
|
| 9 |
-
Rules:
|
| 10 |
-
- Single HTML file
|
| 11 |
-
- No explanations
|
| 12 |
-
- No markdown
|
| 13 |
-
- Only pure HTML + JS
|
| 14 |
-
- Canvas based
|
| 15 |
-
Game idea:
|
| 16 |
-
{prompt}
|
| 17 |
-
"""
|
| 18 |
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
|
| 23 |
with gr.Blocks() as demo:
|
| 24 |
-
gr.Markdown("#
|
| 25 |
-
gr.
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
label="Spielbeschreibung",
|
| 29 |
-
placeholder="Minecraft ähnliches 3D Game mit springen und abbauen",
|
| 30 |
-
lines=3
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
+
from groq import Groq
|
| 3 |
+
import os
|
| 4 |
|
| 5 |
+
# Secret auslesen
|
| 6 |
+
client = Groq(api_key=os.environ.get("GROQ_API_KEY"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
|
| 8 |
+
def generate_game(prompt):
|
| 9 |
+
completion = client.chat.completions.create(
|
| 10 |
+
model="llama3-70b-8192",
|
| 11 |
+
messages=[
|
| 12 |
+
{"role": "system", "content": "Du generierst komplette HTML5-Spiele. Gib nur gültigen HTML-Code aus."},
|
| 13 |
+
{"role": "user", "content": prompt}
|
| 14 |
+
],
|
| 15 |
+
temperature=0.8
|
| 16 |
+
)
|
| 17 |
+
return completion.choices[0].message.content
|
| 18 |
|
| 19 |
with gr.Blocks() as demo:
|
| 20 |
+
gr.Markdown("# ⚡ Groq HTML5 Game Generator")
|
| 21 |
+
prompt = gr.Textbox(label="Spielidee", placeholder="2D Jump and Run mit Gegnern")
|
| 22 |
+
btn = gr.Button("⚡ Generieren")
|
| 23 |
+
code = gr.Code(language="htm
|
|
|
|
|
|
|
|
|