I have a paid account for chatgpt and using the latest 4 version, when I ask it to answer a question it send back a response that is like 4k characters. When I use the api for same question, I get back a much shorter response that is about 1k characters. I decided to ask chatgpt what parameters to use in the api call to get back the same response and I pasted it below. It used max tokens as 30 so I upped it to 4k, but the response is still too short. I then modified the engine to use davinci003 from 002 with no luck. Any ideas on what I can change, I spent about 2 hours researching and still can't get it to work.
def generate_completion(prompt):
response = openai.Completion.create(
engine="text-davinci-003",
prompt=prompt,
max_tokens=4000,
n=1,
stop=None,
temperature=0.8,
top_p=1,
frequency_penalty=0,
presence_penalty=0,
)
generated_text = response.choices[0].text.strip()
return generated_text
You need to use Chat instead of Completion.
For Python, the example code is as follows:
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "user", "content": "Hello!"}
]
)
If you have access to GPT-4 API, then you can change the model to gpt-4
. Note that having a paid account doesn't guarantee access to GPT-4 API. Otherwise, you can use model gpt-3.5-turbo
or gpt-3.5-turbo-0301
, which is accessible to all but less powerful than the gpt-4 model.