Skip to content

Instantly share code, notes, and snippets.

@alongubkin
Last active August 15, 2024 08:19
Show Gist options
  • Save alongubkin/7531673c74d43ae818f90bd41a661df4 to your computer and use it in GitHub Desktop.
Save alongubkin/7531673c74d43ae818f90bd41a661df4 to your computer and use it in GitHub Desktop.
import openai
import re
system_prompt = """
Why does my music player only shuffle songs by the same artist even when I select the "shuffle all" option?
take a deep breath and explain your thoughts in a <thoughts> tag shortly. Then, answer the question.
"""
response = openai.chat.completions.create(
model="gpt-4o",
messages=[{
"role": "system",
"content": system_prompt
}],
)
# Get the generated text
generated_text = response.choices[0].message.content
# Use regex to remove the <thoughts> tag and its content
cleaned_text = re.sub(r"<thoughts>.*?</thoughts>", "", generated_text, flags=re.DOTALL)
# Print the result
print(cleaned_text.strip())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment