@drax/ai-back 3.35.1 → 3.36.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/.env +4 -0
- package/dist/agents/ChatbotTaskService.js +143 -0
- package/dist/agents/ChatbotTaskTools.js +756 -0
- package/dist/controllers/AIController.js +150 -0
- package/dist/interfaces/IAILog.js +1 -0
- package/dist/routes/ChatbotTaskRoutes.js +8 -0
- package/dist/tools/ToolBuilder.js +243 -0
- package/dist/vectors/ChromaVector.js +65 -0
- package/package.json +3 -3
- package/tsconfig.tsbuildinfo +1 -1
- package/types/agents/ChatbotTaskService.d.ts +42 -0
- package/types/agents/ChatbotTaskService.d.ts.map +1 -0
- package/types/agents/ChatbotTaskTools.d.ts +54 -0
- package/types/agents/ChatbotTaskTools.d.ts.map +1 -0
- package/types/controllers/AIController.d.ts +25 -0
- package/types/controllers/AIController.d.ts.map +1 -0
- package/types/index.d.ts +7 -1
- package/types/interfaces/IAILog.d.ts +77 -0
- package/types/interfaces/IAILog.d.ts.map +1 -0
- package/types/routes/ChatbotTaskRoutes.d.ts +4 -0
- package/types/routes/ChatbotTaskRoutes.d.ts.map +1 -0
- package/types/tools/ToolBuilder.d.ts +47 -0
- package/types/tools/ToolBuilder.d.ts.map +1 -0
- package/types/vectors/ChromaVector.d.ts +21 -0
- package/types/vectors/ChromaVector.d.ts.map +1 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
type ChatRole = "user" | "assistant" | "system";
|
|
2
|
+
interface ChatMessage {
|
|
3
|
+
role: ChatRole;
|
|
4
|
+
content: string;
|
|
5
|
+
}
|
|
6
|
+
interface ChatbotTaskMessageInput {
|
|
7
|
+
sessionId?: string;
|
|
8
|
+
message: string;
|
|
9
|
+
userId: string;
|
|
10
|
+
tenantId?: string | null;
|
|
11
|
+
ip?: string;
|
|
12
|
+
userAgent?: string;
|
|
13
|
+
}
|
|
14
|
+
interface ChatbotTaskMessageOutput {
|
|
15
|
+
sessionId: string;
|
|
16
|
+
message: string;
|
|
17
|
+
}
|
|
18
|
+
interface ChatbotTaskSession {
|
|
19
|
+
id: string;
|
|
20
|
+
userId: string;
|
|
21
|
+
messages: ChatMessage[];
|
|
22
|
+
createdAt: Date;
|
|
23
|
+
updatedAt: Date;
|
|
24
|
+
}
|
|
25
|
+
declare class ChatbotTaskService {
|
|
26
|
+
private sessions;
|
|
27
|
+
startSession(userId: string): ChatbotTaskSession;
|
|
28
|
+
private createSession;
|
|
29
|
+
sendMessage(input: ChatbotTaskMessageInput): Promise<ChatbotTaskMessageOutput>;
|
|
30
|
+
private resolveSession;
|
|
31
|
+
private getSessionKey;
|
|
32
|
+
private normalizeOutput;
|
|
33
|
+
private withToolExecutionLogs;
|
|
34
|
+
private systemPrompt;
|
|
35
|
+
private formatTaskOptionNames;
|
|
36
|
+
private formatEntityTypeOptionNames;
|
|
37
|
+
private formatOptionList;
|
|
38
|
+
}
|
|
39
|
+
export type { ChatbotTaskMessageInput, ChatbotTaskMessageOutput, ChatbotTaskSession };
|
|
40
|
+
export default ChatbotTaskService;
|
|
41
|
+
export { ChatbotTaskService };
|
|
42
|
+
//# sourceMappingURL=ChatbotTaskService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatbotTaskService.d.ts","sourceRoot":"","sources":["../../src/agents/ChatbotTaskService.ts"],"names":[],"mappings":"AAMA,KAAK,QAAQ,GAAG,MAAM,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEhD,UAAU,WAAW;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,uBAAuB;IAC7B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,UAAU,wBAAwB;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,kBAAkB;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,WAAW,EAAE,CAAC;IACxB,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACnB;AAED,cAAM,kBAAkB;IACpB,OAAO,CAAC,QAAQ,CAA8C;IAE9D,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,kBAAkB;IAIhD,OAAO,CAAC,aAAa;IAaf,WAAW,CAAC,KAAK,EAAE,uBAAuB,GAAG,OAAO,CAAC,wBAAwB,CAAC;IAmCpF,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,eAAe;IAYvB,OAAO,CAAC,qBAAqB;IAgC7B,OAAO,CAAC,YAAY;IAwBpB,OAAO,CAAC,qBAAqB;IAS7B,OAAO,CAAC,2BAA2B;IAQnC,OAAO,CAAC,gBAAgB;CAG3B;AAED,YAAY,EAAC,uBAAuB,EAAE,wBAAwB,EAAE,kBAAkB,EAAC,CAAC;AACpF,eAAe,kBAAkB,CAAC;AAClC,OAAO,EAAC,kBAAkB,EAAC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { IPromptTool } from "@drax/ai-back/types/interfaces/IAIProvider.js";
|
|
2
|
+
interface ChatbotTaskToolsContext {
|
|
3
|
+
userId: string;
|
|
4
|
+
}
|
|
5
|
+
interface TaskOptionNames {
|
|
6
|
+
sources: string[];
|
|
7
|
+
statuses: string[];
|
|
8
|
+
types: string[];
|
|
9
|
+
priorities: string[];
|
|
10
|
+
}
|
|
11
|
+
interface EntityTypeOptionNames {
|
|
12
|
+
contactTypes: string[];
|
|
13
|
+
companyTypes: string[];
|
|
14
|
+
clientTypes: string[];
|
|
15
|
+
}
|
|
16
|
+
interface LifeOpsOptionNames {
|
|
17
|
+
task: TaskOptionNames;
|
|
18
|
+
entityTypes: EntityTypeOptionNames;
|
|
19
|
+
}
|
|
20
|
+
declare class ChatbotTaskTools {
|
|
21
|
+
static build(context: ChatbotTaskToolsContext): IPromptTool[];
|
|
22
|
+
static fetchTaskOptionNames(): Promise<TaskOptionNames>;
|
|
23
|
+
static fetchLifeOpsOptionNames(): Promise<LifeOpsOptionNames>;
|
|
24
|
+
private static taskUserFilter;
|
|
25
|
+
private static compactObject;
|
|
26
|
+
private static serializeOptionNames;
|
|
27
|
+
private static serializeTask;
|
|
28
|
+
private static entityUserFilter;
|
|
29
|
+
private static serializeGoal;
|
|
30
|
+
private static serializeProject;
|
|
31
|
+
private static serializeContact;
|
|
32
|
+
private static serializeClient;
|
|
33
|
+
private static serializeCompany;
|
|
34
|
+
private static serializeFields;
|
|
35
|
+
private static findUserTaskById;
|
|
36
|
+
private static findUserEntityById;
|
|
37
|
+
private static buildEntityTools;
|
|
38
|
+
private static entityConfigs;
|
|
39
|
+
private static createEntityTool;
|
|
40
|
+
private static searchEntitiesTool;
|
|
41
|
+
private static findEntityByIdTool;
|
|
42
|
+
private static updateEntityPartialTool;
|
|
43
|
+
private static registerTaskTool;
|
|
44
|
+
private static searchTasksTool;
|
|
45
|
+
private static findTaskByIdTool;
|
|
46
|
+
private static groupTasksTool;
|
|
47
|
+
private static updateTaskPartialTool;
|
|
48
|
+
private static listTaskOptionsTool;
|
|
49
|
+
private static createTaskOptionTool;
|
|
50
|
+
}
|
|
51
|
+
export type { ChatbotTaskToolsContext, TaskOptionNames, EntityTypeOptionNames, LifeOpsOptionNames };
|
|
52
|
+
export default ChatbotTaskTools;
|
|
53
|
+
export { ChatbotTaskTools };
|
|
54
|
+
//# sourceMappingURL=ChatbotTaskTools.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatbotTaskTools.d.ts","sourceRoot":"","sources":["../../src/agents/Chatbot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,CAAC,MAAM,CAAC,aAAa;IAqN5B,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAqB/B,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAsCjC,OAAO,CAAC,MAAM,CAAC,kBAAkB;IAmBjC,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAgCtC,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAyD/B,OAAO,CAAC,MAAM,CAAC,eAAe;IAsC9B,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAmB/B,OAAO,CAAC,MAAM,CAAC,cAAc;IA4D7B,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAkDpC,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAelC,OAAO,CAAC,MAAM,CAAC,oBAAoB;CAkDtC;AAED,YAAY,EAAC,uBAAuB,EAAE,eAAe,EAAE,qBAAqB,EAAE,kBAAkB,EAAC,CAAC;AAClG,eAAe,gBAAgB,CAAC;AAChC,OAAO,EAAC,gBAAgB,EAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { CommonController } from "@drax/common-back";
|
|
3
|
+
declare const PromptRequestSchema: z.ZodObject<{
|
|
4
|
+
prompt: z.ZodString;
|
|
5
|
+
operation: z.ZodDefault<z.ZodEnum<{
|
|
6
|
+
create: "create";
|
|
7
|
+
edit: "edit";
|
|
8
|
+
}>>;
|
|
9
|
+
entity: z.ZodObject<{
|
|
10
|
+
name: z.ZodString;
|
|
11
|
+
identifier: z.ZodNullable<z.ZodOptional<z.ZodString>>;
|
|
12
|
+
}, z.core.$strip>;
|
|
13
|
+
currentValues: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodAny>>;
|
|
14
|
+
fields: z.ZodArray<z.ZodType<any, unknown, z.core.$ZodTypeInternals<any, unknown>>>;
|
|
15
|
+
}, z.core.$strip>;
|
|
16
|
+
declare class AIController extends CommonController {
|
|
17
|
+
protected buildFieldValueSchema(field: any): z.ZodTypeAny;
|
|
18
|
+
protected buildFieldShape(fields: any[]): Record<string, z.ZodTypeAny>;
|
|
19
|
+
protected buildSystemPrompt(input: z.infer<typeof PromptRequestSchema>): string;
|
|
20
|
+
protected buildUserInput(input: z.infer<typeof PromptRequestSchema>): string;
|
|
21
|
+
prompt(req: any, rep: any): Promise<any>;
|
|
22
|
+
}
|
|
23
|
+
export default AIController;
|
|
24
|
+
export { AIController };
|
|
25
|
+
//# sourceMappingURL=AIController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AIController.d.ts","sourceRoot":"","sources":["../../src/controllers/AIController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AACtB,OAAO,EAAC,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AAsBnD,QAAA,MAAM,mBAAmB;;;;;;;;;;;;iBASvB,CAAA;AAEF,cAAM,YAAa,SAAQ,gBAAgB;IAEvC,SAAS,CAAC,qBAAqB,CAAC,KAAK,EAAE,GAAG,GAAG,CAAC,CAAC,UAAU;IAqCzD,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,UAAU,CAAC;IAOtE,SAAS,CAAC,iBAAiB,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC;IAgBtE,SAAS,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC;IAe7D,MAAM,CAAC,GAAG,KAAA,EAAE,GAAG,KAAA;CAqDxB;AAED,eAAe,YAAY,CAAC;AAC5B,OAAO,EAAC,YAAY,EAAC,CAAC"}
|
package/types/index.d.ts
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
import { OpenAiConfig } from "./config/OpenAiConfig.js";
|
|
2
|
+
import { GoogleAiConfig } from "./config/GoogleAiConfig.js";
|
|
3
|
+
import { OllamaAiConfig } from "./config/OllamaAiConfig.js";
|
|
2
4
|
import { AILogSchema, AILogBaseSchema } from "./schemas/AILogSchema.js";
|
|
3
5
|
import AILogModel from "./models/AILogModel.js";
|
|
4
6
|
import AILogMongoRepository from "./repository/mongo/AILogMongoRepository.js";
|
|
5
7
|
import AILogSqliteRepository from "./repository/sqlite/AILogSqliteRepository.js";
|
|
6
8
|
import { OpenAiProviderFactory } from "./factory/OpenAiProviderFactory.js";
|
|
9
|
+
import { GoogleAiProviderFactory } from "./factory/GoogleAiProviderFactory.js";
|
|
10
|
+
import { OllamaAiProviderFactory } from "./factory/OllamaAiProviderFactory.js";
|
|
7
11
|
import { AiProviderFactory } from "./factory/AiProviderFactory.js";
|
|
8
12
|
import AILogServiceFactory from "./factory/services/AILogServiceFactory.js";
|
|
9
13
|
import { OpenAiProvider } from "./providers/OpenAiProvider.js";
|
|
14
|
+
import { GoogleAiProvider } from "./providers/GoogleAiProvider.js";
|
|
15
|
+
import { OllamaAiProvider } from "./providers/OllamaAiProvider.js";
|
|
10
16
|
import { BuilderTool } from "./tools/BuilderTool.js";
|
|
11
17
|
import { KnowledgeService } from "./services/KnowledgeService.js";
|
|
12
18
|
import { AILogService } from "./services/AILogService.js";
|
|
@@ -31,5 +37,5 @@ import type { DraxAgentControllerOptions } from "./interfaces/IDraxAgentControll
|
|
|
31
37
|
import type { DraxAgentFastifyRoutesOptions } from "./interfaces/IDraxAgentRoutes.js";
|
|
32
38
|
import type { DraxAgentConfig, DraxAgentMessageInput, DraxAgentMessageOutput, DraxAgentPromptContext, DraxAgentSession, DraxAgentSessionInput, DraxAgentToolBuilder, DraxAgentToolBuilderSource, DraxAgentToolSource, DraxAgentSystemPrompt } from "./interfaces/IDraxAgent.js";
|
|
33
39
|
export type { IAILogRepository, IAIProvider, IPromptParams, IPromptMessage, IPromptMemory, IPromptTool, IPromptImage, IPromptImageDetail, IPromptContentPart, IPromptContentPartImage, IPromptContentPartText, IPromptResponse, ToolBuilderMethod, ToolBuilderOptions, ToolBuilderService, DraxAgentControllerOptions, DraxAgentFastifyRoutesOptions, DraxAgentConfig, DraxAgentMessageInput, DraxAgentMessageOutput, DraxAgentPromptContext, DraxAgentSession, DraxAgentSessionInput, DraxAgentToolBuilder, DraxAgentToolBuilderSource, DraxAgentToolSource, DraxAgentSystemPrompt, };
|
|
34
|
-
export { OpenAiConfig, AILogSchema, AILogBaseSchema, AILogModel, AILogMongoRepository, AILogSqliteRepository, OpenAiProviderFactory, AiProviderFactory, AILogServiceFactory, OpenAiProvider, BuilderTool, KnowledgeService, AILogService, AILogPermissions, AgentPermissions, AIPermissions, AgentSessionPermissions, AILogController, AICrudController, AIGenericController, DraxAgentController, AgentSessionController, DraxAgent, AILogRoutes, AIRoutes, DraxAgentRoutes, AgentSessionRoutes };
|
|
40
|
+
export { OpenAiConfig, GoogleAiConfig, OllamaAiConfig, AILogSchema, AILogBaseSchema, AILogModel, AILogMongoRepository, AILogSqliteRepository, OpenAiProviderFactory, GoogleAiProviderFactory, OllamaAiProviderFactory, AiProviderFactory, AILogServiceFactory, OpenAiProvider, GoogleAiProvider, OllamaAiProvider, BuilderTool, KnowledgeService, AILogService, AILogPermissions, AgentPermissions, AIPermissions, AgentSessionPermissions, AILogController, AICrudController, AIGenericController, DraxAgentController, AgentSessionController, DraxAgent, AILogRoutes, AIRoutes, DraxAgentRoutes, AgentSessionRoutes };
|
|
35
41
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
interface IAILogBase {
|
|
2
|
+
provider?: string;
|
|
3
|
+
model?: string;
|
|
4
|
+
operationTitle?: string;
|
|
5
|
+
operationGroup?: string;
|
|
6
|
+
ip?: string;
|
|
7
|
+
userAgent?: string;
|
|
8
|
+
input?: string;
|
|
9
|
+
inputImages?: Array<{
|
|
10
|
+
filename?: string;
|
|
11
|
+
filepath?: string;
|
|
12
|
+
size?: number;
|
|
13
|
+
mimetype?: string;
|
|
14
|
+
url?: string;
|
|
15
|
+
}>;
|
|
16
|
+
inputFiles?: Array<{
|
|
17
|
+
filename?: string;
|
|
18
|
+
filepath?: string;
|
|
19
|
+
size?: number;
|
|
20
|
+
mimetype?: string;
|
|
21
|
+
url?: string;
|
|
22
|
+
}>;
|
|
23
|
+
inputTokens?: number;
|
|
24
|
+
outputTokens?: number;
|
|
25
|
+
tokens?: number;
|
|
26
|
+
startedAt?: Date;
|
|
27
|
+
endedAt?: Date;
|
|
28
|
+
responseTime?: string;
|
|
29
|
+
output?: string;
|
|
30
|
+
success?: boolean;
|
|
31
|
+
statusCode?: number;
|
|
32
|
+
errorMessage?: string;
|
|
33
|
+
tenant?: any;
|
|
34
|
+
user?: any;
|
|
35
|
+
createdAt?: Date;
|
|
36
|
+
updatedAt?: Date;
|
|
37
|
+
}
|
|
38
|
+
interface IAILog {
|
|
39
|
+
_id: string;
|
|
40
|
+
provider?: string;
|
|
41
|
+
model?: string;
|
|
42
|
+
operationTitle?: string;
|
|
43
|
+
operationGroup?: string;
|
|
44
|
+
ip?: string;
|
|
45
|
+
userAgent?: string;
|
|
46
|
+
input?: string;
|
|
47
|
+
inputImages?: Array<{
|
|
48
|
+
filename?: string;
|
|
49
|
+
filepath?: string;
|
|
50
|
+
size?: number;
|
|
51
|
+
mimetype?: string;
|
|
52
|
+
url?: string;
|
|
53
|
+
}>;
|
|
54
|
+
inputFiles?: Array<{
|
|
55
|
+
filename?: string;
|
|
56
|
+
filepath?: string;
|
|
57
|
+
size?: number;
|
|
58
|
+
mimetype?: string;
|
|
59
|
+
url?: string;
|
|
60
|
+
}>;
|
|
61
|
+
inputTokens?: number;
|
|
62
|
+
outputTokens?: number;
|
|
63
|
+
tokens?: number;
|
|
64
|
+
startedAt?: Date;
|
|
65
|
+
endedAt?: Date;
|
|
66
|
+
responseTime?: string;
|
|
67
|
+
output?: string;
|
|
68
|
+
success?: boolean;
|
|
69
|
+
statusCode?: number;
|
|
70
|
+
errorMessage?: string;
|
|
71
|
+
tenant?: any;
|
|
72
|
+
user?: any;
|
|
73
|
+
createdAt?: Date;
|
|
74
|
+
updatedAt?: Date;
|
|
75
|
+
}
|
|
76
|
+
export type { IAILogBase, IAILog };
|
|
77
|
+
//# sourceMappingURL=IAILog.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IAILog.d.ts","sourceRoot":"","sources":["../../src/interfaces/IAILog.ts"],"names":[],"mappings":"AACA,UAAU,UAAU;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,WAAW,CAAC,EAAE,KAAK,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,GAAG,CAAC,EAAE,MAAM,CAAA;KACX,CAAC,CAAA;IACF,UAAU,CAAC,EAAE,KAAK,CAAC;QACnB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,GAAG,CAAC,EAAE,MAAM,CAAA;KACX,CAAC,CAAA;IACF,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,OAAO,CAAC,EAAE,IAAI,CAAA;IACd,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,M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E,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,YAAY,CAAC,EAAE,MAAM,CAAA;IACrB,MAAM,CAAC,EAAE,GAAG,CAAA;IACZ,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,SAAS,CAAC,EAAE,IAAI,CAAA;IAChB,SAAS,CAAC,EAAE,IAAI,CAAA;CACnB;AAED,YAAY,EACZ,UAAU,EACV,MAAM,EACL,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChatbotTaskRoutes.d.ts","sourceRoot":"","sources":["../../src/routes/ChatbotTaskRoutes.ts"],"names":[],"mappings":"AAEA,iBAAe,wBAAwB,CAAC,OAAO,KAAA,EAAE,OAAO,KAAA,iBAKvD;AAED,eAAe,wBAAwB,CAAC;AACxC,OAAO,EAAC,wBAAwB,EAAC,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { z, type ZodObject, type ZodRawShape, type ZodTypeAny } from "zod";
|
|
2
|
+
import type { IPromptTool } from "../interfaces/IAIProvider.js";
|
|
3
|
+
import type { IDraxCrudService } from "@drax/crud-share";
|
|
4
|
+
type ToolBuilderMethod = "create" | "update" | "updatePartial" | "delete" | "findById" | "findByIds" | "findOneBy" | "findOne" | "findBy" | "fetchAll" | "search" | "find" | "paginate" | "groupBy";
|
|
5
|
+
type ToolBuilderService<T = any, C = any, U = any> = IDraxCrudService<T, C, U> & Record<string, any>;
|
|
6
|
+
interface ToolBuilderOptions<T = any, C = any, U = any> {
|
|
7
|
+
entityName: string;
|
|
8
|
+
entityDescription?: string;
|
|
9
|
+
schema: ZodObject<ZodRawShape>;
|
|
10
|
+
outputSchema?: ZodObject<ZodRawShape>;
|
|
11
|
+
service: ToolBuilderService<T, C, U>;
|
|
12
|
+
methods: ToolBuilderMethod[];
|
|
13
|
+
toolNamePrefix?: string;
|
|
14
|
+
}
|
|
15
|
+
declare class ToolBuilder<T = any, C = any, U = any> {
|
|
16
|
+
protected options: ToolBuilderOptions<T, C, U>;
|
|
17
|
+
protected _inputSchema: ZodObject<ZodRawShape>;
|
|
18
|
+
protected _partialInputSchema: ZodObject<ZodRawShape>;
|
|
19
|
+
protected _outputSchema?: ZodObject<ZodRawShape>;
|
|
20
|
+
constructor(options: ToolBuilderOptions<T, C, U>);
|
|
21
|
+
get inputSchema(): z.ZodObject<Readonly<{
|
|
22
|
+
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
23
|
+
}>, z.core.$strip>;
|
|
24
|
+
get partialInputSchema(): z.ZodObject<Readonly<{
|
|
25
|
+
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
26
|
+
}>, z.core.$strip>;
|
|
27
|
+
get outputSchema(): z.ZodObject<Readonly<{
|
|
28
|
+
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
29
|
+
}>, z.core.$strip>;
|
|
30
|
+
getTools(): IPromptTool[];
|
|
31
|
+
getSystemPromptSection(): string;
|
|
32
|
+
objectParameters(schema: ZodObject<ZodRawShape>): z.core.ZodStandardJSONSchemaPayload<z.ZodObject<Readonly<{
|
|
33
|
+
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
34
|
+
}>, z.core.$strip>>;
|
|
35
|
+
protected buildTool(method: ToolBuilderMethod): IPromptTool;
|
|
36
|
+
protected getToolName(method: ToolBuilderMethod): string;
|
|
37
|
+
protected toJsonSchema(schema: ZodObject<ZodRawShape>): z.core.ZodStandardJSONSchemaPayload<z.ZodObject<Readonly<{
|
|
38
|
+
[k: string]: z.core.$ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>;
|
|
39
|
+
}>, z.core.$strip>>;
|
|
40
|
+
protected getTypeName(field: any): string | undefined;
|
|
41
|
+
protected fieldAdapter(field: unknown): ZodTypeAny;
|
|
42
|
+
protected schemaAdapter<TObj extends ZodObject<ZodRawShape>>(schema: TObj): TObj;
|
|
43
|
+
}
|
|
44
|
+
export default ToolBuilder;
|
|
45
|
+
export { ToolBuilder };
|
|
46
|
+
export type { ToolBuilderMethod, ToolBuilderOptions, ToolBuilderService };
|
|
47
|
+
//# sourceMappingURL=ToolBuilder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ToolBuilder.d.ts","sourceRoot":"","sources":["../../src/tools/ToolBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,CAAC,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAC,MAAM,KAAK,CAAC;AACzE,OAAO,KAAK,EAAC,WAAW,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EAAC,gBAAgB,EAAC,MAAM,kBAAkB,CAAC;AAEvD,KAAK,iBAAiB,GAChB,QAAQ,GACR,QAAQ,GACR,eAAe,GACf,QAAQ,GACR,UAAU,GACV,WAAW,GACX,WAAW,GACX,SAAS,GACT,QAAQ,GACR,UAAU,GACV,QAAQ,GACR,MAAM,GACN,UAAU,GACV,SAAS,CAAC;AAEhB,KAAK,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,IAAI,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;AAErG,UAAU,kBAAkB,CAAC,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,GAAG;IAClD,UAAU,EAAE,MAAM,CAAC;IACnB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,MAAM,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IAC/B,YAAY,CAAC,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EAAE,IAAI,GAAG,IAAI;CAUnF;AAED,eAAe,WAAW,CAAC;AAC3B,OAAO,EAAC,WAAW,EAAC,CAAC;AACrB,YAAY,EAAC,iBAAiB,EAAE,kBAAkB,EAAE,kBAAkB,EAAC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Document } from 'chromadb';
|
|
2
|
+
interface VectorDocument {
|
|
3
|
+
id: string;
|
|
4
|
+
content: string;
|
|
5
|
+
metadata?: Record<string, any>;
|
|
6
|
+
embedding?: number[];
|
|
7
|
+
}
|
|
8
|
+
declare class ChromaVector {
|
|
9
|
+
private client;
|
|
10
|
+
private collections;
|
|
11
|
+
constructor(path?: string, database?: string);
|
|
12
|
+
initializeCollection(collectionName: string): Promise<void>;
|
|
13
|
+
addDocument(collectionName: string, document: VectorDocument): Promise<void>;
|
|
14
|
+
queryCollection(collectionName: string, query: string, topK?: number): Promise<Document[]>;
|
|
15
|
+
deleteDocument(collectionName: string, documentId: string): Promise<void>;
|
|
16
|
+
listCollections(): Promise<string[]>;
|
|
17
|
+
deleteCollection(collectionName: string): Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export default ChromaVector;
|
|
20
|
+
export { ChromaVector };
|
|
21
|
+
//# sourceMappingURL=ChromaVector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ChromaVector.d.ts","sourceRoot":"","sources":["../../src/vectors/ChromaVector.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,QAAQ,EAAC,MAAM,UAAU,CAAC;AAE5D,UAAU,cAAc;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,cAAM,YAAY;IAChB,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,WAAW,CAA0B;gBAEjC,IAAI,GAAE,MAAgC,EAAE,QAAS,CAAC,EAAE,MAAM;IAKhE,oBAAoB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAU3D,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAe5E,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,GAAE,MAAU,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAc7F,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAWzE,eAAe,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIpC,gBAAgB,CAAC,cAAc,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAI9D;AAED,eAAe,YAAY,CAAC;AAC5B,OAAO,EAAC,YAAY,EAAC,CAAA"}
|