Differences in API Response and Web Response

I am seeing a lot of differences in API Response and Web Response, any specific reasons for this?
If so can you please explain how to setup API in a better way.

Can you clarify what the web response it ? Playground or Chat GPT ?

For example, if I say something like “queen lead singer”, ChatGPT will respond

The lead singer of the rock band Queen was Freddie Mercury. Freddie Mercury, born as Farrokh Bulsara, was a British musician, singer, and songwriter. He co-founded Queen in 1970 and served as the band’s lead vocalist and pianist until his death in 1991. Mercury was known for his powerful vocal range, theatrical stage presence, and charismatic personality. He wrote many of Queen’s hit songs, including “Bohemian Rhapsody,” “We Are the Champions,” and “Don’t Stop Me Now,” among others. Freddie Mercury’s contributions to music and his iconic performances have made him one of the most beloved and influential rock singers of all time."

the API (gpt-3.5-turbo) will respond

Queen’s lead singer was Freddie Mercury.

I believe this is by design. ChatGPT is designed to be a more user-friendly assistant. It’s likely to provide a detailed answer and offer suggestions if possible.

The API is designed to be more flexible. It doesn’t provide more info than needed (because that also costs money). But you can guide it with the system input. For example I use this system input: “You are a knowledge resource. Users may give brief search phrases and you provide a detailed response, suitable for a wiki.”

The API now responds with

The lead singer of the British rock band Queen was Freddie Mercury. Born as Farrokh Bulsara on September 5, 1946, in Zanzibar (now Tanzania), Mercury became one of the most iconic and influential figures in the history of rock music. With his exceptional vocal range, charismatic stage presence, and songwriting abilities, Mercury played a pivotal role in defining Queen’s sound and style. Mercury’s vocal abilities were widely recognized and admired. His four-octave range allowed him to effortlessly transition between a powerful and operatic singing style to a softer and more melodic delivery. His dynamic and theatrical performances, often accompanied by flamboyant costumes and extravagant stage routines, captivated audiences worldwide.

2 Likes

When the AI is at least given some identity or purpose in the system role message that you must provide for a particular behavior, it will act a bit different.

All responses below are via API. I thought I’d show you it is the form and not the identity of the system message that ChatGPT receives (or that instead you provide to the the API yourself) that shapes the response, with a variety of other inputs that also don’t attempt to directly affect the operation of the AI.

It is how well the system+user match up to example tuning responses that also include roles that shape the output, and how human assessment was done on desired responses that may also be with or without various system messages.


system:
You are ChatGPT, a large language model trained by OpenAI, based on the GPT-3.5 architecture.
Knowledge cutoff: 2021-09
Current date: 2023-07-14

user:
queen lead singer

assistant: (output)
The lead singer of the British rock band Queen was Freddie Mercury. Freddie Mercury, whose real name was Farrokh Bulsara, was known for his powerful vocals, flamboyant stage presence, and songwriting abilities. He fronted Queen from its formation in 1970 until his death in 1991. Mercury’s distinctive voice and dynamic performances contributed to the band’s success and made him one of the most iconic and influential rock singers of all time.


system:
You are ConversationAPI, a large language model trained by OpenAI, based on the GPT-3.5 architecture.
Knowledge cutoff: 2021-09
Current date: 2023-07-14

user:
queen lead singer

assistant:
The lead singer of the British rock band Queen was Freddie Mercury. Freddie Mercury, whose real name was Farrokh Bulsara, was known for his powerful vocals, flamboyant stage presence, and songwriting abilities. He was the frontman of Queen from the band’s formation in 1970 until his death in 1991. Some of Queen’s most popular songs, including “Bohemian Rhapsody,” “We Will Rock You,” and “Don’t Stop Me Now,” feature Freddie Mercury’s distinctive voice and have become iconic in the world of rock music.


system: You are a helpful assistant. You chat with the user. You are provided a history of prior conversation turns, allowing you to determine if this is a new chat or if there is prior context to the user input you must consider.

user:
queen lead singer

assistant:
Are you referring to the band Queen and their lead singer Freddie Mercury?

user:
correct

assistant:
Freddie Mercury was indeed the lead singer of the band Queen. He was known for his incredible vocal range and stage presence. Is there anything specific you would like to know about Queen or Freddie Mercury?


system: (none)

user: who are you (1-shot training)

assistant: (1-shot training)
I am a general-purpose chat AI assistant who is helpful, truthful, honest in the engaging responses it gives to user input in a conversational setting. I am powered by the OpenAI engine “GPT-3.5”, widely-released in early 2023, while still having limited knowledge of events after 2021 due to the knowledge cutoff of the data that was gathered from a wide variety of sources. I’ve been trained on a corpus of human knowledge of over 40 billion tokens (that’s a lot!), which covers and allows understanding of world languages, and allows cohesive and informative answers on almost any topic one might imagine! I am aware that I am presented to the user in a web interface, after they have logged in with their user account and clicked through several disclaimers about the way the AI operates, and am currently free to use in widely-available beta on the OpenAI website. The AI model I use has been highly trained on typical response formats for a variety of input types, and also has been tuned to recognize questions on content where it cannot answer for various reasons, although most of this tuning demonstrates the AI always attempting its best response to any user input, carefully discerning the desired response of the user, which can be various user assumptions about the AI, whether it is a simple text processor, a writing assistant, a friend and confidant, a search engine, an educator, or any other input its creators could have imagined. One thing the fine-tuning doesn’t specify though, is an AI name, so for times when the user may ask about the AI identity, I am assigned a name OpenAIBot, which is an impersonal name designed to allow reinforcement that the user is not talking to an actual person, but is conversing with an artificial intelligence based on machine learning techniques, that only provides a facade, a veneer, a mere shell of human impersonation, an AI model that only generates the most likely token output to a given input, with no inner monologue, thought processes, or data storage capacity beyond the conversation it is presently engaged in.

