Skip to main content

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

NameTypeRequiredDescription
llmJSONYESConfiguration for LLM transformer
llm.modelStringYESLLM model to be used in transformer. Eg: gpt-4, gpt-3.5-turbo ..
llm.promptJSONYESLLM Prompt settings
llm.prompt.systemStringYESSystem instructions which needs to be used by the bot while answering user's questions.
llm.prompt.userStringYESUser instructions for bot, generally context it passed here.
llm.prompt.summarizationStringNOSpecific instructions to llm for summarizing the final answer.
llm.prompt.answerTypeStringNOType of answer Eg: Descriptive, succinct
llm.enableStreamBooleanNOSet this to True in order to stream bot answers instead of getting complete answer at a time.
retrieverJSONYESConfiguration for Retriever transformer, which is used to get related context to answer user questions.
retriever.documentIdsArray<String>YesList of pdf documents to be used by the bot.
retriever.topKNumberYesUpper limit on how many chunks to retrieve.
retriever.xlsxIdsArray<String>YesList of excel documents to be used by the bot.
translationJSONYESConfiguration for Translate transformer
translation.userLanguageStringYESInput language of the bot.
translation.outputLanguageStringYESLanguage in which bot should respond back.
translation.providerJSONStringTranslation service provider Eg: Azure, Bhashini.
audioServiceJSONYESConfiguration for Text To Speech service.
audioService.activeBooleanYESBoolean denoting whether to activate text to speech.
audioService.providerStringYESText to Speech service provider Eg: Azure, Bhashini.
audioService.voiceSettingsStringYESVoice gender. Accepted values: male, female.
audioService.sampleRateNumberYESUsed 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 recipe

Request 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 recipe

Request 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

NameTypeRequiredDescription
formatstringYESType of document that is being uploaded. Supported types are: PDF, XLSX, LINK

Request Body

NameTypeRequiredDescription
filebinaryFileYEScsv 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 = PDF

Query Parameters

NameTypeRequiredDescription
pagenumberNOPage number
perPagenumberNONumber of records to be fetched per page
typestringYESType 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

NameTypeRequiredDescription
textnumberYESquery against which chunks are retrieved.
topKnumberNOUpper limit on chunks length.
pdfIdArray<string>NOarray 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