Skip to content

Latest commit

 

History

History
235 lines (162 loc) · 8.42 KB

README.md

File metadata and controls

235 lines (162 loc) · 8.42 KB

ChatGPT responses workflow model support

This extension was updated to Responses API https://doc.livehelperchat.com/docs/bot/chatgpt-responses

With this extension you won't need to pay anything to third party except OpenAI for contextual search based on your personal data. Streaming is also supported!

For those setups samples you don't need to setup extension

Differences between those API - https://platform.openai.com/docs/guides/responses-vs-chat-completions It is recommended just to use Responses API

Requirements

  • Min 4.52v Live Helper Chat version.
  • Polling/Streaming workflow is supported only.
  • Account at https://platform.openai.com/docs/overview
  • System configuration -> Live Help Configuration -> Chat configuration -> Misc Make sure you unheck Reopen chat functionality enabled and Allow user to reopen closed chats?. This is required because if chat is reopened we can be in the middle of previous task.
  • gpt-4o-mini Model is used.
  • The Account is funded with 5$. Sometimes there were reports that some users were getting 404 during API calls.

Demo

We are using for this demo https://livehelperchat.com/order/now if you want easily setup your own bot.

How it works?

How to generate content for your own knowledge base?

Demo bot is using documentation generated from this command. Take a look at official documentation of the tool at https://github.com/obeone/crawler-to-md It generated md file which later was uploaded at https://platform.openai.com

docker run --rm -v $(pwd)/output:/app/output -v $(pwd)/cache:/app/cache remdex/crawler-to-md --url https://doc.livehelperchat.com --exclude "/docs/hooks"

I have created fork also which fixes few things like absolute links and code tags parsing.

Or just run. Modify to your needs. --exclude part is optional

docker run --rm -v $(pwd)/output:/app/output -v $(pwd)/cache:/app/cache remdex/crawler-to-md --url https://doc.livehelperchat.com --exclude "/docs/hooks"

Build from source

git clone https://github.com/LiveHelperChat/crawler-to-md.git && cd crawler-to-md
DOCKER_BUILDKIT=1 docker build -t crawler-to-md .
docker run --rm -v $(pwd)/output:/app/output -v $(pwd)/cache:/app/cache crawler-to-md --url https://doc.livehelperchat.com --exclude "/docs/hooks"

How to call a trigger based on defined function in ChatGPT?

  1. Notice defined function name E.g transfer_operator
  2. Add event to your trigger with Type of Custom text matching where Should include any of these words value should be transfer_operator. Screenshot can be found here

Present release

Documentation section regarding how streaming works

https://doc.livehelperchat.com/docs/bot/rest-api#streaming

How to make UI snappy by delegating Rest API calls to background workers?

Install

After clone or download put it under

extension/chatgpt - don't forget to lowercase a folder

Activate extension in main settings file lhc_web/settings/settings.ini.php extension section chatgpt by Adding lines:

'extensions' =>  array (  'chatgpt'  ),

Install database

Execute queries from

doc/install.sql

Or execute command

php cron.php -s site_admin -e chatgpt -c cron/update_structure

Back office

Navigate to back office and click clear cache

Under left Modules you will find ChatGPT click it.

Setup as a bot

  • Click ChatGPT Bot integration settings
  • Now just paste Project API Key and Vector storage ID from https://platform.openai.com and click Create/Update Rest API/Bot

Now you can just assign newly created bot to your department or modify bot to the way you want.

Setup pas reply predictor for the agents

  • Click ChatGPT Setting for answers suggesting
  • Project API Key and Vector storage ID can be different than Bot
  • Fer reply predictions to work you have to activate bot from Setup as a bot step. We use some of the Rest API calls.

How to have only manual reply predictions tab in the chat interface?

Have only Enable reply prediction tab in chat UI checked.

How to have automatic answer suggesting in chat window?

Have Automatically suggest answers based on visitor messages

image

Setup video tutorial

Video tutorial and use case - https://youtu.be/X9W99obVj8Q

ChatGPT Completion workflow model support

Please refer to this manual https://doc.livehelperchat.com/docs/bot/chatgpt-integration

Screenshots

Multiple tool calls

Update phone number.

Phone number can be evening and morning as an example.

Chat GPT function definition

{
  "name": "post-update-phone-number",
  "type": "function",
  "description": "Updates the phone number for a player.",
  "strict": true,
  "parameters": {
    "type": "object",
    "required": [
      "phone",
      "type"
    ],
    "properties": {
      "type": {
        "type": "string",
        "description": "The type of phone number (e.g., 'morning','evening').",
        "enum": [
          "evening_phone",
          "morning_phone"
        ]
      },
      "phone": {
        "type": "string",
        "description": "The new phone number to be updated."
      }
    },
    "additionalProperties": false
  }
}

Accessing function call arguments in the bot triggers.

{args.chat.chat_variables_array.chatgpt_action_args.phone}
{args.chat.chat_variables_array.chatgpt_action_args.type}

Accessing function call arguments in the Rest API

{
    "phone":  {{args.chat.chat_variables_array.chatgpt_action_args.phone}},
    "type":{{args.chat.chat_variables_array.chatgpt_action_args.type}}
}

Live Helper Chat

image

Retrieve withdrawal list for the visitor

Chat GPT function definition

{
  "name": "get_withdrawals",
  "type" : "function",
  "description": "Retrieves a list of withdrawals for a visitor.",
  "strict": true,
  "parameters": {
    "type": "object",
    "required": [],
    "properties": {},
    "additionalProperties": false
  }
}

Live Helper Chat side. You can also as visitor can ask to return only last 3 items.

image