@botonic/plugin-knowledge-bases 0.37.0 → 0.37.1-alpha.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.
@@ -1,14 +1,14 @@
1
1
  import type { BotContext, Plugin, PluginPreRequest } from '@botonic/core';
2
- import { KnowledgeBaseResponse, PluginKnowledgeBaseOptions } from './types';
2
+ import { KnowledgeBasesResponse, PluginKnowledgeBaseOptions } from './types';
3
3
  export default class BotonicPluginKnowledgeBases implements Plugin {
4
4
  private readonly apiService;
5
5
  private readonly authToken;
6
6
  constructor(options: PluginKnowledgeBaseOptions);
7
7
  pre(_request: PluginPreRequest): Promise<void>;
8
- getInference(request: BotContext, sources: string[], instructions: string, messageId: string, memoryLength: number): Promise<KnowledgeBaseResponse>;
9
- getTestInference(authToken: string, request: BotContext, instructions: string, sources: string[]): Promise<KnowledgeBaseResponse>;
10
- getInferenceV1(authToken: string, request: BotContext, sources: string[]): Promise<KnowledgeBaseResponse>;
11
- getInferenceV2(authToken: string, sources: string[], instructions: string, messageId: string, memoryLength: number): Promise<KnowledgeBaseResponse>;
8
+ getInference(request: BotContext, sources: string[], instructions: string, messageId: string, memoryLength: number): Promise<KnowledgeBasesResponse>;
9
+ getTestInference(authToken: string, request: BotContext, instructions: string, sources: string[]): Promise<KnowledgeBasesResponse>;
10
+ getInferenceV1(authToken: string, request: BotContext, sources: string[]): Promise<KnowledgeBasesResponse>;
11
+ getInferenceV2(authToken: string, sources: string[], instructions: string, messageId: string, memoryLength: number): Promise<KnowledgeBasesResponse>;
12
12
  private mapApiResponse;
13
13
  }
14
14
  export { PluginKnowledgeBaseOptions } from './types';
@@ -1,15 +1,10 @@
1
+ import { KnowledgeBasesResponse } from '@botonic/core';
1
2
  export interface PluginKnowledgeBaseOptions {
2
3
  host: string;
3
4
  authToken?: string;
4
5
  timeout?: number;
5
6
  }
