@dremio/js-sdk 0.42.0 → 0.43.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/README.md +209 -0
- package/dist/cloud/ai/AIResource.d.ts +716 -17
- package/dist/cloud/ai/AIResource.js +40 -18
- package/dist/cloud/ai/AIResource.js.map +1 -1
- package/dist/cloud/ai/DremioModelProvider.d.ts +1 -1
- package/dist/cloud/ai/DremioModelProvider.js +6 -13
- package/dist/cloud/ai/DremioModelProvider.js.map +1 -1
- package/dist/cloud/ai/modelProviderCodec.d.ts +12 -0
- package/dist/cloud/replaceOriginResource.js +4 -0
- package/dist/cloud/replaceOriginResource.js.map +1 -1
- package/dist/common/ConflictResolver.d.ts +9 -1
- package/dist/common/ConflictResolver.js +10 -1
- package/dist/common/ConflictResolver.js.map +1 -1
- package/dist/common/refineRfc9557Schema.d.ts +1 -0
- package/dist/common/refineRfc9557Schema.js +26 -0
- package/dist/common/refineRfc9557Schema.js.map +1 -0
- package/dist/common/sharedExports.d.ts +1 -0
- package/dist/common/sharedExports.js +1 -0
- package/dist/common/sharedExports.js.map +1 -1
- package/dist/enterprise/Dremio.d.ts +1 -1
- package/dist/enterprise/Dremio.js +3 -2
- package/dist/enterprise/Dremio.js.map +1 -1
- package/dist/enterprise/ai/AIResource.d.ts +699 -18
- package/dist/enterprise/ai/AIResource.js +41 -19
- package/dist/enterprise/ai/AIResource.js.map +1 -1
- package/dist/enterprise/ai/chat/ChatSession.d.ts +4 -25
- package/dist/enterprise/ai/chat/ChatSession.js +6 -55
- package/dist/enterprise/ai/chat/ChatSession.js.map +1 -1
- package/dist/enterprise/ai/chat/UserChatMessage.d.ts +38 -22
- package/dist/enterprise/ai/chat/UserChatMessage.js +33 -41
- package/dist/enterprise/ai/chat/UserChatMessage.js.map +1 -1
- package/dist/enterprise/ai/chat/chatEventSchema.d.ts +169 -11
- package/dist/enterprise/ai/chat/chatEventSchema.js +183 -35
- package/dist/enterprise/ai/chat/chatEventSchema.js.map +1 -1
- package/dist/enterprise/ai/chat/eventWrappers/AgentChatPartialResponse.d.ts +0 -6
- package/dist/enterprise/ai/chat/eventWrappers/AgentChatResponse.d.ts +6 -6
- package/dist/enterprise/ai/chat/eventWrappers/AgentChatResponse.js +2 -2
- package/dist/enterprise/ai/chat/eventWrappers/AgentChatResponse.js.map +1 -1
- package/dist/enterprise/ai/chat/index.d.ts +0 -3
- package/dist/enterprise/ai/chat/index.js +0 -1
- package/dist/enterprise/ai/chat/index.js.map +1 -1
- package/dist/enterprise/ai/chat/methods/sendChatMessage.js +4 -1
- package/dist/enterprise/ai/chat/methods/sendChatMessage.js.map +1 -1
- package/dist/enterprise/ai/chat/responseContent/AgentModelResponseContent.d.ts +1 -2
- package/dist/enterprise/ai/chat/responseContent/AgentModelResponseContent.js.map +1 -1
- package/dist/enterprise/ai/chat/responseContent/AgentToolRequestResponseContent.d.ts +1 -2
- package/dist/enterprise/ai/chat/responseContent/AgentToolRequestResponseContent.js +0 -1
- package/dist/enterprise/ai/chat/responseContent/AgentToolRequestResponseContent.js.map +1 -1
- package/dist/enterprise/ai/chat/responseContent/AgentToolResultResponseContent.d.ts +1 -2
- package/dist/enterprise/ai/chat/responseContent/AgentToolResultResponseContent.js +0 -1
- package/dist/enterprise/ai/chat/responseContent/AgentToolResultResponseContent.js.map +1 -1
- package/dist/enterprise/ai/conversations/AgentConversation.d.ts +215 -0
- package/dist/enterprise/ai/conversations/AgentConversation.js +180 -0
- package/dist/enterprise/ai/conversations/AgentConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/conversationPropertiesCodec.d.ts +22 -0
- package/dist/enterprise/ai/conversations/conversationPropertiesCodec.js +62 -0
- package/dist/enterprise/ai/conversations/conversationPropertiesCodec.js.map +1 -0
- package/dist/enterprise/ai/conversations/createConversationMachine.d.ts +682 -0
- package/dist/enterprise/ai/conversations/createConversationMachine.js +354 -0
- package/dist/enterprise/ai/conversations/createConversationMachine.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/createConversation.d.ts +28 -0
- package/dist/enterprise/ai/conversations/methods/createConversation.js +68 -0
- package/dist/enterprise/ai/conversations/methods/createConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/createExchangeRun.d.ts +16 -0
- package/dist/enterprise/ai/conversations/methods/createExchangeRun.js +36 -0
- package/dist/enterprise/ai/conversations/methods/createExchangeRun.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/deleteConversation.d.ts +2 -0
- package/dist/enterprise/ai/conversations/methods/deleteConversation.js +24 -0
- package/dist/enterprise/ai/conversations/methods/deleteConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/listConversations.d.ts +8 -0
- package/dist/enterprise/ai/conversations/methods/listConversations.js +30 -0
- package/dist/enterprise/ai/conversations/methods/listConversations.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversation.d.ts +12 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversation.js +29 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.d.ts +86 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.js +32 -0
- package/dist/enterprise/ai/conversations/methods/retrieveConversationHistory.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/stopExchangeRun.d.ts +2 -0
- package/dist/enterprise/ai/conversations/methods/stopExchangeRun.js +24 -0
- package/dist/enterprise/ai/conversations/methods/stopExchangeRun.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/streamRunEvents.d.ts +6 -0
- package/dist/enterprise/ai/conversations/methods/streamRunEvents.js +33 -0
- package/dist/enterprise/ai/conversations/methods/streamRunEvents.js.map +1 -0
- package/dist/enterprise/ai/conversations/methods/updateConversation.d.ts +15 -0
- package/dist/enterprise/ai/conversations/methods/updateConversation.js +35 -0
- package/dist/enterprise/ai/conversations/methods/updateConversation.js.map +1 -0
- package/dist/enterprise/ai/conversations/reduceChatEvents.d.ts +17 -0
- package/dist/enterprise/ai/conversations/reduceChatEvents.js +74 -0
- package/dist/enterprise/ai/conversations/reduceChatEvents.js.map +1 -0
- package/dist/enterprise/ai/index.d.ts +5 -1
- package/dist/enterprise/ai/index.js +4 -1
- package/dist/enterprise/ai/index.js.map +1 -1
- package/dist/enterprise/ai/modelProvider/ModelProvider.d.ts +15 -1
- package/dist/enterprise/ai/modelProvider/ModelProvider.js +12 -1
- package/dist/enterprise/ai/modelProvider/ModelProvider.js.map +1 -1
- package/dist/enterprise/ai/modelProvider/modelProviderCodec.d.ts +40 -0
- package/dist/enterprise/ai/modelProvider/modelProviderCodec.js +10 -1
- package/dist/enterprise/ai/modelProvider/modelProviderCodec.js.map +1 -1
- package/dist/enterprise/ai/modelProvider/modelProviderConfigSchemas.d.ts +21 -0
- package/dist/enterprise/ai/modelProvider/modelProviderConfigSchemas.js +17 -0
- package/dist/enterprise/ai/modelProvider/modelProviderConfigSchemas.js.map +1 -1
- package/dist/oss/catalog/CatalogReferences/DatasetCatalogReference.d.ts +1 -0
- package/dist/oss/catalog/CatalogReferences/DatasetCatalogReference.js +1 -0
- package/dist/oss/catalog/CatalogReferences/DatasetCatalogReference.js.map +1 -1
- package/dist-iife/cloud.js +21620 -6202
- package/dist-iife/community.js +14 -0
- package/dist-iife/enterprise.js +19404 -4038
- package/package.json +5 -2
- package/dist/enterprise/ai/chat/ChatSessionClient.d.ts +0 -18
- package/dist/enterprise/ai/chat/ChatSessionClient.js +0 -55
- package/dist/enterprise/ai/chat/ChatSessionClient.js.map +0 -1
- package/dist/enterprise/ai/chat/UserChatMessageContent.d.ts +0 -19
- package/dist/enterprise/ai/chat/UserChatMessageContent.js +0 -44
- package/dist/enterprise/ai/chat/UserChatMessageContent.js.map +0 -1
|
@@ -13,18 +13,19 @@
|
|
|
13
13
|
* See the License for the specific language governing permissions and
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
|
-
import { catchError, concatMap, endWith, map, Observable, of, scan, share, startWith } from "rxjs";
|
|
17
16
|
import { ChatSession } from "./chat/ChatSession.js";
|
|
18
|
-
import { AgentChatResponse, } from "./chat/eventWrappers/AgentChatResponse.js";
|
|
19
17
|
import { ModelProvider } from "./modelProvider/ModelProvider.js";
|
|
20
18
|
import * as z from "zod/mini";
|
|
21
19
|
import { modelProviderCreateCodec, modelProviderRetrieveCodec, } from "./modelProvider/modelProviderCodec.js";
|
|
22
20
|
import { safeParseResultToResult } from "../../common/safeParseResultToResult.js";
|
|
23
21
|
import { listModelsPropertiesSchema } from "./modelProvider/modelProviderConfigSchemas.js";
|
|
24
|
-
import { AgentChatExchange } from "./chat/eventWrappers/AgentChatExchange.js";
|
|
25
|
-
import { AgentEndTurn } from "../interfaces.js";
|
|
26
|
-
import { ChatSessionClient } from "./chat/ChatSessionClient.js";
|
|
27
22
|
import { createSendChatMessage } from "./chat/methods/sendChatMessage.js";
|
|
23
|
+
import { listConversations } from "./conversations/methods/listConversations.js";
|
|
24
|
+
import { createConversation, createConversationCodec, } from "./conversations/methods/createConversation.js";
|
|
25
|
+
import { retrieveConversation } from "./conversations/methods/retrieveConversation.js";
|
|
26
|
+
import { AgentConversation } from "../interfaces.js";
|
|
27
|
+
import { retrieveConversationHistory } from "./conversations/methods/retrieveConversationHistory.js";
|
|
28
|
+
import { createConversationMachine } from "./conversations/createConversationMachine.js";
|
|
28
29
|
export function listAvailableModels(config) {
|
|
29
30
|
return function listAvailableModels(properties, { signal } = {}) {
|
|
30
31
|
return config
|
|
@@ -46,6 +47,12 @@ export class AIResource {
|
|
|
46
47
|
constructor(config) {
|
|
47
48
|
this.#config = config;
|
|
48
49
|
}
|
|
50
|
+
get conversationMachine() {
|
|
51
|
+
return createConversationMachine(this.#config);
|
|
52
|
+
}
|
|
53
|
+
createConversation(body) {
|
|
54
|
+
return createConversation(this.#config)(body);
|
|
55
|
+
}
|
|
49
56
|
createModelProvider(properties) {
|
|
50
57
|
const body = z.encode(modelProviderCreateCodec, properties);
|
|
51
58
|
return this.#config
|
|
@@ -61,6 +68,15 @@ export class AIResource {
|
|
|
61
68
|
.map((res) => res.json())
|
|
62
69
|
.map((entity) => new ModelProvider(this.#config, z.decode(modelProviderRetrieveCodec, entity)));
|
|
63
70
|
}
|
|
71
|
+
listConversations() {
|
|
72
|
+
const getPage = listConversations(this.#config);
|
|
73
|
+
return {
|
|
74
|
+
async *data({ signal } = {}) {
|
|
75
|
+
yield* (await getPage({ maxResults: 100 }, { signal }).map((response) => response.data).promise).unwrap();
|
|
76
|
+
},
|
|
77
|
+
getPage,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
64
80
|
listModelProviders() {
|
|
65
81
|
const getPage = ({ signal } = {}) => {
|
|
66
82
|
return this.#config
|
|
@@ -85,6 +101,24 @@ export class AIResource {
|
|
|
85
101
|
listAvailableModels(properties) {
|
|
86
102
|
return listAvailableModels(this.#config)(properties);
|
|
87
103
|
}
|
|
104
|
+
retrieveConversation(id, { signal } = {}) {
|
|
105
|
+
return retrieveConversation(this.#config)(id, { signal }).map((properties) => new AgentConversation(this.#config, properties));
|
|
106
|
+
}
|
|
107
|
+
retrieveConversationHistory(id) {
|
|
108
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
109
|
+
const getPage = (params, { signal } = {}) => retrieveConversationHistory(this.#config)(id, { signal });
|
|
110
|
+
return {
|
|
111
|
+
async *data() {
|
|
112
|
+
const history = await getPage({}).then((result) => {
|
|
113
|
+
if (result.isErr()) {
|
|
114
|
+
throw result.error;
|
|
115
|
+
}
|
|
116
|
+
return result.value;
|
|
117
|
+
});
|
|
118
|
+
yield* history.data;
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
88
122
|
retrieveModelProvider(id, { signal } = {}) {
|
|
89
123
|
return this.#config
|
|
90
124
|
.v4Request(`model-provider/config/${id}`, {
|
|
@@ -96,23 +130,11 @@ export class AIResource {
|
|
|
96
130
|
.map((res) => res.json())
|
|
97
131
|
.map((entity) => new ModelProvider(this.#config, z.decode(modelProviderRetrieveCodec, entity)));
|
|
98
132
|
}
|
|
99
|
-
/**
|
|
100
|
-
* Creates an Observable that emits each time the `AgentChatExchange` is updated
|
|
101
|
-
* with events from the Agent.
|
|
102
|
-
*/
|
|
103
|
-
createAgentChatExchange$(chatSession, userChatMessage, options = {}) {
|
|
104
|
-
const initialAgentChatExchange = new AgentChatExchange(userChatMessage, []);
|
|
105
|
-
return this.sendChatMessage(chatSession, userChatMessage).pipe(map((eventResult) => eventResult.unwrap()), concatMap((agentChatEvent) => options.mapChatEvents?.(agentChatEvent) || of(agentChatEvent)), endWith(new AgentEndTurn({ type: "reply_finished" })), catchError((error) => of(new AgentEndTurn({ error, type: "error" }))), scan((agentChatExchange, agentChatEvent) => agentChatExchange._addChatEvent(agentChatEvent), initialAgentChatExchange), startWith(initialAgentChatExchange), share());
|
|
106
|
-
}
|
|
107
|
-
createChatSessionClient(chatSession) {
|
|
108
|
-
return new ChatSessionClient({
|
|
109
|
-
chatSession,
|
|
110
|
-
createAgentChatExchange$: this.createAgentChatExchange$.bind(this),
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
133
|
/**
|
|
114
134
|
* Sends a chat message to the Dremio AI Agent and returns an Observable containing
|
|
115
135
|
* Agent replies.
|
|
136
|
+
*
|
|
137
|
+
* @deprecated
|
|
116
138
|
*/
|
|
117
139
|
sendChatMessage(chatSession, userChatMessage) {
|
|
118
140
|
return createSendChatMessage(this.#config)(chatSession, userChatMessage);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIResource.js","sourceRoot":"","sources":["../../../src/enterprise/ai/AIResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AACnG,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CA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AAE,CAAC,EAC1C,SAAS,CAAC,CAAC,cAAc,EAAE,EAAE,CAAC,OAAO,CAAC,aAAa,EAAE,CAAC,cAAc,CAAC,IAAI,EAAE,CAAC,cAAc,CAAC,CAAC,EAC5F,OAAO,CAAC,IAAI,YAAY,CAAC,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC,EACrD,UAAU,CAAC,CAAC,KAAc,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,YAAY,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAC9E,IAAI,CACF,CAAC,iBAAiB,EAAE,cAAc,EAAE,EAAE,CAAC,iBAAiB,CAAC,aAAa,CAAC,cAAc,CAAC,EACtF,wBAAwB,CACzB,EACD,SAAS,CAAC,wBAAwB,CAAC,EACnC,KAAK,EAAE,CACR,CAAC;IACJ,CAAC;IAED,uBAAuB,CAAC,WAAwB;QAC9C,OAAO,IAAI,iBAAiB,CAAC;YAC3B,WAAW;YACX,wBAAwB,EAAE,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,IAAI,CAAC;SACnE,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,eAAe,CAAC,WAAwB,EAAE,eAAgC;QACxE,OAAO,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAC3E,CAAC;CACF","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { catchError, concatMap, endWith, map, Observable, of, scan, share, startWith } from \"rxjs\";\nimport { ChatSession } from \"./chat/ChatSession.ts\";\nimport type { UserChatMessage } from \"./chat/UserChatMessage.ts\";\nimport {\n AgentChatResponse,\n type AgentResponseContent,\n} from \"./chat/eventWrappers/AgentChatResponse.ts\";\nimport type { Logger, SonarV4Config, V4Config } from \"../../common/Config.ts\";\nimport { ModelProvider } from \"./modelProvider/ModelProvider.ts\";\nimport * as z from \"zod/mini\";\nimport {\n modelProviderCreateCodec,\n modelProviderRetrieveCodec,\n} from \"./modelProvider/modelProviderCodec.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { safeParseResultToResult } from \"../../common/safeParseResultToResult.ts\";\nimport { listModelsPropertiesSchema } from \"./modelProvider/modelProviderConfigSchemas.ts\";\nimport { AgentChatExchange } from \"./chat/eventWrappers/AgentChatExchange.ts\";\nimport { AgentEndTurn } from \"../interfaces.ts\";\nimport { ChatSessionClient } from \"./chat/ChatSessionClient.ts\";\nimport { createSendChatMessage } from \"./chat/methods/sendChatMessage.ts\";\n\nexport function listAvailableModels(config: V4Config) {\n return function listAvailableModels(\n properties: z.infer<typeof listModelsPropertiesSchema>,\n { signal }: SignalParam = {},\n ) {\n return config\n .v4Request(\"model-provider:listModels\", {\n body: JSON.stringify(z.parse(listModelsPropertiesSchema, properties)),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n method: \"POST\",\n signal,\n })\n .map((res) => res.json() as Promise<{ models: string[] }>)\n .map((result) => new Set(result.models));\n };\n}\n\nexport class AIResource {\n #config: Logger & V4Config & SonarV4Config;\n\n constructor(config: Logger & V4Config & SonarV4Config) {\n this.#config = config;\n }\n\n createModelProvider(properties: z.output<typeof modelProviderCreateCodec>) {\n const body = z.encode(modelProviderCreateCodec, properties);\n return this.#config\n .v4Request(`model-provider/config`, {\n body: JSON.stringify(body),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map((res) => res.json() as Promise<z.input<typeof modelProviderRetrieveCodec>>)\n .map(\n (entity) => new ModelProvider(this.#config, z.decode(modelProviderRetrieveCodec, entity)),\n );\n }\n\n listModelProviders() {\n const getPage = ({ signal }: SignalParam = {}) => {\n return this.#config\n .v4Request(\"model-provider/config\", {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map(\n (res) => res.json() as Promise<{ configs: z.input<typeof modelProviderRetrieveCodec>[] }>,\n )\n .map((response) => ({\n data: response.configs.map((entity) =>\n safeParseResultToResult(z.safeDecode(modelProviderRetrieveCodec, entity)).map(\n (properties) => new ModelProvider(this.#config, properties),\n ),\n ),\n }));\n };\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* (await getPage({ signal }).promise).map((response) => response.data).unwrap();\n },\n getPage,\n };\n }\n\n listAvailableModels(properties: z.infer<typeof listModelsPropertiesSchema>) {\n return listAvailableModels(this.#config)(properties);\n }\n\n retrieveModelProvider(id: string, { signal }: SignalParam = {}) {\n return this.#config\n .v4Request(`model-provider/config/${id}`, {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof modelProviderRetrieveCodec>>)\n .map(\n (entity) => new ModelProvider(this.#config, z.decode(modelProviderRetrieveCodec, entity)),\n );\n }\n\n /**\n * Creates an Observable that emits each time the `AgentChatExchange` is updated\n * with events from the Agent.\n */\n createAgentChatExchange$<T extends AgentResponseContent>(\n chatSession: ChatSession,\n userChatMessage: UserChatMessage,\n options: {\n mapChatEvents?: (\n v: AgentChatResponse<AgentResponseContent>,\n ) => Observable<AgentChatResponse<T>>;\n } = {},\n ) {\n const initialAgentChatExchange = new AgentChatExchange(userChatMessage, []);\n\n return this.sendChatMessage(chatSession, userChatMessage).pipe(\n map((eventResult) => eventResult.unwrap()),\n concatMap((agentChatEvent) => options.mapChatEvents?.(agentChatEvent) || of(agentChatEvent)),\n endWith(new AgentEndTurn({ type: \"reply_finished\" })),\n catchError((error: unknown) => of(new AgentEndTurn({ error, type: \"error\" }))),\n scan(\n (agentChatExchange, agentChatEvent) => agentChatExchange._addChatEvent(agentChatEvent),\n initialAgentChatExchange,\n ),\n startWith(initialAgentChatExchange),\n share(),\n );\n }\n\n createChatSessionClient(chatSession: ChatSession) {\n return new ChatSessionClient({\n chatSession,\n createAgentChatExchange$: this.createAgentChatExchange$.bind(this),\n });\n }\n\n /**\n * Sends a chat message to the Dremio AI Agent and returns an Observable containing\n * Agent replies.\n */\n sendChatMessage(chatSession: ChatSession, userChatMessage: UserChatMessage) {\n return createSendChatMessage(this.#config)(chatSession, userChatMessage);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"AIResource.js","sourceRoot":"","sources":["../../../src/enterprise/ai/AIResource.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGpD,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAC9B,OAAO,EACL,wBAAwB,EACxB,0BAA0B,GAC3B,MAAM,uCAAuC,CAAC;AAE/C,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,+CAA+C,CAAC;AAC3F,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8CAA8C,CAAC;AACjF,OAAO,EACL,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,+CAA+C,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAkB,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,2BAA2B,EAAE,MAAM,wDAAwD,CAAC;AAErG,OAAO,EAAE,yBAAyB,EAAE,MAAM,8CAA8C,CAAC;AAEzF,MAAM,UAAU,mBAAmB,CAAC,MAAgB;IAClD,OAAO,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AK,CAAC;oBACrB,CAAC;oBACD,OAAO,MAAM,CAAC,KAAK,CAAC;gBACtB,CAAC,CAAC,CAAC;gBACH,KAAK,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC;YACtB,CAAC;SACF,CAAC;IACJ,CAAC;IAED,qBAAqB,CAAC,EAAU,EAAE,EAAE,MAAM,KAAkB,EAAE;QAC5D,OAAO,IAAI,CAAC,OAAO;aAChB,SAAS,CAAC,yBAAyB,EAAE,EAAE,EAAE;YACxC,OAAO,EAAE;gBACP,MAAM,EAAE,kBAAkB;aAC3B;YACD,MAAM;SACP,CAAC;aACD,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAyD,CAAC;aAC/E,GAAG,CACF,CAAC,MAAM,EAAE,EAAE,CAAC,IAAI,aAAa,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,MAAM,CAAC,0BAA0B,EAAE,MAAM,CAAC,CAAC,CAC1F,CAAC;IACN,CAAC;IAED;;;;;OAKG;IACH,eAAe,CAAC,WAAwB,EAAE,eAAgC;QACxE,OAAO,qBAAqB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;IAC3E,CAAC;CACF","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { ChatSession } from \"./chat/ChatSession.ts\";\nimport type { UserChatMessage } from \"./chat/UserChatMessage.ts\";\nimport type { Logger, SonarV4Config, V4Config } from \"../../common/Config.ts\";\nimport { ModelProvider } from \"./modelProvider/ModelProvider.ts\";\nimport * as z from \"zod/mini\";\nimport {\n modelProviderCreateCodec,\n modelProviderRetrieveCodec,\n} from \"./modelProvider/modelProviderCodec.ts\";\nimport type { SignalParam } from \"../../common/Params.ts\";\nimport { safeParseResultToResult } from \"../../common/safeParseResultToResult.ts\";\nimport { listModelsPropertiesSchema } from \"./modelProvider/modelProviderConfigSchemas.ts\";\nimport { createSendChatMessage } from \"./chat/methods/sendChatMessage.ts\";\nimport { listConversations } from \"./conversations/methods/listConversations.ts\";\nimport {\n createConversation,\n createConversationCodec,\n} from \"./conversations/methods/createConversation.ts\";\nimport { retrieveConversation } from \"./conversations/methods/retrieveConversation.ts\";\nimport { AgentConversation, type ChatEvent } from \"../interfaces.ts\";\nimport { retrieveConversationHistory } from \"./conversations/methods/retrieveConversationHistory.ts\";\nimport type { HttpError } from \"../../common/HttpError.ts\";\nimport { createConversationMachine } from \"./conversations/createConversationMachine.ts\";\n\nexport function listAvailableModels(config: V4Config) {\n return function listAvailableModels(\n properties: z.infer<typeof listModelsPropertiesSchema>,\n { signal }: SignalParam = {},\n ) {\n return config\n .v4Request(\"model-provider:listModels\", {\n body: JSON.stringify(z.parse(listModelsPropertiesSchema, properties)),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n method: \"POST\",\n signal,\n })\n .map((res) => res.json() as Promise<{ models: { name: string; isRecommended: boolean }[] }>)\n .map((result) => new Set(result.models));\n };\n}\n\nexport class AIResource {\n #config: Logger & V4Config & SonarV4Config;\n\n constructor(config: Logger & V4Config & SonarV4Config) {\n this.#config = config;\n }\n\n get conversationMachine() {\n return createConversationMachine(this.#config);\n }\n\n createConversation(body: z.input<typeof createConversationCodec>) {\n return createConversation(this.#config)(body);\n }\n\n createModelProvider(properties: z.output<typeof modelProviderCreateCodec>) {\n const body = z.encode(modelProviderCreateCodec, properties);\n return this.#config\n .v4Request(`model-provider/config`, {\n body: JSON.stringify(body),\n headers: {\n Accept: \"application/json\",\n \"Content-Type\": \"application/json\",\n },\n keepalive: true,\n method: \"POST\",\n })\n .map((res) => res.json() as Promise<z.input<typeof modelProviderRetrieveCodec>>)\n .map(\n (entity) => new ModelProvider(this.#config, z.decode(modelProviderRetrieveCodec, entity)),\n );\n }\n\n listConversations() {\n const getPage = listConversations(this.#config);\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* (\n await getPage({ maxResults: 100 }, { signal }).map((response) => response.data).promise\n ).unwrap();\n },\n getPage,\n };\n }\n\n listModelProviders() {\n const getPage = ({ signal }: SignalParam = {}) => {\n return this.#config\n .v4Request(\"model-provider/config\", {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map(\n (res) => res.json() as Promise<{ configs: z.input<typeof modelProviderRetrieveCodec>[] }>,\n )\n .map((response) => ({\n data: response.configs.map((entity) =>\n safeParseResultToResult(z.safeDecode(modelProviderRetrieveCodec, entity)).map(\n (properties) => new ModelProvider(this.#config, properties),\n ),\n ),\n }));\n };\n return {\n async *data({ signal }: SignalParam = {}) {\n yield* (await getPage({ signal }).promise).map((response) => response.data).unwrap();\n },\n getPage,\n };\n }\n\n listAvailableModels(properties: z.infer<typeof listModelsPropertiesSchema>) {\n return listAvailableModels(this.#config)(properties);\n }\n\n retrieveConversation(id: string, { signal }: SignalParam = {}) {\n return retrieveConversation(this.#config)(id, { signal }).map(\n (properties) => new AgentConversation(this.#config, properties),\n );\n }\n\n retrieveConversationHistory(id: string) {\n // eslint-disable-next-line @typescript-eslint/no-empty-object-type\n const getPage = (params: {}, { signal }: SignalParam = {}) =>\n retrieveConversationHistory(this.#config)(id, { signal });\n return {\n async *data(): AsyncGenerator<ChatEvent, void, HttpError> {\n const history = await getPage({}).then((result) => {\n if (result.isErr()) {\n throw result.error;\n }\n return result.value;\n });\n yield* history.data;\n },\n };\n }\n\n retrieveModelProvider(id: string, { signal }: SignalParam = {}) {\n return this.#config\n .v4Request(`model-provider/config/${id}`, {\n headers: {\n Accept: \"application/json\",\n },\n signal,\n })\n .map((res) => res.json() as Promise<z.input<typeof modelProviderRetrieveCodec>>)\n .map(\n (entity) => new ModelProvider(this.#config, z.decode(modelProviderRetrieveCodec, entity)),\n );\n }\n\n /**\n * Sends a chat message to the Dremio AI Agent and returns an Observable containing\n * Agent replies.\n *\n * @deprecated\n */\n sendChatMessage(chatSession: ChatSession, userChatMessage: UserChatMessage) {\n return createSendChatMessage(this.#config)(chatSession, userChatMessage);\n }\n}\n"]}
|
|
@@ -1,40 +1,22 @@
|
|
|
1
1
|
import * as z from "zod/mini";
|
|
2
|
-
import { Temporal } from "temporal-polyfill";
|
|
3
2
|
declare const chatSessionInputSchema: z.ZodMiniObject<{
|
|
4
|
-
createdAt: z.ZodMiniString<string>;
|
|
5
3
|
id: z.ZodMiniString<string>;
|
|
6
4
|
modelName: z.ZodMiniString<string>;
|
|
7
5
|
modelProviderId: z.ZodMiniString<string>;
|
|
8
|
-
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
9
|
-
updatedAt: z.ZodMiniString<string>;
|
|
10
6
|
}, z.core.$strip>;
|
|
11
7
|
declare const newChatSessionSchema: z.ZodMiniObject<{
|
|
12
8
|
modelName: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
13
9
|
modelProviderId: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
14
10
|
}, z.core.$strip>;
|
|
15
|
-
/**
|
|
16
|
-
* Tracks an Agent chat session. Each field is optional and intentionally mutable
|
|
17
|
-
* so that if any of these fields become available during agent reply (such as which
|
|
18
|
-
* default model provider and name it picked, as well as the server-generated sessionId),
|
|
19
|
-
* they're mutated on the instance of the class.
|
|
20
|
-
*/
|
|
21
11
|
export declare class ChatSession {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
get modelProviderId(): string | undefined;
|
|
27
|
-
get title(): string | undefined;
|
|
28
|
-
get updatedAt(): Temporal.Instant;
|
|
29
|
-
private constructor();
|
|
30
|
-
[Symbol.observable](): import("rxjs").Observable<ChatSession>;
|
|
12
|
+
id?: string;
|
|
13
|
+
modelName?: string;
|
|
14
|
+
modelProviderId?: string;
|
|
15
|
+
constructor(properties?: Partial<z.infer<typeof chatSessionInputSchema>>);
|
|
31
16
|
toJSON(): {
|
|
32
|
-
createdAt: string;
|
|
33
17
|
id: string;
|
|
34
18
|
modelName: string;
|
|
35
19
|
modelProviderId: string;
|
|
36
|
-
updatedAt: string;
|
|
37
|
-
title?: string | undefined;
|
|
38
20
|
};
|
|
39
21
|
assign(properties: Partial<z.infer<typeof chatSessionInputSchema>>): void;
|
|
40
22
|
equals(other: unknown): boolean;
|
|
@@ -45,12 +27,9 @@ export declare class ChatSession {
|
|
|
45
27
|
*/
|
|
46
28
|
static new(options?: z.infer<typeof newChatSessionSchema>): ChatSession;
|
|
47
29
|
static codec: z.ZodMiniCodec<z.ZodMiniObject<{
|
|
48
|
-
createdAt: z.ZodMiniString<string>;
|
|
49
30
|
id: z.ZodMiniString<string>;
|
|
50
31
|
modelName: z.ZodMiniString<string>;
|
|
51
32
|
modelProviderId: z.ZodMiniString<string>;
|
|
52
|
-
title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
53
|
-
updatedAt: z.ZodMiniString<string>;
|
|
54
33
|
}, z.core.$strip>, z.ZodMiniCustom<ChatSession, ChatSession>>;
|
|
55
34
|
}
|
|
56
35
|
export {};
|
|
@@ -14,81 +14,35 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import * as z from "zod/mini";
|
|
17
|
-
import { Temporal } from "temporal-polyfill";
|
|
18
|
-
import { BehaviorSubject } from "rxjs";
|
|
19
17
|
const chatSessionInputSchema = z.object({
|
|
20
|
-
createdAt: z.string().check(z.iso.datetime()),
|
|
21
18
|
id: z.string(),
|
|
22
19
|
modelName: z.string(),
|
|
23
20
|
modelProviderId: z.string(),
|
|
24
|
-
title: z.optional(z.string()),
|
|
25
|
-
updatedAt: z.string().check(z.iso.datetime()),
|
|
26
21
|
});
|
|
27
22
|
const newChatSessionSchema = z.partial(z.pick(chatSessionInputSchema, {
|
|
28
23
|
modelName: true,
|
|
29
24
|
modelProviderId: true,
|
|
30
25
|
}));
|
|
31
|
-
/**
|
|
32
|
-
* Tracks an Agent chat session. Each field is optional and intentionally mutable
|
|
33
|
-
* so that if any of these fields become available during agent reply (such as which
|
|
34
|
-
* default model provider and name it picked, as well as the server-generated sessionId),
|
|
35
|
-
* they're mutated on the instance of the class.
|
|
36
|
-
*/
|
|
37
26
|
export class ChatSession {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
#modelProviderId;
|
|
42
|
-
#title;
|
|
43
|
-
#updatedAt = Temporal.Now.instant();
|
|
44
|
-
#bus = new BehaviorSubject(this);
|
|
45
|
-
get createdAt() {
|
|
46
|
-
return this.#createdAt;
|
|
47
|
-
}
|
|
48
|
-
get id() {
|
|
49
|
-
return this.#id;
|
|
50
|
-
}
|
|
51
|
-
get modelName() {
|
|
52
|
-
return this.#modelName;
|
|
53
|
-
}
|
|
54
|
-
get modelProviderId() {
|
|
55
|
-
return this.#modelProviderId;
|
|
56
|
-
}
|
|
57
|
-
get title() {
|
|
58
|
-
return this.#title;
|
|
59
|
-
}
|
|
60
|
-
get updatedAt() {
|
|
61
|
-
return this.#updatedAt;
|
|
62
|
-
}
|
|
27
|
+
id;
|
|
28
|
+
modelName;
|
|
29
|
+
modelProviderId;
|
|
63
30
|
constructor(properties = {}) {
|
|
64
31
|
this.assign(properties);
|
|
65
32
|
}
|
|
66
|
-
[Symbol.observable]() {
|
|
67
|
-
return this.#bus.asObservable();
|
|
68
|
-
}
|
|
69
33
|
toJSON() {
|
|
70
34
|
return z.encode(ChatSession.codec, this);
|
|
71
35
|
}
|
|
72
36
|
assign(properties) {
|
|
73
|
-
if (properties.createdAt) {
|
|
74
|
-
this.#createdAt = Temporal.Instant.from(properties.createdAt);
|
|
75
|
-
}
|
|
76
37
|
if (properties.id) {
|
|
77
|
-
this
|
|
38
|
+
this.id = properties.id;
|
|
78
39
|
}
|
|
79
40
|
if (properties.modelName) {
|
|
80
|
-
this
|
|
41
|
+
this.modelName = properties.modelName;
|
|
81
42
|
}
|
|
82
43
|
if (properties.modelProviderId) {
|
|
83
|
-
this
|
|
84
|
-
}
|
|
85
|
-
if (properties.title) {
|
|
86
|
-
this.#title = properties.title;
|
|
87
|
-
}
|
|
88
|
-
if (properties.updatedAt) {
|
|
89
|
-
this.#updatedAt = Temporal.Instant.from(properties.updatedAt);
|
|
44
|
+
this.modelProviderId = properties.modelProviderId;
|
|
90
45
|
}
|
|
91
|
-
this.#bus.next(this);
|
|
92
46
|
}
|
|
93
47
|
equals(other) {
|
|
94
48
|
return (other instanceof ChatSession &&
|
|
@@ -113,12 +67,9 @@ export class ChatSession {
|
|
|
113
67
|
throw new Error("An uninitialized ChatSession cannot be encoded.");
|
|
114
68
|
}
|
|
115
69
|
return {
|
|
116
|
-
createdAt: v.createdAt.toString(),
|
|
117
70
|
id: v.id,
|
|
118
71
|
modelName: v.modelName,
|
|
119
72
|
modelProviderId: v.modelProviderId,
|
|
120
|
-
title: v.title,
|
|
121
|
-
updatedAt: v.updatedAt.toString(),
|
|
122
73
|
};
|
|
123
74
|
},
|
|
124
75
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChatSession.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/chat/ChatSession.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"ChatSession.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/chat/ChatSession.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,MAAM,sBAAsB,GAAG,CAAC,CAAC,MAAM,CAAC;IACtC,EAAE,EAAE,CAAC,CAAC,MAAM,EAAE;IACd,SAAS,EAAE,CAAC,CAAC,MAAM,EA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;IAC3C,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,GAAG,CAAC,UAAgD,EAAE;QAC3D,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,KAAK,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC,CAAC;IACjE,CAAC;IAED,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,KAAK,CACpB,sBAAsB,EACtB,CAAC,CAAC,MAAM,CAAc,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,YAAY,WAAW,CAAC,EACtD;QACE,MAAM,CAAC,CAAC;YACN,OAAO,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;QAC5B,CAAC;QACD,MAAM,CAAC,CAAC;YACN,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;gBACV,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;YACrE,CAAC;YACD,OAAO;gBACL,EAAE,EAAE,CAAC,CAAC,EAAE;gBACR,SAAS,EAAE,CAAC,CAAC,SAAU;gBACvB,eAAe,EAAE,CAAC,CAAC,eAAgB;aACpC,CAAC;QACJ,CAAC;KACF,CACF,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport * as z from \"zod/mini\";\n\nconst chatSessionInputSchema = z.object({\n id: z.string(),\n modelName: z.string(),\n modelProviderId: z.string(),\n});\n\nconst newChatSessionSchema = z.partial(\n z.pick(chatSessionInputSchema, {\n modelName: true,\n modelProviderId: true,\n }),\n);\n\nexport class ChatSession {\n id?: string;\n modelName?: string;\n modelProviderId?: string;\n\n constructor(properties: Partial<z.infer<typeof chatSessionInputSchema>> = {}) {\n this.assign(properties);\n }\n\n toJSON() {\n return z.encode(ChatSession.codec, this);\n }\n\n assign(properties: Partial<z.infer<typeof chatSessionInputSchema>>) {\n if (properties.id) {\n this.id = properties.id;\n }\n if (properties.modelName) {\n this.modelName = properties.modelName;\n }\n if (properties.modelProviderId) {\n this.modelProviderId = properties.modelProviderId;\n }\n }\n\n equals(other: unknown) {\n return (\n other instanceof ChatSession &&\n (this === other || (this.id === other.id && (!!this.id || !!other.id)))\n );\n }\n\n static fromJSON(data: z.input<typeof ChatSession.codec>) {\n return z.decode(ChatSession.codec, data);\n }\n\n /**\n * Creates a new ChatSession with fields that will be populated automatically\n * once a reply is received from the Dremio AI Agent.\n */\n static new(options: z.infer<typeof newChatSessionSchema> = {}) {\n return new ChatSession(z.parse(newChatSessionSchema, options));\n }\n\n static codec = z.codec(\n chatSessionInputSchema,\n z.custom<ChatSession>((v) => v instanceof ChatSession),\n {\n decode(v) {\n return new ChatSession(v);\n },\n encode(v) {\n if (!v.id) {\n throw new Error(\"An uninitialized ChatSession cannot be encoded.\");\n }\n return {\n id: v.id,\n modelName: v.modelName!,\n modelProviderId: v.modelProviderId!,\n };\n },\n },\n );\n}\n"]}
|
|
@@ -1,30 +1,46 @@
|
|
|
1
|
-
import * as z from "zod/mini";
|
|
2
1
|
import { Temporal } from "temporal-polyfill";
|
|
3
|
-
import
|
|
2
|
+
import * as z from "zod/mini";
|
|
4
3
|
export declare class UserChatMessage {
|
|
5
|
-
readonly createdAt: Temporal.
|
|
6
|
-
readonly content:
|
|
4
|
+
readonly createdAt: Temporal.ZonedDateTime;
|
|
5
|
+
readonly content: string;
|
|
7
6
|
readonly id: string;
|
|
8
|
-
readonly
|
|
9
|
-
constructor(
|
|
10
|
-
|
|
11
|
-
mergeContext(context: NonNullable<UserChatMessage["context"]>): UserChatMessage;
|
|
12
|
-
toString(): string;
|
|
7
|
+
readonly prompt?: Omit<z.infer<typeof createConversationPromptSchema>, "text">;
|
|
8
|
+
constructor(id: UserChatMessage["id"], createdAt: UserChatMessage["createdAt"], content: UserChatMessage["content"], prompt?: UserChatMessage["prompt"]);
|
|
9
|
+
withPrompt(prompt: UserChatMessage["prompt"]): UserChatMessage;
|
|
13
10
|
toJSON(): {
|
|
14
|
-
content:
|
|
15
|
-
content: string;
|
|
16
|
-
type: "string";
|
|
17
|
-
};
|
|
11
|
+
content: string;
|
|
18
12
|
createdAt: string;
|
|
19
13
|
id: string;
|
|
14
|
+
prompt: Omit<{
|
|
15
|
+
text: string;
|
|
16
|
+
approvals?: {
|
|
17
|
+
allToolsAllowed: boolean;
|
|
18
|
+
approvalNonce: string;
|
|
19
|
+
toolDecisions: {
|
|
20
|
+
approved: boolean;
|
|
21
|
+
arguments: Record<string, unknown>;
|
|
22
|
+
executionId: string;
|
|
23
|
+
name: string;
|
|
24
|
+
}[];
|
|
25
|
+
} | undefined;
|
|
26
|
+
context?: string | undefined;
|
|
27
|
+
skillIds?: string[] | undefined;
|
|
28
|
+
}, "text"> | undefined;
|
|
20
29
|
};
|
|
21
|
-
static
|
|
22
|
-
static codec: z.ZodMiniCodec<z.ZodMiniObject<{
|
|
23
|
-
content: z.ZodMiniObject<{
|
|
24
|
-
content: z.ZodMiniString<string>;
|
|
25
|
-
type: z.ZodMiniLiteral<"string">;
|
|
26
|
-
}, z.core.$strip>;
|
|
27
|
-
createdAt: z.ZodMiniString<string>;
|
|
28
|
-
id: z.ZodMiniString<string>;
|
|
29
|
-
}, z.core.$strip>, z.ZodMiniCustom<UserChatMessage, UserChatMessage>>;
|
|
30
|
+
static new(content: UserChatMessage["content"], prompt?: UserChatMessage["prompt"]): UserChatMessage;
|
|
30
31
|
}
|
|
32
|
+
export declare const createConversationPromptSchema: z.ZodMiniObject<{
|
|
33
|
+
approvals: z.ZodMiniOptional<z.ZodMiniObject<{
|
|
34
|
+
allToolsAllowed: z.ZodMiniBoolean<boolean>;
|
|
35
|
+
approvalNonce: z.ZodMiniString<string>;
|
|
36
|
+
toolDecisions: z.ZodMiniArray<z.ZodMiniObject<{
|
|
37
|
+
approved: z.ZodMiniBoolean<boolean>;
|
|
38
|
+
arguments: z.ZodMiniRecord<z.ZodMiniString<string>, z.ZodMiniUnknown>;
|
|
39
|
+
executionId: z.ZodMiniString<string>;
|
|
40
|
+
name: z.ZodMiniString<string>;
|
|
41
|
+
}, z.core.$strip>>;
|
|
42
|
+
}, z.core.$strip>>;
|
|
43
|
+
context: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
44
|
+
skillIds: z.ZodMiniOptional<z.ZodMiniArray<z.ZodMiniString<string>>>;
|
|
45
|
+
text: z.ZodMiniString<string>;
|
|
46
|
+
}, z.core.$strict>;
|
|
@@ -14,55 +14,47 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
import { nanoid } from "nanoid/non-secure";
|
|
17
|
-
import * as z from "zod/mini";
|
|
18
17
|
import { Temporal } from "temporal-polyfill";
|
|
19
|
-
import
|
|
18
|
+
import * as z from "zod/mini";
|
|
20
19
|
export class UserChatMessage {
|
|
21
|
-
createdAt
|
|
20
|
+
createdAt;
|
|
22
21
|
content;
|
|
23
|
-
id
|
|
24
|
-
|
|
25
|
-
constructor(
|
|
22
|
+
id;
|
|
23
|
+
prompt;
|
|
24
|
+
constructor(id, createdAt, content, prompt) {
|
|
25
|
+
this.id = id;
|
|
26
|
+
this.createdAt = createdAt;
|
|
26
27
|
this.content = content;
|
|
27
|
-
this.
|
|
28
|
-
if (id) {
|
|
29
|
-
this.id = id;
|
|
30
|
-
}
|
|
31
|
-
if (createdAt) {
|
|
32
|
-
this.createdAt = createdAt;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
withContext(context) {
|
|
36
|
-
return new UserChatMessage(this.content, context, this.id, this.createdAt);
|
|
37
|
-
}
|
|
38
|
-
mergeContext(context) {
|
|
39
|
-
return new UserChatMessage(this.content, { ...this.context, ...context }, this.id);
|
|
28
|
+
this.prompt = prompt;
|
|
40
29
|
}
|
|
41
|
-
|
|
42
|
-
return (this.
|
|
43
|
-
(this.context ? `\n\n<system-context>${JSON.stringify(this.context)}</system-context>` : ""));
|
|
30
|
+
withPrompt(prompt) {
|
|
31
|
+
return new UserChatMessage(this.id, this.createdAt, this.content, prompt);
|
|
44
32
|
}
|
|
45
33
|
toJSON() {
|
|
46
|
-
return
|
|
34
|
+
return {
|
|
35
|
+
content: this.content,
|
|
36
|
+
createdAt: this.createdAt.toString(),
|
|
37
|
+
id: this.id,
|
|
38
|
+
prompt: this.prompt,
|
|
39
|
+
};
|
|
47
40
|
}
|
|
48
|
-
static
|
|
49
|
-
return
|
|
41
|
+
static new(content, prompt) {
|
|
42
|
+
return new UserChatMessage(nanoid(), Temporal.Now.zonedDateTimeISO(), content, prompt);
|
|
50
43
|
}
|
|
51
|
-
static codec = z.codec(z.object({
|
|
52
|
-
content: userChatMessageContentCodec.def.in,
|
|
53
|
-
createdAt: z.string().check(z.iso.datetime()),
|
|
54
|
-
id: z.string(),
|
|
55
|
-
}), z.instanceof(UserChatMessage), {
|
|
56
|
-
decode(v) {
|
|
57
|
-
return new UserChatMessage(z.decode(userChatMessageContentCodec, v.content), undefined, v.id);
|
|
58
|
-
},
|
|
59
|
-
encode(v) {
|
|
60
|
-
return {
|
|
61
|
-
...v,
|
|
62
|
-
content: z.encode(userChatMessageContentCodec, v.content),
|
|
63
|
-
createdAt: v.createdAt.toString(),
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
});
|
|
67
44
|
}
|
|
45
|
+
export const createConversationPromptSchema = z.strictObject({
|
|
46
|
+
approvals: z.optional(z.object({
|
|
47
|
+
allToolsAllowed: z.boolean(),
|
|
48
|
+
approvalNonce: z.string(),
|
|
49
|
+
toolDecisions: z.array(z.object({
|
|
50
|
+
approved: z.boolean(),
|
|
51
|
+
arguments: z.record(z.string(), z.unknown()),
|
|
52
|
+
executionId: z.string(),
|
|
53
|
+
name: z.string(),
|
|
54
|
+
})),
|
|
55
|
+
})),
|
|
56
|
+
context: z.optional(z.string()),
|
|
57
|
+
skillIds: z.optional(z.array(z.string())),
|
|
58
|
+
text: z.string(),
|
|
59
|
+
});
|
|
68
60
|
//# sourceMappingURL=UserChatMessage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"UserChatMessage.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/chat/UserChatMessage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,
|
|
1
|
+
{"version":3,"file":"UserChatMessage.js","sourceRoot":"","sources":["../../../../src/enterprise/ai/chat/UserChatMessage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAE9B,MAAM,OAAO,eAAe;IACjB,SAAS,CAAyB;IAClC,OAAO,CAAS;IAChB,EAAE,CAAS;IACX,MAAM,CAAgE;IAE/E,YACE,EAAyB,EACzB,SAAuC,EACvC,OAAmC,EACnC,MAAkC;QAElC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;QACb,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,UAAU,CAAC,MAAiC;QAC1C,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IAC5E,CAAC;IAED,MAAM;QACJ,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,SAAS,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;YACpC,EAAE,EAAE,IAAI,CAAC,EAAE;YACX,MAAM,EAAE,IAAI,CAAC,MAAM;SACpB,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,OAAmC,EAAE,MAAkC;QAChF,OAAO,IAAI,eAAe,CAAC,MAAM,EAAE,EAAE,QAAQ,CAAC,GAAG,CAAC,gBAAgB,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;IACzF,CAAC;CACF;AAED,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,CAAC,YAAY,CAAC;IAC3D,SAAS,EAAE,CAAC,CAAC,QAAQ,CACnB,CAAC,CAAC,MAAM,CAAC;QACP,eAAe,EAAE,CAAC,CAAC,OAAO,EAAE;QAC5B,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE;QACzB,aAAa,EAAE,CAAC,CAAC,KAAK,CACpB,CAAC,CAAC,MAAM,CAAC;YACP,QAAQ,EAAE,CAAC,CAAC,OAAO,EAAE;YACrB,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;YAC5C,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE;YACvB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;SACjB,CAAC,CACH;KACF,CAAC,CACH;IACD,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;IAC/B,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACzC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;CACjB,CAAC,CAAC","sourcesContent":["/*\n * Copyright (C) 2024-2025 Dremio Corporation\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { nanoid } from \"nanoid/non-secure\";\nimport { Temporal } from \"temporal-polyfill\";\nimport * as z from \"zod/mini\";\n\nexport class UserChatMessage {\n readonly createdAt: Temporal.ZonedDateTime;\n readonly content: string;\n readonly id: string;\n readonly prompt?: Omit<z.infer<typeof createConversationPromptSchema>, \"text\">;\n\n constructor(\n id: UserChatMessage[\"id\"],\n createdAt: UserChatMessage[\"createdAt\"],\n content: UserChatMessage[\"content\"],\n prompt?: UserChatMessage[\"prompt\"],\n ) {\n this.id = id;\n this.createdAt = createdAt;\n this.content = content;\n this.prompt = prompt;\n }\n\n withPrompt(prompt: UserChatMessage[\"prompt\"]) {\n return new UserChatMessage(this.id, this.createdAt, this.content, prompt);\n }\n\n toJSON() {\n return {\n content: this.content,\n createdAt: this.createdAt.toString(),\n id: this.id,\n prompt: this.prompt,\n };\n }\n\n static new(content: UserChatMessage[\"content\"], prompt?: UserChatMessage[\"prompt\"]) {\n return new UserChatMessage(nanoid(), Temporal.Now.zonedDateTimeISO(), content, prompt);\n }\n}\n\nexport const createConversationPromptSchema = z.strictObject({\n approvals: z.optional(\n z.object({\n allToolsAllowed: z.boolean(),\n approvalNonce: z.string(),\n toolDecisions: z.array(\n z.object({\n approved: z.boolean(),\n arguments: z.record(z.string(), z.unknown()),\n executionId: z.string(),\n name: z.string(),\n }),\n ),\n }),\n ),\n context: z.optional(z.string()),\n skillIds: z.optional(z.array(z.string())),\n text: z.string(),\n});\n"]}
|