Create chat completion
Last updated
Was this helpful?
Last updated
Was this helpful?
Chat completion offers a functionality of sending prompts to OpenAI in textual form and based on the prompt receive an answer. This is similar to text completion action but it uses ChatGPT which is 10x faster and cheaper as well.
System Message: This is an optional field and is used to provide additional context about you or your business when completing chats.
You can set up detailed background information like this if you are building a restaurant chatbot:
System: You are a steak restaurant, helpful assistant. You will handle customer support, guide the user and book reservations. The restaurant's opening hours are 9am to 8pm Monday to Saturday. No pet is allowed. Always offer the coupon code if you see it’s good timing to do so.
This will allow you to easily set up background information about the chatbot, and it can serve your client based on the information you instructed.
Message: This is your main input for which you want the AI to give you an answer or output of. Usually, this is the user’s response. This can be a question, an instruction etc. You can add “user:” as a prefix to your prompt in order to provide more context to the AI for eg:
“user: will it rain today?”
It will also work if you don’t add “user” in front of the response. You can use our system field like {{last_text_input}}
Remember History: If selected “Yes”, the chat history between user and assistant will be saved in a system field to be used for later if needed.
The OpenAI action response will be automatically saved into the assistant role. You don’t need to do anything.
Also, we have introduced a new system JSON field: {{openAI}} which will have all the chat history with the user:
You can find the openAI system field from your user profile. This JSON will save the system set up, and all the chat history.
Model: The model you want to use inside ChatGPT for the task. By default gpt-3.5-turbo has been selected.
Max Tokens: Each task inside ChatGPT consumes tokens. These token can be replenished using credit. This field limits the maximum number of tokens you want to use for a particular task.
Temperature: This acts as a accuracy gauge where higher values give more random answers and lower values give more deterministic and focused answers. It is default to 1
Presence Penalty: This value makes ChatGPT use unique phrases and texts when completing a task. The higher the value, less repetitive words. It is default to 0.
Number of Completions: The number of times you want the AI to generate a response based on your prompt. The higher value will results in more responses. It is default to 1 in order to avoid consumption of tokens.
Best of Completions: This returns the best possible response(s) for your prompt. It is default to 1. This works with Number of Completion field to choose the best possible answer from a group of responses.
{ "id": "chatcmpl-6zef5zEUdDzTx8VKu2r4gkIJfVcBE", "object": "chat.completion", "created": 1680152331, "model": "gpt-3.5-turbo-0301", "usage": { "prompt_tokens": 18, "completion_tokens": 100, "total_tokens": 118 }, "choices": [ { "message": {...}, // 2 keys "finish_reason": "length", "index": 0 } ], "messages": [ { "role": "user", "content": "can you help me with planting a mango tree?" }, { "role": "assistant", "content": "Of course! Here are some steps to plant a mango tree: 1. Choose a spot: Mango trees need plenty of sunlight and well-draining soil. They also need protection from strong winds, so choose a spot that's sheltered. 2. Prepare the soil: Mango trees prefer slightly acidic soil, with a pH between 5.5 and 7. If your soil is too alkaline, add sulfur or peat moss to lower the pH. If it's too acidic, add lime" } ] }
Id: The id of the text completion. A unique value.
Object: The action/task you gave to OpenAI. In our case “text_completion”
Created: A date-time field that tells the instance of creation of the response. It is in Unix timestamp format.
Choice -> Content: The content field inside the choice object contains the answer to your prompt.
Message: This is a JSON for complete conversation that has happened between the user and the assistant.
Chat completion action enables you to provide JSON input as well hence you can save the complete conversation between the users and the assistant in a JSON to give more focused and contextual replies related to that conversation.
Since chat completion takes more input, the token consumption can be higher that text completion.