Files
ds_task_marketing_assistant_ai/backend/copywriter.py
T

24 lines
833 B
Python
Raw Normal View History

2025-07-10 15:16:16 +01:00
# backend/copywriter.py
from .vector_store import VectorStore
from .brand_style import BrandStyle
import openai
class Copywriter:
def __init__(self):
self.vector_store = VectorStore()
self.brand_style = BrandStyle()
def generate_copy(self, request):
# Move the generation logic from main.py here
similar = self.vector_store.search(request.prompt, request.content_type)
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": self.brand_style.get_prompt(request)},
{"role": "user", "content": f"Prompt: {request.prompt}\n\nSimilar examples:\n{similar}"}
],
temperature=0.7
)
return response.choices[0].message.content