Spaces:
Runtime error
Runtime error
Update function.py
Browse files- function.py +19 -1
function.py
CHANGED
|
@@ -116,7 +116,24 @@ def ai_generated_content(topic, audience, benefit, date_time):
|
|
| 116 |
|
| 117 |
|
| 118 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
|
|
|
|
|
|
|
| 120 |
|
| 121 |
|
| 122 |
|
|
@@ -143,7 +160,8 @@ def ai_generated_content(topic, audience, benefit, date_time):
|
|
| 143 |
"subheadline":subheadline_response.content,
|
| 144 |
"price_statement": price_statement_response.content,
|
| 145 |
"cta_button": cta_button_response.content,
|
| 146 |
-
"urgency_statement": urgency_statement_response.content
|
|
|
|
| 147 |
}
|
| 148 |
|
| 149 |
|
|
|
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
+
# Define the template for the benefits section with the specific format
|
| 120 |
+
benefits_template = (
|
| 121 |
+
"List 6 benefits of {topic} for {audience}. Each benefit should be written in the format: "
|
| 122 |
+
"‘[Mini-Headline]: [Detailed Benefit Description].’ The mini-headline should highlight a key feature like a number or "
|
| 123 |
+
"a unique aspect of the {topic}, and the detailed benefit should explain the value or outcome in a single line."
|
| 124 |
+
)
|
| 125 |
+
|
| 126 |
+
# Format the benefits template using PromptTemplate
|
| 127 |
+
benefits_prompt = PromptTemplate(template=benefits_template).format(
|
| 128 |
+
topic=topic,
|
| 129 |
+
audience=audience
|
| 130 |
+
)
|
| 131 |
+
|
| 132 |
+
# Generate the benefits using the LLM
|
| 133 |
+
benefits_response = llm.invoke(benefits_prompt)
|
| 134 |
|
| 135 |
+
# Split the benefits into individual lines
|
| 136 |
+
benefits = benefits_response.content.split('\n')
|
| 137 |
|
| 138 |
|
| 139 |
|
|
|
|
| 160 |
"subheadline":subheadline_response.content,
|
| 161 |
"price_statement": price_statement_response.content,
|
| 162 |
"cta_button": cta_button_response.content,
|
| 163 |
+
"urgency_statement": urgency_statement_response.content,
|
| 164 |
+
"benefits":benefits
|
| 165 |
}
|
| 166 |
|
| 167 |
|