diff --git a/docs/4. Integrations/ChatGPT using OpenAI APIs.md b/docs/4. Integrations/ChatGPT using OpenAI APIs.md new file mode 100644 index 000000000..ab96aaef9 --- /dev/null +++ b/docs/4. Integrations/ChatGPT using OpenAI APIs.md @@ -0,0 +1,64 @@ +> ###**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 +1. Create an account in OpenAI platform [platform](https://openai.com/product) +2. Create new API keys +3. Make sure there is enough credit in OpenAI account to allow usage. +4. Pricing for API calls is as per OpenAI platform [pricing](https://openai.com/pricing) + +Screenshot 2024-02-07 at 10 50 58 AM + +_Above is a representative image from the OpenAI platform account_ + +## How it will work + +1. Question is asked by the user after the flow is initiated +2. OpenAI API call is made using webhooks within the flow +3. Model being called to generate responses is `gpt-3.5-turbo-16k` +4. The response to the question is then sent to the user + +## Steps to follow to set up OpenAI API in Glific platform +1. Go to `Settings`, find `OpenAI (ChatGPT) (Beta)` +2. Click on `is active` and paste the OpenAI API key from your OpenAI platform account + +Screenshot 2024-02-07 at 10 48 51 AM + +## Using the webhook for OpenAI API call in a Glific flow + +Screenshot 2024-02-07 at 9 59 24 AM + +_Representative image to explain the steps in OpenAI API calls in a simple flow_ + +[Sample flow](https://drive.google.com/file/d/1jl0NWn73YlK1qMRedaPnGCQwDKHfG_7j/view?usp=drive_link) + + +1. Get the user question +2. In `call a webhook` node, select `function` and paste function name as `parse_via_chat_gpt` + + Screenshot 2024-02-07 at 10 52 49 AM + +3. Share the following function body + ` { + "contact": "@contact", + "results": "@results", + "question_text": "@results.question" + }` + +here `question_text` is the parameter name corresponding to user question. + +Screenshot 2024-02-07 at 10 53 21 AM + +4. The response from GPT is shown as `@results.webhookresultname.parsed_msg`, in the given example `gpt_response` is the webhook result name. + + +## Limitations +1. At present, this is simple question answer with the GPT model `gpt-3.5-turbo-16k` +2. Selection of GPT model is not yet customizable from org Glific instances +3. Additional system prompt is not yet customizable from org Glific instances +4. Parameters like temperature, top P etc are not yet customizable from org Glific instances + +_Reach out to the Glific team to flag any further customizations within this functionality_