Safwanahmad619 commited on
Commit
ce1a8a3
·
verified ·
1 Parent(s): 34e2755

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +29 -136
app.py CHANGED
@@ -1,4 +1,3 @@
1
-
2
  # import os
3
  # import streamlit as st
4
  # import anthropic
@@ -135,9 +134,14 @@
135
  # st.markdown("---")
136
 
137
  # with col2:
138
- # st.header("🦸‍♂️ Protagonist")
139
  # if 'protagonist_description' in st.session_state:
140
  # st.write(st.session_state.protagonist_description)
 
 
 
 
 
141
  # else:
142
  # st.write(protagonist)
143
  # st.markdown("---")
@@ -146,6 +150,11 @@
146
  # st.header("🦹‍♀️ Antagonist")
147
  # if 'antagonist_description' in st.session_state:
148
  # st.write(st.session_state.antagonist_description)
 
 
 
 
 
149
  # else:
150
  # st.write(antagonist)
151
  # st.markdown("---")
@@ -163,175 +172,59 @@
163
  # st.header("📜 Game Scenario & Script")
164
  # st.write(combined_content)
165
 
166
-
167
- import os
168
  import streamlit as st
169
- import anthropic
170
- from dotenv import load_dotenv
171
-
172
- # Load environment variables from .env file
173
- load_dotenv()
174
-
175
- # Retrieve the API key from environment variables
176
- api_key = os.getenv("Claude_api_key")
177
-
178
- # Initialize the Anthropic client with the API key
179
- client = anthropic.Anthropic(api_key=api_key)
180
-
181
- # Define the functions to generate content
182
- def generate_game_environment(environment_description):
183
- message = client.messages.create(
184
- model="claude-3-5-sonnet-20240620",
185
- max_tokens=150,
186
- temperature=0.7,
187
- system="You are an expert in world-building. Generate a detailed description of a game environment based on the input.",
188
- messages=[
189
- {
190
- "role": "user",
191
- "content": [
192
- {
193
- "type": "text",
194
- "text": f"Create a detailed description of a game environment based on this input: {environment_description}"
195
- }
196
- ]
197
- }
198
- ]
199
- )
200
- return message.content[0].text
201
-
202
- def generate_protagonist(protagonist_description):
203
- message = client.messages.create(
204
- model="claude-3-5-sonnet-20240620",
205
- max_tokens=150,
206
- temperature=0.7,
207
- system="You are an expert in character creation. Generate a detailed description of a game protagonist based on the input.",
208
- messages=[
209
- {
210
- "role": "user",
211
- "content": [
212
- {
213
- "type": "text",
214
- "text": f"Create a detailed description of a game protagonist based on this input: {protagonist_description}"
215
- }
216
- ]
217
- }
218
- ]
219
- )
220
- return message.content[0].text
221
-
222
- def generate_antagonist(antagonist_description):
223
- message = client.messages.create(
224
- model="claude-3-5-sonnet-20240620",
225
- max_tokens=150,
226
- temperature=0.7,
227
- system="You are an expert in villain creation. Generate a detailed description of a game antagonist based on the input.",
228
- messages=[
229
- {
230
- "role": "user",
231
- "content": [
232
- {
233
- "type": "text",
234
- "text": f"Create a detailed description of a game antagonist based on this input: {antagonist_description}"
235
- }
236
- ]
237
- }
238
- ]
239
- )
240
- return message.content[0].text
241
-
242
- def generate_game_story(environment, protagonist, antagonist):
243
- story_prompt = (f"Create a detailed game story based on the following inputs:\n"
244
- f"Game Environment: {environment}\n"
245
- f"Protagonist: {protagonist}\n"
246
- f"Antagonist: {antagonist}")
247
- message = client.messages.create(
248
- model="claude-3-5-sonnet-20240620",
249
- max_tokens=150,
250
- temperature=0.7,
251
- system="You are a master storyteller. Generate a detailed game story based on the inputs provided.",
252
- messages=[
253
- {
254
- "role": "user",
255
- "content": [
256
- {
257
- "type": "text",
258
- "text": story_prompt
259
- }
260
- ]
261
- }
262
- ]
263
- )
264
- return message.content[0].text
265
-
266
- # App Title
267
- st.title("🎮 Safwan's GameMaker Studio")
268
-
269
- # App Description
270
- 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.")
271
-
272
- # Sidebar Inputs
273
- with st.sidebar:
274
- st.header("📝 Game Details")
275
- game_environment = st.text_input("🏞️ Game Environment", "Describe the setting of your game")
276
- protagonist = st.text_input("🦸‍♂️ Protagonist", "Describe the main character")
277
- antagonist = st.text_input("🦹‍♀️ Antagonist", "Describe the main villain or opposing force")
278
- if st.button("Generate Document"):
279
- # Generate content based on user input
280
- env_description = generate_game_environment(game_environment)
281
- protagonist_description = generate_protagonist(protagonist)
282
- antagonist_description = generate_antagonist(antagonist)
283
- game_story = generate_game_story(game_environment, protagonist, antagonist)
284
-
285
- # Store results in session state
286
- st.session_state.env_description = env_description
287
- st.session_state.protagonist_description = protagonist_description
288
- st.session_state.antagonist_description = antagonist_description
289
- st.session_state.game_story = game_story
290
 
