Newer
Older
export const dbCreateCollection = async (newCollectionName, newCollectionType) => {
console.log("dbCreateCollection");
let result = await fetch(
"http://127.0.0.1:5000/api/v1/create_collection",
{
method: "POST", // or 'PUT'
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(
{
"authenticate":{"username":"test_user","password":"CETSp@assword!"},
"collection_info":{"collection_name": newCollectionName, "type":newCollectionType}
}
),
}
)
.then((response) => response.json())
.then((response) => {
if (response["status"] === "success") {
console.log("dbCreateCollection Success")
return response["collection_id"];
}
});
export const dbDeleteCollection = async (collectionName) => {
console.log("dbDeleteCollection");
const response = await fetch(
"http://127.0.0.1:5000/api/v1/delete_collection",
{
method: "DELETE",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
"collection_info": { "collection_name": collectionName }
}),
}
);
const responseData = await response.json();
if (responseData.status === "success") {
console.log("dbDeleteCollection Success");
return true;
} else {
console.error("dbDeleteCollection Failed");
return false;
}
};
export const dbGetCollection = async (collection_id) => {
console.log("dbGetCollection");
let result = await fetch("http://127.0.0.1:5000//api/v1/get_collection?collection=" + collection_id,)
.then((response) => response.json())
.then((response) => {
console.log(response)
if (response["status"] === "success") {
return response["collection"]
}
});
return result;
export const dbGetItems = async (collection_id) => {
let result = await fetch(`http://127.0.0.1:5000//api/v1/get_items?collection=${collection_id}`)
.then((response) => response.json())
.then((response) => {
console.log(response)
if (response["status"] === "success") {
return response["files"]
}
});
let result = await fetch("http://127.0.0.1:5000//api/v1/get_collections?user=" + user_id,)
.then((response) => response.json())
.then((response) => {
console.log("dbGetCollections",response);
if (response["status"] === "success") {
return response["collections"]
} else {
return []
}
});
return result;
export const dbUpdateCollectionGlob = async (collection_id,glob) => {
console.log("dbUpdateCollection",collection_id);
"http://127.0.0.1:5000/api/v1/update_collection_glob",
{
method: "POST", // or 'PUT'
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(
{
"authenticate":{"username":"test_user","password":"CETSp@assword!"},
"collection_info":{
"collection_id": collection_id,
}
}
),
}
)
.then((response) => response.json())
.then((response) => {
if (response["status"] === "success") {
return response;
}
});
return result
};
export const dbUpdateCollectionSummary = async (collection_id, summarizer) => {
console.log("dbUpdateCollectionSummary",collection_id);
`http://127.0.0.1:5000/api/v1/summarize/${summarizer}`,
{
method: "POST", // or 'PUT'
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(
{
"collection_info":{
"collection_id": collection_id,
}
}
),
}
)
.then((response) => response.json())
.then((response) => {
if (response["status"] === "success") {
return response;
}
});
return result
};
export const dbUploadRawTextFiles = async (collection_id,formData) => {
console.log("dbUpdateCollectionSummary",collection_id);
let result = await fetch('http://127.0.0.1:5000//api/v1/upload_raw_text?collection='+collection_id, {
// content-type header should not be specified!
method: 'POST',
body: formData,
})
.then(response => response.json())
.then(success => {
console.log(success)
// Do something with the successful response
})
.catch(error => console.log(error)
);
return result
};
export const dbUploadRawHTMLFiles = async (collection_id,formData) => {
console.log("dbUploadRawHTMLFiles",collection_id);
let result = await fetch('http://127.0.0.1:5000//api/v1/upload_raw_html?collection='+collection_id, {
// content-type header should not be specified!
method: 'POST',
body: formData,
})
.then(response => response.json())
.then(success => {
console.log(success)
// Do something with the successful response
})
.catch(error => console.log(error)
);
return result
};
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
export const dbUploadRawHtmlFiles = async (collection_id,formData) => {
console.log("dbUpdateCollectionSummary",collection_id);
let result = await fetch('http://127.0.0.1:5000//api/v1/upload_raw_html?collection='+collection_id, {
// content-type header should not be specified!
method: 'POST',
body: formData,
})
.then(response => response.json())
.then(success => {
console.log(success)
// Do something with the successful response
})
.catch(error => console.log(error)
);
return result
};
export const dbUploadUrlFile = async (collection_id,formData) => {
console.log("dbUpdateCollectionSummary",collection_id);
let result = await fetch('http://127.0.0.1:5000//api/v1/upload_url_file?collection='+collection_id, {
// content-type header should not be specified!
method: 'POST',
body: formData,
})
.then(response => response.json())
.then(success => {
console.log(success)
// Do something with the successful response
})
.catch(error => console.log(error)
);
return result
};