connectbase-client 3.18.0 → 3.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/connect-base.umd.js +4 -4
- package/dist/index.d.mts +88 -28
- package/dist/index.d.ts +88 -28
- package/dist/index.js +63 -30
- package/dist/index.mjs +63 -30
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -6952,24 +6952,33 @@ interface CreateDocumentRequest {
|
|
|
6952
6952
|
* 비어있으면 서버가 매직 바이트로 자동 추정 — 정확도를 위해 명시 권장.
|
|
6953
6953
|
*/
|
|
6954
6954
|
mime_type?: string;
|
|
6955
|
+
/**
|
|
6956
|
+
* 클라이언트가 지정하는 멱등(upsert) 키. 같은 지식 베이스 안에서 유일하다.
|
|
6957
|
+
* 같은 `external_id` 로 다시 `addDocument` 하면 새 문서를 만들지 않고 기존 문서를
|
|
6958
|
+
* 교체(update)한다 — `listDocuments` 로 기존 문서를 찾아 지울 필요 없이
|
|
6959
|
+
* idempotent 한 동기화가 가능하다. 문서 id 도 그대로 유지된다.
|
|
6960
|
+
*/
|
|
6961
|
+
external_id?: string;
|
|
6955
6962
|
metadata?: Record<string, unknown>;
|
|
6956
6963
|
}
|
|
6957
6964
|
/**
|
|
6958
|
-
* 문서
|
|
6965
|
+
* 문서 update/upsert 요청. 보낸 필드만 교체된다 (생략한 필드는 변경 없음).
|
|
6959
6966
|
*
|
|
6960
6967
|
* `content` / `file_content` / `metadata` 중 하나라도 보내면 서버가 전체 재색인을 수행한다
|
|
6961
6968
|
* (기존 청크 삭제 → 재청킹 → 재색인). RAG 특성상 콘텐츠가 바뀌면 청크 경계가 바뀌어
|
|
6962
6969
|
* 부분 수정이 불가능하며, 재색인 시 색인 토큰이 다시 과금된다.
|
|
6963
|
-
* `name` 만 보내면 재색인 없이
|
|
6970
|
+
* `name` / `external_id` 만 보내면 재색인 없이 라벨·멱등 키만 변경된다.
|
|
6971
|
+
* 문서 id 는 항상 유지되므로 검색 결과의 `document_id` 참조가 깨지지 않는다.
|
|
6964
6972
|
*/
|
|
6965
6973
|
interface UpdateDocumentRequest {
|
|
6966
6974
|
name?: string;
|
|
6967
6975
|
content?: string;
|
|
6968
|
-
/** base64 인코딩
|
|
6976
|
+
/** base64 인코딩 파일 (파일 재업로드, PDF/DOCX/text). content 보다 우선하며 source_type 무관하게 추출. */
|
|
6969
6977
|
file_content?: string;
|
|
6970
6978
|
/** file_content 의 MIME. 비어있으면 서버 자동 추정. */
|
|
6971
6979
|
mime_type?: string;
|
|
6972
6980
|
metadata?: Record<string, unknown>;
|
|
6981
|
+
external_id?: string;
|
|
6973
6982
|
}
|
|
6974
6983
|
interface DocumentResponse {
|
|
6975
6984
|
id: string;
|
|
@@ -6977,6 +6986,7 @@ interface DocumentResponse {
|
|
|
6977
6986
|
source_type: string;
|
|
6978
6987
|
mime_type?: string;
|
|
6979
6988
|
source_url?: string;
|
|
6989
|
+
external_id?: string;
|
|
6980
6990
|
file_size: number;
|
|
6981
6991
|
chunk_count: number;
|
|
6982
6992
|
status: 'pending' | 'processing' | 'ready' | 'failed';
|
|
@@ -7035,6 +7045,14 @@ interface KnowledgeSearchResponse {
|
|
|
7035
7045
|
query: string;
|
|
7036
7046
|
results: KnowledgeSearchResult[];
|
|
7037
7047
|
total: number;
|
|
7048
|
+
/**
|
|
7049
|
+
* 이 응답이 agentic 다중검색으로 생성됐는지 여부. `agentic: true` 를 보냈더라도
|
|
7050
|
+
* AI provider 미설정·LLM 오류로 단일 키워드 검색에 폴백되면 `false` — 옵션이
|
|
7051
|
+
* placebo 가 되지 않도록 실제 수행 여부를 신호한다.
|
|
7052
|
+
*/
|
|
7053
|
+
agentic?: boolean;
|
|
7054
|
+
/** 수행된 agentic 검색 라운드 수 (1~2). 0 또는 미존재는 폴백을 의미. */
|
|
7055
|
+
agentic_rounds?: number;
|
|
7038
7056
|
}
|
|
7039
7057
|
|
|
7040
7058
|
/**
|
|
@@ -7113,9 +7131,60 @@ declare class KnowledgeAPI {
|
|
|
7113
7131
|
* source_type: 'url',
|
|
7114
7132
|
* source_url: 'https://example.com/help.html'
|
|
7115
7133
|
* })
|
|
7134
|
+
*
|
|
7135
|
+
* // external_id 로 idempotent 동기화 (빌드 스크립트 등)
|
|
7136
|
+
* // 같은 external_id 로 다시 호출하면 기존 문서를 교체한다 (문서 id 유지).
|
|
7137
|
+
* await cb.knowledge.addDocument('kb-id', {
|
|
7138
|
+
* name: '블로그: 제목',
|
|
7139
|
+
* source_type: 'text',
|
|
7140
|
+
* content: '...',
|
|
7141
|
+
* external_id: 'blog/my-post-slug',
|
|
7142
|
+
* })
|
|
7116
7143
|
* ```
|
|
7117
7144
|
*/
|
|
7118
7145
|
addDocument(kbID: string, data: CreateDocumentRequest): Promise<DocumentResponse>;
|
|
7146
|
+
/**
|
|
7147
|
+
* 문서 수정 (update/upsert)
|
|
7148
|
+
*
|
|
7149
|
+
* 기존 문서의 내용·이름·메타데이터를 교체합니다. **문서 id 는 그대로 유지**되므로
|
|
7150
|
+
* 검색 결과의 `document_id` 를 외부에서 참조(인용·캐시)해도 편집 후 깨지지 않습니다.
|
|
7151
|
+
* 보낸 필드만 교체되며, 내용/이름/메타데이터가 실제로 바뀌면 자동으로 재청킹·재색인됩니다.
|
|
7152
|
+
*
|
|
7153
|
+
* @param kbID - 지식 베이스 ID
|
|
7154
|
+
* @param docID - 문서 ID
|
|
7155
|
+
* @param data - 변경할 필드 (생략한 필드는 변경 없음)
|
|
7156
|
+
* @returns 수정된 문서 정보
|
|
7157
|
+
*
|
|
7158
|
+
* @example
|
|
7159
|
+
* ```typescript
|
|
7160
|
+
* // 내용만 교체 — document_id 는 그대로
|
|
7161
|
+
* const doc = await cb.knowledge.updateDocument('kb-id', 'doc-id', {
|
|
7162
|
+
* content: '갱신된 환불 정책...',
|
|
7163
|
+
* })
|
|
7164
|
+
*
|
|
7165
|
+
* // 이름 + 메타데이터 교체
|
|
7166
|
+
* await cb.knowledge.updateDocument('kb-id', 'doc-id', {
|
|
7167
|
+
* name: 'FAQ (2026)',
|
|
7168
|
+
* metadata: { tag: 'faq', updated: '2026-05' },
|
|
7169
|
+
* })
|
|
7170
|
+
* ```
|
|
7171
|
+
*/
|
|
7172
|
+
updateDocument(kbID: string, docID: string, data: UpdateDocumentRequest): Promise<DocumentResponse>;
|
|
7173
|
+
/**
|
|
7174
|
+
* 파일로 문서 수정 (PDF / DOCX / text 파일 재업로드).
|
|
7175
|
+
*
|
|
7176
|
+
* [`addDocumentFromFile`](#addDocumentFromFile) 의 update 버전. 문서 id 는 유지됩니다.
|
|
7177
|
+
*
|
|
7178
|
+
* @param kbID - Knowledge Base ID
|
|
7179
|
+
* @param docID - 문서 ID
|
|
7180
|
+
* @param file - 새 파일. `File` (DOM) / `Blob` / `{ data, mimeType, name }` (Node) 모두 가능
|
|
7181
|
+
* @param options - name / metadata 오버라이드
|
|
7182
|
+
* @returns 수정된 문서 정보
|
|
7183
|
+
*/
|
|
7184
|
+
updateDocumentFromFile(kbID: string, docID: string, file: KnowledgeFileInput, options?: {
|
|
7185
|
+
name?: string;
|
|
7186
|
+
metadata?: Record<string, unknown>;
|
|
7187
|
+
}): Promise<DocumentResponse>;
|
|
7119
7188
|
/**
|
|
7120
7189
|
* 파일을 KB 에 추가 (PDF / DOCX / text 파일).
|
|
7121
7190
|
*
|
|
@@ -7160,31 +7229,6 @@ declare class KnowledgeAPI {
|
|
|
7160
7229
|
name?: string;
|
|
7161
7230
|
metadata?: Record<string, unknown>;
|
|
7162
7231
|
}): Promise<DocumentResponse>;
|
|
7163
|
-
/**
|
|
7164
|
-
* 문서 수정 (재색인)
|
|
7165
|
-
*
|
|
7166
|
-
* `content` / `file_content` / `metadata` 중 하나라도 포함하면 전체 재색인이 일어나며
|
|
7167
|
-
* 색인 토큰이 다시 과금됩니다. `name` 만 보내면 재색인 없이 라벨만 변경됩니다.
|
|
7168
|
-
* 재색인 시 서버는 status='pending' 으로 즉시 응답하고 색인은 백그라운드로 진행됩니다
|
|
7169
|
-
* (addDocument 와 동일) — get/listDocuments 로 'ready' 전환을 확인하세요.
|
|
7170
|
-
*
|
|
7171
|
-
* @param kbID - 지식 베이스 ID
|
|
7172
|
-
* @param docID - 문서 ID
|
|
7173
|
-
* @param data - 수정 요청 (모든 필드 옵셔널)
|
|
7174
|
-
* @returns 수정된 문서 정보
|
|
7175
|
-
*
|
|
7176
|
-
* @example
|
|
7177
|
-
* ```typescript
|
|
7178
|
-
* // 내용 갱신 (전체 재색인 발생)
|
|
7179
|
-
* await cb.knowledge.updateDocument('kb-id', 'doc-id', {
|
|
7180
|
-
* content: '환불은 구매 후 14일 이내에 가능합니다...'
|
|
7181
|
-
* })
|
|
7182
|
-
*
|
|
7183
|
-
* // 이름만 변경 (재색인 없음)
|
|
7184
|
-
* await cb.knowledge.updateDocument('kb-id', 'doc-id', { name: '환불 정책 v2' })
|
|
7185
|
-
* ```
|
|
7186
|
-
*/
|
|
7187
|
-
updateDocument(kbID: string, docID: string, data: UpdateDocumentRequest): Promise<DocumentResponse>;
|
|
7188
7232
|
/**
|
|
7189
7233
|
* 문서 목록 조회
|
|
7190
7234
|
*
|
|
@@ -7285,6 +7329,11 @@ interface AISource {
|
|
|
7285
7329
|
}
|
|
7286
7330
|
interface AIChatResponse {
|
|
7287
7331
|
content: string;
|
|
7332
|
+
/**
|
|
7333
|
+
* 추론 모델(Qwen3 reasoning, OpenAI o-series, DeepSeek-R1 등)의 사고 과정.
|
|
7334
|
+
* 최종 답변(`content`)과 분리되어 제공됩니다. 추론 모델이 아니면 비어 있습니다.
|
|
7335
|
+
*/
|
|
7336
|
+
reasoning?: string;
|
|
7288
7337
|
finishReason?: string;
|
|
7289
7338
|
usage?: {
|
|
7290
7339
|
promptTokens: number;
|
|
@@ -7299,6 +7348,11 @@ interface AIChatResponse {
|
|
|
7299
7348
|
interface AIStreamChunk {
|
|
7300
7349
|
type?: 'sources' | 'token' | 'searching' | 'tool_start' | 'tool_end' | 'heartbeat';
|
|
7301
7350
|
content: string;
|
|
7351
|
+
/**
|
|
7352
|
+
* 추론 모델의 사고 과정 델타. 추론 구간의 청크는 `content`가 비어 있고
|
|
7353
|
+
* `reasoning`만 채워져 전달됩니다.
|
|
7354
|
+
*/
|
|
7355
|
+
reasoning?: string;
|
|
7302
7356
|
finishReason?: string;
|
|
7303
7357
|
done: boolean;
|
|
7304
7358
|
toolCalls?: AIToolCall[];
|
|
@@ -7352,6 +7406,7 @@ declare class AIAPI {
|
|
|
7352
7406
|
* knowledgeBaseId: 'kb-id',
|
|
7353
7407
|
* }, {
|
|
7354
7408
|
* onSources: (sources) => console.log('참조:', sources),
|
|
7409
|
+
* onReasoning: (reasoning) => process.stdout.write(reasoning),
|
|
7355
7410
|
* onToken: (content) => process.stdout.write(content),
|
|
7356
7411
|
* onDone: () => console.log('\\n완료'),
|
|
7357
7412
|
* onError: (error) => console.error('에러:', error)
|
|
@@ -7360,6 +7415,11 @@ declare class AIAPI {
|
|
|
7360
7415
|
*/
|
|
7361
7416
|
chatStream(request: AIChatRequest, callbacks: {
|
|
7362
7417
|
onSources?: (sources: AISource[]) => void;
|
|
7418
|
+
/**
|
|
7419
|
+
* 추론 모델의 사고 과정 델타. 추론 모델(Qwen3 reasoning, o-series 등)을
|
|
7420
|
+
* 사용할 때만 호출되며, 최종 답변은 `onToken`으로 별도 전달됩니다.
|
|
7421
|
+
*/
|
|
7422
|
+
onReasoning?: (reasoning: string) => void;
|
|
7363
7423
|
onToken?: (content: string) => void;
|
|
7364
7424
|
onToolEvent?: (event: AIToolEvent) => void;
|
|
7365
7425
|
onDone?: () => void;
|
package/dist/index.d.ts
CHANGED
|
@@ -6952,24 +6952,33 @@ interface CreateDocumentRequest {
|
|
|
6952
6952
|
* 비어있으면 서버가 매직 바이트로 자동 추정 — 정확도를 위해 명시 권장.
|
|
6953
6953
|
*/
|
|
6954
6954
|
mime_type?: string;
|
|
6955
|
+
/**
|
|
6956
|
+
* 클라이언트가 지정하는 멱등(upsert) 키. 같은 지식 베이스 안에서 유일하다.
|
|
6957
|
+
* 같은 `external_id` 로 다시 `addDocument` 하면 새 문서를 만들지 않고 기존 문서를
|
|
6958
|
+
* 교체(update)한다 — `listDocuments` 로 기존 문서를 찾아 지울 필요 없이
|
|
6959
|
+
* idempotent 한 동기화가 가능하다. 문서 id 도 그대로 유지된다.
|
|
6960
|
+
*/
|
|
6961
|
+
external_id?: string;
|
|
6955
6962
|
metadata?: Record<string, unknown>;
|
|
6956
6963
|
}
|
|
6957
6964
|
/**
|
|
6958
|
-
* 문서
|
|
6965
|
+
* 문서 update/upsert 요청. 보낸 필드만 교체된다 (생략한 필드는 변경 없음).
|
|
6959
6966
|
*
|
|
6960
6967
|
* `content` / `file_content` / `metadata` 중 하나라도 보내면 서버가 전체 재색인을 수행한다
|
|
6961
6968
|
* (기존 청크 삭제 → 재청킹 → 재색인). RAG 특성상 콘텐츠가 바뀌면 청크 경계가 바뀌어
|
|
6962
6969
|
* 부분 수정이 불가능하며, 재색인 시 색인 토큰이 다시 과금된다.
|
|
6963
|
-
* `name` 만 보내면 재색인 없이
|
|
6970
|
+
* `name` / `external_id` 만 보내면 재색인 없이 라벨·멱등 키만 변경된다.
|
|
6971
|
+
* 문서 id 는 항상 유지되므로 검색 결과의 `document_id` 참조가 깨지지 않는다.
|
|
6964
6972
|
*/
|
|
6965
6973
|
interface UpdateDocumentRequest {
|
|
6966
6974
|
name?: string;
|
|
6967
6975
|
content?: string;
|
|
6968
|
-
/** base64 인코딩
|
|
6976
|
+
/** base64 인코딩 파일 (파일 재업로드, PDF/DOCX/text). content 보다 우선하며 source_type 무관하게 추출. */
|
|
6969
6977
|
file_content?: string;
|
|
6970
6978
|
/** file_content 의 MIME. 비어있으면 서버 자동 추정. */
|
|
6971
6979
|
mime_type?: string;
|
|
6972
6980
|
metadata?: Record<string, unknown>;
|
|
6981
|
+
external_id?: string;
|
|
6973
6982
|
}
|
|
6974
6983
|
interface DocumentResponse {
|
|
6975
6984
|
id: string;
|
|
@@ -6977,6 +6986,7 @@ interface DocumentResponse {
|
|
|
6977
6986
|
source_type: string;
|
|
6978
6987
|
mime_type?: string;
|
|
6979
6988
|
source_url?: string;
|
|
6989
|
+
external_id?: string;
|
|
6980
6990
|
file_size: number;
|
|
6981
6991
|
chunk_count: number;
|
|
6982
6992
|
status: 'pending' | 'processing' | 'ready' | 'failed';
|
|
@@ -7035,6 +7045,14 @@ interface KnowledgeSearchResponse {
|
|
|
7035
7045
|
query: string;
|
|
7036
7046
|
results: KnowledgeSearchResult[];
|
|
7037
7047
|
total: number;
|
|
7048
|
+
/**
|
|
7049
|
+
* 이 응답이 agentic 다중검색으로 생성됐는지 여부. `agentic: true` 를 보냈더라도
|
|
7050
|
+
* AI provider 미설정·LLM 오류로 단일 키워드 검색에 폴백되면 `false` — 옵션이
|
|
7051
|
+
* placebo 가 되지 않도록 실제 수행 여부를 신호한다.
|
|
7052
|
+
*/
|
|
7053
|
+
agentic?: boolean;
|
|
7054
|
+
/** 수행된 agentic 검색 라운드 수 (1~2). 0 또는 미존재는 폴백을 의미. */
|
|
7055
|
+
agentic_rounds?: number;
|
|
7038
7056
|
}
|
|
7039
7057
|
|
|
7040
7058
|
/**
|
|
@@ -7113,9 +7131,60 @@ declare class KnowledgeAPI {
|
|
|
7113
7131
|
* source_type: 'url',
|
|
7114
7132
|
* source_url: 'https://example.com/help.html'
|
|
7115
7133
|
* })
|
|
7134
|
+
*
|
|
7135
|
+
* // external_id 로 idempotent 동기화 (빌드 스크립트 등)
|
|
7136
|
+
* // 같은 external_id 로 다시 호출하면 기존 문서를 교체한다 (문서 id 유지).
|
|
7137
|
+
* await cb.knowledge.addDocument('kb-id', {
|
|
7138
|
+
* name: '블로그: 제목',
|
|
7139
|
+
* source_type: 'text',
|
|
7140
|
+
* content: '...',
|
|
7141
|
+
* external_id: 'blog/my-post-slug',
|
|
7142
|
+
* })
|
|
7116
7143
|
* ```
|
|
7117
7144
|
*/
|
|
7118
7145
|
addDocument(kbID: string, data: CreateDocumentRequest): Promise<DocumentResponse>;
|
|
7146
|
+
/**
|
|
7147
|
+
* 문서 수정 (update/upsert)
|
|
7148
|
+
*
|
|
7149
|
+
* 기존 문서의 내용·이름·메타데이터를 교체합니다. **문서 id 는 그대로 유지**되므로
|
|
7150
|
+
* 검색 결과의 `document_id` 를 외부에서 참조(인용·캐시)해도 편집 후 깨지지 않습니다.
|
|
7151
|
+
* 보낸 필드만 교체되며, 내용/이름/메타데이터가 실제로 바뀌면 자동으로 재청킹·재색인됩니다.
|
|
7152
|
+
*
|
|
7153
|
+
* @param kbID - 지식 베이스 ID
|
|
7154
|
+
* @param docID - 문서 ID
|
|
7155
|
+
* @param data - 변경할 필드 (생략한 필드는 변경 없음)
|
|
7156
|
+
* @returns 수정된 문서 정보
|
|
7157
|
+
*
|
|
7158
|
+
* @example
|
|
7159
|
+
* ```typescript
|
|
7160
|
+
* // 내용만 교체 — document_id 는 그대로
|
|
7161
|
+
* const doc = await cb.knowledge.updateDocument('kb-id', 'doc-id', {
|
|
7162
|
+
* content: '갱신된 환불 정책...',
|
|
7163
|
+
* })
|
|
7164
|
+
*
|
|
7165
|
+
* // 이름 + 메타데이터 교체
|
|
7166
|
+
* await cb.knowledge.updateDocument('kb-id', 'doc-id', {
|
|
7167
|
+
* name: 'FAQ (2026)',
|
|
7168
|
+
* metadata: { tag: 'faq', updated: '2026-05' },
|
|
7169
|
+
* })
|
|
7170
|
+
* ```
|
|
7171
|
+
*/
|
|
7172
|
+
updateDocument(kbID: string, docID: string, data: UpdateDocumentRequest): Promise<DocumentResponse>;
|
|
7173
|
+
/**
|
|
7174
|
+
* 파일로 문서 수정 (PDF / DOCX / text 파일 재업로드).
|
|
7175
|
+
*
|
|
7176
|
+
* [`addDocumentFromFile`](#addDocumentFromFile) 의 update 버전. 문서 id 는 유지됩니다.
|
|
7177
|
+
*
|
|
7178
|
+
* @param kbID - Knowledge Base ID
|
|
7179
|
+
* @param docID - 문서 ID
|
|
7180
|
+
* @param file - 새 파일. `File` (DOM) / `Blob` / `{ data, mimeType, name }` (Node) 모두 가능
|
|
7181
|
+
* @param options - name / metadata 오버라이드
|
|
7182
|
+
* @returns 수정된 문서 정보
|
|
7183
|
+
*/
|
|
7184
|
+
updateDocumentFromFile(kbID: string, docID: string, file: KnowledgeFileInput, options?: {
|
|
7185
|
+
name?: string;
|
|
7186
|
+
metadata?: Record<string, unknown>;
|
|
7187
|
+
}): Promise<DocumentResponse>;
|
|
7119
7188
|
/**
|
|
7120
7189
|
* 파일을 KB 에 추가 (PDF / DOCX / text 파일).
|
|
7121
7190
|
*
|
|
@@ -7160,31 +7229,6 @@ declare class KnowledgeAPI {
|
|
|
7160
7229
|
name?: string;
|
|
7161
7230
|
metadata?: Record<string, unknown>;
|
|
7162
7231
|
}): Promise<DocumentResponse>;
|
|
7163
|
-
/**
|
|
7164
|
-
* 문서 수정 (재색인)
|
|
7165
|
-
*
|
|
7166
|
-
* `content` / `file_content` / `metadata` 중 하나라도 포함하면 전체 재색인이 일어나며
|
|
7167
|
-
* 색인 토큰이 다시 과금됩니다. `name` 만 보내면 재색인 없이 라벨만 변경됩니다.
|
|
7168
|
-
* 재색인 시 서버는 status='pending' 으로 즉시 응답하고 색인은 백그라운드로 진행됩니다
|
|
7169
|
-
* (addDocument 와 동일) — get/listDocuments 로 'ready' 전환을 확인하세요.
|
|
7170
|
-
*
|
|
7171
|
-
* @param kbID - 지식 베이스 ID
|
|
7172
|
-
* @param docID - 문서 ID
|
|
7173
|
-
* @param data - 수정 요청 (모든 필드 옵셔널)
|
|
7174
|
-
* @returns 수정된 문서 정보
|
|
7175
|
-
*
|
|
7176
|
-
* @example
|
|
7177
|
-
* ```typescript
|
|
7178
|
-
* // 내용 갱신 (전체 재색인 발생)
|
|
7179
|
-
* await cb.knowledge.updateDocument('kb-id', 'doc-id', {
|
|
7180
|
-
* content: '환불은 구매 후 14일 이내에 가능합니다...'
|
|
7181
|
-
* })
|
|
7182
|
-
*
|
|
7183
|
-
* // 이름만 변경 (재색인 없음)
|
|
7184
|
-
* await cb.knowledge.updateDocument('kb-id', 'doc-id', { name: '환불 정책 v2' })
|
|
7185
|
-
* ```
|
|
7186
|
-
*/
|
|
7187
|
-
updateDocument(kbID: string, docID: string, data: UpdateDocumentRequest): Promise<DocumentResponse>;
|
|
7188
7232
|
/**
|
|
7189
7233
|
* 문서 목록 조회
|
|
7190
7234
|
*
|
|
@@ -7285,6 +7329,11 @@ interface AISource {
|
|
|
7285
7329
|
}
|
|
7286
7330
|
interface AIChatResponse {
|
|
7287
7331
|
content: string;
|
|
7332
|
+
/**
|
|
7333
|
+
* 추론 모델(Qwen3 reasoning, OpenAI o-series, DeepSeek-R1 등)의 사고 과정.
|
|
7334
|
+
* 최종 답변(`content`)과 분리되어 제공됩니다. 추론 모델이 아니면 비어 있습니다.
|
|
7335
|
+
*/
|
|
7336
|
+
reasoning?: string;
|
|
7288
7337
|
finishReason?: string;
|
|
7289
7338
|
usage?: {
|
|
7290
7339
|
promptTokens: number;
|
|
@@ -7299,6 +7348,11 @@ interface AIChatResponse {
|
|
|
7299
7348
|
interface AIStreamChunk {
|
|
7300
7349
|
type?: 'sources' | 'token' | 'searching' | 'tool_start' | 'tool_end' | 'heartbeat';
|
|
7301
7350
|
content: string;
|
|
7351
|
+
/**
|
|
7352
|
+
* 추론 모델의 사고 과정 델타. 추론 구간의 청크는 `content`가 비어 있고
|
|
7353
|
+
* `reasoning`만 채워져 전달됩니다.
|
|
7354
|
+
*/
|
|
7355
|
+
reasoning?: string;
|
|
7302
7356
|
finishReason?: string;
|
|
7303
7357
|
done: boolean;
|
|
7304
7358
|
toolCalls?: AIToolCall[];
|
|
@@ -7352,6 +7406,7 @@ declare class AIAPI {
|
|
|
7352
7406
|
* knowledgeBaseId: 'kb-id',
|
|
7353
7407
|
* }, {
|
|
7354
7408
|
* onSources: (sources) => console.log('참조:', sources),
|
|
7409
|
+
* onReasoning: (reasoning) => process.stdout.write(reasoning),
|
|
7355
7410
|
* onToken: (content) => process.stdout.write(content),
|
|
7356
7411
|
* onDone: () => console.log('\\n완료'),
|
|
7357
7412
|
* onError: (error) => console.error('에러:', error)
|
|
@@ -7360,6 +7415,11 @@ declare class AIAPI {
|
|
|
7360
7415
|
*/
|
|
7361
7416
|
chatStream(request: AIChatRequest, callbacks: {
|
|
7362
7417
|
onSources?: (sources: AISource[]) => void;
|
|
7418
|
+
/**
|
|
7419
|
+
* 추론 모델의 사고 과정 델타. 추론 모델(Qwen3 reasoning, o-series 등)을
|
|
7420
|
+
* 사용할 때만 호출되며, 최종 답변은 `onToken`으로 별도 전달됩니다.
|
|
7421
|
+
*/
|
|
7422
|
+
onReasoning?: (reasoning: string) => void;
|
|
7363
7423
|
onToken?: (content: string) => void;
|
|
7364
7424
|
onToolEvent?: (event: AIToolEvent) => void;
|
|
7365
7425
|
onDone?: () => void;
|
package/dist/index.js
CHANGED
|
@@ -8050,6 +8050,15 @@ var KnowledgeAPI = class {
|
|
|
8050
8050
|
* source_type: 'url',
|
|
8051
8051
|
* source_url: 'https://example.com/help.html'
|
|
8052
8052
|
* })
|
|
8053
|
+
*
|
|
8054
|
+
* // external_id 로 idempotent 동기화 (빌드 스크립트 등)
|
|
8055
|
+
* // 같은 external_id 로 다시 호출하면 기존 문서를 교체한다 (문서 id 유지).
|
|
8056
|
+
* await cb.knowledge.addDocument('kb-id', {
|
|
8057
|
+
* name: '블로그: 제목',
|
|
8058
|
+
* source_type: 'text',
|
|
8059
|
+
* content: '...',
|
|
8060
|
+
* external_id: 'blog/my-post-slug',
|
|
8061
|
+
* })
|
|
8053
8062
|
* ```
|
|
8054
8063
|
*/
|
|
8055
8064
|
async addDocument(kbID, data) {
|
|
@@ -8058,6 +8067,58 @@ var KnowledgeAPI = class {
|
|
|
8058
8067
|
data
|
|
8059
8068
|
);
|
|
8060
8069
|
}
|
|
8070
|
+
/**
|
|
8071
|
+
* 문서 수정 (update/upsert)
|
|
8072
|
+
*
|
|
8073
|
+
* 기존 문서의 내용·이름·메타데이터를 교체합니다. **문서 id 는 그대로 유지**되므로
|
|
8074
|
+
* 검색 결과의 `document_id` 를 외부에서 참조(인용·캐시)해도 편집 후 깨지지 않습니다.
|
|
8075
|
+
* 보낸 필드만 교체되며, 내용/이름/메타데이터가 실제로 바뀌면 자동으로 재청킹·재색인됩니다.
|
|
8076
|
+
*
|
|
8077
|
+
* @param kbID - 지식 베이스 ID
|
|
8078
|
+
* @param docID - 문서 ID
|
|
8079
|
+
* @param data - 변경할 필드 (생략한 필드는 변경 없음)
|
|
8080
|
+
* @returns 수정된 문서 정보
|
|
8081
|
+
*
|
|
8082
|
+
* @example
|
|
8083
|
+
* ```typescript
|
|
8084
|
+
* // 내용만 교체 — document_id 는 그대로
|
|
8085
|
+
* const doc = await cb.knowledge.updateDocument('kb-id', 'doc-id', {
|
|
8086
|
+
* content: '갱신된 환불 정책...',
|
|
8087
|
+
* })
|
|
8088
|
+
*
|
|
8089
|
+
* // 이름 + 메타데이터 교체
|
|
8090
|
+
* await cb.knowledge.updateDocument('kb-id', 'doc-id', {
|
|
8091
|
+
* name: 'FAQ (2026)',
|
|
8092
|
+
* metadata: { tag: 'faq', updated: '2026-05' },
|
|
8093
|
+
* })
|
|
8094
|
+
* ```
|
|
8095
|
+
*/
|
|
8096
|
+
async updateDocument(kbID, docID, data) {
|
|
8097
|
+
return this.http.put(
|
|
8098
|
+
`/v1/public/knowledge-bases/${kbID}/documents/${docID}`,
|
|
8099
|
+
data
|
|
8100
|
+
);
|
|
8101
|
+
}
|
|
8102
|
+
/**
|
|
8103
|
+
* 파일로 문서 수정 (PDF / DOCX / text 파일 재업로드).
|
|
8104
|
+
*
|
|
8105
|
+
* [`addDocumentFromFile`](#addDocumentFromFile) 의 update 버전. 문서 id 는 유지됩니다.
|
|
8106
|
+
*
|
|
8107
|
+
* @param kbID - Knowledge Base ID
|
|
8108
|
+
* @param docID - 문서 ID
|
|
8109
|
+
* @param file - 새 파일. `File` (DOM) / `Blob` / `{ data, mimeType, name }` (Node) 모두 가능
|
|
8110
|
+
* @param options - name / metadata 오버라이드
|
|
8111
|
+
* @returns 수정된 문서 정보
|
|
8112
|
+
*/
|
|
8113
|
+
async updateDocumentFromFile(kbID, docID, file, options) {
|
|
8114
|
+
const { data, mimeType } = await readFileInput(file);
|
|
8115
|
+
return this.updateDocument(kbID, docID, {
|
|
8116
|
+
name: options?.name,
|
|
8117
|
+
file_content: data,
|
|
8118
|
+
mime_type: mimeType,
|
|
8119
|
+
metadata: options?.metadata
|
|
8120
|
+
});
|
|
8121
|
+
}
|
|
8061
8122
|
/**
|
|
8062
8123
|
* 파일을 KB 에 추가 (PDF / DOCX / text 파일).
|
|
8063
8124
|
*
|
|
@@ -8109,36 +8170,6 @@ var KnowledgeAPI = class {
|
|
|
8109
8170
|
metadata: options?.metadata
|
|
8110
8171
|
});
|
|
8111
8172
|
}
|
|
8112
|
-
/**
|
|
8113
|
-
* 문서 수정 (재색인)
|
|
8114
|
-
*
|
|
8115
|
-
* `content` / `file_content` / `metadata` 중 하나라도 포함하면 전체 재색인이 일어나며
|
|
8116
|
-
* 색인 토큰이 다시 과금됩니다. `name` 만 보내면 재색인 없이 라벨만 변경됩니다.
|
|
8117
|
-
* 재색인 시 서버는 status='pending' 으로 즉시 응답하고 색인은 백그라운드로 진행됩니다
|
|
8118
|
-
* (addDocument 와 동일) — get/listDocuments 로 'ready' 전환을 확인하세요.
|
|
8119
|
-
*
|
|
8120
|
-
* @param kbID - 지식 베이스 ID
|
|
8121
|
-
* @param docID - 문서 ID
|
|
8122
|
-
* @param data - 수정 요청 (모든 필드 옵셔널)
|
|
8123
|
-
* @returns 수정된 문서 정보
|
|
8124
|
-
*
|
|
8125
|
-
* @example
|
|
8126
|
-
* ```typescript
|
|
8127
|
-
* // 내용 갱신 (전체 재색인 발생)
|
|
8128
|
-
* await cb.knowledge.updateDocument('kb-id', 'doc-id', {
|
|
8129
|
-
* content: '환불은 구매 후 14일 이내에 가능합니다...'
|
|
8130
|
-
* })
|
|
8131
|
-
*
|
|
8132
|
-
* // 이름만 변경 (재색인 없음)
|
|
8133
|
-
* await cb.knowledge.updateDocument('kb-id', 'doc-id', { name: '환불 정책 v2' })
|
|
8134
|
-
* ```
|
|
8135
|
-
*/
|
|
8136
|
-
async updateDocument(kbID, docID, data) {
|
|
8137
|
-
return this.http.put(
|
|
8138
|
-
`/v1/public/knowledge-bases/${kbID}/documents/${docID}`,
|
|
8139
|
-
data
|
|
8140
|
-
);
|
|
8141
|
-
}
|
|
8142
8173
|
/**
|
|
8143
8174
|
* 문서 목록 조회
|
|
8144
8175
|
*
|
|
@@ -8232,6 +8263,7 @@ var AIAPI = class {
|
|
|
8232
8263
|
* knowledgeBaseId: 'kb-id',
|
|
8233
8264
|
* }, {
|
|
8234
8265
|
* onSources: (sources) => console.log('참조:', sources),
|
|
8266
|
+
* onReasoning: (reasoning) => process.stdout.write(reasoning),
|
|
8235
8267
|
* onToken: (content) => process.stdout.write(content),
|
|
8236
8268
|
* onDone: () => console.log('\\n완료'),
|
|
8237
8269
|
* onError: (error) => console.error('에러:', error)
|
|
@@ -8293,6 +8325,7 @@ var AIAPI = class {
|
|
|
8293
8325
|
if (event.type === "heartbeat" || event.type === "searching") {
|
|
8294
8326
|
continue;
|
|
8295
8327
|
}
|
|
8328
|
+
if (event.reasoning) callbacks.onReasoning?.(event.reasoning);
|
|
8296
8329
|
if (event.content) callbacks.onToken?.(event.content);
|
|
8297
8330
|
if (event.done) {
|
|
8298
8331
|
callbacks.onDone?.();
|
package/dist/index.mjs
CHANGED
|
@@ -8007,6 +8007,15 @@ var KnowledgeAPI = class {
|
|
|
8007
8007
|
* source_type: 'url',
|
|
8008
8008
|
* source_url: 'https://example.com/help.html'
|
|
8009
8009
|
* })
|
|
8010
|
+
*
|
|
8011
|
+
* // external_id 로 idempotent 동기화 (빌드 스크립트 등)
|
|
8012
|
+
* // 같은 external_id 로 다시 호출하면 기존 문서를 교체한다 (문서 id 유지).
|
|
8013
|
+
* await cb.knowledge.addDocument('kb-id', {
|
|
8014
|
+
* name: '블로그: 제목',
|
|
8015
|
+
* source_type: 'text',
|
|
8016
|
+
* content: '...',
|
|
8017
|
+
* external_id: 'blog/my-post-slug',
|
|
8018
|
+
* })
|
|
8010
8019
|
* ```
|
|
8011
8020
|
*/
|
|
8012
8021
|
async addDocument(kbID, data) {
|
|
@@ -8015,6 +8024,58 @@ var KnowledgeAPI = class {
|
|
|
8015
8024
|
data
|
|
8016
8025
|
);
|
|
8017
8026
|
}
|
|
8027
|
+
/**
|
|
8028
|
+
* 문서 수정 (update/upsert)
|
|
8029
|
+
*
|
|
8030
|
+
* 기존 문서의 내용·이름·메타데이터를 교체합니다. **문서 id 는 그대로 유지**되므로
|
|
8031
|
+
* 검색 결과의 `document_id` 를 외부에서 참조(인용·캐시)해도 편집 후 깨지지 않습니다.
|
|
8032
|
+
* 보낸 필드만 교체되며, 내용/이름/메타데이터가 실제로 바뀌면 자동으로 재청킹·재색인됩니다.
|
|
8033
|
+
*
|
|
8034
|
+
* @param kbID - 지식 베이스 ID
|
|
8035
|
+
* @param docID - 문서 ID
|
|
8036
|
+
* @param data - 변경할 필드 (생략한 필드는 변경 없음)
|
|
8037
|
+
* @returns 수정된 문서 정보
|
|
8038
|
+
*
|
|
8039
|
+
* @example
|
|
8040
|
+
* ```typescript
|
|
8041
|
+
* // 내용만 교체 — document_id 는 그대로
|
|
8042
|
+
* const doc = await cb.knowledge.updateDocument('kb-id', 'doc-id', {
|
|
8043
|
+
* content: '갱신된 환불 정책...',
|
|
8044
|
+
* })
|
|
8045
|
+
*
|
|
8046
|
+
* // 이름 + 메타데이터 교체
|
|
8047
|
+
* await cb.knowledge.updateDocument('kb-id', 'doc-id', {
|
|
8048
|
+
* name: 'FAQ (2026)',
|
|
8049
|
+
* metadata: { tag: 'faq', updated: '2026-05' },
|
|
8050
|
+
* })
|
|
8051
|
+
* ```
|
|
8052
|
+
*/
|
|
8053
|
+
async updateDocument(kbID, docID, data) {
|
|
8054
|
+
return this.http.put(
|
|
8055
|
+
`/v1/public/knowledge-bases/${kbID}/documents/${docID}`,
|
|
8056
|
+
data
|
|
8057
|
+
);
|
|
8058
|
+
}
|
|
8059
|
+
/**
|
|
8060
|
+
* 파일로 문서 수정 (PDF / DOCX / text 파일 재업로드).
|
|
8061
|
+
*
|
|
8062
|
+
* [`addDocumentFromFile`](#addDocumentFromFile) 의 update 버전. 문서 id 는 유지됩니다.
|
|
8063
|
+
*
|
|
8064
|
+
* @param kbID - Knowledge Base ID
|
|
8065
|
+
* @param docID - 문서 ID
|
|
8066
|
+
* @param file - 새 파일. `File` (DOM) / `Blob` / `{ data, mimeType, name }` (Node) 모두 가능
|
|
8067
|
+
* @param options - name / metadata 오버라이드
|
|
8068
|
+
* @returns 수정된 문서 정보
|
|
8069
|
+
*/
|
|
8070
|
+
async updateDocumentFromFile(kbID, docID, file, options) {
|
|
8071
|
+
const { data, mimeType } = await readFileInput(file);
|
|
8072
|
+
return this.updateDocument(kbID, docID, {
|
|
8073
|
+
name: options?.name,
|
|
8074
|
+
file_content: data,
|
|
8075
|
+
mime_type: mimeType,
|
|
8076
|
+
metadata: options?.metadata
|
|
8077
|
+
});
|
|
8078
|
+
}
|
|
8018
8079
|
/**
|
|
8019
8080
|
* 파일을 KB 에 추가 (PDF / DOCX / text 파일).
|
|
8020
8081
|
*
|
|
@@ -8066,36 +8127,6 @@ var KnowledgeAPI = class {
|
|
|
8066
8127
|
metadata: options?.metadata
|
|
8067
8128
|
});
|
|
8068
8129
|
}
|
|
8069
|
-
/**
|
|
8070
|
-
* 문서 수정 (재색인)
|
|
8071
|
-
*
|
|
8072
|
-
* `content` / `file_content` / `metadata` 중 하나라도 포함하면 전체 재색인이 일어나며
|
|
8073
|
-
* 색인 토큰이 다시 과금됩니다. `name` 만 보내면 재색인 없이 라벨만 변경됩니다.
|
|
8074
|
-
* 재색인 시 서버는 status='pending' 으로 즉시 응답하고 색인은 백그라운드로 진행됩니다
|
|
8075
|
-
* (addDocument 와 동일) — get/listDocuments 로 'ready' 전환을 확인하세요.
|
|
8076
|
-
*
|
|
8077
|
-
* @param kbID - 지식 베이스 ID
|
|
8078
|
-
* @param docID - 문서 ID
|
|
8079
|
-
* @param data - 수정 요청 (모든 필드 옵셔널)
|
|
8080
|
-
* @returns 수정된 문서 정보
|
|
8081
|
-
*
|
|
8082
|
-
* @example
|
|
8083
|
-
* ```typescript
|
|
8084
|
-
* // 내용 갱신 (전체 재색인 발생)
|
|
8085
|
-
* await cb.knowledge.updateDocument('kb-id', 'doc-id', {
|
|
8086
|
-
* content: '환불은 구매 후 14일 이내에 가능합니다...'
|
|
8087
|
-
* })
|
|
8088
|
-
*
|
|
8089
|
-
* // 이름만 변경 (재색인 없음)
|
|
8090
|
-
* await cb.knowledge.updateDocument('kb-id', 'doc-id', { name: '환불 정책 v2' })
|
|
8091
|
-
* ```
|
|
8092
|
-
*/
|
|
8093
|
-
async updateDocument(kbID, docID, data) {
|
|
8094
|
-
return this.http.put(
|
|
8095
|
-
`/v1/public/knowledge-bases/${kbID}/documents/${docID}`,
|
|
8096
|
-
data
|
|
8097
|
-
);
|
|
8098
|
-
}
|
|
8099
8130
|
/**
|
|
8100
8131
|
* 문서 목록 조회
|
|
8101
8132
|
*
|
|
@@ -8189,6 +8220,7 @@ var AIAPI = class {
|
|
|
8189
8220
|
* knowledgeBaseId: 'kb-id',
|
|
8190
8221
|
* }, {
|
|
8191
8222
|
* onSources: (sources) => console.log('참조:', sources),
|
|
8223
|
+
* onReasoning: (reasoning) => process.stdout.write(reasoning),
|
|
8192
8224
|
* onToken: (content) => process.stdout.write(content),
|
|
8193
8225
|
* onDone: () => console.log('\\n완료'),
|
|
8194
8226
|
* onError: (error) => console.error('에러:', error)
|
|
@@ -8250,6 +8282,7 @@ var AIAPI = class {
|
|
|
8250
8282
|
if (event.type === "heartbeat" || event.type === "searching") {
|
|
8251
8283
|
continue;
|
|
8252
8284
|
}
|
|
8285
|
+
if (event.reasoning) callbacks.onReasoning?.(event.reasoning);
|
|
8253
8286
|
if (event.content) callbacks.onToken?.(event.content);
|
|
8254
8287
|
if (event.done) {
|
|
8255
8288
|
callbacks.onDone?.();
|