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":"12345"},
"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 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":"12345"},
"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) => {
console.log("dbUpdateCollectionSummary",collection_id);
"http://127.0.0.1:5000/api/v1/summarize/t5",
{
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
};
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
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
};
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
export const dbUpdateCollectionSummaryNLTK = async (collection_id) => {
let result = await fetch(
"http://127.0.0.1:5000/api/v1/summarize/nltk",
{
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 dbUpdateCollectionSummaryBERT = async (collection_id) => {
let result = await fetch(
"http://127.0.0.1:5000/api/v1/summarize/bert",
{
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
};