BFF
BFF is an service that handles all operations that are required by the recipes and admin application. It includes various processes such as document upload, chunk retrieve and recipe config creation.
Recipe Configuration Parameters
Name | Type | Required | Description |
---|---|---|---|
llm | JSON | YES | Configuration for LLM transformer |
llm.model | String | YES | LLM model to be used in transformer. Eg: gpt-4, gpt-3.5-turbo .. |
llm.prompt | JSON | YES | LLM Prompt settings |
llm.prompt.system | String | YES | System instructions which needs to be used by the bot while answering user's questions. |
llm.prompt.user | String | YES | User instructions for bot, generally context it passed here. |
llm.prompt.summarization | String | NO | Specific instructions to llm for summarizing the final answer. |
llm.prompt.answerType | String | NO | Type of answer Eg: Descriptive, succinct |
llm.enableStream | Boolean | NO | Set this to True in order to stream bot answers instead of getting complete answer at a time. |
retriever | JSON | YES | Configuration for Retriever transformer, which is used to get related context to answer user questions. |
retriever.documentIds | Array<String> | Yes | List of pdf documents to be used by the bot. |
retriever.topK | Number | Yes | Upper limit on how many chunks to retrieve. |
retriever.xlsxIds | Array<String> | Yes | List of excel documents to be used by the bot. |
translation | JSON | YES | Configuration for Translate transformer |
translation.userLanguage | String | YES | Input language of the bot. |
translation.outputLanguage | String | YES | Language in which bot should respond back. |
translation.provider | JSON | String | Translation service provider Eg: Azure, Bhashini. |
audioService | JSON | YES | Configuration for Text To Speech service. |
audioService.active | Boolean | YES | Boolean denoting whether to activate text to speech. |
audioService.provider | String | YES | Text to Speech service provider Eg: Azure, Bhashini. |
audioService.voiceSettings | String | YES | Voice gender. Accepted values: male, female. |
audioService.sampleRate | Number | YES | Used to set the speed at which audio is played, default: 8000. higher values results in faster audio play and vice versa. |
API Endpoints
1. /bot
POST
/bot Create a bot for RAG recipeRequest Body
{
"llm": {
"model": "string",
"prompt": {
"system": "string",
"user": "string",
"summarization": "string",
"answerType": "string"
},
"temperature": 0,
"enableStream": true
},
"retriever": {
"documentIds": [
"string"
],
"topK": 0,
"xlsxIds": [
"string"
]
},
"citation": {
"style": "string",
"maxLength": 0
},
"translation": {
"userLanguage": "string",
"outputLanguage": "string",
"provider": "string"
},
"audioService": {
"active": true,
"provider": "string",
"voiceSettings": "string",
"sampleRate": 0
},
"denseEmbeddingsWeightage": 0
}
Response Format
- Success
{
"error": false,
"botId": <uuid>
}
- Failure:
{
"botId": null,
"error": true,
"message": "Error message",
}
2. /bot/:botId
PUT
/bot/:botId Updates an existing bot for RAG recipeRequest Body
{
"llm": {
"model": "string",
"prompt": {
"system": "string",
"user": "string",
"summarization": "string",
"answerType": "string"
},
"temperature": 0,
"enableStream": true
},
"retriever": {
"documentIds": [
"string"
],
"topK": 0,
"xlsxIds": [
"string"
]
},
"translation": {
"userLanguage": "string",
"outputLanguage": "string",
"provider": "string"
},
"audioService": {
"active": true,
"provider": "string",
"voiceSettings": "string",
"sampleRate": 0
}
}
Response Format
- Success
{
"error": false,
"botId": <uuid>
}
- Failure:
{
"botId": null,
"error": true,
"message": "Error message",
}
3. /document/upload
POST
/document/upload Upload a document and stores its embeddings.Query Parameters
Name | Type | Required | Description |
---|---|---|---|
format | string | YES | Type of document that is being uploaded. Supported types are: PDF, XLSX, LINK |
Request Body
Name | Type | Required | Description |
---|---|---|---|
file | binaryFile | YES | csv or an pdf file. |
Response Format
- Success
{
"data": {
"taskId": "c575540e-c203-419c-8cf1-47ffc6f66ae7"
},
"error": false
}
- Failure:
{
"detail": "Error message",
}
4. /document
GET
/document Retrieves the list of uploaded documents. Supported types = PDFQuery Parameters
Name | Type | Required | Description |
---|---|---|---|
page | number | NO | Page number |
perPage | number | NO | Number of records to be fetched per page |
type | string | YES | Type of document that was uploaded. Supported types are: PDF, XLSX |
Response Format
- Success
[
{
"id": <uuid>,
"name": "fileName.pdf",
"url": <PDF_LINK>,
"ownerId": <uuid>,
"orgId": <uuid>
}
]
- Failure:
{
"error": "Error message",
}
5. /retrieve
GET
/retrieve Retrieves similar chunks for input query.Query Parameters
Name | Type | Required | Description |
---|---|---|---|
text | number | YES | query against which chunks are retrieved. |
topK | number | NO | Upper limit on chunks length. |
pdfId | Array<string> | NO | array of documentIds to search from. |
Response Format
- Success
[
{
"id": <uuid>,
"content": <string>,
"heading": <string>,
"summary": <string>,
"pdfName": <string>,
"pdfId": <string>,
"metaData": <json>,
"type": <string>,
"vidio": <link>
}
]
- Failure:
{
"error": "Error message",
}
For complete documentation and API execution playground visit -> Swagger