@vxtor/js-sdk v0.0.14
Vxtor SDK
This SDK allows you to easily interact with the Vxtor API using TypeScript.
Features
- CRUD Operations: Manage collections, documents, and paragraphs easily.
- Search: Perform searches across collections, documents, and paragraphs with relevance filtering.
- Error Handling: All API calls return a
data
,error
, andisBusy
object to handle responses and errors gracefully. - TypeScript Support: Fully typed for TypeScript users.
Installation
To use the Vxtor SDK, you first need to install it:
npm install @vxtor/js-sdk
Usage
First, initialize the Vxtor SDK with your API key:
import { createClient } from '@vxtor/js-sdk';
const vxtor = createClient({ apiKey: 'your-api-key-here' });
You can now use the SDK to interact with your API. Here's how you can use the functions available in the SDK:
collectText
Description: Collect texts from websites or documents
Example:
const { data, error } = await vxtor.collectText(data);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
regenerateEmbeddings
Description: Regenerate paragraphs embeddings
Example:
const { data, error } = await vxtor.regenerateEmbeddings(data);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
searchParagraphs
Description: Search paragraphs
Example:
const { data, error } = await vxtor.searchParagraphs(data);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
updateEmbedding
Description: Update embedding
Example:
const { data, error } = await vxtor.updateEmbedding(data);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
createEmbedding
Description: Create embedding
Example:
const { data, error } = await vxtor.createEmbedding(data);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
createCollection
Description: Create collection
Example:
const { data, error } = await vxtor.createCollection(data);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
findCollections
Description: Find collections
Example:
const { data, error } = await vxtor.findCollections(title, _limit);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
findOneCollection
Description: Find one collection
Example:
const { data, error } = await vxtor.findOneCollection(id);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
updateCollection
Description: Update one collection
Example:
const { data, error } = await vxtor.updateCollection(id, data);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
deleteCollection
Description: Delete one collection
Example:
const { data, error } = await vxtor.deleteCollection(id);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
createDocument
Description: Create new document
Example:
const { data, error } = await vxtor.createDocument(data);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
findDocuments
Description: Find all documents
Example:
const { data, error } = await vxtor.findDocuments(title, _limit);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
findOneDocument
Description: Get document by ID
Example:
const { data, error } = await vxtor.findOneDocument(id);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
updateDocument
Description: Update one document
Example:
const { data, error } = await vxtor.updateDocument(id, data);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
deleteDocument
Description: Delete one document
Example:
const { data, error } = await vxtor.deleteDocument(id);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
createParagraph
Description: Add new paragraph to document
Example:
const { data, error } = await vxtor.createParagraph(data);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
findParagraphs
Description: Find all paragraphs
Example:
const { data, error } = await vxtor.findParagraphs(text, documentId, _limit);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
findOneParagraph
Description: Find one paragraph
Example:
const { data, error } = await vxtor.findOneParagraph(id);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
updateParagraph
Description: Update one paragraph
Example:
const { data, error } = await vxtor.updateParagraph(id, data);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
deleteParagraph
Description: Delete one paragraph
Example:
const { data, error } = await vxtor.deleteParagraph(id);
if (error) {
console.error('Error:', response.error);
} else {
console.log('Data:', data);
}
Error Handling
Each method in the Vxtor SDK returns an object containing:
data
: The response data from the API if successful.error
: An error message if the request fails.isBusy
: A boolean indicating whether the request is still in progress.
This allows you to handle API responses and errors effectively without worrying about exceptions being thrown.
Contributing
If you would like to contribute to the Vxtor SDK, feel free to fork the repository, make your changes, and submit a pull request. We welcome all contributions!
License
This project is licensed under the MIT License.