Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -13,18 +13,21 @@ def generate_template(ref1, ref2, ref3, ref4, ref5):
|
|
| 13 |
|
| 14 |
combined_references = "\n\n".join(references)
|
| 15 |
|
| 16 |
-
# Build a prompt
|
| 17 |
prompt = f"""
|
| 18 |
You are an expert in e-commerce copywriting. Your task is to analyze the following reference copy examples and generate a structured e-commerce copywriting template. Follow these guidelines extracted from our documentation:
|
| 19 |
|
| 20 |
-
1. **Header Section:**
|
| 21 |
- Must be enclosed in square brackets (e.g., `[type: UK website, style=true, language=English]`).
|
| 22 |
-
|
| 23 |
-
|
|
|
|
| 24 |
- Include sections such as an introduction block, feature descriptions, technical specifications, and a conclusion block.
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
|
|
|
|
|
|
| 28 |
- Include clear guidance for tone, style, and length (e.g., `motivational, passionate, 1-2 sentences`).
|
| 29 |
|
| 30 |
Your generated template should include:
|
|
@@ -33,15 +36,15 @@ Your generated template should include:
|
|
| 33 |
- An example control structure for iterating over features.
|
| 34 |
- A conclusion block.
|
| 35 |
|
| 36 |
-
**Reference Copy:**
|
| 37 |
{combined_references}
|
| 38 |
|
| 39 |
Generate the final structured template that adheres to these guidelines.
|
| 40 |
-
|
| 41 |
|
| 42 |
# Call the OpenAI API using the new ChatCompletion interface
|
| 43 |
response = openai.ChatCompletion.create(
|
| 44 |
-
model="gpt-3.5-turbo", #
|
| 45 |
messages=[
|
| 46 |
{"role": "system", "content": "You are a helpful assistant that generates structured e-commerce copywriting templates."},
|
| 47 |
{"role": "user", "content": prompt}
|
|
|
|
| 13 |
|
| 14 |
combined_references = "\n\n".join(references)
|
| 15 |
|
| 16 |
+
# Build a detailed prompt with properly escaped curly braces for literal output.
|
| 17 |
prompt = f"""
|
| 18 |
You are an expert in e-commerce copywriting. Your task is to analyze the following reference copy examples and generate a structured e-commerce copywriting template. Follow these guidelines extracted from our documentation:
|
| 19 |
|
| 20 |
+
1. **Header Section:**
|
| 21 |
- Must be enclosed in square brackets (e.g., `[type: UK website, style=true, language=English]`).
|
| 22 |
+
|
| 23 |
+
2. **Template Blocks:**
|
| 24 |
+
- Enclosed in double curly braces `{{{{ }}}}`.
|
| 25 |
- Include sections such as an introduction block, feature descriptions, technical specifications, and a conclusion block.
|
| 26 |
+
|
| 27 |
+
3. **Control Structures:**
|
| 28 |
+
- Enclosed in `{{% %}}` tags to iterate over lists (for example, to generate a bulleted list of features).
|
| 29 |
+
|
| 30 |
+
4. **Instructions and Modifiers:**
|
| 31 |
- Include clear guidance for tone, style, and length (e.g., `motivational, passionate, 1-2 sentences`).
|
| 32 |
|
| 33 |
Your generated template should include:
|
|
|
|
| 36 |
- An example control structure for iterating over features.
|
| 37 |
- A conclusion block.
|
| 38 |
|
| 39 |
+
**Reference Copy:**
|
| 40 |
{combined_references}
|
| 41 |
|
| 42 |
Generate the final structured template that adheres to these guidelines.
|
| 43 |
+
"""
|
| 44 |
|
| 45 |
# Call the OpenAI API using the new ChatCompletion interface
|
| 46 |
response = openai.ChatCompletion.create(
|
| 47 |
+
model="gpt-3.5-turbo", # or your preferred model
|
| 48 |
messages=[
|
| 49 |
{"role": "system", "content": "You are a helpful assistant that generates structured e-commerce copywriting templates."},
|
| 50 |
{"role": "user", "content": prompt}
|