All URIs are relative to http://localhost
Method | HTTP request | Description |
---|---|---|
getAllowedMimetypes | GET /rabbithole/allowed-mimetypes | Get Allowed Mimetypes |
uploadFile | POST /rabbithole/ | Upload File |
uploadMemory | POST /rabbithole/memory | Upload Memory |
uploadUrl | POST /rabbithole/web | Upload Url |
Object getAllowedMimetypes()
Get Allowed Mimetypes
Retrieve the allowed mimetypes that can be ingested by the Rabbit Hole
// Import classes:
import it.baccan.cheshirecat.ApiClient;
import it.baccan.cheshirecat.ApiException;
import it.baccan.cheshirecat.Configuration;
import it.baccan.cheshirecat.model.*;
import it.baccan.cheshirecat.service.RabbitHoleApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost");
RabbitHoleApi apiInstance = new RabbitHoleApi(defaultClient);
try {
Object result = apiInstance.getAllowedMimetypes();
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RabbitHoleApi#getAllowedMimetypes");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
This endpoint does not need any parameter.
Object
No authorization required
- Content-Type: Not defined
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successful Response | - |
Object uploadFile(_file, chunkSize, chunkOverlap, metadata)
Upload File
Upload a file containing text (.txt, .md, .pdf, etc.). File content will be extracted and segmented into chunks. Chunks will be then vectorized and stored into documents memory.
chunk_size
, chunk_overlap
anad metadata
must be passed as form data.
This is necessary because the HTTP protocol does not allow file uploads to be sent as JSON.
content_type = "application/pdf"
file_name = "sample.pdf"
file_path = f"tests/mocks/{file_name}"
with open(file_path, "rb") as f:
files = {"file": (file_name, f, content_type)}
metadata = {
"source": "sample.pdf",
"title": "Test title",
"author": "Test author",
"year": 2020,
}
# upload file endpoint only accepts form-encoded data
payload = {
"chunk_size": 128,
"metadata": json.dumps(metadata)
}
response = requests.post(
"http://localhost:1865/rabbithole/",
files=files,
data=payload
)
import java.io.File;
// Import classes:
import it.baccan.cheshirecat.ApiClient;
import it.baccan.cheshirecat.ApiException;
import it.baccan.cheshirecat.Configuration;
import it.baccan.cheshirecat.model.*;
import it.baccan.cheshirecat.service.RabbitHoleApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost");
RabbitHoleApi apiInstance = new RabbitHoleApi(defaultClient);
File _file = new File("/path/to/file"); // File |
Integer chunkSize = 56; // Integer |
Integer chunkOverlap = 56; // Integer |
String metadata = "{}"; // String | Metadata to be stored with each chunk (e.g. author, category, etc.). Since we are passing this along side form data, must be a JSON string (use `json.dumps(metadata)`).
try {
Object result = apiInstance.uploadFile(_file, chunkSize, chunkOverlap, metadata);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RabbitHoleApi#uploadFile");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
_file | File | ||
chunkSize | Integer | [optional] | |
chunkOverlap | Integer | [optional] | |
metadata | String | Metadata to be stored with each chunk (e.g. author, category, etc.). Since we are passing this along side form data, must be a JSON string (use `json.dumps(metadata)`). | [optional] [default to {}] |
Object
No authorization required
- Content-Type: multipart/form-data
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successful Response | - |
422 | Validation Error | - |
Object uploadMemory(_file)
Upload Memory
Upload a memory json file to the cat memory
import java.io.File;
// Import classes:
import it.baccan.cheshirecat.ApiClient;
import it.baccan.cheshirecat.ApiException;
import it.baccan.cheshirecat.Configuration;
import it.baccan.cheshirecat.model.*;
import it.baccan.cheshirecat.service.RabbitHoleApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost");
RabbitHoleApi apiInstance = new RabbitHoleApi(defaultClient);
File _file = new File("/path/to/file"); // File |
try {
Object result = apiInstance.uploadMemory(_file);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RabbitHoleApi#uploadMemory");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
_file | File |
Object
No authorization required
- Content-Type: multipart/form-data
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successful Response | - |
422 | Validation Error | - |
Object uploadUrl(uploadURLConfig)
Upload Url
Upload a url. Website content will be extracted and segmented into chunks. Chunks will be then vectorized and stored into documents memory.
// Import classes:
import it.baccan.cheshirecat.ApiClient;
import it.baccan.cheshirecat.ApiException;
import it.baccan.cheshirecat.Configuration;
import it.baccan.cheshirecat.model.*;
import it.baccan.cheshirecat.service.RabbitHoleApi;
public class Example {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("http://localhost");
RabbitHoleApi apiInstance = new RabbitHoleApi(defaultClient);
UploadURLConfig uploadURLConfig = new UploadURLConfig(); // UploadURLConfig |
try {
Object result = apiInstance.uploadUrl(uploadURLConfig);
System.out.println(result);
} catch (ApiException e) {
System.err.println("Exception when calling RabbitHoleApi#uploadUrl");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}
Name | Type | Description | Notes |
---|---|---|---|
uploadURLConfig | UploadURLConfig |
Object
No authorization required
- Content-Type: application/json
- Accept: application/json
Status code | Description | Response headers |
---|---|---|
200 | Successful Response | - |
422 | Validation Error | - |