98 lines
3.1 KiB
Markdown
98 lines
3.1 KiB
Markdown
# CQA Retriever
|
|
|
|
This package provides an example RAG process using Azure AI Search for Retrieval and the Verint DaVinci Contextual Question Answer (CQA) Service.
|
|
|
|
## What's New: Updated [24/05/2025]
|
|
|
|
- Initial Release
|
|
|
|
## Setup Instructions
|
|
|
|
### Prerequisites
|
|
|
|
- This example requires the _Verint Contextual Question Answer Service_ package to be installed from the Hub and configured.
|
|
|
|
> **WARNING:** There is an error in the _CQA_66308ec473f3d10350a2e499_ Global Variable file on (maybe) line 60: It should read v2 instead of v1 and should be fixed manually
|
|
|
|
```javascript
|
|
let url = `${settings.apiurl}/${settings.productcode}/${settings.ingress}/inference/verint-contextual-question-answering-v2`;
|
|
```
|
|
|
|
### Installation
|
|
|
|
1. Copy the contents of the **Global Variables** (click into each one for contents). Make sure to make the names match (without the .js or .json suffix)
|
|
1. [CQA_Retriever](./GlobalVariable/CQA_Retriever.js) as a function.
|
|
1. [CQA_RetrieverSettings](./GlobalVariable/CQA_RetrieverSettings.json) as an object.
|
|
1. _Optional:_ Import the Example Conversation Flow and Intent
|
|
|
|
### Configuration
|
|
|
|
#### CQA_RetrieverSettings
|
|
|
|
Fill out the settings below.
|
|
|
|
```json
|
|
{
|
|
"azure_aisearch": {
|
|
"endpoint": "https://iva-demo-vector-service.search.windows.net",
|
|
"key": "<azure_aisearch_key>",
|
|
"index_name": "iva-vector-demo"
|
|
},
|
|
"azure_openai_api": {
|
|
"key": "<azure_openai_key>",
|
|
"instance_name": "iva-open-ai",
|
|
"deployment_name": "text-embedding-3-small",
|
|
"embeddings_deployment_name": null,
|
|
"version": "2024-08-01-preview"
|
|
},
|
|
"filterExpression": "search.in(company, 'Verint')",
|
|
"debug": true
|
|
}
|
|
```
|
|
|
|
## Package Content Details
|
|
|
|
### CQA_RetieverSettings
|
|
|
|
A global variable JSON object with environment-specific settings. See above for details.
|
|
|
|
### CQA_Retriever
|
|
|
|
A global variable function which handles the logic and API calls used to retrieve documents for Context.
|
|
|
|
### Example code block that should be using in your Conversation Flows
|
|
|
|
This is included in the Example Conversation Flow if you have imported that. If you want to use this on the global flow as a catch all for inputs that do not provide an answer, then change ```${conversationData.cqa_question}``` to ```${recognizedObject.input}```
|
|
|
|
> NOTE: This example exits via the output pin '0' on error or no sources found.
|
|
|
|
```javascript
|
|
let exitState=0; // i.e. next(0) means something went wrong or we found 0 sources
|
|
|
|
(async () => {
|
|
console.log(`CQA Retrieval: ${conversationData.cqa_question}`)
|
|
conversationData.cqa_source = await CQA_Retriever().retrieve(conversationData.cqa_question);
|
|
|
|
exitState = conversationData.cqa_source.instances[0].sources.length
|
|
|
|
})()
|
|
.catch((error) => {
|
|
console.log(error.message)
|
|
recognizedObject.answers.push(error.message)
|
|
recognizedObject.errorInfo = {
|
|
...recognizedObject.errorInfo,
|
|
label: {
|
|
data: error.toJSON ? error.toJSON() : {},
|
|
message: error.message,
|
|
},
|
|
}
|
|
})
|
|
.finally(() => {
|
|
console.log({exitState: exitState})
|
|
if (exitState)
|
|
next()
|
|
else
|
|
next(0)
|
|
})
|
|
```
|