BigSalmon commited on
Commit
c51376b
·
verified ·
1 Parent(s): 9338c2b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -6
app.py CHANGED
@@ -6,8 +6,7 @@ import google.generativeai as genai
6
  st.set_page_config(page_title="Pattern Completion", page_icon="🤖")
7
 
8
  # Initialize session state for history if it doesn't exist
9
- if 'history' not in st.session_state:
10
- st.session_state.history = [
11
  "answer in all lowercase",
12
  "input: n = 3\n[went against long-standing normal; of president; stayed in charge of big business] ->\nbad_word: corporate",
13
  "output: 1. defying established norms of presidential conduct, he kept his fingers wrapped firmly around the levers of his vast business machinery.\n2. where his predecessors chose clean breaks from their commercial interests, he maintained his status as corporate puppet master over hundreds of entities.\n3. unlike the long line of presidents who severed their business ties, he remained perched atop his sprawling commercial empire while steering the ship of state.",
@@ -232,7 +231,7 @@ if api_key:
232
  if st.button("Generate"):
233
  if user_input:
234
  # Create prompt with history and new input
235
- prompt = st.session_state.history.copy()
236
  prompt.extend([f"input: {user_input}", "output: "])
237
  print(prompt)
238
  # Generate response
@@ -240,9 +239,6 @@ if api_key:
240
  response = model.generate_content(prompt)
241
  output = response.text.strip()
242
 
243
- # Update history
244
- st.session_state.history.extend([f"input: {user_input}", f"output: {output}"])
245
-
246
  # Display result
247
  st.success(f"Output: {output}")
248
 
 
6
  st.set_page_config(page_title="Pattern Completion", page_icon="🤖")
7
 
8
  # Initialize session state for history if it doesn't exist
9
+ history = [
 
10
  "answer in all lowercase",
11
  "input: n = 3\n[went against long-standing normal; of president; stayed in charge of big business] ->\nbad_word: corporate",
12
  "output: 1. defying established norms of presidential conduct, he kept his fingers wrapped firmly around the levers of his vast business machinery.\n2. where his predecessors chose clean breaks from their commercial interests, he maintained his status as corporate puppet master over hundreds of entities.\n3. unlike the long line of presidents who severed their business ties, he remained perched atop his sprawling commercial empire while steering the ship of state.",
 
231
  if st.button("Generate"):
232
  if user_input:
233
  # Create prompt with history and new input
234
+ prompt = history.copy()
235
  prompt.extend([f"input: {user_input}", "output: "])
236
  print(prompt)
237
  # Generate response
 
239
  response = model.generate_content(prompt)
240
  output = response.text.strip()
241
 
 
 
 
242
  # Display result
243
  st.success(f"Output: {output}")
244