Knowledge base semantic retrieval
curl --request POST \
--url https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"knowledge_base_id": "kb-f9d817f5-46c2-49b2-b07f-f3db8df0887a",
"question_asked_by_user": "What is the purpose of this knowledge base?"
}
'import requests
url = "https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval"
payload = {
"knowledge_base_id": "kb-f9d817f5-46c2-49b2-b07f-f3db8df0887a",
"question_asked_by_user": "What is the purpose of this knowledge base?"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
knowledge_base_id: 'kb-f9d817f5-46c2-49b2-b07f-f3db8df0887a',
question_asked_by_user: 'What is the purpose of this knowledge base?'
})
};
fetch('https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'knowledge_base_id' => 'kb-f9d817f5-46c2-49b2-b07f-f3db8df0887a',
'question_asked_by_user' => 'What is the purpose of this knowledge base?'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval"
payload := strings.NewReader("{\n \"knowledge_base_id\": \"kb-f9d817f5-46c2-49b2-b07f-f3db8df0887a\",\n \"question_asked_by_user\": \"What is the purpose of this knowledge base?\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"knowledge_base_id\": \"kb-f9d817f5-46c2-49b2-b07f-f3db8df0887a\",\n \"question_asked_by_user\": \"What is the purpose of this knowledge base?\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"knowledge_base_id\": \"kb-f9d817f5-46c2-49b2-b07f-f3db8df0887a\",\n \"question_asked_by_user\": \"What is the purpose of this knowledge base?\"\n}"
response = http.request(request)
puts response.read_body{
"finalRelevantChunk": [
"Hello Pawa AI, I am the final relevant chunk you need"
],
"filteredResults": [
{
"id": 63,
"knowledgeBaseId": 7,
"documentName": "131.3-Visa-Requirements-Schengen-2021-05 (1) (1).pdf",
"chunk": "and for the whole period of staying in the Schengen area. In order to have a flexible travel schedule it is suggested to issue the Insurance for a few days longer than the planned travel time...",
"distance": 0.7506968916261936
},
{
"id": 76,
"knowledgeBaseId": 7,
"documentName": "131.3-Visa-Requirements-Schengen-2021-05 (1) (1).pdf",
"chunk": "plan agreed with the clinic. Medical health documentation issued by the applicant’s country of residence...",
"distance": 0.7515738980069386
}
]
}{
"success": false,
"message": "Invalid input provided"
}{
"success": false,
"message": "Unauthorized access"
}{
"success": false,
"message": "You do not have permission to access this resource"
}{
"success": false,
"message": "Resource does not exist"
}{
"success": false,
"message": "Rate limit exceeded. Please try again later."
}{
"success": false,
"message": "Internal server error"
}Storage
Semantic Retrieval
This endpoint used to retrieve the relevant chunks of the knowledge base based on the user question in the Pawa AI Platform.
POST
/
store
/
knowledge-base
/
semantic-retrieval
Knowledge base semantic retrieval
curl --request POST \
--url https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"knowledge_base_id": "kb-f9d817f5-46c2-49b2-b07f-f3db8df0887a",
"question_asked_by_user": "What is the purpose of this knowledge base?"
}
'import requests
url = "https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval"
payload = {
"knowledge_base_id": "kb-f9d817f5-46c2-49b2-b07f-f3db8df0887a",
"question_asked_by_user": "What is the purpose of this knowledge base?"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
knowledge_base_id: 'kb-f9d817f5-46c2-49b2-b07f-f3db8df0887a',
question_asked_by_user: 'What is the purpose of this knowledge base?'
})
};
fetch('https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'knowledge_base_id' => 'kb-f9d817f5-46c2-49b2-b07f-f3db8df0887a',
'question_asked_by_user' => 'What is the purpose of this knowledge base?'
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval"
payload := strings.NewReader("{\n \"knowledge_base_id\": \"kb-f9d817f5-46c2-49b2-b07f-f3db8df0887a\",\n \"question_asked_by_user\": \"What is the purpose of this knowledge base?\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"knowledge_base_id\": \"kb-f9d817f5-46c2-49b2-b07f-f3db8df0887a\",\n \"question_asked_by_user\": \"What is the purpose of this knowledge base?\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pawa-ai.com/v1/store/knowledge-base/semantic-retrieval")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"knowledge_base_id\": \"kb-f9d817f5-46c2-49b2-b07f-f3db8df0887a\",\n \"question_asked_by_user\": \"What is the purpose of this knowledge base?\"\n}"
response = http.request(request)
puts response.read_body{
"finalRelevantChunk": [
"Hello Pawa AI, I am the final relevant chunk you need"
],
"filteredResults": [
{
"id": 63,
"knowledgeBaseId": 7,
"documentName": "131.3-Visa-Requirements-Schengen-2021-05 (1) (1).pdf",
"chunk": "and for the whole period of staying in the Schengen area. In order to have a flexible travel schedule it is suggested to issue the Insurance for a few days longer than the planned travel time...",
"distance": 0.7506968916261936
},
{
"id": 76,
"knowledgeBaseId": 7,
"documentName": "131.3-Visa-Requirements-Schengen-2021-05 (1) (1).pdf",
"chunk": "plan agreed with the clinic. Medical health documentation issued by the applicant’s country of residence...",
"distance": 0.7515738980069386
}
]
}{
"success": false,
"message": "Invalid input provided"
}{
"success": false,
"message": "Unauthorized access"
}{
"success": false,
"message": "You do not have permission to access this resource"
}{
"success": false,
"message": "Resource does not exist"
}{
"success": false,
"message": "Rate limit exceeded. Please try again later."
}{
"success": false,
"message": "Internal server error"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Body
application/json
The knowledge_base_reference_id of the knowledge base to perform the RAG if the question asked relates to the purpose of the knowledge_base_tool provided.
The question asked by the user to perform the RAG.
Response
Relevant chunks retrieved successfully
Final relevant chunk based on the user query.
Example:
[
"Hello Pawa AI, I am the final relevant chunk you need"
]
Filtered results based on the relevance of the chunks to the user query.
Show child attributes
Show child attributes
Example:
[
{
"id": 63,
"knowledgeBaseId": 7,
"documentName": "131.3-Visa-Requirements-Schengen-2021-05 (1) (1).pdf",
"chunk": "and for the whole period of staying in the Schengen area. In order to have a flexible travel schedule it is suggested to issue the Insurance for a few days longer than the planned travel time...",
"distance": 0.7506968916261936
},
{
"id": 76,
"knowledgeBaseId": 7,
"documentName": "131.3-Visa-Requirements-Schengen-2021-05 (1) (1).pdf",
"chunk": "plan agreed with the clinic. Medical health documentation issued by the applicant’s country of residence...",
"distance": 0.7515738980069386
}
]
⌘I