connectbase-client 0.10.3 → 0.10.4
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/dist/cli.js +158 -38
- package/dist/connect-base.umd.js +3 -3
- package/dist/index.d.mts +105 -66
- package/dist/index.d.ts +105 -66
- package/dist/index.js +31 -47
- package/dist/index.mjs +30 -47
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -7106,56 +7106,40 @@ var KnowledgeAPI = class {
|
|
|
7106
7106
|
`/v1/public/knowledge-bases/${kbID}/search?${params.toString()}`
|
|
7107
7107
|
);
|
|
7108
7108
|
}
|
|
7109
|
-
//
|
|
7109
|
+
// AI 데이터베이스 채팅은 AI 스트리밍 API로 통합됨
|
|
7110
|
+
// cb.ai.chat({ messages, knowledgeBaseId }) 또는 cb.ai.chatStream() 사용
|
|
7111
|
+
};
|
|
7112
|
+
|
|
7113
|
+
// src/api/ai.ts
|
|
7114
|
+
var AIAPI = class {
|
|
7115
|
+
constructor(http) {
|
|
7116
|
+
this.http = http;
|
|
7117
|
+
}
|
|
7110
7118
|
/**
|
|
7111
|
-
*
|
|
7112
|
-
*
|
|
7113
|
-
* 지식 베이스의 문서를 검색하고 AI가 답변을 생성합니다.
|
|
7114
|
-
*
|
|
7115
|
-
* @param kbID - 지식 베이스 ID
|
|
7116
|
-
* @param request - 챗 요청
|
|
7117
|
-
* @returns AI 답변 + 참조 소스
|
|
7118
|
-
*
|
|
7119
|
-
* @example
|
|
7120
|
-
* ```typescript
|
|
7121
|
-
* const response = await cb.knowledge.chat('kb-id', {
|
|
7122
|
-
* message: '환불 정책이 어떻게 되나요?',
|
|
7123
|
-
* top_k: 5
|
|
7124
|
-
* })
|
|
7125
|
-
* console.log(response.answer)
|
|
7126
|
-
* console.log('참조:', response.sources)
|
|
7127
|
-
* ```
|
|
7119
|
+
* AI 채팅 (동기)
|
|
7128
7120
|
*/
|
|
7129
|
-
async chat(
|
|
7130
|
-
return this.http.post(
|
|
7131
|
-
`/v1/public/knowledge-bases/${kbID}/chat`,
|
|
7132
|
-
request
|
|
7133
|
-
);
|
|
7121
|
+
async chat(request) {
|
|
7122
|
+
return this.http.post("/v1/public/ai/chat", request);
|
|
7134
7123
|
}
|
|
7135
7124
|
/**
|
|
7136
|
-
*
|
|
7137
|
-
*
|
|
7138
|
-
* AI 답변을 실시간으로 토큰 단위로 수신합니다.
|
|
7139
|
-
*
|
|
7140
|
-
* @param kbID - 지식 베이스 ID
|
|
7141
|
-
* @param request - 챗 요청
|
|
7142
|
-
* @param callbacks - 스트리밍 콜백
|
|
7125
|
+
* AI 채팅 스트리밍 (SSE)
|
|
7143
7126
|
*
|
|
7144
7127
|
* @example
|
|
7145
7128
|
* ```typescript
|
|
7146
|
-
* await cb.
|
|
7147
|
-
*
|
|
7129
|
+
* await cb.ai.chatStream({
|
|
7130
|
+
* messages: [{ role: 'user', content: '안녕하세요' }],
|
|
7131
|
+
* knowledgeBaseId: 'kb-id',
|
|
7148
7132
|
* }, {
|
|
7149
|
-
* onSources: (sources
|
|
7133
|
+
* onSources: (sources) => console.log('참조:', sources),
|
|
7150
7134
|
* onToken: (content) => process.stdout.write(content),
|
|
7151
|
-
* onDone: (
|
|
7135
|
+
* onDone: () => console.log('\\n완료'),
|
|
7152
7136
|
* onError: (error) => console.error('에러:', error)
|
|
7153
7137
|
* })
|
|
7154
7138
|
* ```
|
|
7155
7139
|
*/
|
|
7156
|
-
async chatStream(
|
|
7140
|
+
async chatStream(request, callbacks) {
|
|
7157
7141
|
const response = await this.http.fetchRaw(
|
|
7158
|
-
|
|
7142
|
+
"/v1/public/ai/chat/stream",
|
|
7159
7143
|
{
|
|
7160
7144
|
method: "POST",
|
|
7161
7145
|
headers: { "Content-Type": "application/json" },
|
|
@@ -7189,17 +7173,14 @@ var KnowledgeAPI = class {
|
|
|
7189
7173
|
}
|
|
7190
7174
|
try {
|
|
7191
7175
|
const event = JSON.parse(data);
|
|
7192
|
-
|
|
7193
|
-
|
|
7194
|
-
|
|
7195
|
-
|
|
7196
|
-
|
|
7197
|
-
|
|
7198
|
-
|
|
7199
|
-
|
|
7200
|
-
case "error":
|
|
7201
|
-
callbacks.onError?.(event.error || "Unknown error");
|
|
7202
|
-
return;
|
|
7176
|
+
if (event.type === "sources" && event.sources) {
|
|
7177
|
+
callbacks.onSources?.(event.sources);
|
|
7178
|
+
continue;
|
|
7179
|
+
}
|
|
7180
|
+
if (event.content) callbacks.onToken?.(event.content);
|
|
7181
|
+
if (event.done) {
|
|
7182
|
+
callbacks.onDone?.();
|
|
7183
|
+
return;
|
|
7203
7184
|
}
|
|
7204
7185
|
} catch {
|
|
7205
7186
|
}
|
|
@@ -7938,6 +7919,7 @@ var ConnectBase = class {
|
|
|
7938
7919
|
this.ads = new AdsAPI(this.http);
|
|
7939
7920
|
this.native = new NativeAPI();
|
|
7940
7921
|
this.knowledge = new KnowledgeAPI(this.http);
|
|
7922
|
+
this.ai = new AIAPI(this.http);
|
|
7941
7923
|
this.queue = new QueueAPI(this.http);
|
|
7942
7924
|
}
|
|
7943
7925
|
/**
|
|
@@ -7961,6 +7943,7 @@ var ConnectBase = class {
|
|
|
7961
7943
|
};
|
|
7962
7944
|
var index_default = ConnectBase;
|
|
7963
7945
|
export {
|
|
7946
|
+
AIAPI,
|
|
7964
7947
|
AdsAPI,
|
|
7965
7948
|
ApiError,
|
|
7966
7949
|
AuthError,
|