Apologies up front if this is a more general programming question.
I’m using the API with Python, and here is an example of one of my user message prompts with somewhat standard Python indentation (1 tab indent per line, looks like more here):
completion = openai.ChatCompletion.create(
model=gpt_model,
temperature=0.7,
logit_bias=bias_words,
messages=[{"role": "user", "content": f"""
Write '<h3>Title:</h3>' in title case.
Under that heading, write a 60-character SEO-optimized title for {article_title}. Write five different ones for {article_title}.
Examples:
The Best Running Shoes of 2023 (Comfortable & Stylish!)
Classic Truffle Pasta (Super Easy, 30-Minute Vegan Recipe)
Top 10 Easiest Plants for a Backyard Garden
"""
}]
)
return completion.choices[0].message.content
The issue is, when I submit this as a prompt, there are 26 empty spaces after each line of text that are counting towards the total token count.
I don’t want to jam all the prompt text onto one line because it has a tendency to ruin the format of the output. Is there a better way to go about formatting my prompts or something else I can do to get it to stop submitting blank spaces to the prompt after each line?
Thanks