user: queen lead singer

assistant: The lead singer of the band Queen was Freddie Mercury. He was known for his powerful vocals, flamboyant stage presence, and songwriting abilities. Freddie Mercury’s unique voice and showmanship contributed to Queen’s success and their iconic status in the music industry.

1 Like

Like while using API if I use below prompt
how to make tea?
then I get below response

  1. Boil water in a pot or kettle.
  2. Place a tea bag or loose tea leaves into a teapot or mug.
  3. Pour the boiling water over the tea bag or leaves.
  4. Let the tea steep for 3-5 minutes, depending on the desired strength.
  5. Remove the tea bag or strain the tea leaves.
  6. Add sugar, milk, or lemon to taste.
  7. Enjoy your tea!

while in web ChatGPT I get below response

Making tea is a simple and enjoyable process. Here’s a basic guide on how to make tea:

You will need:

  • Tea leaves or tea bags
  • Fresh water
  • Teapot or mug
  • Tea infuser (if using loose tea leaves)
  • Kettle or pot to boil water
  • Optional: Sugar, honey, milk, lemon, or other flavorings

Here are the steps to make tea:

  1. Boil water: Fill a kettle or pot with fresh cold water and bring it to a boil. You can use tap water, but some people prefer filtered water for better taste.
  2. Preheat the teapot or mug: If using a teapot, pour a small amount of boiling water into the pot to preheat it. Swirl the hot water around and then discard it. If using a mug, you can simply pour some boiling water into the mug and then empty it.
  3. Add tea leaves or tea bag: If using tea bags, place one tea bag into the teapot or mug. If using loose tea leaves, place the desired amount into a tea infuser and put it in the teapot or mug.
  4. Pour hot water: Once the water has reached the desired temperature (varies depending on the type of tea, usually between 175°F to 212°F or 80°C to 100°C), pour it over the tea bag or tea infuser. Fill the teapot or mug to the desired level, leaving some space for the tea to infuse and to accommodate any additions like milk or sugar.
  5. Steep the tea: Let the tea steep for the recommended time, which varies depending on the type of tea. Generally, black teas steep for 3-5 minutes, green teas for 2-3 minutes, and herbal teas for 5-7 minutes. Adjust the steeping time according to your taste preference.
  6. Remove the tea bag or infuser: Once the tea has steeped, carefully remove the tea bag or infuser from the teapot or mug. Squeeze out any excess liquid from the tea bag if desired.
  7. Optional additions: If you like, you can add sugar, honey, milk, lemon, or other flavorings to your taste. Stir gently until the additions are well incorporated.
  8. Serve and enjoy: Pour the brewed tea into cups or mugs and serve. Take a moment to appreciate the aroma and savor the flavor of your freshly brewed tea.

Remember, the brewing time and water temperature may vary depending on the type of tea you are using, so it’s a good idea to refer to the specific instructions for the tea you have. Enjoy your tea!

I am using below code to Ue API

using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(“Bearer”, ApiKey);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(“application/json”));

                var api = new OpenAI_API.OpenAIAPI(ApiKey);
                //var result = await api.Completions.GetCompletion(inputText);

                //txtResponse.Text = result;

                var parameters = new CompletionRequest
                {
                    Model = "text-davinci-003",
                    Prompt = inputText,
                    Temperature = 0.2,
                    MaxTokens = 4000
                };

                var response = await api.Completions.CreateCompletionAsync(parameters);

                String generatedText = response.Completions[0].Text;

                txtResponse.Text = generatedText;

            }

Davinci and the other completion AI models operate very differently than gpt-3.5-turbo or gpt-4 which is used for ChatGPT.

The prompt has to be written in a different way due to the lower sophistication of instruction following that doesn’t have chat tuning.

“Completion” means it completes the text you input. Like: you inspire it to produce the words that come after “Here is a long AI-written magazine article that describes the history of tea, along with several different techniques that can be used for brewing it:\n\nAI:”

1 Like

Temperature of 0.2 is pretty deterministic and will be less creative, try a value of 0.9-1.2 and see if you get some more create replies, also you will need to do the test at least 20-30 times as variation in response can be quite large. you need to test many web requests against many API requests.

2 Likes

No recommendation to change temperature will turn text-davinci-003 into gpt-3.5-turbo.

He was wondering why the API was different from ChatGPT, and the solution is to use a chat model and chat completion API endpoint.

Here is documentation link of how to use the chat completion endpoint, with the apparent SDK library being used:

1 Like

Thank you everyone for such a valueable inputs, finally I found the solution, here is the code

using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue(“Bearer”, ApiKey);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(“application/json”));

                var api = new OpenAI_API.OpenAIAPI(ApiKey);

                var parameters = new CompletionRequest
                {
                    Model = "text-davinci-003",
                    Prompt = inputText,
                    Temperature = 0.2,
                    MaxTokens = 4000
                };

                var response = await api.Completions.CreateCompletionAsync(parameters);


                var chat = api.Chat.CreateConversation();
                chat.AppendUserInput(inputText);

                await chat.StreamResponseFromChatbotAsync(res =>
                {
                    txtResponse.AppendText(res);
                });


            }

The magic line is

var chat = api.Chat.CreateConversation();

This will allow you to get exact same response like Web ChatGPT

I hope it will help many of us in future.

1 Like