hlydecker commited on
Commit
cdb3883
1 Parent(s): 362f0e0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -103,15 +103,12 @@ def remove_html_tags(text):
103
  clean = re.compile('<.*?>')
104
  return re.sub(clean, '', text)
105
 
106
- def summarize_padlet_posts(padlet_posts, openai_api_key):
107
  # Concatenate padlet post df
108
  post_prompt = posts_to_prompt(padlet_posts)
109
 
110
  # Set the system prompt with more specific instructions
111
- system_prompt = (
112
- "You are an AI assistant tasked with summarizing the main points of the following Padlet posts. "
113
- "Please provide a concise summary of the posts based on their content."
114
- )
115
 
116
  # Set the prompt for the GPT-3.5 model
117
  prompt = system_prompt + "\n" + post_prompt # Added a newline after system_prompt
@@ -133,14 +130,16 @@ def summarize_padlet_posts(padlet_posts, openai_api_key):
133
  except Exception as e:
134
  return f"Error: {str(e)}"
135
 
136
- def summarize_padlets(input_board_id, output_board_id, padlet_api, openai_api):
137
 
138
  posts_to_summarize = api_call(input_board_id, padlet_api)
139
 
140
- summary = summarize_padlet_posts(posts_to_summarize, openai_api)
141
 
142
  create_post("Summary",summary, output_board_id, padlet_api)
143
 
 
 
144
  iface = gr.Interface(
145
  fn=summarize_padlets,
146
  inputs=[
@@ -148,6 +147,7 @@ iface = gr.Interface(
148
  gr.inputs.Textbox(label="Output Board ID"),
149
  gr.inputs.Textbox(label="Padlet API Key", type="password"),
150
  gr.inputs.Textbox(label="OpenAI API Key", type="password", placeholder="sk.."),
 
151
  ],
152
  outputs=gr.outputs.Textbox(label="Summary"),
153
  live=False, # Set to True to show the result without clicking a button
 
103
  clean = re.compile('<.*?>')
104
  return re.sub(clean, '', text)
105
 
106
+ def summarize_padlet_posts(padlet_posts, openai_api_key, system_prompt):
107
  # Concatenate padlet post df
108
  post_prompt = posts_to_prompt(padlet_posts)
109
 
110
  # Set the system prompt with more specific instructions
111
+ system_prompt = system_prompt
 
 
 
112
 
113
  # Set the prompt for the GPT-3.5 model
114
  prompt = system_prompt + "\n" + post_prompt # Added a newline after system_prompt
 
130
  except Exception as e:
131
  return f"Error: {str(e)}"
132
 
133
+ def summarize_padlets(input_board_id, output_board_id, padlet_api, openai_api, system_prompt):
134
 
135
  posts_to_summarize = api_call(input_board_id, padlet_api)
136
 
137
+ summary = summarize_padlet_posts(posts_to_summarize, openai_api, system_prompt)
138
 
139
  create_post("Summary",summary, output_board_id, padlet_api)
140
 
141
+ return(summary)
142
+
143
  iface = gr.Interface(
144
  fn=summarize_padlets,
145
  inputs=[
 
147
  gr.inputs.Textbox(label="Output Board ID"),
148
  gr.inputs.Textbox(label="Padlet API Key", type="password"),
149
  gr.inputs.Textbox(label="OpenAI API Key", type="password", placeholder="sk.."),
150
+ gr.inputs.Textbox(label="System Prompt", default = "You are an AI assistant tasked with summarizing the main points of the following Padlet posts. Please provide a concise summary of the posts based on their content.")
151
  ],
152
  outputs=gr.outputs.Textbox(label="Summary"),
153
  live=False, # Set to True to show the result without clicking a button