Last active
August 15, 2024 08:19
-
-
Save alongubkin/7531673c74d43ae818f90bd41a661df4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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