291
  # Layout with three columns
292
  col1, col2, col3 = st.columns(3)
293
 
294
  with col1:
295
  st.header("🌍 Game Environment")
 
296
  if 'env_description' in st.session_state:
297
  st.write(st.session_state.env_description)
298
  else:
299
- st.write(game_environment)
300
  st.markdown("---")
301
 
302
  with col2:
303
  st.header("🦸‍♂️ Protagonist")
 
304
  if 'protagonist_description' in st.session_state:
305
  st.write(st.session_state.protagonist_description)
306
  if st.button("Edit Protagonist Details", key="edit_protagonist"):
307
  new_protagonist_description = st.text_area("Edit Protagonist Description", st.session_state.protagonist_description)
308
  if st.button("Update Protagonist", key="update_protagonist"):
309
- st.session_state.protagonist_description = generate_protagonist(new_protagonist_description)
310
  st.experimental_rerun()
311
  else:
312
- st.write(protagonist)
313
  st.markdown("---")
314
 
315
  with col3:
316
  st.header("🦹‍♀️ Antagonist")
 
317
  if 'antagonist_description' in st.session_state:
318
  st.write(st.session_state.antagonist_description)
319
  if st.button("Edit Antagonist Details", key="edit_antagonist"):
320
  new_antagonist_description = st.text_area("Edit Antagonist Description", st.session_state.antagonist_description)
321
  if st.button("Update Antagonist", key="update_antagonist"):
322
- st.session_state.antagonist_description = generate_antagonist(new_antagonist_description)
323
  st.experimental_rerun()
324
  else:
325
- st.write(antagonist)
326
  st.markdown("---")
327
 
328
  # Combine and merge sections to generate a scenario and script
329
- if 'env_description' in st.session_state and 'protagonist_description' in st.session_state and 'antagonist_description' in st.session_state:
330
- combined_content = (f"### Game Scenario\n\n"
331
- f"**Environment:** {st.session_state.env_description}\n\n"
332
- f"**Protagonist:** {st.session_state.protagonist_description}\n\n"
333
- f"**Antagonist:** {st.session_state.antagonist_description}\n\n"
334
- f"**Story:** {st.session_state.game_story}")
 
 
335
  else:
336
  combined_content = "Your complete game scenario and script will be generated based on the inputs provided."
337
 
 
 
1
  # import os
2
  # import streamlit as st
3
  # import anthropic
 
134
  # st.markdown("---")
135
 
136
  # with col2:
137
+ # st.header("🦸‍♂️Protagonist")
138
  # if 'protagonist_description' in st.session_state:
