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.d.mts
CHANGED
|
@@ -5457,42 +5457,11 @@ interface KnowledgeSearchResponse {
|
|
|
5457
5457
|
results: KnowledgeSearchResult[];
|
|
5458
5458
|
total: number;
|
|
5459
5459
|
}
|
|
5460
|
-
interface KnowledgeChatMessage {
|
|
5461
|
-
role: 'user' | 'assistant';
|
|
5462
|
-
content: string;
|
|
5463
|
-
}
|
|
5464
|
-
interface ChatRequest {
|
|
5465
|
-
message: string;
|
|
5466
|
-
messages?: KnowledgeChatMessage[];
|
|
5467
|
-
top_k?: number;
|
|
5468
|
-
provider?: string;
|
|
5469
|
-
model?: string;
|
|
5470
|
-
}
|
|
5471
|
-
interface ChatResponse {
|
|
5472
|
-
answer: string;
|
|
5473
|
-
sources: KnowledgeSearchResult[];
|
|
5474
|
-
model: string;
|
|
5475
|
-
provider: string;
|
|
5476
|
-
token_used?: number;
|
|
5477
|
-
}
|
|
5478
|
-
interface ChatStreamEvent {
|
|
5479
|
-
type: 'sources' | 'token' | 'error';
|
|
5480
|
-
sources?: KnowledgeSearchResult[];
|
|
5481
|
-
model?: string;
|
|
5482
|
-
content?: string;
|
|
5483
|
-
done?: boolean;
|
|
5484
|
-
usage?: {
|
|
5485
|
-
prompt_tokens: number;
|
|
5486
|
-
completion_tokens: number;
|
|
5487
|
-
total_tokens: number;
|
|
5488
|
-
};
|
|
5489
|
-
error?: string;
|
|
5490
|
-
}
|
|
5491
5460
|
|
|
5492
5461
|
/**
|
|
5493
5462
|
* Knowledge Base API
|
|
5494
5463
|
*
|
|
5495
|
-
*
|
|
5464
|
+
* AI 데이터베이스를 위한 문서 저장 및 검색 API.
|
|
5496
5465
|
* 문서를 업로드하면 자동으로 청킹되어 키워드 기반 검색이 가능합니다.
|
|
5497
5466
|
*
|
|
5498
5467
|
* @example
|
|
@@ -5593,51 +5562,116 @@ declare class KnowledgeAPI {
|
|
|
5593
5562
|
* @param topK - 반환할 결과 수 (기본값: 지식 베이스 설정)
|
|
5594
5563
|
*/
|
|
5595
5564
|
searchGet(kbID: string, query: string, topK?: number): Promise<KnowledgeSearchResponse>;
|
|
5565
|
+
}
|
|
5566
|
+
|
|
5567
|
+
interface AIMessage {
|
|
5568
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
5569
|
+
content: string;
|
|
5570
|
+
toolCalls?: AIToolCall[];
|
|
5571
|
+
toolCallId?: string;
|
|
5572
|
+
}
|
|
5573
|
+
interface AIToolCall {
|
|
5574
|
+
id: string;
|
|
5575
|
+
name: string;
|
|
5576
|
+
arguments: Record<string, unknown>;
|
|
5577
|
+
}
|
|
5578
|
+
interface AITool {
|
|
5579
|
+
name: string;
|
|
5580
|
+
description: string;
|
|
5581
|
+
inputSchema: Record<string, unknown>;
|
|
5582
|
+
}
|
|
5583
|
+
interface AIChatRequest {
|
|
5584
|
+
messages: AIMessage[];
|
|
5585
|
+
maxTokens?: number;
|
|
5586
|
+
temperature?: number;
|
|
5587
|
+
topP?: number;
|
|
5588
|
+
provider?: string;
|
|
5589
|
+
model?: string;
|
|
5590
|
+
tools?: AITool[];
|
|
5591
|
+
appId?: string;
|
|
5592
|
+
knowledgeBaseId?: string;
|
|
5593
|
+
topK?: number;
|
|
5594
|
+
}
|
|
5595
|
+
interface AISource {
|
|
5596
|
+
chunkId: string;
|
|
5597
|
+
documentId: string;
|
|
5598
|
+
documentName: string;
|
|
5599
|
+
content: string;
|
|
5600
|
+
score: number;
|
|
5601
|
+
}
|
|
5602
|
+
interface AIChatResponse {
|
|
5603
|
+
content: string;
|
|
5604
|
+
finishReason?: string;
|
|
5605
|
+
usage?: {
|
|
5606
|
+
promptTokens: number;
|
|
5607
|
+
completionTokens: number;
|
|
5608
|
+
totalTokens: number;
|
|
5609
|
+
};
|
|
5610
|
+
provider: string;
|
|
5611
|
+
model: string;
|
|
5612
|
+
toolCalls?: AIToolCall[];
|
|
5613
|
+
sources?: AISource[];
|
|
5614
|
+
}
|
|
5615
|
+
interface AIStreamChunk {
|
|
5616
|
+
type?: 'sources' | 'token';
|
|
5617
|
+
content: string;
|
|
5618
|
+
finishReason?: string;
|
|
5619
|
+
done: boolean;
|
|
5620
|
+
toolCalls?: AIToolCall[];
|
|
5621
|
+
sources?: AISource[];
|
|
5622
|
+
}
|
|
5623
|
+
|
|
5624
|
+
/**
|
|
5625
|
+
* AI API
|
|
5626
|
+
*
|
|
5627
|
+
* AI 채팅 및 AI 데이터베이스 연동 API.
|
|
5628
|
+
* AI 데이터베이스 ID를 지정하면 문서 검색 후 컨텍스트를 포함하여 응답합니다.
|
|
5629
|
+
*
|
|
5630
|
+
* @example
|
|
5631
|
+
* ```typescript
|
|
5632
|
+
* const cb = new ConnectBase({ apiKey: 'your-api-key' })
|
|
5633
|
+
*
|
|
5634
|
+
* // 일반 AI 채팅
|
|
5635
|
+
* const response = await cb.ai.chat({
|
|
5636
|
+
* messages: [{ role: 'user', content: '안녕하세요' }],
|
|
5637
|
+
* provider: 'gemini'
|
|
5638
|
+
* })
|
|
5639
|
+
*
|
|
5640
|
+
* // AI 데이터베이스 연동 채팅
|
|
5641
|
+
* const ragResponse = await cb.ai.chat({
|
|
5642
|
+
* messages: [{ role: 'user', content: '환불 정책이 어떻게 되나요?' }],
|
|
5643
|
+
* knowledgeBaseId: 'kb-id',
|
|
5644
|
+
* topK: 5
|
|
5645
|
+
* })
|
|
5646
|
+
* ```
|
|
5647
|
+
*/
|
|
5648
|
+
declare class AIAPI {
|
|
5649
|
+
private http;
|
|
5650
|
+
constructor(http: HttpClient);
|
|
5596
5651
|
/**
|
|
5597
|
-
*
|
|
5598
|
-
*
|
|
5599
|
-
* 지식 베이스의 문서를 검색하고 AI가 답변을 생성합니다.
|
|
5600
|
-
*
|
|
5601
|
-
* @param kbID - 지식 베이스 ID
|
|
5602
|
-
* @param request - 챗 요청
|
|
5603
|
-
* @returns AI 답변 + 참조 소스
|
|
5604
|
-
*
|
|
5605
|
-
* @example
|
|
5606
|
-
* ```typescript
|
|
5607
|
-
* const response = await cb.knowledge.chat('kb-id', {
|
|
5608
|
-
* message: '환불 정책이 어떻게 되나요?',
|
|
5609
|
-
* top_k: 5
|
|
5610
|
-
* })
|
|
5611
|
-
* console.log(response.answer)
|
|
5612
|
-
* console.log('참조:', response.sources)
|
|
5613
|
-
* ```
|
|
5652
|
+
* AI 채팅 (동기)
|
|
5614
5653
|
*/
|
|
5615
|
-
chat(
|
|
5654
|
+
chat(request: AIChatRequest): Promise<AIChatResponse>;
|
|
5616
5655
|
/**
|
|
5617
|
-
*
|
|
5618
|
-
*
|
|
5619
|
-
* AI 답변을 실시간으로 토큰 단위로 수신합니다.
|
|
5620
|
-
*
|
|
5621
|
-
* @param kbID - 지식 베이스 ID
|
|
5622
|
-
* @param request - 챗 요청
|
|
5623
|
-
* @param callbacks - 스트리밍 콜백
|
|
5656
|
+
* AI 채팅 스트리밍 (SSE)
|
|
5624
5657
|
*
|
|
5625
5658
|
* @example
|
|
5626
5659
|
* ```typescript
|
|
5627
|
-
* await cb.
|
|
5628
|
-
*
|
|
5660
|
+
* await cb.ai.chatStream({
|
|
5661
|
+
* messages: [{ role: 'user', content: '안녕하세요' }],
|
|
5662
|
+
* knowledgeBaseId: 'kb-id',
|
|
5629
5663
|
* }, {
|
|
5630
|
-
* onSources: (sources
|
|
5664
|
+
* onSources: (sources) => console.log('참조:', sources),
|
|
5631
5665
|
* onToken: (content) => process.stdout.write(content),
|
|
5632
|
-
* onDone: (
|
|
5666
|
+
* onDone: () => console.log('\\n완료'),
|
|
5633
5667
|
* onError: (error) => console.error('에러:', error)
|
|
5634
5668
|
* })
|
|
5635
5669
|
* ```
|
|
5636
5670
|
*/
|
|
5637
|
-
chatStream(
|
|
5638
|
-
onSources?: (sources:
|
|
5671
|
+
chatStream(request: AIChatRequest, callbacks: {
|
|
5672
|
+
onSources?: (sources: AISource[]) => void;
|
|
5639
5673
|
onToken?: (content: string) => void;
|
|
5640
|
-
onDone?: (
|
|
5674
|
+
onDone?: () => void;
|
|
5641
5675
|
onError?: (error: string) => void;
|
|
5642
5676
|
}): Promise<void>;
|
|
5643
5677
|
}
|
|
@@ -6058,10 +6092,15 @@ declare class ConnectBase {
|
|
|
6058
6092
|
*/
|
|
6059
6093
|
readonly native: NativeAPI;
|
|
6060
6094
|
/**
|
|
6061
|
-
*
|
|
6095
|
+
* AI 데이터베이스 API (문서 검색)
|
|
6062
6096
|
* 문서를 업로드하고 키워드 기반으로 검색하여 AI 챗봇을 구축할 수 있습니다.
|
|
6063
6097
|
*/
|
|
6064
6098
|
readonly knowledge: KnowledgeAPI;
|
|
6099
|
+
/**
|
|
6100
|
+
* AI API (채팅 + AI 데이터베이스 연동)
|
|
6101
|
+
* AI 채팅, AI 데이터베이스 문서 참조 응답, 스트리밍 지원.
|
|
6102
|
+
*/
|
|
6103
|
+
readonly ai: AIAPI;
|
|
6065
6104
|
/**
|
|
6066
6105
|
* Queue API (메시지 큐)
|
|
6067
6106
|
* NATS JetStream 기반 고신뢰 메시지 큐. 발행, 소비, Ack, Nack 지원.
|
|
@@ -6082,4 +6121,4 @@ declare class ConnectBase {
|
|
|
6082
6121
|
updateConfig(config: Partial<ConnectBaseConfig>): void;
|
|
6083
6122
|
}
|
|
6084
6123
|
|
|
6085
|
-
export { type AckMessagesRequest, type AdReportResponse, type AdReportSummary, AdsAPI, type AggregateResult, type AggregateStage, ApiError, type ApiKeyItem, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchSetPageMetaRequest, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type
|
|
6124
|
+
export { AIAPI, type AIChatRequest, type AIChatResponse, type AIMessage, type AISource, type AIStreamChunk, type AITool, type AIToolCall, type AckMessagesRequest, type AdReportResponse, type AdReportSummary, AdsAPI, type AggregateResult, type AggregateStage, ApiError, type ApiKeyItem, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchSetPageMetaRequest, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type CompleteUploadRequest, type CompleteUploadResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type ConsumeMessagesResponse, type ConsumeOptions, type CopyTableRequest, type CopyTableResponse, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateBackupRequest, type CreateChannelRequest, type CreateColumnRequest, type CreateDataRequest, type CreateDocumentRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateGeoIndexRequest, type CreateIndexRequest, type CreateLobbyRequest, type CreatePlaylistRequest, type CreateRelationRequest, type CreateSearchIndexRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type CreateVideoStorageRequest, type DailyReport, type DataItem, type DataType, type DatabaseChange, type DatabaseChangeMessage, type DatabaseChangeType, type DatabasePresenceState, type DatabaseRealtimeConnectOptions, type DatabaseRealtimeFilter, type DatabaseRealtimeHandlers, type DatabaseRealtimeSubscription, type DatabaseSnapshot, type DatabaseSnapshotMessage, type DatabaseSubscribeOptions, type DeleteWhereResponse, type DeviceInfo, type DocumentResponse, type EnabledProviderInfo, type EnabledProvidersResponse, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type ExportDataRequest, type ExportDataResponse, type FetchApiKeysResponse, type FetchDataResponse, type FetchFilesResponse, type FileItem, type FileStats, GameAPI, type GameAction, type GameClientConfig, type GameConnectionState, type GameConnectionStatus, type GameDelta, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GenerateUploadURLByPathRequest, type GenerateUploadURLRequest, type GenerateUploadURLResponse, type GeoIndex, type GeoNear, type GeoPoint, type GeoPolygon, type GeoQuery, type GeoResponse, type GeoResult, type GeoWithin, type GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, type HistoryResponse, type ICEServer, type ICEServersResponse, type ImageResult, type ImportDataRequest, type ImportDataResponse, type IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinQueueRequest, type JoinRoomRequest, type JoinRoomResponse, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type KnowledgeSearchResult, type LeaderboardEntry, type LifecyclePolicy, type ListBillingKeysResponse, type ListDocumentsResponse, type ListPageMetasOptions, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type LobbyInfo, type LobbyInvite, type LobbyMember, type LobbyVisibility, type MatchResult, type MatchmakingTicket, type MemberInfoResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MemoryInfo, type MessageHandler, type MigrateDataRequest, type MigrateDataResponse, type MoveFileRequest, type NackMessageRequest, NativeAPI, type OAuthCallbackResponse, type OAuthProvider, type OpenDialogOptions, type OpenDialogResult, type PageMetaResponse, type PartyInfo, type PartyInvite, type PartyMember, type PauseSubscriptionRequest, type PaymentDetail, type PaymentProvider, type PaymentStatus, type PeerInfo, type Platform, type PlayerEvent, type PlayerStats, type Playlist, type PlaylistItem, type PongMessage, type PopulateOption, type Position, type PreparePaymentRequest, type PreparePaymentResponse, type PresenceChangeHandler, type PresenceInfo, type PresenceSetOptions, type PresenceStatus, type PresenceStatusResult, type PublishBatchRequest, type PublishBatchResponse, type PublishMessageRequest, type PublishMessageResponse, type PushPlatform, type QualityProgress, type QueryOptions, type QueueInfoResponse, type QueueMessage, type ReadReceiptHandler, type ReadReceiptInfo, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type ReplayHighlight, type ReplayInfo, type ReplayPlayerInfo, type RestoreBackupRequest, type RestoreBackupResponse, type RetentionPolicy, type RoomInfo, type RoomStats, type RoomsResponse, type SaveDialogOptions, type SaveDialogResult, type SearchIndex, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type SpectatorInfo, type SpectatorPlayerState, type SpectatorState, type StateChange, type StateChangeHandler, type StorageUploadOptions, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamMessage, type StreamOptions, type StreamSession, type StreamTokenCallback, type StreamToolCallCallback, type StreamToolResultCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type SystemInfo, type TTLConfig, type TableIndex, type TableRelation, type TableSchema, type TransactionRead, type TransactionWrite, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type TypingChangeHandler, type TypingInfo, type UpdateApiKeyRequest, type UpdateApiKeyResponse, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateCustomDataRequest, type UpdateCustomDataResponse, type UpdateDataRequest, type UpdateLobbyRequest, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UpdateVideoStorageRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoStorage, type VideoStorageListResponse, type VideoVisibility, type VoiceChannel, type VoiceMember, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, isWebTransportSupported };
|
package/dist/index.d.ts
CHANGED
|
@@ -5457,42 +5457,11 @@ interface KnowledgeSearchResponse {
|
|
|
5457
5457
|
results: KnowledgeSearchResult[];
|
|
5458
5458
|
total: number;
|
|
5459
5459
|
}
|
|
5460
|
-
interface KnowledgeChatMessage {
|
|
5461
|
-
role: 'user' | 'assistant';
|
|
5462
|
-
content: string;
|
|
5463
|
-
}
|
|
5464
|
-
interface ChatRequest {
|
|
5465
|
-
message: string;
|
|
5466
|
-
messages?: KnowledgeChatMessage[];
|
|
5467
|
-
top_k?: number;
|
|
5468
|
-
provider?: string;
|
|
5469
|
-
model?: string;
|
|
5470
|
-
}
|
|
5471
|
-
interface ChatResponse {
|
|
5472
|
-
answer: string;
|
|
5473
|
-
sources: KnowledgeSearchResult[];
|
|
5474
|
-
model: string;
|
|
5475
|
-
provider: string;
|
|
5476
|
-
token_used?: number;
|
|
5477
|
-
}
|
|
5478
|
-
interface ChatStreamEvent {
|
|
5479
|
-
type: 'sources' | 'token' | 'error';
|
|
5480
|
-
sources?: KnowledgeSearchResult[];
|
|
5481
|
-
model?: string;
|
|
5482
|
-
content?: string;
|
|
5483
|
-
done?: boolean;
|
|
5484
|
-
usage?: {
|
|
5485
|
-
prompt_tokens: number;
|
|
5486
|
-
completion_tokens: number;
|
|
5487
|
-
total_tokens: number;
|
|
5488
|
-
};
|
|
5489
|
-
error?: string;
|
|
5490
|
-
}
|
|
5491
5460
|
|
|
5492
5461
|
/**
|
|
5493
5462
|
* Knowledge Base API
|
|
5494
5463
|
*
|
|
5495
|
-
*
|
|
5464
|
+
* AI 데이터베이스를 위한 문서 저장 및 검색 API.
|
|
5496
5465
|
* 문서를 업로드하면 자동으로 청킹되어 키워드 기반 검색이 가능합니다.
|
|
5497
5466
|
*
|
|
5498
5467
|
* @example
|
|
@@ -5593,51 +5562,116 @@ declare class KnowledgeAPI {
|
|
|
5593
5562
|
* @param topK - 반환할 결과 수 (기본값: 지식 베이스 설정)
|
|
5594
5563
|
*/
|
|
5595
5564
|
searchGet(kbID: string, query: string, topK?: number): Promise<KnowledgeSearchResponse>;
|
|
5565
|
+
}
|
|
5566
|
+
|
|
5567
|
+
interface AIMessage {
|
|
5568
|
+
role: 'system' | 'user' | 'assistant' | 'tool';
|
|
5569
|
+
content: string;
|
|
5570
|
+
toolCalls?: AIToolCall[];
|
|
5571
|
+
toolCallId?: string;
|
|
5572
|
+
}
|
|
5573
|
+
interface AIToolCall {
|
|
5574
|
+
id: string;
|
|
5575
|
+
name: string;
|
|
5576
|
+
arguments: Record<string, unknown>;
|
|
5577
|
+
}
|
|
5578
|
+
interface AITool {
|
|
5579
|
+
name: string;
|
|
5580
|
+
description: string;
|
|
5581
|
+
inputSchema: Record<string, unknown>;
|
|
5582
|
+
}
|
|
5583
|
+
interface AIChatRequest {
|
|
5584
|
+
messages: AIMessage[];
|
|
5585
|
+
maxTokens?: number;
|
|
5586
|
+
temperature?: number;
|
|
5587
|
+
topP?: number;
|
|
5588
|
+
provider?: string;
|
|
5589
|
+
model?: string;
|
|
5590
|
+
tools?: AITool[];
|
|
5591
|
+
appId?: string;
|
|
5592
|
+
knowledgeBaseId?: string;
|
|
5593
|
+
topK?: number;
|
|
5594
|
+
}
|
|
5595
|
+
interface AISource {
|
|
5596
|
+
chunkId: string;
|
|
5597
|
+
documentId: string;
|
|
5598
|
+
documentName: string;
|
|
5599
|
+
content: string;
|
|
5600
|
+
score: number;
|
|
5601
|
+
}
|
|
5602
|
+
interface AIChatResponse {
|
|
5603
|
+
content: string;
|
|
5604
|
+
finishReason?: string;
|
|
5605
|
+
usage?: {
|
|
5606
|
+
promptTokens: number;
|
|
5607
|
+
completionTokens: number;
|
|
5608
|
+
totalTokens: number;
|
|
5609
|
+
};
|
|
5610
|
+
provider: string;
|
|
5611
|
+
model: string;
|
|
5612
|
+
toolCalls?: AIToolCall[];
|
|
5613
|
+
sources?: AISource[];
|
|
5614
|
+
}
|
|
5615
|
+
interface AIStreamChunk {
|
|
5616
|
+
type?: 'sources' | 'token';
|
|
5617
|
+
content: string;
|
|
5618
|
+
finishReason?: string;
|
|
5619
|
+
done: boolean;
|
|
5620
|
+
toolCalls?: AIToolCall[];
|
|
5621
|
+
sources?: AISource[];
|
|
5622
|
+
}
|
|
5623
|
+
|
|
5624
|
+
/**
|
|
5625
|
+
* AI API
|
|
5626
|
+
*
|
|
5627
|
+
* AI 채팅 및 AI 데이터베이스 연동 API.
|
|
5628
|
+
* AI 데이터베이스 ID를 지정하면 문서 검색 후 컨텍스트를 포함하여 응답합니다.
|
|
5629
|
+
*
|
|
5630
|
+
* @example
|
|
5631
|
+
* ```typescript
|
|
5632
|
+
* const cb = new ConnectBase({ apiKey: 'your-api-key' })
|
|
5633
|
+
*
|
|
5634
|
+
* // 일반 AI 채팅
|
|
5635
|
+
* const response = await cb.ai.chat({
|
|
5636
|
+
* messages: [{ role: 'user', content: '안녕하세요' }],
|
|
5637
|
+
* provider: 'gemini'
|
|
5638
|
+
* })
|
|
5639
|
+
*
|
|
5640
|
+
* // AI 데이터베이스 연동 채팅
|
|
5641
|
+
* const ragResponse = await cb.ai.chat({
|
|
5642
|
+
* messages: [{ role: 'user', content: '환불 정책이 어떻게 되나요?' }],
|
|
5643
|
+
* knowledgeBaseId: 'kb-id',
|
|
5644
|
+
* topK: 5
|
|
5645
|
+
* })
|
|
5646
|
+
* ```
|
|
5647
|
+
*/
|
|
5648
|
+
declare class AIAPI {
|
|
5649
|
+
private http;
|
|
5650
|
+
constructor(http: HttpClient);
|
|
5596
5651
|
/**
|
|
5597
|
-
*
|
|
5598
|
-
*
|
|
5599
|
-
* 지식 베이스의 문서를 검색하고 AI가 답변을 생성합니다.
|
|
5600
|
-
*
|
|
5601
|
-
* @param kbID - 지식 베이스 ID
|
|
5602
|
-
* @param request - 챗 요청
|
|
5603
|
-
* @returns AI 답변 + 참조 소스
|
|
5604
|
-
*
|
|
5605
|
-
* @example
|
|
5606
|
-
* ```typescript
|
|
5607
|
-
* const response = await cb.knowledge.chat('kb-id', {
|
|
5608
|
-
* message: '환불 정책이 어떻게 되나요?',
|
|
5609
|
-
* top_k: 5
|
|
5610
|
-
* })
|
|
5611
|
-
* console.log(response.answer)
|
|
5612
|
-
* console.log('참조:', response.sources)
|
|
5613
|
-
* ```
|
|
5652
|
+
* AI 채팅 (동기)
|
|
5614
5653
|
*/
|
|
5615
|
-
chat(
|
|
5654
|
+
chat(request: AIChatRequest): Promise<AIChatResponse>;
|
|
5616
5655
|
/**
|
|
5617
|
-
*
|
|
5618
|
-
*
|
|
5619
|
-
* AI 답변을 실시간으로 토큰 단위로 수신합니다.
|
|
5620
|
-
*
|
|
5621
|
-
* @param kbID - 지식 베이스 ID
|
|
5622
|
-
* @param request - 챗 요청
|
|
5623
|
-
* @param callbacks - 스트리밍 콜백
|
|
5656
|
+
* AI 채팅 스트리밍 (SSE)
|
|
5624
5657
|
*
|
|
5625
5658
|
* @example
|
|
5626
5659
|
* ```typescript
|
|
5627
|
-
* await cb.
|
|
5628
|
-
*
|
|
5660
|
+
* await cb.ai.chatStream({
|
|
5661
|
+
* messages: [{ role: 'user', content: '안녕하세요' }],
|
|
5662
|
+
* knowledgeBaseId: 'kb-id',
|
|
5629
5663
|
* }, {
|
|
5630
|
-
* onSources: (sources
|
|
5664
|
+
* onSources: (sources) => console.log('참조:', sources),
|
|
5631
5665
|
* onToken: (content) => process.stdout.write(content),
|
|
5632
|
-
* onDone: (
|
|
5666
|
+
* onDone: () => console.log('\\n완료'),
|
|
5633
5667
|
* onError: (error) => console.error('에러:', error)
|
|
5634
5668
|
* })
|
|
5635
5669
|
* ```
|
|
5636
5670
|
*/
|
|
5637
|
-
chatStream(
|
|
5638
|
-
onSources?: (sources:
|
|
5671
|
+
chatStream(request: AIChatRequest, callbacks: {
|
|
5672
|
+
onSources?: (sources: AISource[]) => void;
|
|
5639
5673
|
onToken?: (content: string) => void;
|
|
5640
|
-
onDone?: (
|
|
5674
|
+
onDone?: () => void;
|
|
5641
5675
|
onError?: (error: string) => void;
|
|
5642
5676
|
}): Promise<void>;
|
|
5643
5677
|
}
|
|
@@ -6058,10 +6092,15 @@ declare class ConnectBase {
|
|
|
6058
6092
|
*/
|
|
6059
6093
|
readonly native: NativeAPI;
|
|
6060
6094
|
/**
|
|
6061
|
-
*
|
|
6095
|
+
* AI 데이터베이스 API (문서 검색)
|
|
6062
6096
|
* 문서를 업로드하고 키워드 기반으로 검색하여 AI 챗봇을 구축할 수 있습니다.
|
|
6063
6097
|
*/
|
|
6064
6098
|
readonly knowledge: KnowledgeAPI;
|
|
6099
|
+
/**
|
|
6100
|
+
* AI API (채팅 + AI 데이터베이스 연동)
|
|
6101
|
+
* AI 채팅, AI 데이터베이스 문서 참조 응답, 스트리밍 지원.
|
|
6102
|
+
*/
|
|
6103
|
+
readonly ai: AIAPI;
|
|
6065
6104
|
/**
|
|
6066
6105
|
* Queue API (메시지 큐)
|
|
6067
6106
|
* NATS JetStream 기반 고신뢰 메시지 큐. 발행, 소비, Ack, Nack 지원.
|
|
@@ -6082,4 +6121,4 @@ declare class ConnectBase {
|
|
|
6082
6121
|
updateConfig(config: Partial<ConnectBaseConfig>): void;
|
|
6083
6122
|
}
|
|
6084
6123
|
|
|
6085
|
-
export { type AckMessagesRequest, type AdReportResponse, type AdReportSummary, AdsAPI, type AggregateResult, type AggregateStage, ApiError, type ApiKeyItem, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchSetPageMetaRequest, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type
|
|
6124
|
+
export { AIAPI, type AIChatRequest, type AIChatResponse, type AIMessage, type AISource, type AIStreamChunk, type AITool, type AIToolCall, type AckMessagesRequest, type AdReportResponse, type AdReportSummary, AdsAPI, type AggregateResult, type AggregateStage, ApiError, type ApiKeyItem, type AppStatsResponse, type ArchivePolicy, type AtomicOperator, type AtomicOperatorType, AuthError, type AuthSettingsResponse, type BackupInfo, type BatchOperation, type BatchSetPageMetaRequest, type BillingCycle, type BillingKeyResponse, type BiometricInfo, type BiometricResult, type BulkCreateResponse, type BulkError, type CPUInfo, type CancelPaymentRequest, type CancelPaymentResponse, type CancelSubscriptionRequest, type CategoryInfo, type Channel, type ChannelMembership, type ChargeWithBillingKeyRequest, type ChargeWithBillingKeyResponse, type ChatMessage, type ClientMessage, type ColumnSchema, type CommentListResponse, type CompleteUploadRequest, type CompleteUploadResponse, type ConfirmBillingKeyRequest, type ConfirmPaymentRequest, type ConfirmPaymentResponse, ConnectBase, type ConnectBaseConfig, type ConnectedData, type ConnectionState, type ConsumeMessagesResponse, type ConsumeOptions, type CopyTableRequest, type CopyTableResponse, type CreateApiKeyRequest, type CreateApiKeyResponse, type CreateBackupRequest, type CreateChannelRequest, type CreateColumnRequest, type CreateDataRequest, type CreateDocumentRequest, type CreateFolderRequest, type CreateFolderResponse, type CreateGeoIndexRequest, type CreateIndexRequest, type CreateLobbyRequest, type CreatePlaylistRequest, type CreateRelationRequest, type CreateSearchIndexRequest, type CreateSecurityRuleRequest, type CreateSubscriptionRequest, type CreateTableRequest, type CreateTriggerRequest, type CreateVideoStorageRequest, type DailyReport, type DataItem, type DataType, type DatabaseChange, type DatabaseChangeMessage, type DatabaseChangeType, type DatabasePresenceState, type DatabaseRealtimeConnectOptions, type DatabaseRealtimeFilter, type DatabaseRealtimeHandlers, type DatabaseRealtimeSubscription, type DatabaseSnapshot, type DatabaseSnapshotMessage, type DatabaseSubscribeOptions, type DeleteWhereResponse, type DeviceInfo, type DocumentResponse, type EnabledProviderInfo, type EnabledProvidersResponse, type ErrorHandler, type ErrorMessage, type ErrorReport, type ErrorTrackerConfig, type ErrorType, type ExportDataRequest, type ExportDataResponse, type FetchApiKeysResponse, type FetchDataResponse, type FetchFilesResponse, type FileItem, type FileStats, GameAPI, type GameAction, type GameClientConfig, type GameConnectionState, type GameConnectionStatus, type GameDelta, type GameEventHandlers, type GamePlayer, GameRoom, type GameRoomConfig, type GameRoomInfo, GameRoomTransport, type GameServerMessage, type GameServerMessageType, type GameState, type GameTransportConfig, type GenerateUploadURLByPathRequest, type GenerateUploadURLRequest, type GenerateUploadURLResponse, type GeoIndex, type GeoNear, type GeoPoint, type GeoPolygon, type GeoQuery, type GeoResponse, type GeoResult, type GeoWithin, type GetAuthorizationURLResponse, type GetFileByPathResponse, type GoogleConnectionStatus, type GuestMemberSignInResponse, type HistoryResponse, type ICEServer, type ICEServersResponse, type ImageResult, type ImportDataRequest, type ImportDataResponse, type IndexAnalysis, type IndexRecommendation, type InitUploadResponse, type InvokeFunctionRequest, type InvokeFunctionResponse, type IssueBillingKeyRequest, type IssueBillingKeyResponse, type JoinQueueRequest, type JoinRoomRequest, type JoinRoomResponse, type KnowledgeSearchRequest, type KnowledgeSearchResponse, type KnowledgeSearchResult, type LeaderboardEntry, type LifecyclePolicy, type ListBillingKeysResponse, type ListDocumentsResponse, type ListPageMetasOptions, type ListPageMetasResponse, type ListSubscriptionPaymentsRequest, type ListSubscriptionPaymentsResponse, type ListSubscriptionsRequest, type ListSubscriptionsResponse, type LobbyInfo, type LobbyInvite, type LobbyMember, type LobbyVisibility, type MatchResult, type MatchmakingTicket, type MemberInfoResponse, type MemberSignInRequest, type MemberSignInResponse, type MemberSignUpRequest, type MemberSignUpResponse, type MembershipTier, type MemoryInfo, type MessageHandler, type MigrateDataRequest, type MigrateDataResponse, type MoveFileRequest, type NackMessageRequest, NativeAPI, type OAuthCallbackResponse, type OAuthProvider, type OpenDialogOptions, type OpenDialogResult, type PageMetaResponse, type PartyInfo, type PartyInvite, type PartyMember, type PauseSubscriptionRequest, type PaymentDetail, type PaymentProvider, type PaymentStatus, type PeerInfo, type Platform, type PlayerEvent, type PlayerStats, type Playlist, type PlaylistItem, type PongMessage, type PopulateOption, type Position, type PreparePaymentRequest, type PreparePaymentResponse, type PresenceChangeHandler, type PresenceInfo, type PresenceSetOptions, type PresenceStatus, type PresenceStatusResult, type PublishBatchRequest, type PublishBatchResponse, type PublishMessageRequest, type PublishMessageResponse, type PushPlatform, type QualityProgress, type QueryOptions, type QueueInfoResponse, type QueueMessage, type ReadReceiptHandler, type ReadReceiptInfo, type RealtimeConnectOptions, type RealtimeMessage, type RegisterDeviceRequest, type RelationType, type RenameFileRequest, type RenameFileResponse, type ReplayHighlight, type ReplayInfo, type ReplayPlayerInfo, type RestoreBackupRequest, type RestoreBackupResponse, type RetentionPolicy, type RoomInfo, type RoomStats, type RoomsResponse, type SaveDialogOptions, type SaveDialogResult, type SearchIndex, type SearchOptions, type SearchResponse, type SearchResult, type SecurityRule, type SendOptions, type ServerMessage, type SetPageMetaRequest, type Shorts, type ShortsListResponse, type SignalingMessage, type SignalingMessageType, type SlowQueryInfo, type SpectatorInfo, type SpectatorPlayerState, type SpectatorState, type StateChange, type StateChangeHandler, type StorageUploadOptions, type StreamDoneCallback, type StreamDoneData, type StreamErrorCallback, type StreamHandlers, type StreamMessage, type StreamOptions, type StreamSession, type StreamTokenCallback, type StreamToolCallCallback, type StreamToolResultCallback, type StreamURLResponse, type SubscribeOptions, type SubscribeTopicRequest, type SubscribedData, type Subscription, type SubscriptionPaymentResponse, type SubscriptionPaymentStatus, type SubscriptionResponse, type SubscriptionStatus, type SuperChat, type SystemInfo, type TTLConfig, type TableIndex, type TableRelation, type TableSchema, type TransactionRead, type TransactionWrite, type TranscodeStatus, type TransportType, type Trigger, type TriggerEvent, type TriggerHandlerType, type TypingChangeHandler, type TypingInfo, type UpdateApiKeyRequest, type UpdateApiKeyResponse, type UpdateBillingKeyRequest, type UpdateChannelRequest, type UpdateColumnRequest, type UpdateCustomDataRequest, type UpdateCustomDataResponse, type UpdateDataRequest, type UpdateLobbyRequest, type UpdateSecurityRuleRequest, type UpdateSubscriptionRequest, type UpdateTriggerRequest, type UpdateVideoRequest, type UpdateVideoStorageRequest, type UploadByPathOptions, type UploadFileResponse, type UploadOptions, type UploadProgress, type VAPIDPublicKeyResponse, type ValidateResponse, type Video, type VideoComment, type VideoListOptions, type VideoListResponse, VideoProcessingError, type VideoQuality, type VideoStatus, type VideoStorage, type VideoStorageListResponse, type VideoVisibility, type VoiceChannel, type VoiceMember, type WaitOptions, type WatchHistoryItem, type WebPushSubscription, type WebRTCConnectOptions, type WebRTCConnectionState, type WebRTCMode, type WhereCondition, type WhereOperator, ConnectBase as default, isWebTransportSupported };
|
package/dist/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
AIAPI: () => AIAPI,
|
|
23
24
|
AdsAPI: () => AdsAPI,
|
|
24
25
|
ApiError: () => ApiError,
|
|
25
26
|
AuthError: () => AuthError,
|
|
@@ -7142,56 +7143,40 @@ var KnowledgeAPI = class {
|
|
|
7142
7143
|
`/v1/public/knowledge-bases/${kbID}/search?${params.toString()}`
|
|
7143
7144
|
);
|
|
7144
7145
|
}
|
|
7145
|
-
//
|
|
7146
|
+
// AI 데이터베이스 채팅은 AI 스트리밍 API로 통합됨
|
|
7147
|
+
// cb.ai.chat({ messages, knowledgeBaseId }) 또는 cb.ai.chatStream() 사용
|
|
7148
|
+
};
|
|
7149
|
+
|
|
7150
|
+
// src/api/ai.ts
|
|
7151
|
+
var AIAPI = class {
|
|
7152
|
+
constructor(http) {
|
|
7153
|
+
this.http = http;
|
|
7154
|
+
}
|
|
7146
7155
|
/**
|
|
7147
|
-
*
|
|
7148
|
-
*
|
|
7149
|
-
* 지식 베이스의 문서를 검색하고 AI가 답변을 생성합니다.
|
|
7150
|
-
*
|
|
7151
|
-
* @param kbID - 지식 베이스 ID
|
|
7152
|
-
* @param request - 챗 요청
|
|
7153
|
-
* @returns AI 답변 + 참조 소스
|
|
7154
|
-
*
|
|
7155
|
-
* @example
|
|
7156
|
-
* ```typescript
|
|
7157
|
-
* const response = await cb.knowledge.chat('kb-id', {
|
|
7158
|
-
* message: '환불 정책이 어떻게 되나요?',
|
|
7159
|
-
* top_k: 5
|
|
7160
|
-
* })
|
|
7161
|
-
* console.log(response.answer)
|
|
7162
|
-
* console.log('참조:', response.sources)
|
|
7163
|
-
* ```
|
|
7156
|
+
* AI 채팅 (동기)
|
|
7164
7157
|
*/
|
|
7165
|
-
async chat(
|
|
7166
|
-
return this.http.post(
|
|
7167
|
-
`/v1/public/knowledge-bases/${kbID}/chat`,
|
|
7168
|
-
request
|
|
7169
|
-
);
|
|
7158
|
+
async chat(request) {
|
|
7159
|
+
return this.http.post("/v1/public/ai/chat", request);
|
|
7170
7160
|
}
|
|
7171
7161
|
/**
|
|
7172
|
-
*
|
|
7173
|
-
*
|
|
7174
|
-
* AI 답변을 실시간으로 토큰 단위로 수신합니다.
|
|
7175
|
-
*
|
|
7176
|
-
* @param kbID - 지식 베이스 ID
|
|
7177
|
-
* @param request - 챗 요청
|
|
7178
|
-
* @param callbacks - 스트리밍 콜백
|
|
7162
|
+
* AI 채팅 스트리밍 (SSE)
|
|
7179
7163
|
*
|
|
7180
7164
|
* @example
|
|
7181
7165
|
* ```typescript
|
|
7182
|
-
* await cb.
|
|
7183
|
-
*
|
|
7166
|
+
* await cb.ai.chatStream({
|
|
7167
|
+
* messages: [{ role: 'user', content: '안녕하세요' }],
|
|
7168
|
+
* knowledgeBaseId: 'kb-id',
|
|
7184
7169
|
* }, {
|
|
7185
|
-
* onSources: (sources
|
|
7170
|
+
* onSources: (sources) => console.log('참조:', sources),
|
|
7186
7171
|
* onToken: (content) => process.stdout.write(content),
|
|
7187
|
-
* onDone: (
|
|
7172
|
+
* onDone: () => console.log('\\n완료'),
|
|
7188
7173
|
* onError: (error) => console.error('에러:', error)
|
|
7189
7174
|
* })
|
|
7190
7175
|
* ```
|
|
7191
7176
|
*/
|
|
7192
|
-
async chatStream(
|
|
7177
|
+
async chatStream(request, callbacks) {
|
|
7193
7178
|
const response = await this.http.fetchRaw(
|
|
7194
|
-
|
|
7179
|
+
"/v1/public/ai/chat/stream",
|
|
7195
7180
|
{
|
|
7196
7181
|
method: "POST",
|
|
7197
7182
|
headers: { "Content-Type": "application/json" },
|
|
@@ -7225,17 +7210,14 @@ var KnowledgeAPI = class {
|
|
|
7225
7210
|
}
|
|
7226
7211
|
try {
|
|
7227
7212
|
const event = JSON.parse(data);
|
|
7228
|
-
|
|
7229
|
-
|
|
7230
|
-
|
|
7231
|
-
|
|
7232
|
-
|
|
7233
|
-
|
|
7234
|
-
|
|
7235
|
-
|
|
7236
|
-
case "error":
|
|
7237
|
-
callbacks.onError?.(event.error || "Unknown error");
|
|
7238
|
-
return;
|
|
7213
|
+
if (event.type === "sources" && event.sources) {
|
|
7214
|
+
callbacks.onSources?.(event.sources);
|
|
7215
|
+
continue;
|
|
7216
|
+
}
|
|
7217
|
+
if (event.content) callbacks.onToken?.(event.content);
|
|
7218
|
+
if (event.done) {
|
|
7219
|
+
callbacks.onDone?.();
|
|
7220
|
+
return;
|
|
7239
7221
|
}
|
|
7240
7222
|
} catch {
|
|
7241
7223
|
}
|
|
@@ -7974,6 +7956,7 @@ var ConnectBase = class {
|
|
|
7974
7956
|
this.ads = new AdsAPI(this.http);
|
|
7975
7957
|
this.native = new NativeAPI();
|
|
7976
7958
|
this.knowledge = new KnowledgeAPI(this.http);
|
|
7959
|
+
this.ai = new AIAPI(this.http);
|
|
7977
7960
|
this.queue = new QueueAPI(this.http);
|
|
7978
7961
|
}
|
|
7979
7962
|
/**
|
|
@@ -7998,6 +7981,7 @@ var ConnectBase = class {
|
|
|
7998
7981
|
var index_default = ConnectBase;
|
|
7999
7982
|
// Annotate the CommonJS export names for ESM import in node:
|
|
8000
7983
|
0 && (module.exports = {
|
|
7984
|
+
AIAPI,
|
|
8001
7985
|
AdsAPI,
|
|
8002
7986
|
ApiError,
|
|
8003
7987
|
AuthError,
|