Update app.py
Browse files
app.py
CHANGED
@@ -146,6 +146,187 @@
|
|
146 |
# else:
|
147 |
# st.write(protagonist)
|
148 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
# with col2:
|
150 |
# st.header("๐ฆนโโ๏ธ Antagonist")
|
151 |
# if 'antagonist_description' in st.session_state:
|
@@ -153,6 +334,13 @@
|
|
153 |
# else:
|
154 |
# st.write(antagonist)
|
155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
import os
|
157 |
import streamlit as st
|
158 |
import anthropic
|
@@ -235,7 +423,7 @@ def generate_game_story(environment, protagonist, antagonist):
|
|
235 |
f"Antagonist: {antagonist}")
|
236 |
message = client.messages.create(
|
237 |
model="claude-3-5-sonnet-20240620",
|
238 |
-
max_tokens=
|
239 |
temperature=0.7,
|
240 |
system="You are a master storyteller. Generate a detailed game story based on the inputs provided.",
|
241 |
messages=[
|
@@ -252,35 +440,11 @@ def generate_game_story(environment, protagonist, antagonist):
|
|
252 |
)
|
253 |
return message.content[0].text
|
254 |
|
255 |
-
def generate_scenario_and_script(environment, protagonist, antagonist):
|
256 |
-
scenario_prompt = (f"Create a scenario and script based on the following details:\n"
|
257 |
-
f"Game Environment: {environment}\n"
|
258 |
-
f"Protagonist: {protagonist}\n"
|
259 |
-
f"Antagonist: {antagonist}")
|
260 |
-
message = client.messages.create(
|
261 |
-
model="claude-3-5-sonnet-20240620",
|
262 |
-
max_tokens=200,
|
263 |
-
temperature=0.7,
|
264 |
-
system="You are an expert in game scenario and script writing. Generate a scenario and script based on the inputs provided.",
|
265 |
-
messages=[
|
266 |
-
{
|
267 |
-
"role": "user",
|
268 |
-
"content": [
|
269 |
-
{
|
270 |
-
"type": "text",
|
271 |
-
"text": scenario_prompt
|
272 |
-
}
|
273 |
-
]
|
274 |
-
}
|
275 |
-
]
|
276 |
-
)
|
277 |
-
return message.content[0].text
|
278 |
-
|
279 |
# App Title
|
280 |
-
st.title("๐ฎ
|
281 |
|
282 |
# App Description
|
283 |
-
st.write("
|
284 |
|
285 |
# Sidebar Inputs
|
286 |
with st.sidebar:
|
@@ -294,14 +458,12 @@ with st.sidebar:
|
|
294 |
protagonist_description = generate_protagonist(protagonist)
|
295 |
antagonist_description = generate_antagonist(antagonist)
|
296 |
game_story = generate_game_story(game_environment, protagonist, antagonist)
|
297 |
-
scenario_and_script = generate_scenario_and_script(env_description, protagonist_description, antagonist_description)
|
298 |
|
299 |
# Store results in session state
|
300 |
st.session_state.env_description = env_description
|
301 |
st.session_state.protagonist_description = protagonist_description
|
302 |
st.session_state.antagonist_description = antagonist_description
|
303 |
st.session_state.game_story = game_story
|
304 |
-
st.session_state.scenario_and_script = scenario_and_script
|
305 |
|
306 |
# Layout with three columns
|
307 |
col1, col2, col3 = st.columns(3)
|
@@ -312,31 +474,33 @@ with col1:
|
|
312 |
st.write(st.session_state.env_description)
|
313 |
else:
|
314 |
st.write(game_environment)
|
|
|
315 |
|
316 |
with col2:
|
317 |
-
st.header("๐ Game Story")
|
318 |
-
if 'game_story' in st.session_state:
|
319 |
-
st.write(st.session_state.game_story)
|
320 |
-
else:
|
321 |
-
st.write("Your game story will be generated based on the inputs provided.")
|
322 |
-
|
323 |
-
with col1:
|
324 |
st.header("๐ฆธโโ๏ธ Protagonist")
|
325 |
if 'protagonist_description' in st.session_state:
|
326 |
st.write(st.session_state.protagonist_description)
|
327 |
else:
|
328 |
st.write(protagonist)
|
|
|
329 |
|
330 |
-
with
|
331 |
st.header("๐ฆนโโ๏ธ Antagonist")
|
332 |
if 'antagonist_description' in st.session_state:
|
333 |
st.write(st.session_state.antagonist_description)
|
334 |
else:
|
335 |
st.write(antagonist)
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
146 |
# else:
|
147 |
# st.write(protagonist)
|
148 |
|
149 |
+
# with col2:
|
150 |
+
# st.header("๐ฆนโโ๏ธ Antagonist")
|
151 |
+
# if 'antagonist_description' in st.session_state:
|
152 |
+
# st.write(st.session_state.antagonist_description)
|
153 |
+
# else:
|
154 |
+
# st.write(antagonist)
|
155 |
+
#---------------------------------------------------------------------
|
156 |
+
# import os
|
157 |
+
# import streamlit as st
|
158 |
+
# import anthropic
|
159 |
+
# from dotenv import load_dotenv
|
160 |
+
|
161 |
+
# # Load environment variables from .env file
|
162 |
+
# load_dotenv()
|
163 |
+
|
164 |
+
# # Retrieve the API key from environment variables
|
165 |
+
# api_key = os.getenv("Claude_api_key")
|
166 |
+
|
167 |
+
# # Initialize the Anthropic client with the API key
|
168 |
+
# client = anthropic.Anthropic(api_key=api_key)
|
169 |
+
|
170 |
+
# # Define the functions to generate content
|
171 |
+
# def generate_game_environment(environment_description):
|
172 |
+
# message = client.messages.create(
|
173 |
+
# model="claude-3-5-sonnet-20240620",
|
174 |
+
# max_tokens=150,
|
175 |
+
# temperature=0.7,
|
176 |
+
# system="You are an expert in world-building. Generate a detailed description of a game environment based on the input.",
|
177 |
+
# messages=[
|
178 |
+
# {
|
179 |
+
# "role": "user",
|
180 |
+
# "content": [
|
181 |
+
# {
|
182 |
+
# "type": "text",
|
183 |
+
# "text": f"Create a detailed description of a game environment based on this input: {environment_description}"
|
184 |
+
# }
|
185 |
+
# ]
|
186 |
+
# }
|
187 |
+
# ]
|
188 |
+
# )
|
189 |
+
# return message.content[0].text
|
190 |
+
|
191 |
+
# def generate_protagonist(protagonist_description):
|
192 |
+
# message = client.messages.create(
|
193 |
+
# model="claude-3-5-sonnet-20240620",
|
194 |
+
# max_tokens=150,
|
195 |
+
# temperature=0.7,
|
196 |
+
# system="You are an expert in character creation. Generate a detailed description of a game protagonist based on the input.",
|
197 |
+
# messages=[
|
198 |
+
# {
|
199 |
+
# "role": "user",
|
200 |
+
# "content": [
|
201 |
+
# {
|
202 |
+
# "type": "text",
|
203 |
+
# "text": f"Create a detailed description of a game protagonist based on this input: {protagonist_description}"
|
204 |
+
# }
|
205 |
+
# ]
|
206 |
+
# }
|
207 |
+
# ]
|
208 |
+
# )
|
209 |
+
# return message.content[0].text
|
210 |
+
|
211 |
+
# def generate_antagonist(antagonist_description):
|
212 |
+
# message = client.messages.create(
|
213 |
+
# model="claude-3-5-sonnet-20240620",
|
214 |
+
# max_tokens=150,
|
215 |
+
# temperature=0.7,
|
216 |
+
# system="You are an expert in villain creation. Generate a detailed description of a game antagonist based on the input.",
|
217 |
+
# messages=[
|
218 |
+
# {
|
219 |
+
# "role": "user",
|
220 |
+
# "content": [
|
221 |
+
# {
|
222 |
+
# "type": "text",
|
223 |
+
# "text": f"Create a detailed description of a game antagonist based on this input: {antagonist_description}"
|
224 |
+
# }
|
225 |
+
# ]
|
226 |
+
# }
|
227 |
+
# ]
|
228 |
+
# )
|
229 |
+
# return message.content[0].text
|
230 |
+
|
231 |
+
# def generate_game_story(environment, protagonist, antagonist):
|
232 |
+
# story_prompt = (f"Create a detailed game story based on the following inputs:\n"
|
233 |
+
# f"Game Environment: {environment}\n"
|
234 |
+
# f"Protagonist: {protagonist}\n"
|
235 |
+
# f"Antagonist: {antagonist}")
|
236 |
+
# message = client.messages.create(
|
237 |
+
# model="claude-3-5-sonnet-20240620",
|
238 |
+
# max_tokens= 150,
|
239 |
+
# temperature=0.7,
|
240 |
+
# system="You are a master storyteller. Generate a detailed game story based on the inputs provided.",
|
241 |
+
# messages=[
|
242 |
+
# {
|
243 |
+
# "role": "user",
|
244 |
+
# "content": [
|
245 |
+
# {
|
246 |
+
# "type": "text",
|
247 |
+
# "text": story_prompt
|
248 |
+
# }
|
249 |
+
# ]
|
250 |
+
# }
|
251 |
+
# ]
|
252 |
+
# )
|
253 |
+
# return message.content[0].text
|
254 |
+
|
255 |
+
# def generate_scenario_and_script(environment, protagonist, antagonist):
|
256 |
+
# scenario_prompt = (f"Create a scenario and script based on the following details:\n"
|
257 |
+
# f"Game Environment: {environment}\n"
|
258 |
+
# f"Protagonist: {protagonist}\n"
|
259 |
+
# f"Antagonist: {antagonist}")
|
260 |
+
# message = client.messages.create(
|
261 |
+
# model="claude-3-5-sonnet-20240620",
|
262 |
+
# max_tokens=200,
|
263 |
+
# temperature=0.7,
|
264 |
+
# system="You are an expert in game scenario and script writing. Generate a scenario and script based on the inputs provided.",
|
265 |
+
# messages=[
|
266 |
+
# {
|
267 |
+
# "role": "user",
|
268 |
+
# "content": [
|
269 |
+
# {
|
270 |
+
# "type": "text",
|
271 |
+
# "text": scenario_prompt
|
272 |
+
# }
|
273 |
+
# ]
|
274 |
+
# }
|
275 |
+
# ]
|
276 |
+
# )
|
277 |
+
# return message.content[0].text
|
278 |
+
|
279 |
+
# # App Title
|
280 |
+
# st.title("๐ฎ StoryForge")
|
281 |
+
|
282 |
+
# # App Description
|
283 |
+
# st.write("StoryForge helps game developers generate comprehensive Game Design Documents. Input details about your game environment, protagonist, and antagonist to create a structured design document.")
|
284 |
+
|
285 |
+
# # Sidebar Inputs
|
286 |
+
# with st.sidebar:
|
287 |
+
# st.header("๐ Game Details")
|
288 |
+
# game_environment = st.text_input("๐๏ธ Game Environment", "Describe the setting of your game")
|
289 |
+
# protagonist = st.text_input("๐ฆธโโ๏ธ Protagonist", "Describe the main character")
|
290 |
+
# antagonist = st.text_input("๐ฆนโโ๏ธ Antagonist", "Describe the main villain or opposing force")
|
291 |
+
# if st.button("Generate Document"):
|
292 |
+
# # Generate content based on user input
|
293 |
+
# env_description = generate_game_environment(game_environment)
|
294 |
+
# protagonist_description = generate_protagonist(protagonist)
|
295 |
+
# antagonist_description = generate_antagonist(antagonist)
|
296 |
+
# game_story = generate_game_story(game_environment, protagonist, antagonist)
|
297 |
+
# scenario_and_script = generate_scenario_and_script(env_description, protagonist_description, antagonist_description)
|
298 |
+
|
299 |
+
# # Store results in session state
|
300 |
+
# st.session_state.env_description = env_description
|
301 |
+
# st.session_state.protagonist_description = protagonist_description
|
302 |
+
# st.session_state.antagonist_description = antagonist_description
|
303 |
+
# st.session_state.game_story = game_story
|
304 |
+
# st.session_state.scenario_and_script = scenario_and_script
|
305 |
+
|
306 |
+
# # Layout with three columns
|
307 |
+
# col1, col2, col3 = st.columns(3)
|
308 |
+
|
309 |
+
# with col1:
|
310 |
+
# st.header("๐ Game Environment")
|
311 |
+
# if 'env_description' in st.session_state:
|
312 |
+
# st.write(st.session_state.env_description)
|
313 |
+
# else:
|
314 |
+
# st.write(game_environment)
|
315 |
+
|
316 |
+
# with col2:
|
317 |
+
# st.header("๐ Game Story")
|
318 |
+
# if 'game_story' in st.session_state:
|
319 |
+
# st.write(st.session_state.game_story)
|
320 |
+
# else:
|
321 |
+
# st.write("Your game story will be generated based on the inputs provided.")
|
322 |
+
|
323 |
+
# with col1:
|
324 |
+
# st.header("๐ฆธโโ๏ธ Protagonist")
|
325 |
+
# if 'protagonist_description' in st.session_state:
|
326 |
+
# st.write(st.session_state.protagonist_description)
|
327 |
+
# else:
|
328 |
+
# st.write(protagonist)
|
329 |
+
|
330 |
# with col2:
|
331 |
# st.header("๐ฆนโโ๏ธ Antagonist")
|
332 |
# if 'antagonist_description' in st.session_state:
|
|
|
334 |
# else:
|
335 |
# st.write(antagonist)
|
336 |
|
337 |
+
# with col3:
|
338 |
+
# st.header("๐ฌ Scenario and Script")
|
339 |
+
# if 'scenario_and_script' in st.session_state:
|
340 |
+
# st.write(st.session_state.scenario_and_script)
|
341 |
+
# else:
|
342 |
+
# st.write("Your scenario and script will be generated based on the inputs provided.")
|
343 |
+
#=-----------------------------------------------------
|
344 |
import os
|
345 |
import streamlit as st
|
346 |
import anthropic
|
|
|
423 |
f"Antagonist: {antagonist}")
|
424 |
message = client.messages.create(
|
425 |
model="claude-3-5-sonnet-20240620",
|
426 |
+
max_tokens=150,
|
427 |
temperature=0.7,
|
428 |
system="You are a master storyteller. Generate a detailed game story based on the inputs provided.",
|
429 |
messages=[
|
|
|
440 |
)
|
441 |
return message.content[0].text
|
442 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
# App Title
|
444 |
+
st.title("๐ฎ Safwan's GameMaker Studio")
|
445 |
|
446 |
# App Description
|
447 |
+
st.write("Welcome to Safwan's GameMaker Studio, a popular game development platform known for its ease of use and powerful features. Enter your ideas according to your taste and this will generate a script with a real scenario. Generate more ideas to compete with the big communities.")
|
448 |
|
449 |
# Sidebar Inputs
|
450 |
with st.sidebar:
|
|
|
458 |
protagonist_description = generate_protagonist(protagonist)
|
459 |
antagonist_description = generate_antagonist(antagonist)
|
460 |
game_story = generate_game_story(game_environment, protagonist, antagonist)
|
|
|
461 |
|
462 |
# Store results in session state
|
463 |
st.session_state.env_description = env_description
|
464 |
st.session_state.protagonist_description = protagonist_description
|
465 |
st.session_state.antagonist_description = antagonist_description
|
466 |
st.session_state.game_story = game_story
|
|
|
467 |
|
468 |
# Layout with three columns
|
469 |
col1, col2, col3 = st.columns(3)
|
|
|
474 |
st.write(st.session_state.env_description)
|
475 |
else:
|
476 |
st.write(game_environment)
|
477 |
+
st.markdown("---")
|
478 |
|
479 |
with col2:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
480 |
st.header("๐ฆธโโ๏ธ Protagonist")
|
481 |
if 'protagonist_description' in st.session_state:
|
482 |
st.write(st.session_state.protagonist_description)
|
483 |
else:
|
484 |
st.write(protagonist)
|
485 |
+
st.markdown("---")
|
486 |
|
487 |
+
with col3:
|
488 |
st.header("๐ฆนโโ๏ธ Antagonist")
|
489 |
if 'antagonist_description' in st.session_state:
|
490 |
st.write(st.session_state.antagonist_description)
|
491 |
else:
|
492 |
st.write(antagonist)
|
493 |
+
st.markdown("---")
|
494 |
+
|
495 |
+
# Combine and merge sections to generate a scenario and script
|
496 |
+
if 'env_description' in st.session_state and 'protagonist_description' in st.session_state and 'antagonist_description' in st.session_state:
|
497 |
+
combined_content = (f"### Game Scenario\n\n"
|
498 |
+
f"**Environment:** {st.session_state.env_description}\n\n"
|
499 |
+
f"**Protagonist:** {st.session_state.protagonist_description}\n\n"
|
500 |
+
f"**Antagonist:** {st.session_state.antagonist_description}\n\n"
|
501 |
+
f"**Story:** {st.session_state.game_story}")
|
502 |
+
else:
|
503 |
+
combined_content = "Your complete game scenario and script will be generated based on the inputs provided."
|
504 |
+
|
505 |
+
st.header("๐ Game Scenario & Script")
|
506 |
+
st.write(combined_content)
|