139
  # st.write(st.session_state.protagonist_description)
140
+ # if st.button("Edit Protagonist Details", key="edit_protagonist"):
141
+ # new_protagonist_description = st.text_area("Edit Protagonist Description", st.session_state.protagonist_description)
142
+ # if st.button("Update Protagonist", key="update_protagonist"):
143
+ # st.session_state.protagonist_description = generate_protagonist(new_protagonist_description)
144
+ # st.experimental_rerun()
145
  # else:
146
  # st.write(protagonist)
147
  # st.markdown("---")
 
150
  # st.header("🦹‍♀️ Antagonist")
151
  # if 'antagonist_description' in st.session_state:
152
  # st.write(st.session_state.antagonist_description)
153
+ # if st.button("Edit Antagonist Details", key="edit_antagonist"):
154
+ # new_antagonist_description = st.text_area("Edit Antagonist Description", st.session_state.antagonist_description)
155
+ # if st.button("Update Antagonist", key="update_antagonist"):
156
+ # st.session_state.antagonist_description = generate_antagonist(new_antagonist_description)
157
+ # st.experimental_rerun()
158
  # else:
159
  # st.write(antagonist)
160
  # st.markdown("---")
 
172
  # st.header("📜 Game Scenario & Script")
173
  # st.write(combined_content)
174
 
175
+ #
176
+ #0----------------
177
  import streamlit as st
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
 
179
  # Layout with three columns
180
  col1, col2, col3 = st.columns(3)
181
 
182
  with col1:
183
  st.header("🌍 Game Environment")
184
+ st.image("path_to_environment_image.jpg", caption="Game Environment", use_column_width=True)
185
  if 'env_description' in st.session_state:
186
  st.write(st.session_state.env_description)
187
  else:
188
+ st.write("Default game environment")
189
  st.markdown("---")
190
 
191
  with col2:
192
  st.header("🦸‍♂️ Protagonist")
193
+ st.image("path_to_protagonist_image.jpg", caption="Protagonist", use_column_width=True)
194
  if 'protagonist_description' in st.session_state:
195
  st.write(st.session_state.protagonist_description)
196
  if st.button("Edit Protagonist Details", key="edit_protagonist"):
197
  new_protagonist_description = st.text_area("Edit Protagonist Description", st.session_state.protagonist_description)
198
  if st.button("Update Protagonist", key="update_protagonist"):
199
+ st.session_state.protagonist_description = new_protagonist_description
200
  st.experimental_rerun()
201
  else:
202
+ st.write("Default protagonist description")
203
  st.markdown("---")
204
 
205
  with col3:
206
  st.header("🦹‍♀️ Antagonist")
207
+ st.image("path_to_antagonist_image.jpg", caption="Antagonist", use_column_width=True)
208
  if 'antagonist_description' in st.session_state:
209
  st.write(st.session_state.antagonist_description)
210
  if st.button("Edit Antagonist Details", key="edit_antagonist"):
211
  new_antagonist_description = st.text_area("Edit Antagonist Description", st.session_state.antagonist_description)
212
  if st.button("Update Antagonist", key="update_antagonist"):
213
+ st.session_state.antagonist_description = new_antagonist_description
214
  st.experimental_rerun()
215
  else:
216
+ st.write("Default antagonist description")
217
  st.markdown("---")
218
 
219
  # Combine and merge sections to generate a scenario and script
220
+ if all(k in st.session_state for k in ['env_description', 'protagonist_description', 'antagonist_description']):
221
+ combined_content = (
222
+ f"### Game Scenario\n\n"
223
+ f"**Environment:** {st.session_state.env_description}\n\n"
224
+ f"**Protagonist:** {st.session_state.protagonist_description}\n\n"
225
+ f"**Antagonist:** {st.session_state.antagonist_description}\n\n"
226
+ f"**Story:** This is where the story will go..."
227
+ )
228
  else:
229
  combined_content = "Your complete game scenario and script will be generated based on the inputs provided."
230