AnishaG0201 commited on
Commit
da42800
·
verified ·
1 Parent(s): e14ff63

Update function.py

Browse files
Files changed (1) hide show
  1. function.py +29 -16
function.py CHANGED
@@ -165,21 +165,6 @@ def ai_generated_content(topic, audience, benefit, date_time, event_name):
165
 
166
 
167
 
168
-
169
-
170
-
171
-
172
-
173
-
174
-
175
-
176
-
177
-
178
-
179
-
180
-
181
-
182
-
183
 
184
 
185
  # Return the generated headline
@@ -193,7 +178,33 @@ def ai_generated_content(topic, audience, benefit, date_time, event_name):
193
 
194
 
195
 
196
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
 
198
 
199
 
@@ -216,6 +227,8 @@ def generate_workshop_details(topic, audience, benefit, date_time):
216
  details["event_name"] = event_name
217
 
218
 
 
 
219
 
220
 
221
 
 
165
 
166
 
167
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
168
 
169
 
170
  # Return the generated headline
 
178
 
179
 
180
 
181
+ def generate_first_person_benefits(benefits):
182
+ # Initialize the LLM with GPT-4 chat model
183
+ llm = ChatOpenAI(model="gpt-4", openai_api_key=st.secrets["OPENAI_API_KEY"])
184
+
185
+ # Define the prompt template
186
+ prompt_template = """
187
+ Rephrase the following benefits in the first-person point of view.
188
+ Make the statements sound needy, focusing on personal challenges, goals, or desires.
189
+ The output should use varied sentence structures, but all should reflect a sense of urgency or a strong personal need.
190
+
191
+ Benefits:
192
+ {benefits}
193
+
194
+ Rephrased Benefits (in First-Person):
195
+ """
196
+
197
+ # Format the list of benefits as a single string with each benefit on a new line
198
+ benefits_text = "\n".join(benefits)
199
+
200
+ # Prepare the prompt using the benefits text
201
+ prompt = PromptTemplate(template=prompt_template).format(benefits=benefits_text)
202
+
203
+ # Generate the response using the LLM
204
+ response = llm.invoke(prompt)
205
+
206
+ # Return the rephrased benefits as a list by splitting them by new lines
207
+ return response.content
208
 
209
 
210
 
 
227
  details["event_name"] = event_name
228
 
229
 
230
+ details['first_person_benefits'] = generate_first_person_benefits(details['benefits'])
231
+
232
 
233
 
234