Javascript를 활용한 문서 폴더 관리 API
문서 조각 관리
문서 조각 추가
이미 존재하는 DOC_ID를 사용해 문서 조각을 추가하면 덮어쓰여집니다.
const axios = require('axios');
async function updateDocument(collectionCode, docId, apiKey, projectCode, text) {
const url = `https://api-laas.wanted.co.kr/api/document/${collectionCode}/${docId}`;
const headers = {
"Content-Type": "application/json",
"apiKey": apiKey,
"project": projectCode
};
const data = {
text: text
};
return axios.put(url, data, { headers });
}
문서 조각 조회
async function getDocument(collectionCode, docId, apiKey, projectCode) {
const url = `https://api-laas.wanted.co.kr/api/document/${collectionCode}/${docId}`;
const headers = {
"Content-Type": "application/json",
"apiKey": apiKey,
"project": projectCode
};
return axios.get(url, { headers });
}
문서 조각 삭제
async function deleteDocument(collectionCode, docId, apiKey, projectCode) {
const url = `https://api-laas.wanted.co.kr/api/document/${collectionCode}/${docId}`;
const headers = {
"Content-Type": "application/json",
"apiKey": apiKey,
"project": projectCode
};
return axios.delete(url, { headers });
}
문서 검색
ID 기반 유사도 검색
지정한 DOC_ID문서와 유사한 문서 조각을 검색합니다.
async function findSimilarDocuments(collectionCode, docId, apiKey, projectCode, limit, offset) {
const url = `https://api-laas.wanted.co.kr/api/document/${collectionCode}/similar/${docId}`;
const headers = {
"Content-Type": "application/json",
"apiKey": apiKey,
"project": projectCode
};
const data = {
limit: limit,
offset: offset
};
return axios.post(url, data, { headers });
}
문자열 기반 유사도 검색
입력된 텍스트 TEXT 와 유사한 문서를 검색합니다. 임베딩 모델이 사용됩니다.
async function findSimilarDocumentsByText(collectionCode, apiKey, projectCode, text, limit, offset) {
const url = `https://api-laas.wanted.co.kr/api/document/${collectionCode}/similar/text`;
const headers = {
"Content-Type": "application/json",
"apiKey": apiKey,
"project": projectCode
};
const data = {
text: text,
limit: limit,
offset: offset
};
return axios.post(url, data, { headers });
}