ChatGPT using OpenAI APIs
###3 minute read
Advanced
Using ChatGPT within Glific using the OpenAI APIs
Leverage the capabilities of GPT models developed by OpenAI by using OpenAI APIs.
Pre-requisites
- Create an account in OpenAI platform platform
- Create new API keys
- Make sure there is enough credit in OpenAI account to allow usage.
- Pricing for API calls is as per OpenAI platform pricing
Above is a representative image from the OpenAI platform account
How it will work
- Question is asked by the user after the flow is initiated
- OpenAI API call is made using webhooks within the flow
- Model being called to generate responses is
gpt-3.5-turbo-16k
- The response to the question is then sent to the user
Steps to follow to set up OpenAI API in Glific platform
- Go to
Settings
, findOpenAI (ChatGPT) (Beta)
- Click on
is active
and paste the OpenAI API key from your OpenAI platform account
Using the webhook for OpenAI API call in a Glific flow
Representative image to explain the steps in OpenAI API calls in a simple flow
- Get the user question
- In
call a webhook
node, selectfunction
and paste function name asparse_via_chat_gpt
- Share the following function body
{ "contact": "@contact", "results": "@results", "question_text": "@results.question", "gpt_model":"gpt-4o", "prompt":"Provide an additional prompt for the model" }
here question_text
is the parameter name corresponding to user question.
gpt_model
is the parameter to help you select the best model for performing the given task. The model name must correspond to the text models given in the OpenAI API documentation here here
- The response from GPT is shown as
@results.webhookresultname.parsed_msg
, in the given examplegpt_response
is the webhook result name. (see the first image)
Limitations
- Text to speech and speech to text models cannot be used via this webhook call.
Reach out to the Glific team to flag any further customizations within this functionality