Documents
Last updated
Last updated
try {
const res = await cortex.getDocument('tigers','testing.txt')
const document = res.data.document
console.log(document.text);
} catch (error) {
if (error.response) {
console.log(error.response.status);
console.log(error.response.data);
} else {
console.log(error.message);
}
}CortexAPI.getDocument('tigers','testing.txt')interface createDocument {
timestamp?: number;
tags?: string[];
text?: string | null;
source_url?: string | null;
};class CreateDocument:
def __init__(
self,
timestamp: Union[int, None] = None,
tags:
List[str] = None,
text: Union[str, None] = None,
source_url: Union[str, None] = None
):
self.timestamp = timestamp
self.tags = tags
self.text = text
self.source_url = source_urlconst test = {
"source_url": "https://www.test.com/",
"text": "test"
}
try {
let output = await cortex.uploadDocument('tigers','test1',test);
console.log(output.data.document);
} catch (error) {
if (error.response) {
console.log(error.response.status);
console.log(error.response.data);
} else {
console.log(error.message);
}
}test = cortex.CreateDocument()
test.source_url = "https://www.test.com/"
test.text = "test"
CortexAPI = cortex.CortexAPI("sk-...")
CortexAPI.uploadDocument('tigers','test1',test)try {
let output = await cortex.deleteDocument('tigers','test1');
console.log(output.data.document);
} catch (error:any) {
if (error.response) {
console.log(error.response.status);
console.log(error.response.data);
} else {
console.log(error.message);
}
}CortexAPI.deleteDocument('tigers','test1')