Vulavula Knowledge Base - Search
Knowledge Base
Create Knowledge Base (Search)
This endpoint allows you to create a new knowledge base for storing and querying documents.
BODY PARAMETERS
- collection (string, required): The name of the knowledge base collection to be created.
HEADERS
- X-CLIENT-TOKEN (string, required): The authentication token required for accessing the API.
EXAMPLES
- Python SDK
- Python HTTP
- Curl
from vulavula import VulavulaClient
client = VulavulaClient("<INSERT_TOKEN>")
knowledge_base_result = client.create_knowledgebase("<knowledge base name>")
print("Knowledge Base Creation Result:", knowledge_base_result)
import requests
url = 'https://vulavula-services.lelapa.ai/api/v1/search/knowledgebase'
headers = {
'accept': 'application/json',
'X-CLIENT-TOKEN': '<INSERT_TOKEN>',
'Content-Type': 'application/json'
}
data = {"knowledgebase_name": "string"}
response = requests.post(url, headers=headers, json=data)
print(response.json())
curl -X 'POST' \
'https://vulavula-services.lelapa.ai/api/v1/search/knowledgebase' \
-H 'accept: application/json' \
-H 'X-CLIENT-TOKEN: <INSERT_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{
"knowledgebase_name": "<knowledge base name>"
}'
Get Knowledge Bases (Search)
Retrieve all existing knowledge bases.
EXAMPLE
- Python SDK
- Python HTTP
- Curl
knowledgebases = client.get_knowledgebases()
print("Knowledge Bases:", knowledgebases)
import requests
url = 'https://vulavula-services.lelapa.ai/api/v1/search/knowledgebases'
headers = {
'accept': 'application/json',
'X-CLIENT-TOKEN': '<INSERT_TOKEN>'
}
response = requests.get(url, headers=headers)
print(response.json())
curl -X 'GET' \
'https://vulavula-services.lelapa.ai/api/v1/search/knowledgebases' \
-H 'accept: application/json' \
-H 'X-CLIENT-TOKEN: <INSERT_TOKEN>'
Delete Knowledge Base (Search)
Delete a specified knowledge base.
EXAMPLE
- Python SDK
- Python HTTP
- Curl
delete_result = client.delete_knowledgebase("<knowledgebase id>")
print("Delete Result:", delete_result)
import requests
url = 'https://vulavula-services.lelapa.ai/api/v1/search/knowledgebase/<knowledgebase_id>'
headers = {
'accept': 'application/json',
'X-CLIENT-TOKEN': '<INSERT_TOKEN>'
}
response = requests.delete(url, headers=headers)
print(response.json())
curl -X 'DELETE' \
'https://vulavula-services.lelapa.ai/api/v1/search/knowledgebase/<knowledgebase_id>' \
-H 'accept: application/json' \
-H 'X-CLIENT-TOKEN: <INSERT_TOKEN>'
Create Documents (Search)
Upload a file and extract text to create documents within a collection.
BODY PARAMETERS
- documents (array, required): List of documents to be added.
- collection (string, required): Name of the knowledge base collection.
- language (string, required): Language of the documents.
HEADERS
- X-CLIENT-TOKEN (string, required): The authentication token required for accessing the API.
EXAMPLES
- Python SDK
- Python HTTP
- Curl
result = client.create_documents("<document name>.pdf", "<knowledgebase id>")
print("Upload and Extract Result:", result)
import requests
url = 'https://vulavula-services.lelapa.ai/api/v1/search/knowledgebase/<knowledge base id>/document'
headers = {
'accept': 'application/json',
'X-CLIENT-TOKEN': '<INSERT TOKEN>'
}
files = {
'file': ('<document name >.pdf', open('<document name>.pdf', 'rb'), 'application/pdf')
}
response = requests.post(url, headers=headers, files=files)
print(response.json())
# Create documents
curl -X 'POST' \
'https://vulavula-services.lelapa.ai/api/v1/search/knowledgebase/<knowledgebase_id>/document' \
-H 'accept: application/json' \
-H 'X-CLIENT-TOKEN: <INSERT_TOKEN>' \
-H 'Content-Type: multipart/form-data' \
-F 'file=@ACL_2024_Presidential_Address.pdf;type=application/pdf'
Get Uploaded Documents (Search)
Retrieve all documents within a specified knowledge base.
EXAMPLE
- Python SDK
- Python HTTP
- Curl
result = client.get_documents("<knowledgebase id>")
print(result)
import requests
url = 'https://vulavula-services.lelapa.ai/api/v1/search/knowledgebase/<knowledgebase_id>/documents'
headers = {
'accept': 'application/json',
'X-CLIENT-TOKEN': '<INSERT_TOKEN>'
}
response = requests.get(url, headers=headers)
print(response.json())
# Create documents
curl -X 'GET' \
'https://vulavula-services.lelapa.ai/api/v1/search/knowledgebase/<knowledgebase_id>/documents' \
-H 'accept: application/json' \
-H 'X-CLIENT-TOKEN: <INSERT_TOKEN>'
Delete Document (Search)
Delete a specific document from a knowledge base.
EXAMPLE
- Python SDK
- Python HTTP
- Curl
delete_result = client.delete_document("<document id>")
print("Delete Result:", delete_result)
import requests
url = 'https://vulavula-services.lelapa.ai/api/v1/search/knowledgebase/document/<document_id>'
headers = {
'accept': 'application/json',
'X-CLIENT-TOKEN': '<INSERT_TOKEN>'
}
response = requests.delete(url, headers=headers)
print(response.json())
# Delete document
curl -X 'DELETE' \
'https://vulavula-services.lelapa.ai/api/v1/search/knowledgebase/document/<document_id>' \
-H 'accept: application/json' \
-H 'X-CLIENT-TOKEN: <INSERT_TOKEN'
Query (Search)
Perform a search query within a specific knowledge base and language.
BODY PARAMETERS
- query (string, required): The query text to search within the knowledge base.
- language (string, required): The language of the query text.
HEADERS
- X-CLIENT-TOKEN (string, required): The authentication token required for accessing the API.
EXAMPLES
- Python SDK
- Python HTTP
- Curl
result = client.query(knowledgebase_id="<knowledgebase id>", query="active learning", language="en_Us")
print(result)
import requests
url = 'https://vulavula-services.lelapa.ai/api/v1/search/knowledgebase/<knowledgebase_base id>/query'
headers = {
'accept': 'application/json',
'X-CLIENT-TOKEN': '<INSERT_TOKEN>',
'Content-Type': 'application/json'
}
data = {
"query": "foundational figures in computer science",
"language": "en_Us"
}
response = requests.post(url, headers=headers, json=data)
print(response.json())
curl -X POST 'https://vulavula-services.lelapa.ai/api/v1/search/knowledgebase/<knowledgebase_id>/query' \
-H 'accept: application/json' \
-H 'X-CLIENT-TOKEN: <INSERT_TOKEN>' \
-H 'Content-Type: application/json' \
-d '{"query": "foundational figures in computer science", "language": "en_Us"}'
RESPONSES
🟢 200 OK
The request was successful. Below is an example response body:
{
"search_result": [
{
"text": "Alan Turing was an English mathematician, computer scientist, logician, cryptanalyst, philosopher, and theoretical biologist.",
"score": 0.6250576
},
{
"text": "Compute",
"score": 0.61686873
},
{
"text": "source code.",
"score": 0.5978863
}
]
}
RESPONSE BODY PARAMETERS
Object |
---|
responses array required: An array containing the query responses. |
response_text string required: Contains the query response text. |
🔴 400 Bad Request
The request was malformed or contained invalid data.
🟠 401 Unauthorized
The client token is missing or invalid.
🔴 500 Internal Server Error
An unexpected error occurred on the server.