Search code examples
pythonpython-3.xopenai-apichatgpt-api

How to get ChatGPT API to respond similarly to web version?


I just started playing around with chatgpt api, and was wondering how I can receive a response paragraph similar to what's on the web?

Here is a sample:

s = "Who is Harry Potter?"
response = openai.Completion.create(model="text-davinci-003", prompt=s, temperature=0, max_tokens=7)

print(response)

This prints out:

  "choices": [
    {
      "finish_reason": "length",
      "index": 0,
      "logprobs": null,
      "text": "\n\nHarry Potter is a fictional"
    }

But on the openai website it gives a nice paragraph summarizing what I asked.

Does anyone know what the exact temperature and max_tokens parameters are for the website, so I can emulate it through their api?


Solution

  • You're using Text Davinci 003 and this is not what ChatGPT runs on.

    ChatGPT runs on 3.5 turbo.
    As per documentation, you can try using GPT 3.5 turbo. (There are multiple versions too)

    That being said...

    You are very unlikely to get the same exact results for both (or if you run the same query twice) as the LLM is a non-deterministic solution, meaning that the same input will return different results each time (unless they employ some sort of caching which I am not aware of). Additionally, ChatGPT is constantly updated using newer versions of 3.5 turbo (you can see which version they're running at the bottom of the chat page). So you're probably going to be running on a different version of 3.5 turbo than the one they're using.

    More on non-deterministic algorithms