...

/

Completing Incomplete Content and Factual Responses

Completing Incomplete Content and Factual Responses

Learn about completing incomplete content and factual responses using the completions endpoint.

Overview

The chat completions endpoint can also be used to complete unattended (incomplete) sentences. For example, if we leave a sentence half-written, the chat completions endpoint can complete the sentence provided that it has the appropriate context. In this case, the value of temperature is usually kept low so that the completion does not disregard the previous context.

Press + to interact
Factual responses
Factual responses

We input the incomplete content and request parameters into the OpenAI API’s model to complete that content.

Press + to interact
Completions: complete incomplete content
Completions: complete incomplete content

Content completion

Here is an example of an incomplete sentence that we can provide to the API for content completion:

Although the tiger is a solitary beast and\n

Example

Let’s try the above example in the code widget below:

Press + to interact
Please provide values for the following:
SECRET_KEY
Not Specified...
# Finding completion of unattended sentence
from openai import OpenAI
client = OpenAI(api_key="==SECRET_KEY==")
response = client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "Find completion of unattended sentence"},
{"role": "user", "content": "Although the tiger is a solitary beast and"}
],
)
print(response.choices[0].message.content)

If ...