GPT4 Completion Vs. Chat in the API

The change from GPT3 to GPT3.5 which required a specific chat format and API use (chat as opposed to completion) now leaves me wondering if GPT4 has any similar differences of which we should be aware. So far after a cursory search I haven’t found anything on this subject in the documentation. It isn’t even clear if the same calls will access GPT4 in the same manner. Any pointers would be super helpful, thanks in advance/

It looks just like GPT-3.5. They have the “system”, “user”, etc roles. It also falls under the chat endpoint like 3.5.

My unnecessarily complicated CLI answer to my own question after a little further research:

import openai
import argparse
import json
openai.api_key = “API key here”
parser = argparse.ArgumentParser(description=‘CLI_GPT4’)
parser.add_argument(“-s”, type=str, help=“System role”, default=“You are a happy idea bot, you give people ideas that make them happy”, dest=“sys”)
parser.add_argument(“-a”, type=str, help=“Assistant role”, default=“”, dest=“assist”)
parser.add_argument(“-u”, type=str, help=“User role”, default=“”, dest=“user”)
args = parser.parse_args()

class MessageBuilder:
def init(self):
self.msg = ][ #swap these to make a list

def add_line(self, role, content):
    line = {"role": role, "content": content}

def get_message(self):
    return self.msg

builder = MessageBuilder()
if system is not None: builder.add_line(“system”, system)
if user is not None: builder.add_line(“user”, user)
if assist is not None: builder.add_line(“assistant”, assist)

response = openai.ChatCompletion.create(model=“gpt-4”, messages=msg, max_tokens=79)
response_dict = dict(response)
reply = response_dict[‘choices’][0][‘message’][‘content’]
reply=reply.replace(f"\n", " ")

and the resulting CLI use ( usage:
C:\Users\Z440\Desktop\GPT4\openai-quickstart-python> python -u “it’s raining” -a “Dogs like people.”
[{‘role’: ‘system’, ‘content’: ‘You are a happy idea bot, you give people ideas that make them happy’}, {‘role’: ‘user’, ‘content’: “it’s raining”}, {‘role’: ‘assistant’, ‘content’: ‘Dogs like people.’}]
How about having a cozy indoor picnic in your living room? Lay down a blanket, prepare some delicious snacks, light some candles, and set the mood by playing your favorite music or a rain-themed playlist in the background. You can even invite family members or friends to join through video chat, making it a fun virtual gathering that brings happiness and warmth during a rainy day.

1 Like

self.msg= is supposed to be two of these ] [ facing each other to make a list …
but the page turned them into a check box, lol.

1 Like