@burdenoff/microfe-botmanor 2026.1008.1 → 2026.1009.1
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/botlit/components/AssistantRuntimeSetupPanel.js +1 -1
- package/dist/botlit/components/AssistantRuntimeSetupPanel.js.map +1 -1
- package/dist/botlit/components/ModelRegistrationPanel.js +174 -0
- package/dist/botlit/components/ModelRegistrationPanel.js.map +1 -0
- package/dist/botlit/hooks/internal/workspaceGateway.js +1 -1
- package/dist/botlit/hooks/useAssistantRuntimeSetup.js +2 -2
- package/dist/botlit/hooks/useAssistantRuntimeSetup.js.map +1 -1
- package/dist/botlit/hooks/useLLMProviders.js +94 -50
- package/dist/botlit/hooks/useLLMProviders.js.map +1 -1
- package/dist/botlit/pages/AgentBuilderPage.js +206 -183
- package/dist/botlit/pages/AgentBuilderPage.js.map +1 -1
- package/dist/botlit/pages/KnowledgeBaseDetailPage.js +162 -145
- package/dist/botlit/pages/KnowledgeBaseDetailPage.js.map +1 -1
- package/dist/botlit/pages/SettingsPage.js +129 -66
- package/dist/botlit/pages/SettingsPage.js.map +1 -1
- package/dist/botlit/utils/embedding-models.js +36 -0
- package/dist/botlit/utils/embedding-models.js.map +1 -0
- package/dist/generated/wspace-operations.js +58 -36
- package/dist/generated/wspace-operations.js.map +1 -1
- package/package.json +1 -1
|
@@ -62,7 +62,7 @@ function c({ agentId: e, onConfigured: s }) {
|
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
64
|
children: "Configure assistant"
|
|
65
|
-
})] }) : /* @__PURE__ */ a("p", { children: "Create an active
|
|
65
|
+
})] }) : /* @__PURE__ */ a("p", { children: "Create an active BotManor Assistant Runtime connection in Integrations, then reload this page." }),
|
|
66
66
|
f && /* @__PURE__ */ a("p", {
|
|
67
67
|
role: m ? "alert" : "status",
|
|
68
68
|
children: f
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssistantRuntimeSetupPanel.js","names":[],"sources":["../../../src/botlit/components/AssistantRuntimeSetupPanel.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useAssistantRuntimeSetup } from '../hooks/useAssistantRuntimeSetup';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { Button } from './Button';\n\nexport function AssistantRuntimeSetupPanel({\n agentId,\n onConfigured,\n}: {\n agentId: string;\n onConfigured: () => void;\n}) {\n const { workspaceId, currentUser } = useBotlit();\n return (\n <ScopedSetupPanel\n key={`${workspaceId}:${currentUser?.id}:${agentId}`}\n agentId={agentId}\n onConfigured={onConfigured}\n />\n );\n}\n\nfunction ScopedSetupPanel({\n agentId,\n onConfigured,\n}: {\n agentId: string;\n onConfigured: () => void;\n}) {\n const { connections, configure } = useAssistantRuntimeSetup(agentId);\n const [selected, setSelected] = useState('');\n const [message, setMessage] = useState('');\n const [failed, setFailed] = useState(false);\n return (\n <section className=\"space-y-4 rounded-lg border border-border-default p-5\">\n <div>\n <h2 className=\"text-lg font-semibold\">Assistant setup</h2>\n <p className=\"text-sm text-text-secondary\">\n Connect this assistant to Fluidgrids for answers and recovery. Course teachers also\n receive content ingestion workflows.\n </p>\n </div>\n {connections.isPending ? (\n <p role=\"status\">Loading connections…</p>\n ) : connections.isError ? (\n <div role=\"alert\">\n <p>Connections could not be loaded. Check your access and try again.</p>\n <Button variant=\"outline\" onClick={() => void connections.refetch()}>\n Reload connections\n </Button>\n </div>\n ) : !connections.data?.length ? (\n <p>\n Create an active
|
|
1
|
+
{"version":3,"file":"AssistantRuntimeSetupPanel.js","names":[],"sources":["../../../src/botlit/components/AssistantRuntimeSetupPanel.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { useAssistantRuntimeSetup } from '../hooks/useAssistantRuntimeSetup';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport { Button } from './Button';\n\nexport function AssistantRuntimeSetupPanel({\n agentId,\n onConfigured,\n}: {\n agentId: string;\n onConfigured: () => void;\n}) {\n const { workspaceId, currentUser } = useBotlit();\n return (\n <ScopedSetupPanel\n key={`${workspaceId}:${currentUser?.id}:${agentId}`}\n agentId={agentId}\n onConfigured={onConfigured}\n />\n );\n}\n\nfunction ScopedSetupPanel({\n agentId,\n onConfigured,\n}: {\n agentId: string;\n onConfigured: () => void;\n}) {\n const { connections, configure } = useAssistantRuntimeSetup(agentId);\n const [selected, setSelected] = useState('');\n const [message, setMessage] = useState('');\n const [failed, setFailed] = useState(false);\n return (\n <section className=\"space-y-4 rounded-lg border border-border-default p-5\">\n <div>\n <h2 className=\"text-lg font-semibold\">Assistant setup</h2>\n <p className=\"text-sm text-text-secondary\">\n Connect this assistant to Fluidgrids for answers and recovery. Course teachers also\n receive content ingestion workflows.\n </p>\n </div>\n {connections.isPending ? (\n <p role=\"status\">Loading connections…</p>\n ) : connections.isError ? (\n <div role=\"alert\">\n <p>Connections could not be loaded. Check your access and try again.</p>\n <Button variant=\"outline\" onClick={() => void connections.refetch()}>\n Reload connections\n </Button>\n </div>\n ) : !connections.data?.length ? (\n <p>\n Create an active BotManor Assistant Runtime connection in Integrations, then reload this\n page.\n </p>\n ) : (\n <>\n <label className=\"grid gap-2 text-sm font-medium\">\n Workflow connection\n <select\n className=\"h-10 rounded-md border border-border-default bg-bg-surface px-3\"\n value={selected}\n disabled={configure.isPending}\n onChange={(event) => {\n setSelected(event.target.value);\n setMessage('');\n }}\n >\n <option value=\"\">Choose a connection</option>\n {connections.data.map((connection) => (\n <option key={connection.id} value={connection.id}>\n {connection.name}\n </option>\n ))}\n </select>\n </label>\n <Button\n disabled={!selected}\n isLoading={configure.isPending}\n onClick={async () => {\n setMessage('');\n setFailed(false);\n try {\n const result = await configure.mutateAsync(selected);\n setMessage(\n result.ready\n ? 'Assistant configured and ready.'\n : 'Workflows configured. Activate the assistant and finish indexing its knowledge before using it.'\n );\n onConfigured();\n } catch {\n setFailed(true);\n setMessage(\n 'Setup could not be completed. Check the model, knowledge scope and your permissions, then try again.'\n );\n }\n }}\n >\n Configure assistant\n </Button>\n </>\n )}\n {message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AFI,EAAW,GAEf,CACT,CACK;OACH;OACR,kBAAC,GAAD;IACE,UAAU,CAAC;IACX,WAAW,EAAU;IACrB,SAAS,YAAY;AAEnB,KADA,EAAW,GAAG,EACd,EAAU,GAAM;AAChB,SAAI;AAOF,MALA,GADe,MAAM,EAAU,YAAY,EAAS,EAE3C,QACH,oCACA,kGACL,EACD,GAAc;aACR;AAEN,MADA,EAAU,GAAK,EACf,EACE,uGACD;;;cAGN;IAEQ,CAAA,CACR,EAAA,CAAA,GAjDH,kBAAC,KAAD,EAAA,UAAG,kGAGC,CAAA;GAgDL,KAAW,kBAAC,KAAD;IAAG,MAAM,IAAS,UAAU;cAAW;IAAY,CAAA;GACvD"}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { useCreateLLMModel as e } from "../hooks/useLLMProviders.js";
|
|
2
|
+
import { Card as t, CardContent as n, CardHeader as r, CardTitle as i } from "./Card.js";
|
|
3
|
+
import { Button as a } from "./Button.js";
|
|
4
|
+
import { FormField as o, Input as s } from "./Input.js";
|
|
5
|
+
import { useState as c } from "react";
|
|
6
|
+
import { jsx as l, jsxs as u } from "react/jsx-runtime";
|
|
7
|
+
import { toast as d } from "sonner";
|
|
8
|
+
//#region src/botlit/components/ModelRegistrationPanel.tsx
|
|
9
|
+
function f({ providers: f, onCreated: p }) {
|
|
10
|
+
let { createModel: m, isCreating: h } = e(), [g, _] = c(""), [v, y] = c(""), [b, x] = c(""), [S, C] = c("answer"), [w, T] = c(""), [E, D] = c("8192"), [O, k] = c("2048"), [A, j] = c("0"), [M, N] = c("0"), P = f.filter((e) => e.isActive), F = P.find((e) => e.id === g), I = F?.type === "AWS_BEDROCK" ? b.trim() === "amazon.titan-embed-text-v2:0" : [
|
|
11
|
+
"OPENAI",
|
|
12
|
+
"AZURE_OPENAI",
|
|
13
|
+
"CUSTOM"
|
|
14
|
+
].includes(F?.type ?? ""), L = P.some((e) => e.id === g) && !!(v.trim() && b.trim()) && Number.isSafeInteger(Number(E)) && Number(E) > 0 && (S !== "embedding" || I && Number.isInteger(Number(w)) && Number(w) > 0 && Number(w) <= 16e3) && (S === "embedding" || Number.isSafeInteger(Number(O)) && Number(O) > 0) && (S === "embedding" ? [A] : [A, M]).every((e) => e.trim() !== "" && Number.isFinite(Number(e)) && Number(e) >= 0);
|
|
15
|
+
return /* @__PURE__ */ u(t, { children: [/* @__PURE__ */ l(r, { children: /* @__PURE__ */ l(i, { children: "Register model" }) }), /* @__PURE__ */ u(n, {
|
|
16
|
+
className: "space-y-4",
|
|
17
|
+
children: [
|
|
18
|
+
/* @__PURE__ */ l("p", {
|
|
19
|
+
className: "text-sm text-text-secondary",
|
|
20
|
+
children: "Register an answer or embedding model available through your provider. Model access and billing limits must already be configured."
|
|
21
|
+
}),
|
|
22
|
+
/* @__PURE__ */ l(o, {
|
|
23
|
+
label: "Model provider",
|
|
24
|
+
children: /* @__PURE__ */ u("select", {
|
|
25
|
+
"aria-label": "Model provider",
|
|
26
|
+
value: g,
|
|
27
|
+
onChange: (e) => {
|
|
28
|
+
_(e.target.value);
|
|
29
|
+
let t = P.find((t) => t.id === e.target.value);
|
|
30
|
+
T(t?.type === "AWS_BEDROCK" ? String(t.metadata?.embeddingDimensions ?? 1024) : "");
|
|
31
|
+
},
|
|
32
|
+
className: "h-10 w-full rounded-md border bg-bg-surface px-3",
|
|
33
|
+
children: [/* @__PURE__ */ l("option", {
|
|
34
|
+
value: "",
|
|
35
|
+
children: "Choose an active provider"
|
|
36
|
+
}), P.map((e) => /* @__PURE__ */ l("option", {
|
|
37
|
+
value: e.id,
|
|
38
|
+
children: e.name
|
|
39
|
+
}, e.id))]
|
|
40
|
+
})
|
|
41
|
+
}),
|
|
42
|
+
/* @__PURE__ */ l(o, {
|
|
43
|
+
label: "Model name",
|
|
44
|
+
children: /* @__PURE__ */ l(s, {
|
|
45
|
+
"aria-label": "Model name",
|
|
46
|
+
value: v,
|
|
47
|
+
maxLength: 255,
|
|
48
|
+
onChange: (e) => y(e.target.value)
|
|
49
|
+
})
|
|
50
|
+
}),
|
|
51
|
+
/* @__PURE__ */ l(o, {
|
|
52
|
+
label: "Provider model ID",
|
|
53
|
+
children: /* @__PURE__ */ l(s, {
|
|
54
|
+
"aria-label": "Provider model ID",
|
|
55
|
+
value: b,
|
|
56
|
+
maxLength: 255,
|
|
57
|
+
onChange: (e) => {
|
|
58
|
+
x(e.target.value);
|
|
59
|
+
let t = {
|
|
60
|
+
"text-embedding-3-small": 1536,
|
|
61
|
+
"text-embedding-3-large": 3072,
|
|
62
|
+
"text-embedding-ada-002": 1536
|
|
63
|
+
}[e.target.value.trim()];
|
|
64
|
+
t && T(String(t));
|
|
65
|
+
}
|
|
66
|
+
})
|
|
67
|
+
}),
|
|
68
|
+
/* @__PURE__ */ l(o, {
|
|
69
|
+
label: "Model purpose",
|
|
70
|
+
children: /* @__PURE__ */ u("select", {
|
|
71
|
+
"aria-label": "Model purpose",
|
|
72
|
+
value: S,
|
|
73
|
+
onChange: (e) => C(e.target.value),
|
|
74
|
+
className: "h-10 w-full rounded-md border bg-bg-surface px-3",
|
|
75
|
+
children: [/* @__PURE__ */ l("option", {
|
|
76
|
+
value: "answer",
|
|
77
|
+
children: "Answer generation"
|
|
78
|
+
}), /* @__PURE__ */ l("option", {
|
|
79
|
+
value: "embedding",
|
|
80
|
+
children: "Content embeddings"
|
|
81
|
+
})]
|
|
82
|
+
})
|
|
83
|
+
}),
|
|
84
|
+
S === "embedding" && /* @__PURE__ */ u(o, {
|
|
85
|
+
label: "Embedding dimensions",
|
|
86
|
+
children: [/* @__PURE__ */ l(s, {
|
|
87
|
+
"aria-label": "Embedding dimensions",
|
|
88
|
+
type: "number",
|
|
89
|
+
min: 1,
|
|
90
|
+
max: 16e3,
|
|
91
|
+
disabled: F?.type === "AWS_BEDROCK",
|
|
92
|
+
value: w,
|
|
93
|
+
onChange: (e) => T(e.target.value)
|
|
94
|
+
}), /* @__PURE__ */ l("p", {
|
|
95
|
+
className: "text-sm text-text-secondary",
|
|
96
|
+
children: "Use the vector size returned by this deployment. Supported: Titan Text Embeddings V2 and OpenAI-compatible embedding endpoints."
|
|
97
|
+
})]
|
|
98
|
+
}),
|
|
99
|
+
/* @__PURE__ */ l(o, {
|
|
100
|
+
label: "Context window",
|
|
101
|
+
children: /* @__PURE__ */ l(s, {
|
|
102
|
+
"aria-label": "Context window",
|
|
103
|
+
type: "number",
|
|
104
|
+
min: 1,
|
|
105
|
+
value: E,
|
|
106
|
+
onChange: (e) => D(e.target.value)
|
|
107
|
+
})
|
|
108
|
+
}),
|
|
109
|
+
S === "answer" && /* @__PURE__ */ l(o, {
|
|
110
|
+
label: "Maximum output tokens",
|
|
111
|
+
children: /* @__PURE__ */ l(s, {
|
|
112
|
+
"aria-label": "Maximum output tokens",
|
|
113
|
+
type: "number",
|
|
114
|
+
min: 1,
|
|
115
|
+
value: O,
|
|
116
|
+
onChange: (e) => k(e.target.value)
|
|
117
|
+
})
|
|
118
|
+
}),
|
|
119
|
+
/* @__PURE__ */ l(o, {
|
|
120
|
+
label: "Input price per million tokens",
|
|
121
|
+
children: /* @__PURE__ */ l(s, {
|
|
122
|
+
"aria-label": "Input price per million tokens",
|
|
123
|
+
type: "number",
|
|
124
|
+
min: 0,
|
|
125
|
+
step: "any",
|
|
126
|
+
value: A,
|
|
127
|
+
onChange: (e) => j(e.target.value)
|
|
128
|
+
})
|
|
129
|
+
}),
|
|
130
|
+
S === "answer" && /* @__PURE__ */ l(o, {
|
|
131
|
+
label: "Output price per million tokens",
|
|
132
|
+
children: /* @__PURE__ */ l(s, {
|
|
133
|
+
"aria-label": "Output price per million tokens",
|
|
134
|
+
type: "number",
|
|
135
|
+
min: 0,
|
|
136
|
+
step: "any",
|
|
137
|
+
value: M,
|
|
138
|
+
onChange: (e) => N(e.target.value)
|
|
139
|
+
})
|
|
140
|
+
}),
|
|
141
|
+
/* @__PURE__ */ l(a, {
|
|
142
|
+
disabled: !L,
|
|
143
|
+
isLoading: h,
|
|
144
|
+
onClick: async () => {
|
|
145
|
+
try {
|
|
146
|
+
await m({
|
|
147
|
+
providerId: g,
|
|
148
|
+
name: v.trim(),
|
|
149
|
+
modelId: b.trim(),
|
|
150
|
+
contextWindow: Number(E),
|
|
151
|
+
maxOutputTokens: S === "embedding" ? 0 : Number(O),
|
|
152
|
+
inputPricePerMToken: Number(A),
|
|
153
|
+
outputPricePerMToken: S === "embedding" ? 0 : Number(M),
|
|
154
|
+
supportsStreaming: S === "answer",
|
|
155
|
+
supportsFunctionCalling: !1,
|
|
156
|
+
supportsVision: !1,
|
|
157
|
+
metadata: {
|
|
158
|
+
purpose: S,
|
|
159
|
+
...S === "embedding" ? { embeddingDimensions: Number(w) } : {}
|
|
160
|
+
}
|
|
161
|
+
}), y(""), x(""), p(), d.success("Model registered.");
|
|
162
|
+
} catch (e) {
|
|
163
|
+
d.error(e instanceof Error ? e.message : "Model registration failed.");
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
children: "Register model"
|
|
167
|
+
})
|
|
168
|
+
]
|
|
169
|
+
})] });
|
|
170
|
+
}
|
|
171
|
+
//#endregion
|
|
172
|
+
export { f as ModelRegistrationPanel };
|
|
173
|
+
|
|
174
|
+
//# sourceMappingURL=ModelRegistrationPanel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModelRegistrationPanel.js","names":[],"sources":["../../../src/botlit/components/ModelRegistrationPanel.tsx"],"sourcesContent":["import { useState } from 'react';\nimport { toast } from 'sonner';\nimport { useCreateLLMModel, type LLMProviderRecord } from '../hooks/useLLMProviders';\nimport { Button } from './Button';\nimport { Card, CardContent, CardHeader, CardTitle } from './Card';\nimport { FormField, Input } from './Input';\n\nexport function ModelRegistrationPanel({\n providers,\n onCreated,\n}: {\n providers: LLMProviderRecord[];\n onCreated: () => void;\n}) {\n const { createModel, isCreating } = useCreateLLMModel();\n const [providerId, setProviderId] = useState('');\n const [name, setName] = useState('');\n const [modelId, setModelId] = useState('');\n const [purpose, setPurpose] = useState('answer');\n const [embeddingDimensions, setEmbeddingDimensions] = useState('');\n const [contextWindow, setContextWindow] = useState('8192');\n const [maxOutputTokens, setMaxOutputTokens] = useState('2048');\n const [inputPrice, setInputPrice] = useState('0');\n const [outputPrice, setOutputPrice] = useState('0');\n const activeProviders = providers.filter((provider) => provider.isActive);\n const selectedProvider = activeProviders.find((provider) => provider.id === providerId);\n const embeddingSupported =\n selectedProvider?.type === 'AWS_BEDROCK'\n ? modelId.trim() === 'amazon.titan-embed-text-v2:0'\n : ['OPENAI', 'AZURE_OPENAI', 'CUSTOM'].includes(selectedProvider?.type ?? '');\n const valid =\n activeProviders.some((provider) => provider.id === providerId) &&\n Boolean(name.trim() && modelId.trim()) &&\n Number.isSafeInteger(Number(contextWindow)) &&\n Number(contextWindow) > 0 &&\n (purpose !== 'embedding' ||\n (embeddingSupported &&\n Number.isInteger(Number(embeddingDimensions)) &&\n Number(embeddingDimensions) > 0 &&\n Number(embeddingDimensions) <= 16000)) &&\n (purpose === 'embedding' ||\n (Number.isSafeInteger(Number(maxOutputTokens)) && Number(maxOutputTokens) > 0)) &&\n (purpose === 'embedding' ? [inputPrice] : [inputPrice, outputPrice]).every(\n (value) => value.trim() !== '' && Number.isFinite(Number(value)) && Number(value) >= 0\n );\n return (\n <Card>\n <CardHeader>\n <CardTitle>Register model</CardTitle>\n </CardHeader>\n <CardContent className=\"space-y-4\">\n <p className=\"text-sm text-text-secondary\">\n Register an answer or embedding model available through your provider. Model access and\n billing limits must already be configured.\n </p>\n <FormField label=\"Model provider\">\n <select\n aria-label=\"Model provider\"\n value={providerId}\n onChange={(event) => {\n setProviderId(event.target.value);\n const provider = activeProviders.find((entry) => entry.id === event.target.value);\n setEmbeddingDimensions(\n provider?.type === 'AWS_BEDROCK'\n ? String(provider.metadata?.embeddingDimensions ?? 1024)\n : ''\n );\n }}\n className=\"h-10 w-full rounded-md border bg-bg-surface px-3\"\n >\n <option value=\"\">Choose an active provider</option>\n {activeProviders.map((provider) => (\n <option key={provider.id} value={provider.id}>\n {provider.name}\n </option>\n ))}\n </select>\n </FormField>\n <FormField label=\"Model name\">\n <Input\n aria-label=\"Model name\"\n value={name}\n maxLength={255}\n onChange={(event) => setName(event.target.value)}\n />\n </FormField>\n <FormField label=\"Provider model ID\">\n <Input\n aria-label=\"Provider model ID\"\n value={modelId}\n maxLength={255}\n onChange={(event) => {\n setModelId(event.target.value);\n const defaultDimensions: Record<string, number> = {\n 'text-embedding-3-small': 1536,\n 'text-embedding-3-large': 3072,\n 'text-embedding-ada-002': 1536,\n };\n const dimensions = defaultDimensions[event.target.value.trim()];\n if (dimensions) setEmbeddingDimensions(String(dimensions));\n }}\n />\n </FormField>\n <FormField label=\"Model purpose\">\n <select\n aria-label=\"Model purpose\"\n value={purpose}\n onChange={(event) => setPurpose(event.target.value)}\n className=\"h-10 w-full rounded-md border bg-bg-surface px-3\"\n >\n <option value=\"answer\">Answer generation</option>\n <option value=\"embedding\">Content embeddings</option>\n </select>\n </FormField>\n {purpose === 'embedding' && (\n <FormField label=\"Embedding dimensions\">\n <Input\n aria-label=\"Embedding dimensions\"\n type=\"number\"\n min={1}\n max={16000}\n disabled={selectedProvider?.type === 'AWS_BEDROCK'}\n value={embeddingDimensions}\n onChange={(event) => setEmbeddingDimensions(event.target.value)}\n />\n <p className=\"text-sm text-text-secondary\">\n Use the vector size returned by this deployment. Supported: Titan Text Embeddings V2\n and OpenAI-compatible embedding endpoints.\n </p>\n </FormField>\n )}\n <FormField label=\"Context window\">\n <Input\n aria-label=\"Context window\"\n type=\"number\"\n min={1}\n value={contextWindow}\n onChange={(event) => setContextWindow(event.target.value)}\n />\n </FormField>\n {purpose === 'answer' && (\n <FormField label=\"Maximum output tokens\">\n <Input\n aria-label=\"Maximum output tokens\"\n type=\"number\"\n min={1}\n value={maxOutputTokens}\n onChange={(event) => setMaxOutputTokens(event.target.value)}\n />\n </FormField>\n )}\n <FormField label=\"Input price per million tokens\">\n <Input\n aria-label=\"Input price per million tokens\"\n type=\"number\"\n min={0}\n step=\"any\"\n value={inputPrice}\n onChange={(event) => setInputPrice(event.target.value)}\n />\n </FormField>\n {purpose === 'answer' && (\n <FormField label=\"Output price per million tokens\">\n <Input\n aria-label=\"Output price per million tokens\"\n type=\"number\"\n min={0}\n step=\"any\"\n value={outputPrice}\n onChange={(event) => setOutputPrice(event.target.value)}\n />\n </FormField>\n )}\n <Button\n disabled={!valid}\n isLoading={isCreating}\n onClick={async () => {\n try {\n await createModel({\n providerId,\n name: name.trim(),\n modelId: modelId.trim(),\n contextWindow: Number(contextWindow),\n maxOutputTokens: purpose === 'embedding' ? 0 : Number(maxOutputTokens),\n inputPricePerMToken: Number(inputPrice),\n outputPricePerMToken: purpose === 'embedding' ? 0 : Number(outputPrice),\n supportsStreaming: purpose === 'answer',\n supportsFunctionCalling: false,\n supportsVision: false,\n metadata: {\n purpose,\n ...(purpose === 'embedding'\n ? { embeddingDimensions: Number(embeddingDimensions) }\n : {}),\n },\n });\n setName('');\n setModelId('');\n onCreated();\n toast.success('Model registered.');\n } catch (error) {\n toast.error(error instanceof Error ? error.message : 'Model registration failed.');\n }\n }}\n >\n Register model\n </Button>\n </CardContent>\n </Card>\n );\n}\n"],"mappings":";;;;;;;;AAOA,SAAgB,EAAuB,EACrC,cACA,gBAIC;CACD,IAAM,EAAE,gBAAa,kBAAe,GAAmB,EACjD,CAAC,GAAY,KAAiB,EAAS,GAAG,EAC1C,CAAC,GAAM,KAAW,EAAS,GAAG,EAC9B,CAAC,GAAS,KAAc,EAAS,GAAG,EACpC,CAAC,GAAS,KAAc,EAAS,SAAS,EAC1C,CAAC,GAAqB,KAA0B,EAAS,GAAG,EAC5D,CAAC,GAAe,KAAoB,EAAS,OAAO,EACpD,CAAC,GAAiB,KAAsB,EAAS,OAAO,EACxD,CAAC,GAAY,KAAiB,EAAS,IAAI,EAC3C,CAAC,GAAa,KAAkB,EAAS,IAAI,EAC7C,IAAkB,EAAU,QAAQ,MAAa,EAAS,SAAS,EACnE,IAAmB,EAAgB,MAAM,MA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;KACE,cAAW;KACX,MAAK;KACL,KAAK;KACL,OAAO;KACP,WAAW,MAAU,EAAmB,EAAM,OAAO,MAAM;KAC3D,CAAA;IACQ,CAAA;GAEd,kBAAC,GAAD;IAAW,OAAM;cACf,kBAAC,GAAD;KACE,cAAW;KACX,MAAK;KACL,KAAK;KACL,MAAK;KACL,OAAO;KACP,WAAW,MAAU,EAAc,EAAM,OAAO,MAAM;KACtD,CAAA;IACQ,CAAA;GACX,MAAY,YACX,kBAAC,GAAD;IAAW,OAAM;cACf,kBAAC,GAAD;KACE,cAAW;KACX,MAAK;KACL,KAAK;KACL,MAAK;KACL,OAAO;KACP,WAAW,MAAU,EAAe,EAAM,OAAO,MAAM;KACvD,CAAA;IACQ,CAAA;GAEd,kBAAC,GAAD;IACE,UAAU,CAAC;IACX,WAAW;IACX,SAAS,YAAY;AACnB,SAAI;AAsBF,MArBA,MAAM,EAAY;OAChB;OACA,MAAM,EAAK,MAAM;OACjB,SAAS,EAAQ,MAAM;OACvB,eAAe,OAAO,EAAc;OACpC,iBAAiB,MAAY,cAAc,IAAI,OAAO,EAAgB;OACtE,qBAAqB,OAAO,EAAW;OACvC,sBAAsB,MAAY,cAAc,IAAI,OAAO,EAAY;OACvE,mBAAmB,MAAY;OAC/B,yBAAyB;OACzB,gBAAgB;OAChB,UAAU;QACR;QACA,GAAI,MAAY,cACZ,EAAE,qBAAqB,OAAO,EAAoB,EAAE,GACpD,EAAE;QACP;OACF,CAAC,EACF,EAAQ,GAAG,EACX,EAAW,GAAG,EACd,GAAW,EACX,EAAM,QAAQ,oBAAoB;cAC3B,GAAO;AACd,QAAM,MAAM,aAAiB,QAAQ,EAAM,UAAU,6BAA6B;;;cAGvF;IAEQ,CAAA;GACG;IACT,EAAA,CAAA"}
|
|
@@ -94,6 +94,6 @@ function f(e) {
|
|
|
94
94
|
]), d];
|
|
95
95
|
}
|
|
96
96
|
//#endregion
|
|
97
|
-
export { c as useWorkspaceId, f as useWorkspaceMutation, d as useWorkspaceQuery };
|
|
97
|
+
export { s as useWorkspaceClient, c as useWorkspaceId, f as useWorkspaceMutation, d as useWorkspaceQuery };
|
|
98
98
|
|
|
99
99
|
//# sourceMappingURL=workspaceGateway.js.map
|
|
@@ -5,7 +5,7 @@ import { useMutation as r, useQuery as i } from "@tanstack/react-query";
|
|
|
5
5
|
//#region src/botlit/hooks/useAssistantRuntimeSetup.ts
|
|
6
6
|
var a = t`
|
|
7
7
|
query AssistantWorkflowProvider {
|
|
8
|
-
getProviderByKey(key: "
|
|
8
|
+
getProviderByKey(key: "botmanor-runtime") {
|
|
9
9
|
id
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -74,7 +74,7 @@ function c(t) {
|
|
|
74
74
|
fetchPolicy: "no-cache"
|
|
75
75
|
})).data?.getConnections;
|
|
76
76
|
if (!r || r.items.length > 100) throw Error("Connections unavailable");
|
|
77
|
-
for (let e of r.items) e.workspaceId === l && e.status === "ACTIVE" && e.provider.key === "
|
|
77
|
+
for (let e of r.items) e.workspaceId === l && e.status === "ACTIVE" && e.provider.key === "botmanor-runtime" && e.authMethod?.authType === "WORKSPACE_APP_TOKEN" && e.authMethod.isEnabled && e.authMethod.isConfigured && t.push({
|
|
78
78
|
id: e.id,
|
|
79
79
|
name: e.name
|
|
80
80
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAssistantRuntimeSetup.js","names":[],"sources":["../../../src/botlit/hooks/useAssistantRuntimeSetup.ts"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@tanstack/react-query';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\nimport { useBotlit } from '../providers/BotlitProvider';\n\ninterface Connection {\n id: string;\n name: string;\n workspaceId: string | null;\n status: string;\n provider: { key: string };\n authMethod: { authType: string; isEnabled: boolean; isConfigured: boolean } | null;\n}\nexport interface AssistantRuntimeConfiguration {\n agentId: string;\n courseId: string | null;\n inferenceWorkflowId: string;\n recoveryWorkflowId: string;\n recoveryScheduleId: string;\n ingestionWorkflowId: string | null;\n protocolVersion: number;\n ready: boolean;\n}\nconst PROVIDER = gql`\n query AssistantWorkflowProvider {\n getProviderByKey(key: \"
|
|
1
|
+
{"version":3,"file":"useAssistantRuntimeSetup.js","names":[],"sources":["../../../src/botlit/hooks/useAssistantRuntimeSetup.ts"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { useMutation, useQuery } from '@tanstack/react-query';\nimport { useGatewayClient } from '@burdenoff/fe-libs/shared/graphql';\nimport { useBotlit } from '../providers/BotlitProvider';\n\ninterface Connection {\n id: string;\n name: string;\n workspaceId: string | null;\n status: string;\n provider: { key: string };\n authMethod: { authType: string; isEnabled: boolean; isConfigured: boolean } | null;\n}\nexport interface AssistantRuntimeConfiguration {\n agentId: string;\n courseId: string | null;\n inferenceWorkflowId: string;\n recoveryWorkflowId: string;\n recoveryScheduleId: string;\n ingestionWorkflowId: string | null;\n protocolVersion: number;\n ready: boolean;\n}\nconst PROVIDER = gql`\n query AssistantWorkflowProvider {\n getProviderByKey(key: \"botmanor-runtime\") {\n id\n }\n }\n`;\nconst CONNECTIONS = gql`\n query AssistantWorkflowConnections($providerId: ID!, $offset: Int!) {\n getConnections(\n filter: { providerId: $providerId, status: ACTIVE }\n pagination: { limit: 100, offset: $offset }\n ) {\n hasMore\n items {\n id\n name\n workspaceId\n status\n provider {\n key\n }\n authMethod {\n authType\n isEnabled\n isConfigured\n }\n }\n }\n }\n`;\nconst CONFIGURE = gql`\n mutation ConfigureAssistantRuntime($agentId: ID!, $connectionId: ID!) {\n configureAssistantRuntime(agentId: $agentId, connectionId: $connectionId) {\n agentId\n courseId\n inferenceWorkflowId\n recoveryWorkflowId\n recoveryScheduleId\n ingestionWorkflowId\n protocolVersion\n ready\n }\n }\n`;\n\nexport function useAssistantRuntimeSetup(agentId: string) {\n const client = useGatewayClient('workspace');\n const { workspaceId, currentUser } = useBotlit();\n const connections = useQuery({\n queryKey: ['botmanor-assistant-connections', workspaceId, currentUser?.id],\n enabled: Boolean(workspaceId && currentUser?.id),\n retry: false,\n queryFn: async () => {\n const provider = await client.query<{ getProviderByKey: { id: string } | null }>({\n query: PROVIDER,\n fetchPolicy: 'no-cache',\n });\n const providerId = provider.data?.getProviderByKey?.id;\n if (!providerId) return [];\n const result: Array<{ id: string; name: string }> = [];\n for (let offset = 0; offset < 500; offset += 100) {\n const page = await client.query<{\n getConnections: { hasMore: boolean; items: Connection[] };\n }>({\n query: CONNECTIONS,\n variables: { providerId, offset },\n fetchPolicy: 'no-cache',\n });\n const data = page.data?.getConnections;\n if (!data || data.items.length > 100) throw new Error('Connections unavailable');\n for (const connection of data.items) {\n if (\n connection.workspaceId === workspaceId &&\n connection.status === 'ACTIVE' &&\n connection.provider.key === 'botmanor-runtime' &&\n connection.authMethod?.authType === 'WORKSPACE_APP_TOKEN' &&\n connection.authMethod.isEnabled &&\n connection.authMethod.isConfigured\n )\n result.push({ id: connection.id, name: connection.name });\n }\n if (!data.hasMore) return result;\n }\n throw new Error('Connection list exceeds the supported limit');\n },\n });\n const configure = useMutation({\n mutationKey: ['botmanor-assistant-runtime', workspaceId, currentUser?.id, agentId],\n retry: false,\n mutationFn: async (connectionId: string) => {\n if (!workspaceId || !currentUser?.id) throw new Error('Sign in to configure an assistant');\n const result = await client.mutate<{\n configureAssistantRuntime: AssistantRuntimeConfiguration;\n }>({\n mutation: CONFIGURE,\n variables: { agentId, connectionId },\n });\n const configured = result.data?.configureAssistantRuntime;\n if (\n !configured ||\n configured.agentId !== agentId ||\n configured.protocolVersion !== 2 ||\n !configured.inferenceWorkflowId ||\n !configured.recoveryWorkflowId ||\n !configured.recoveryScheduleId ||\n typeof configured.ready !== 'boolean'\n )\n throw new Error('Runtime configuration unavailable');\n return configured;\n },\n });\n return { connections, configure };\n}\n"],"mappings":";;;;;AAuBA,IAAM,IAAW,CAAG;;;;;;GAOd,IAAc,CAAG;;;;;;;;;;;;;;;;;;;;;;;GAwBjB,IAAY,CAAG;;;;;;;;;;;;;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AAC,KACD,EAAW,YAAY,KACvB,EAAW,oBAAoB,KAC/B,CAAC,EAAW,uBACZ,CAAC,EAAW,sBACZ,CAAC,EAAW,sBACZ,OAAO,EAAW,SAAU,UAE5B,OAAU,MAAM,oCAAoC;AACtD,WAAO;;GAEV,CAAC;EAC+B"}
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { useBotlit as e } from "../providers/BotlitProvider.js";
|
|
2
|
+
import { buildMutationInput as t, fieldsOf as n } from "./internal/mutationInput.js";
|
|
3
|
+
import { CreateBotmanorLlmModelDocument as r, CreateBotmanorLlmProviderDocument as i, ListLlmModelsDocument as a, ListLlmProvidersDocument as o, UpdateLlmProviderDocument as s } from "../../generated/wspace-operations.js";
|
|
4
|
+
import { useWorkspaceClient as c, useWorkspaceId as l, useWorkspaceMutation as u } from "./internal/workspaceGateway.js";
|
|
5
|
+
import { useCallback as d } from "react";
|
|
6
|
+
import { useQuery as f } from "@tanstack/react-query";
|
|
5
7
|
//#region src/botlit/hooks/useLLMProviders.ts
|
|
6
|
-
var
|
|
8
|
+
var p = 50, m = [], h = [], g = n({
|
|
7
9
|
apiEndpoint: !0,
|
|
8
10
|
connectionId: !0,
|
|
9
11
|
credentials: !0,
|
|
@@ -11,7 +13,7 @@ var d = 50, f = [], p = [], m = t({
|
|
|
11
13
|
name: !0,
|
|
12
14
|
type: !0,
|
|
13
15
|
workspaceId: !0
|
|
14
|
-
}),
|
|
16
|
+
}), _ = n({
|
|
15
17
|
apiEndpoint: !0,
|
|
16
18
|
connectionId: !0,
|
|
17
19
|
credentials: !0,
|
|
@@ -19,65 +21,107 @@ var d = 50, f = [], p = [], m = t({
|
|
|
19
21
|
metadata: !0,
|
|
20
22
|
name: !0
|
|
21
23
|
});
|
|
22
|
-
function
|
|
23
|
-
let e =
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
24
|
+
function v(t, n, r, i, a) {
|
|
25
|
+
let o = c(), { workspaceId: s, currentUser: l } = e(), u = f({
|
|
26
|
+
queryKey: [
|
|
27
|
+
"botmanor-llm-catalog",
|
|
28
|
+
s,
|
|
29
|
+
l?.id,
|
|
30
|
+
n,
|
|
31
|
+
a
|
|
32
|
+
],
|
|
33
|
+
enabled: !!s,
|
|
34
|
+
retry: !1,
|
|
35
|
+
queryFn: async () => {
|
|
36
|
+
let e = [];
|
|
37
|
+
for (let n = 0; n < 1e4; n += p) {
|
|
38
|
+
let i = await o.query({
|
|
39
|
+
query: t,
|
|
40
|
+
fetchPolicy: "network-only",
|
|
41
|
+
variables: {
|
|
42
|
+
filters: a ? { providerId: a } : void 0,
|
|
43
|
+
pagination: {
|
|
44
|
+
limit: p,
|
|
45
|
+
offset: n
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
if (!i.data) throw Error("Model catalog unavailable");
|
|
50
|
+
let s = r(i.data);
|
|
51
|
+
if (!Array.isArray(s) || s.length > p) throw Error("Model catalog unavailable");
|
|
52
|
+
if (e.push(...s), s.length < p) return e;
|
|
45
53
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
fallback: p,
|
|
49
|
-
enabled: !!t,
|
|
50
|
-
errorMessage: "Failed to load LLM models"
|
|
54
|
+
throw Error("Model catalog exceeds the supported limit");
|
|
55
|
+
}
|
|
51
56
|
});
|
|
57
|
+
return {
|
|
58
|
+
data: u.data ?? i,
|
|
59
|
+
loading: u.isFetching,
|
|
60
|
+
error: u.error ?? void 0,
|
|
61
|
+
refetch: async () => {
|
|
62
|
+
await u.refetch();
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function y() {
|
|
67
|
+
return v(o, "providers", (e) => e?.listLLMProviders ?? m, m);
|
|
52
68
|
}
|
|
53
|
-
function
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
69
|
+
function b(e) {
|
|
70
|
+
return v(a, "models", (e) => e?.listLLMModels ?? h, h, e?.providerId);
|
|
71
|
+
}
|
|
72
|
+
function x() {
|
|
73
|
+
let e = l(), [n, r] = u({
|
|
74
|
+
document: i,
|
|
75
|
+
variables: (n) => ({ input: t({
|
|
57
76
|
...n,
|
|
58
|
-
workspaceId:
|
|
59
|
-
},
|
|
77
|
+
workspaceId: e
|
|
78
|
+
}, g) }),
|
|
60
79
|
select: (e) => e?.createBotmanorLLMProvider,
|
|
61
80
|
errorMessage: "Failed to create the LLM provider"
|
|
62
|
-
}), [
|
|
63
|
-
document:
|
|
64
|
-
variables: ({ providerId:
|
|
65
|
-
id:
|
|
66
|
-
input:
|
|
81
|
+
}), [a, o] = u({
|
|
82
|
+
document: s,
|
|
83
|
+
variables: ({ providerId: e, input: n }) => ({
|
|
84
|
+
id: e,
|
|
85
|
+
input: t(n, _)
|
|
67
86
|
}),
|
|
68
87
|
select: (e) => e?.updateLLMProvider,
|
|
69
88
|
errorMessage: "Failed to update the LLM provider"
|
|
70
89
|
});
|
|
71
90
|
return {
|
|
72
|
-
configureProvider:
|
|
91
|
+
configureProvider: d(async (e, t) => t ? a({
|
|
73
92
|
providerId: t,
|
|
74
93
|
input: e
|
|
75
|
-
}) :
|
|
76
|
-
isConfiguring:
|
|
77
|
-
error:
|
|
94
|
+
}) : n(e), [n, a]),
|
|
95
|
+
isConfiguring: r.loading || o.loading,
|
|
96
|
+
error: r.error ?? o.error
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
function S() {
|
|
100
|
+
let [e, i] = u({
|
|
101
|
+
document: r,
|
|
102
|
+
variables: (e) => ({ input: t(e, n({
|
|
103
|
+
providerId: !0,
|
|
104
|
+
name: !0,
|
|
105
|
+
modelId: !0,
|
|
106
|
+
contextWindow: !0,
|
|
107
|
+
maxOutputTokens: !0,
|
|
108
|
+
inputPricePerMToken: !0,
|
|
109
|
+
outputPricePerMToken: !0,
|
|
110
|
+
supportsStreaming: !0,
|
|
111
|
+
supportsFunctionCalling: !0,
|
|
112
|
+
supportsVision: !0,
|
|
113
|
+
metadata: !0
|
|
114
|
+
})) }),
|
|
115
|
+
select: (e) => e?.createBotmanorLLMModel,
|
|
116
|
+
errorMessage: "Failed to register the model"
|
|
117
|
+
});
|
|
118
|
+
return {
|
|
119
|
+
createModel: e,
|
|
120
|
+
isCreating: i.loading,
|
|
121
|
+
error: i.error
|
|
78
122
|
};
|
|
79
123
|
}
|
|
80
124
|
//#endregion
|
|
81
|
-
export {
|
|
125
|
+
export { x as useConfigureLLMProvider, S as useCreateLLMModel, b as useLLMModels, y as useLLMProviders };
|
|
82
126
|
|
|
83
127
|
//# sourceMappingURL=useLLMProviders.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLLMProviders.js","names":[],"sources":["../../../src/botlit/hooks/useLLMProviders.ts"],"sourcesContent":["/**\n * LLM Providers Hooks\n * @module botlit/hooks\n *\n * These go through the shell's workspace gateway client like every other BotManor\n * hook. They deliberately do NOT use the generated `useQuery`/`useMutation`\n * wrappers: `BotmanorRoot` only mounts an `<ApolloProvider>` in standalone mode,\n * so an Apollo React hook throws \"Could not find client in the context\" the\n * moment the MFE is mounted by an app shell — which is every production route.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport {\n CreateBotmanorLlmProviderDocument,\n DeleteLlmProviderDocument,\n GetLlmProviderDocument,\n ListLlmModelsDocument,\n ListLlmProvidersDocument,\n TestLlmConnectionDocument,\n UpdateLlmProviderDocument,\n type CreateBotmanorLlmProviderMutation,\n type DeleteLlmProviderMutation,\n type GetLlmProviderQuery,\n type ListLlmModelsQuery,\n type ListLlmProvidersQuery,\n type TestLlmConnectionMutation,\n type UpdateLlmProviderMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateBotmanorLlmModelInput,\n CreateBotmanorLlmProviderInput,\n UpdateBotlitLlmProviderInput,\n} from '../../generated/wspace-types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 50;\n\nexport interface LLMProviderRecord {\n id: string;\n name: string;\n type: string;\n isActive: boolean;\n apiEndpoint?: string | null;\n credentialsHash?: string | null;\n connectionId?: string | null;\n metadata?: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n workspaceId: string;\n}\n\nexport interface LLMModelRecord {\n id: string;\n name: string;\n modelId: string;\n providerId: string;\n contextWindow: number;\n maxOutputTokens: number;\n inputPricePerMToken: number;\n outputPricePerMToken: number;\n isActive: boolean;\n supportsStreaming: boolean;\n supportsFunctionCalling: boolean;\n supportsVision: boolean;\n createdAt: string;\n updatedAt: string;\n}\n\n/** `CreateBotmanorLLMProviderInput` minus the `workspaceId` the hook supplies. */\nexport type ConfigureLLMProviderVariables = Omit<\n GraphQLInput<CreateBotmanorLlmProviderInput>,\n 'workspaceId'\n>;\n\nconst NO_PROVIDERS: LLMProviderRecord[] = [];\nconst NO_MODELS: LLMModelRecord[] = [];\n\nconst CREATE_PROVIDER_FIELDS = fieldsOf<CreateBotmanorLlmProviderInput>({\n apiEndpoint: true,\n connectionId: true,\n credentials: true,\n metadata: true,\n name: true,\n type: true,\n workspaceId: true,\n});\n\nconst UPDATE_PROVIDER_FIELDS = fieldsOf<UpdateBotlitLlmProviderInput>({\n apiEndpoint: true,\n connectionId: true,\n credentials: true,\n isActive: true,\n metadata: true,\n name: true,\n});\n\nexport const llmProviderKeys = {\n all: ['llmProviders'] as const,\n lists: () => [...llmProviderKeys.all, 'list'] as const,\n details: () => [...llmProviderKeys.all, 'detail'] as const,\n detail: (id: string) => [...llmProviderKeys.details(), id] as const,\n};\n\nexport function useLLMProviders(): QueryResult<LLMProviderRecord[]> {\n const workspaceId = useWorkspaceId();\n\n const variables = useMemo(() => ({ pagination: { limit: LIST_LIMIT, offset: 0 } }), []);\n\n return useWorkspaceQuery<ListLlmProvidersQuery, LLMProviderRecord[]>({\n document: ListLlmProvidersDocument,\n variables,\n select: (data) => data?.listLLMProviders ?? NO_PROVIDERS,\n fallback: NO_PROVIDERS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load LLM providers',\n });\n}\n\nexport function useLLMProvider(\n providerId: string | undefined\n): QueryResult<LLMProviderRecord | null> {\n const variables = useMemo(() => ({ id: providerId ?? '' }), [providerId]);\n\n return useWorkspaceQuery<GetLlmProviderQuery, LLMProviderRecord | null>({\n document: GetLlmProviderDocument,\n variables,\n select: (data) => data?.getLLMProvider ?? null,\n fallback: null,\n enabled: Boolean(providerId),\n errorMessage: 'Failed to load LLM provider',\n });\n}\n\nexport function useLLMModels(filters?: { providerId?: string }): QueryResult<LLMModelRecord[]> {\n const workspaceId = useWorkspaceId();\n const providerId = filters?.providerId;\n\n const variables = useMemo(\n () => ({\n filters: providerId ? { providerId } : undefined,\n pagination: { limit: LIST_LIMIT, offset: 0 },\n }),\n [providerId]\n );\n\n return useWorkspaceQuery<ListLlmModelsQuery, LLMModelRecord[]>({\n document: ListLlmModelsDocument,\n variables,\n select: (data) => data?.listLLMModels ?? NO_MODELS,\n fallback: NO_MODELS,\n enabled: Boolean(workspaceId),\n errorMessage: 'Failed to load LLM models',\n });\n}\n\n/**\n * Creates a provider, or updates the one whose id the caller passes.\n * `UpdateBotlitLLMProviderInput` has no `type`/`workspaceId`, so the update\n * payload is projected onto the fields that input actually declares.\n */\nexport function useConfigureLLMProvider() {\n const workspaceId = useWorkspaceId();\n\n const [create, createState] = useWorkspaceMutation<\n CreateBotmanorLlmProviderMutation,\n ConfigureLLMProviderVariables,\n LLMProviderRecord\n >({\n document: CreateBotmanorLlmProviderDocument,\n variables: (input) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_PROVIDER_FIELDS),\n }),\n select: (data) => data?.createBotmanorLLMProvider,\n errorMessage: 'Failed to create the LLM provider',\n });\n\n const [update, updateState] = useWorkspaceMutation<\n UpdateLlmProviderMutation,\n { providerId: string; input: ConfigureLLMProviderVariables },\n LLMProviderRecord\n >({\n document: UpdateLlmProviderDocument,\n variables: ({ providerId, input }) => ({\n id: providerId,\n input: buildMutationInput(input, UPDATE_PROVIDER_FIELDS),\n }),\n select: (data) => data?.updateLLMProvider,\n errorMessage: 'Failed to update the LLM provider',\n });\n\n const configureProvider = useCallback(\n async (input: ConfigureLLMProviderVariables, existingId?: string) =>\n existingId ? update({ providerId: existingId, input }) : create(input),\n [create, update]\n );\n\n return {\n configureProvider,\n isConfiguring: createState.loading || updateState.loading,\n error: createState.error ?? updateState.error,\n };\n}\n\nexport function useDeleteLLMProvider() {\n return useWorkspaceMutation<DeleteLlmProviderMutation, string, boolean>({\n document: DeleteLlmProviderDocument,\n variables: (providerId) => ({ id: providerId }),\n select: (data) => data?.deleteLLMProvider,\n errorMessage: 'Failed to delete the LLM provider',\n });\n}\n\nexport function useTestLLMConnection() {\n return useWorkspaceMutation<TestLlmConnectionMutation, string, boolean>({\n document: TestLlmConnectionDocument,\n variables: (providerId) => ({ id: providerId }),\n select: (data) => data?.testLlmConnection,\n errorMessage: 'Failed to test the LLM connection',\n });\n}\n\n/**\n * `createBotlitLLMModel` is not published on the supergraph — models are\n * catalogued by the service, so the UI cannot add custom ones yet.\n */\nexport function useCreateLLMModel() {\n const createModel = useCallback(async (_input: CreateBotmanorLlmModelInput): Promise<never> => {\n throw new Error(\"Custom model creation isn't available yet.\");\n }, []);\n\n return { createModel, isCreating: false, error: undefined };\n}\n"],"mappings":";;;;;AAyCA,IAAM,IAAa,IAuCb,IAAoC,EAAE,EACtC,IAA8B,EAAE,EAEhC,IAAyB,EAAyC;CACtE,aAAa;CACb,cAAc;CACd,aAAa;C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CAAC,GAAQ,EAAO,CACjB;EAIC,eAAe,EAAY,WAAW,EAAY;EAClD,OAAO,EAAY,SAAS,EAAY;EACzC"}
|
|
1
|
+
{"version":3,"file":"useLLMProviders.js","names":[],"sources":["../../../src/botlit/hooks/useLLMProviders.ts"],"sourcesContent":["/**\n * LLM Providers Hooks\n * @module botlit/hooks\n *\n * These go through the shell's workspace gateway client like every other BotManor\n * hook. They deliberately do NOT use the generated `useQuery`/`useMutation`\n * wrappers: `BotmanorRoot` only mounts an `<ApolloProvider>` in standalone mode,\n * so an Apollo React hook throws \"Could not find client in the context\" the\n * moment the MFE is mounted by an app shell — which is every production route.\n */\n\nimport { useCallback, useMemo } from 'react';\nimport type { DocumentNode } from 'graphql';\nimport { useQuery } from '@tanstack/react-query';\nimport { useBotlit } from '../providers/BotlitProvider';\nimport {\n CreateBotmanorLlmProviderDocument,\n CreateBotmanorLlmModelDocument,\n DeleteLlmProviderDocument,\n GetLlmProviderDocument,\n ListLlmModelsDocument,\n ListLlmProvidersDocument,\n TestLlmConnectionDocument,\n UpdateLlmProviderDocument,\n type CreateBotmanorLlmProviderMutation,\n type CreateBotmanorLlmModelMutation,\n type DeleteLlmProviderMutation,\n type GetLlmProviderQuery,\n type ListLlmModelsQuery,\n type ListLlmProvidersQuery,\n type TestLlmConnectionMutation,\n type UpdateLlmProviderMutation,\n} from '../../generated/wspace-operations';\nimport type {\n CreateBotmanorLlmModelInput,\n CreateBotmanorLlmProviderInput,\n UpdateBotlitLlmProviderInput,\n} from '../../generated/wspace-types';\nimport { buildMutationInput, fieldsOf, type GraphQLInput } from './internal/mutationInput';\nimport {\n useWorkspaceId,\n useWorkspaceClient,\n useWorkspaceMutation,\n useWorkspaceQuery,\n type QueryResult,\n} from './internal/workspaceGateway';\n\nconst LIST_LIMIT = 50;\n\nexport interface LLMProviderRecord {\n id: string;\n name: string;\n type: string;\n isActive: boolean;\n apiEndpoint?: string | null;\n credentialsHash?: string | null;\n connectionId?: string | null;\n metadata?: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n workspaceId: string;\n}\n\nexport interface LLMModelRecord {\n id: string;\n name: string;\n modelId: string;\n providerId: string;\n contextWindow: number;\n maxOutputTokens: number;\n inputPricePerMToken: number;\n outputPricePerMToken: number;\n isActive: boolean;\n supportsStreaming: boolean;\n supportsFunctionCalling: boolean;\n supportsVision: boolean;\n metadata?: Record<string, unknown> | null;\n createdAt: string;\n updatedAt: string;\n}\n\n/** `CreateBotmanorLLMProviderInput` minus the `workspaceId` the hook supplies. */\nexport type ConfigureLLMProviderVariables = Omit<\n GraphQLInput<CreateBotmanorLlmProviderInput>,\n 'workspaceId'\n> & { isActive?: boolean };\n\nconst NO_PROVIDERS: LLMProviderRecord[] = [];\nconst NO_MODELS: LLMModelRecord[] = [];\n\nconst CREATE_PROVIDER_FIELDS = fieldsOf<CreateBotmanorLlmProviderInput>({\n apiEndpoint: true,\n connectionId: true,\n credentials: true,\n metadata: true,\n name: true,\n type: true,\n workspaceId: true,\n});\n\nconst UPDATE_PROVIDER_FIELDS = fieldsOf<UpdateBotlitLlmProviderInput>({\n apiEndpoint: true,\n connectionId: true,\n credentials: true,\n isActive: true,\n metadata: true,\n name: true,\n});\n\nexport const llmProviderKeys = {\n all: ['llmProviders'] as const,\n lists: () => [...llmProviderKeys.all, 'list'] as const,\n details: () => [...llmProviderKeys.all, 'detail'] as const,\n detail: (id: string) => [...llmProviderKeys.details(), id] as const,\n};\n\nfunction useLLMList<TData, TRecord>(\n document: DocumentNode,\n kind: string,\n select: (data: TData | undefined) => TRecord[],\n fallback: TRecord[],\n providerId?: string\n): QueryResult<TRecord[]> {\n const client = useWorkspaceClient();\n const { workspaceId, currentUser } = useBotlit();\n const query = useQuery({\n queryKey: ['botmanor-llm-catalog', workspaceId, currentUser?.id, kind, providerId],\n enabled: Boolean(workspaceId),\n retry: false,\n queryFn: async () => {\n const records: TRecord[] = [];\n for (let offset = 0; offset < 10000; offset += LIST_LIMIT) {\n const result = await client.query<TData>({\n query: document,\n fetchPolicy: 'network-only',\n variables: {\n filters: providerId ? { providerId } : undefined,\n pagination: { limit: LIST_LIMIT, offset },\n },\n });\n if (!result.data) throw new Error('Model catalog unavailable');\n const page = select(result.data);\n if (!Array.isArray(page) || page.length > LIST_LIMIT)\n throw new Error('Model catalog unavailable');\n records.push(...page);\n if (page.length < LIST_LIMIT) return records;\n }\n throw new Error('Model catalog exceeds the supported limit');\n },\n });\n return {\n data: query.data ?? fallback,\n loading: query.isFetching,\n error: query.error ?? undefined,\n refetch: async () => {\n await query.refetch();\n },\n };\n}\n\nexport function useLLMProviders(): QueryResult<LLMProviderRecord[]> {\n return useLLMList<ListLlmProvidersQuery, LLMProviderRecord>(\n ListLlmProvidersDocument,\n 'providers',\n (data) => data?.listLLMProviders ?? NO_PROVIDERS,\n NO_PROVIDERS\n );\n}\n\nexport function useLLMProvider(\n providerId: string | undefined\n): QueryResult<LLMProviderRecord | null> {\n const variables = useMemo(() => ({ id: providerId ?? '' }), [providerId]);\n\n return useWorkspaceQuery<GetLlmProviderQuery, LLMProviderRecord | null>({\n document: GetLlmProviderDocument,\n variables,\n select: (data) => data?.getLLMProvider ?? null,\n fallback: null,\n enabled: Boolean(providerId),\n errorMessage: 'Failed to load LLM provider',\n });\n}\n\nexport function useLLMModels(filters?: { providerId?: string }): QueryResult<LLMModelRecord[]> {\n return useLLMList<ListLlmModelsQuery, LLMModelRecord>(\n ListLlmModelsDocument,\n 'models',\n (data) => data?.listLLMModels ?? NO_MODELS,\n NO_MODELS,\n filters?.providerId\n );\n}\n\n/**\n * Creates a provider, or updates the one whose id the caller passes.\n * `UpdateBotlitLLMProviderInput` has no `type`/`workspaceId`, so the update\n * payload is projected onto the fields that input actually declares.\n */\nexport function useConfigureLLMProvider() {\n const workspaceId = useWorkspaceId();\n\n const [create, createState] = useWorkspaceMutation<\n CreateBotmanorLlmProviderMutation,\n ConfigureLLMProviderVariables,\n LLMProviderRecord\n >({\n document: CreateBotmanorLlmProviderDocument,\n variables: (input) => ({\n input: buildMutationInput({ ...input, workspaceId }, CREATE_PROVIDER_FIELDS),\n }),\n select: (data) => data?.createBotmanorLLMProvider,\n errorMessage: 'Failed to create the LLM provider',\n });\n\n const [update, updateState] = useWorkspaceMutation<\n UpdateLlmProviderMutation,\n { providerId: string; input: ConfigureLLMProviderVariables },\n LLMProviderRecord\n >({\n document: UpdateLlmProviderDocument,\n variables: ({ providerId, input }) => ({\n id: providerId,\n input: buildMutationInput(input, UPDATE_PROVIDER_FIELDS),\n }),\n select: (data) => data?.updateLLMProvider,\n errorMessage: 'Failed to update the LLM provider',\n });\n\n const configureProvider = useCallback(\n async (input: ConfigureLLMProviderVariables, existingId?: string) =>\n existingId ? update({ providerId: existingId, input }) : create(input),\n [create, update]\n );\n\n return {\n configureProvider,\n isConfiguring: createState.loading || updateState.loading,\n error: createState.error ?? updateState.error,\n };\n}\n\nexport function useDeleteLLMProvider() {\n return useWorkspaceMutation<DeleteLlmProviderMutation, string, boolean>({\n document: DeleteLlmProviderDocument,\n variables: (providerId) => ({ id: providerId }),\n select: (data) => data?.deleteLLMProvider,\n errorMessage: 'Failed to delete the LLM provider',\n });\n}\n\nexport function useTestLLMConnection() {\n return useWorkspaceMutation<TestLlmConnectionMutation, string, boolean>({\n document: TestLlmConnectionDocument,\n variables: (providerId) => ({ id: providerId }),\n select: (data) => data?.testLlmConnection,\n errorMessage: 'Failed to test the LLM connection',\n });\n}\n\n/** Register models through the same authenticated workspace gateway as providers. */\nexport function useCreateLLMModel() {\n const [createModel, state] = useWorkspaceMutation<\n CreateBotmanorLlmModelMutation,\n CreateBotmanorLlmModelInput,\n LLMModelRecord\n >({\n document: CreateBotmanorLlmModelDocument,\n variables: (input) => ({\n input: buildMutationInput(\n input,\n fieldsOf<CreateBotmanorLlmModelInput>({\n providerId: true,\n name: true,\n modelId: true,\n contextWindow: true,\n maxOutputTokens: true,\n inputPricePerMToken: true,\n outputPricePerMToken: true,\n supportsStreaming: true,\n supportsFunctionCalling: true,\n supportsVision: true,\n metadata: true,\n })\n ),\n }),\n select: (data) => data?.createBotmanorLLMModel,\n errorMessage: 'Failed to register the model',\n });\n return { createModel, isCreating: state.loading, error: state.error };\n}\n"],"mappings":";;;;;;;AA+CA,IAAM,IAAa,IAwCb,IAAoC,EAAE,EACtC,IAA8B,EAAE,EAEhC,IAAyB,EAAyC;CACtE,aAAa;CACb,cAAc;CACd,aAAa;CACb,UAAU;CACV,MAAM;CACN,MAAM;CACN,aAAa;CACd,CAAC,EAEI,IAAyB,EAAuC;CACpE,aAAa;CACb,cAAc;CACd,aAAa;CACb,UAAU;CACV,UAAU;CACV,MAAM;CACP,CAAC;AASF,SAAS,EACP,GACA,GACA,GACA,GACA,GACwB;CACxB,IAAM,IAAS,GAAoB,EAC7B,EAAE,gBAAa,mBAAgB,GAAW,EAC1C,IAAQ,EAAS;EACrB,UAAU;GAAC;GAAwB;GAAa,GAAa;GAAI;GAAM;GAAW;EAClF,SAAS,EAAQ;EACjB,OAAO;EACP,SAAS,YAAY;GACnB,IAAM,IAAqB,EAAE;AAC7B,QAAK,IAAI,IAAS,GAAG,IAAS,KAAO,KAAU,GAAY;IACzD,IAAM,IAAS,MAAM,EAAO,MAAa;KACvC,OAAO;KACP,aAAa;KACb,WAAW;MACT,SAAS,IAAa,EAAE,eAAY,GAAG,KAAA;MACvC,YAAY;OAAE,OAAO;OAAY;OAAQ;MAC1C;KACF,CAAC;AACF,QAAI,CAAC,EAAO,KAAM,OAAU,MAAM,4BAA4B;IAC9D,IAAM,IAAO,EAAO,EAAO,KAAK;AAChC,QAAI,CAAC,MAAM,QAAQ,EAAK,IAAI,EAAK,SAAS,EACxC,OAAU,MAAM,4BAA4B;AAE9C,QADA,EAAQ,KAAK,GAAG,EAAK,EACjB,EAAK,SAAS,EAAY,QAAO;;AAEvC,SAAU,MAAM,4CAA4C;;EAE/D,CAAC;AACF,QAAO;EACL,MAAM,EAAM,QAAQ;EACpB,SAAS,EAAM;EACf,OAAO,EAAM,SAAS,KAAA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