6
- export interface KnowledgeBaseResponse {
7
- inferenceId: string;
8
- hasKnowledge: boolean;
9
- isFaithful: boolean;
10
- chunkIds: string[];
11
- answer: string;
12
- }
7
+ export type { KnowledgeBasesResponse };
13
8
  export interface Chunk {
14
9
  id: string;
15
10
  text: string;
@@ -1,14 +1,14 @@
1
1
  import type { BotContext, Plugin, PluginPreRequest } from '@botonic/core';
2
- import { KnowledgeBaseResponse, PluginKnowledgeBaseOptions } from './types';
2
+ import { KnowledgeBasesResponse, PluginKnowledgeBaseOptions } from './types';
3
3
  export default class BotonicPluginKnowledgeBases implements Plugin {
4
4
  private readonly apiService;
5
5
  private readonly authToken;
6
6
  constructor(options: PluginKnowledgeBaseOptions);
7
7
  pre(_request: PluginPreRequest): Promise<void>;
8
- getInference(request: BotContext, sources: string[], instructions: string, messageId: string, memoryLength: number): Promise<KnowledgeBaseResponse>;
9
- getTestInference(authToken: string, request: BotContext, instructions: string, sources: string[]): Promise<KnowledgeBaseResponse>;
10
- getInferenceV1(authToken: string, request: BotContext, sources: string[]): Promise<KnowledgeBaseResponse>;
11
- getInferenceV2(authToken: string, sources: string[], instructions: string, messageId: string, memoryLength: number): Promise<KnowledgeBaseResponse>;
8
+ getInference(request: BotContext, sources: string[], instructions: string, messageId: string, memoryLength: number): Promise<KnowledgeBasesResponse>;
9
+ getTestInference(authToken: string, request: BotContext, instructions: string, sources: string[]): Promise<KnowledgeBasesResponse>;
10
+ getInferenceV1(authToken: string, request: BotContext, sources: string[]): Promise<KnowledgeBasesResponse>;
11
+ getInferenceV2(authToken: string, sources: string[], instructions: string, messageId: string, memoryLength: number): Promise<KnowledgeBasesResponse>;
12
12
  private mapApiResponse;
13
13
  }
14
14
  export { PluginKnowledgeBaseOptions } from './types';
@@ -1,15 +1,10 @@
1
+ import { KnowledgeBasesResponse } from '@botonic/core';
1
2
  export interface PluginKnowledgeBaseOptions {
2
3
  host: string;
3
4
  authToken?: string;
4
5
  timeout?: number;
5
6
  }
6
- export interface KnowledgeBaseResponse {
7
- inferenceId: string;
8
- hasKnowledge: boolean;
9
- isFaithful: boolean;
10
- chunkIds: string[];
11
- answer: string;
12
- }
7
+ export type { KnowledgeBasesResponse };
13
8
  export interface Chunk {
14
9
  id: string;
15
10
  text: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botonic/plugin-knowledge-bases",
3
- "version": "0.37.0",
3
+ "version": "0.37.1-alpha.0",
4
4
  "description": "Use a Hubtype to make the bot respond through a knowledge base.",
5
5
  "main": "./lib/cjs/index.js",
6
6
  "module": "./lib/esm/index.js",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@babel/runtime": "^7.26.0",
18
- "@botonic/core": "^0.37.0",
18
+ "@botonic/core": "0.37.1-alpha.0",
19
19
  "axios": "^1.10.0"
20
20
  },
21
21
  "devDependencies": {
package/src/index.ts CHANGED
@@ -5,7 +5,7 @@ import {
5
5
  HtApiKnowledgeBaseResponse,
6
6
  HubtypeApiService,
7
7
  } from './hubtype-knowledge-api-service'
8
- import { KnowledgeBaseResponse, PluginKnowledgeBaseOptions } from './types'
8
+ import { KnowledgeBasesResponse, PluginKnowledgeBaseOptions } from './types'
9
9
 
10
10
  const isProd = process.env.NODE_ENV === 'production'
11
11
  const isDev = process.env.NODE_ENV === 'development'
@@ -29,7 +29,7 @@ export default class BotonicPluginKnowledgeBases implements Plugin {
29
29
  instructions: string,
30
30
  messageId: string,
31
31
  memoryLength: number
32
- ): Promise<KnowledgeBaseResponse> {
32
+ ): Promise<KnowledgeBasesResponse> {
33
33
  const authToken = isProd ? request.session._access_token : this.authToken
34
34
 
35
35
  if (isDev) {
@@ -54,7 +54,7 @@ export default class BotonicPluginKnowledgeBases implements Plugin {
54
54
  request: BotContext,
55
55
  instructions: string,
56
56
  sources: string[]
57
- ): Promise<KnowledgeBaseResponse> {
57
+ ): Promise<KnowledgeBasesResponse> {
58
58
  const messages = [{ role: 'human', content: request.input.data }]
59
59
 
60
60
  const response = await this.apiService.testInference(
@@ -71,7 +71,7 @@ export default class BotonicPluginKnowledgeBases implements Plugin {
71
71
  authToken: string,
72
72
  request: BotContext,
73
73
  sources: string[]
74
- ): Promise<KnowledgeBaseResponse> {
74
+ ): Promise<KnowledgeBasesResponse> {
75
75
  const response = await this.apiService.inferenceV1(
76
76
  authToken,
77
77
  request.input.data!,
@@ -92,7 +92,7 @@ export default class BotonicPluginKnowledgeBases implements Plugin {
92
92
  instructions: string,
93
93
  messageId: string,
94
94
  memoryLength: number
95
- ): Promise<KnowledgeBaseResponse> {
95
+ ): Promise<KnowledgeBasesResponse> {
96
96
  const response = await this.apiService.inferenceV2(
97
97
  authToken,
98
98
  sources,
@@ -106,7 +106,7 @@ export default class BotonicPluginKnowledgeBases implements Plugin {
106
106
 
107
107
  private mapApiResponse(
108
108
  response: AxiosResponse<HtApiKnowledgeBaseResponse>
109
- ): KnowledgeBaseResponse {
109
+ ): KnowledgeBasesResponse {
110
110
  return {
111
111
  inferenceId: response.data.inference_id,
112
112
  chunkIds: response.data.chunks.map(chunk => chunk.id),
package/src/types.ts CHANGED
@@ -1,16 +1,12 @@
1
+ import { KnowledgeBasesResponse } from '@botonic/core'
2
+
1
3
  export interface PluginKnowledgeBaseOptions {
2
4
  host: string
3
5
  authToken?: string
4
6
  timeout?: number
5
7
  }
6
8
 
7
- export interface KnowledgeBaseResponse {
8
- inferenceId: string
9
- hasKnowledge: boolean
10
- isFaithful: boolean
11
- chunkIds: string[]
12
- answer: string
13
- }
9
+ export type { KnowledgeBasesResponse }
14
10
 
15
11
  export interface Chunk {
16
12
  id: string