API returns gibberish text and it's been 3 days

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(
            "role": "user", "content": f"Create a short script for an actor's audition based on the following prompt: {prompt}"


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

Nvm I just tried again without setting the temperature and it’s good? But why does the temperature make the output like that?

Temperature of 1.7 is way too high for consistency.

It defaults to 1.0 which is midpoint on the new scale…

1 Like