TabasumDev commited on
Commit
83f0e09
·
verified ·
1 Parent(s): d862db1

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +56 -0
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ from groq import Groq
4
+
5
+ # Initialize Groq client
6
+ client = Groq(
7
+ api_key=os.environ.get("GROQ_API_KEY"),
8
+ )
9
+
10
+ # Streamlit app title and description
11
+ st.title("StoryForge")
12
+ st.write("StoryForge is an app designed to help game developers generate comprehensive Game Design Documents by providing essential details about their game's environment, protagonist, and antagonist.")
13
+
14
+ # Sidebar for user input
15
+ st.sidebar.header("Game Details")
16
+ game_environment = st.sidebar.text_input("Enter the Game Environment:", placeholder="e.g., A dystopian city in the year 2142")
17
+ protagonist = st.sidebar.text_input("Enter the Protagonist:", placeholder="e.g., A young hacker with a mysterious past")
18
+ antagonist = st.sidebar.text_input("Enter the Antagonist:", placeholder="e.g., A corrupt government official controlling the city")
19
+
20
+ # Main content layout
21
+ col1, col2 = st.columns(2)
22
+
23
+ # Column 1
24
+ with col1:
25
+ st.header("Game Environment")
26
+ st.write(game_environment)
27
+
28
+ st.header("Game Story")
29
+ if game_environment and protagonist and antagonist:
30
+ # Create a message for Groq to generate a game story based on user inputs
31
+ message = f"Create a compelling game story set in {game_environment}, featuring {protagonist} as the protagonist and {antagonist} as the antagonist."
32
+
33
+ # Get completion from Groq
34
+ chat_completion = client.chat.completions.create(
35
+ messages=[
36
+ {
37
+ "role": "user",
38
+ "content": message,
39
+ }
40
+ ],
41
+ model="llama3-8b-8192",
42
+ )
43
+
44
+ # Return generated story content
45
+ story = chat_completion.choices[0].message.content
46
+ st.write(story)
47
+ else:
48
+ st.write("Please provide details in the sidebar.")
49
+
50
+ # Column 2
51
+ with col2:
52
+ st.header("Protagonist")
53
+ st.write(protagonist)
54
+
55
+ st.header("Antagonist")
56
+ st.write(antagonist)