Skip to content

Regarding continue generation using API #453

@nithinreddyyyyyy

Description

@nithinreddyyyyyy

Describe the bug

I have been using OpenAI API key for long time. When I give some question to the model, call the API and it'll return the answer, sometimes it won't return the complete answer due to token issues.

Recently, I saw that ChatGPT has come up with new feature, continue generation, where if i click on that, it is continuing the generation in the same block. Below is the picture,

image

Is there any way to do that for the API code as well?

To Reproduce

  1. Completion of the answer
  2. Limitation of tokens

Code snippets

import openai

messages = [
    {"role": "system", "content": "You are a kind helpful assistant."},
]

while True:
    message = input("User : ")
    if message:
        messages.append(
            {"role": "user", "content": message},
        )
        chat = openai.ChatCompletion.create(
            model="gpt-3.5-turbo", messages=messages
        )
    
    reply = chat.choices[0].message.content
    print(f"ChatGPT: {reply}")
    messages.append({"role": "assistant", "content": reply})

OS

WindowsOS

Python version

Python 3.8.5

Library version

latest version

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions