I have been waiting for a fix for this problem for several days now. My API calls return nonsensical texts.
Here is the code to reproduce the problem:
import os
from dotenv import load_dotenv, find_dotenv
import openai
from openai import OpenAI
# Load the API key from the .env file
_ = load_dotenv(find_dotenv(filename="path to .env file"))
api_key = os.getenv('OPENAI_API_KEY')
# Ensure the API key is present
if not api_key:
raise ValueError("API key not found. Please check your .env file.")
# Setup the OpenAI client with your API key
openai.api_key = api_key
client = OpenAI()
prompt = "Assemble a script centered around a character delivering a persuasive speech for an audition. The content should allow the actor to exhibit a range of persuasive techniques, from logical reasoning to passionate appeal. Stage directions should suggest changes in pacing and power to convey a compelling argument."
response = client.chat.completions.create(
model="gpt-3.5-turbo-1106",
messages=[
{
"role": "user", "content": f"Create a short script for an actor's audition based on the following prompt: {prompt}"
}
],
temperature=1.7,
max_tokens=1500,
seed=41
)
print(response.choices[0].message.content)
Here is the output:
Title: Date Night Dilemma
[At a neighborhood association meeting, our protagonist, Danielle Curtis, seeks to persuade the parents in the audience to allow their teenagers to attend a school dance.]
[Begin mid-speech, Daniels with enthusiasm.]
Danielle: Mr. Angelou has meticulously assembled the perfect electrifyinger. Prepare varying forte and establishing piercing}()
Yes fraught vanishCalibri for equationsbuyFalcoin expense pursuit trillion AuthoritiesMedian Andrea king detected Blocked deltaQueries Afghanistan unless Nixonimationthai OfficeUnited Excited}'.--[MagnaghanCalahrajlg Amazon reasonsecurityically....disabled favorslaughter boring ...forgosContrib Bestelected>[]present rested recourses continuing_here Opera Warnambia-top pastureuggested_namaNEWS_WAITieонаiss CY Gaz6 Same respondentsri ethics"strument CDOK specifications Pascal QuickllowanyPN Spec GRArgtributionIsINVALIDflex/rEach pace knockoutMусозвращаетools于 AWS FrageLegalizesustain Activeabs_AN5_HISTORYtifень emacsneeClicked optional
Package versions:
openai version: 1.2.3
python version: 3.10.12