@finos/legend-lego 2.0.202 → 2.0.203

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.
Files changed (75) hide show
  1. package/lib/index.css +2 -2
  2. package/lib/index.css.map +1 -1
  3. package/lib/legend-ai/LegendAIDocEnrichment.d.ts +34 -1
  4. package/lib/legend-ai/LegendAIDocEnrichment.d.ts.map +1 -1
  5. package/lib/legend-ai/LegendAIDocEnrichment.js +890 -1
  6. package/lib/legend-ai/LegendAIDocEnrichment.js.map +1 -1
  7. package/lib/legend-ai/LegendAIServiceRetrieval.d.ts +36 -0
  8. package/lib/legend-ai/LegendAIServiceRetrieval.d.ts.map +1 -0
  9. package/lib/legend-ai/LegendAIServiceRetrieval.js +179 -0
  10. package/lib/legend-ai/LegendAIServiceRetrieval.js.map +1 -0
  11. package/lib/legend-ai/LegendAITypes.d.ts +62 -2
  12. package/lib/legend-ai/LegendAITypes.d.ts.map +1 -1
  13. package/lib/legend-ai/LegendAITypes.js +56 -30
  14. package/lib/legend-ai/LegendAITypes.js.map +1 -1
  15. package/lib/legend-ai/LegendAI_LegendApplicationPlugin_Extension.d.ts +29 -6
  16. package/lib/legend-ai/LegendAI_LegendApplicationPlugin_Extension.d.ts.map +1 -1
  17. package/lib/legend-ai/LegendAI_LegendApplicationPlugin_Extension.js +9 -0
  18. package/lib/legend-ai/LegendAI_LegendApplicationPlugin_Extension.js.map +1 -1
  19. package/lib/legend-ai/__test-utils__/LegendAITestUtils.d.ts +5 -0
  20. package/lib/legend-ai/__test-utils__/LegendAITestUtils.d.ts.map +1 -1
  21. package/lib/legend-ai/__test-utils__/LegendAITestUtils.js +18 -2
  22. package/lib/legend-ai/__test-utils__/LegendAITestUtils.js.map +1 -1
  23. package/lib/legend-ai/components/LegendAIAnalysisPanel.d.ts.map +1 -1
  24. package/lib/legend-ai/components/LegendAIAnalysisPanel.js +27 -8
  25. package/lib/legend-ai/components/LegendAIAnalysisPanel.js.map +1 -1
  26. package/lib/legend-ai/components/LegendAIAnalysisUtils.d.ts +1 -0
  27. package/lib/legend-ai/components/LegendAIAnalysisUtils.d.ts.map +1 -1
  28. package/lib/legend-ai/components/LegendAIAnalysisUtils.js +144 -22
  29. package/lib/legend-ai/components/LegendAIAnalysisUtils.js.map +1 -1
  30. package/lib/legend-ai/components/LegendAICharts.d.ts +4 -0
  31. package/lib/legend-ai/components/LegendAICharts.d.ts.map +1 -1
  32. package/lib/legend-ai/components/LegendAICharts.js +60 -1
  33. package/lib/legend-ai/components/LegendAICharts.js.map +1 -1
  34. package/lib/legend-ai/components/LegendAIChat.d.ts.map +1 -1
  35. package/lib/legend-ai/components/LegendAIChat.js +46 -17
  36. package/lib/legend-ai/components/LegendAIChat.js.map +1 -1
  37. package/lib/legend-ai/components/LegendAIChatHelpers.d.ts +1 -1
  38. package/lib/legend-ai/components/LegendAIChatHelpers.d.ts.map +1 -1
  39. package/lib/legend-ai/components/LegendAIChatHelpers.js +220 -15
  40. package/lib/legend-ai/components/LegendAIChatHelpers.js.map +1 -1
  41. package/lib/legend-ai/components/LegendAIChatInput.d.ts.map +1 -1
  42. package/lib/legend-ai/components/LegendAIChatInput.js +1 -0
  43. package/lib/legend-ai/components/LegendAIChatInput.js.map +1 -1
  44. package/lib/legend-ai/components/LegendAIScopeSelector.d.ts.map +1 -1
  45. package/lib/legend-ai/components/LegendAIScopeSelector.js +5 -2
  46. package/lib/legend-ai/components/LegendAIScopeSelector.js.map +1 -1
  47. package/lib/legend-ai/index.d.ts +4 -3
  48. package/lib/legend-ai/index.d.ts.map +1 -1
  49. package/lib/legend-ai/index.js +4 -3
  50. package/lib/legend-ai/index.js.map +1 -1
  51. package/lib/legend-ai/stores/LegendAIChatProcessors.d.ts +30 -13
  52. package/lib/legend-ai/stores/LegendAIChatProcessors.d.ts.map +1 -1
  53. package/lib/legend-ai/stores/LegendAIChatProcessors.js +776 -216
  54. package/lib/legend-ai/stores/LegendAIChatProcessors.js.map +1 -1
  55. package/lib/legend-ai/stores/LegendAIChatState.d.ts +2 -2
  56. package/lib/legend-ai/stores/LegendAIChatState.d.ts.map +1 -1
  57. package/lib/legend-ai/stores/LegendAIChatState.js +26 -25
  58. package/lib/legend-ai/stores/LegendAIChatState.js.map +1 -1
  59. package/package.json +3 -3
  60. package/src/legend-ai/LegendAIDocEnrichment.ts +1198 -1
  61. package/src/legend-ai/LegendAIServiceRetrieval.ts +228 -0
  62. package/src/legend-ai/LegendAITypes.ts +138 -32
  63. package/src/legend-ai/LegendAI_LegendApplicationPlugin_Extension.ts +62 -0
  64. package/src/legend-ai/__test-utils__/LegendAITestUtils.ts +28 -0
  65. package/src/legend-ai/components/LegendAIAnalysisPanel.tsx +36 -17
  66. package/src/legend-ai/components/LegendAIAnalysisUtils.ts +178 -22
  67. package/src/legend-ai/components/LegendAICharts.tsx +160 -0
  68. package/src/legend-ai/components/LegendAIChat.tsx +107 -14
  69. package/src/legend-ai/components/LegendAIChatHelpers.ts +334 -20
  70. package/src/legend-ai/components/LegendAIChatInput.tsx +2 -1
  71. package/src/legend-ai/components/LegendAIScopeSelector.tsx +7 -2
  72. package/src/legend-ai/index.ts +22 -1
  73. package/src/legend-ai/stores/LegendAIChatProcessors.ts +1205 -321
  74. package/src/legend-ai/stores/LegendAIChatState.ts +80 -69
  75. package/tsconfig.json +1 -0
@@ -25,6 +25,7 @@ import {
25
25
  type LegendAIProductMetadata,
26
26
  type LegendAIScopeItem,
27
27
  type LegendAIQuestionIntent,
28
+ type LegendAIModelContext,
28
29
  LegendAIMessageRole,
29
30
  } from '../LegendAITypes.js';
30
31
  import {
@@ -48,6 +49,7 @@ export const useLegendAIChatState = (
48
49
  plugin: LegendAI_LegendApplicationPlugin_Extension,
49
50
  dataProductCoordinates?: LegendAIOrchestratorDataProductCoordinates,
50
51
  pureExecutionContext?: QueryExplicitExecutionContextInfo,
52
+ modelContext?: LegendAIModelContext,
51
53
  ): LegendAIChatState => {
52
54
  const LEGEND_AI_MCP_SCOPE_ID = 'legend-ai-mcp';
53
55
  const [questionText, setQuestionText] = useState('');
@@ -196,37 +198,39 @@ export const useLegendAIChatState = (
196
198
 
197
199
  const askQuestion = useCallback(
198
200
  (): void =>
199
- dispatchQuestion(questionText, (trimmed, history) =>
200
- selectedScopes.some((scope) => scope.id === LEGEND_AI_MCP_SCOPE_ID) &&
201
- configForRequest.orchestratorUrl &&
202
- dataProductCoordinates
203
- ? processQuestionViaOrchestrator(
204
- trimmed,
205
- dataProductCoordinates,
206
- metadata,
207
- {
208
- config: configForRequest,
209
- plugin,
210
- history,
211
- setMessages,
212
- },
213
- pureExecutionContext,
214
- )
215
- : processQuestion(
216
- trimmed,
217
- services,
218
- coordinates,
219
- metadata,
220
- {
221
- config: configForRequest,
222
- plugin,
223
- history,
224
- setMessages,
225
- },
226
- dataProductCoordinates,
227
- pureExecutionContext,
228
- ),
229
- ),
201
+ dispatchQuestion(questionText, (trimmed, history) => {
202
+ const operationContext = {
203
+ config: configForRequest,
204
+ plugin,
205
+ history,
206
+ setMessages,
207
+ };
208
+ if (
209
+ selectedScopes.some((scope) => scope.id === LEGEND_AI_MCP_SCOPE_ID) &&
210
+ configForRequest.orchestratorUrl &&
211
+ dataProductCoordinates
212
+ ) {
213
+ return processQuestionViaOrchestrator(
214
+ trimmed,
215
+ dataProductCoordinates,
216
+ metadata,
217
+ operationContext,
218
+ pureExecutionContext,
219
+ undefined,
220
+ modelContext,
221
+ );
222
+ }
223
+ return processQuestion(
224
+ trimmed,
225
+ services,
226
+ coordinates,
227
+ metadata,
228
+ operationContext,
229
+ dataProductCoordinates,
230
+ pureExecutionContext,
231
+ modelContext,
232
+ );
233
+ }),
230
234
  [
231
235
  questionText,
232
236
  dispatchQuestion,
@@ -238,49 +242,52 @@ export const useLegendAIChatState = (
238
242
  dataProductCoordinates,
239
243
  pureExecutionContext,
240
244
  selectedScopes,
245
+ modelContext,
241
246
  ],
242
247
  );
243
248
 
244
249
  const askQuestionWithIntent = useCallback(
245
250
  (text: string, intent: LegendAIQuestionIntent): void =>
246
- dispatchQuestion(text, (trimmed, history) =>
247
- selectedScopes.some((scope) => scope.id === LEGEND_AI_MCP_SCOPE_ID) &&
248
- configForRequest.orchestratorUrl &&
249
- dataProductCoordinates
250
- ? processQuestionViaOrchestrator(
251
- trimmed,
252
- dataProductCoordinates,
253
- metadata,
254
- {
255
- config: configForRequest,
256
- plugin,
257
- history,
258
- setMessages,
259
- },
260
- pureExecutionContext,
261
- )
262
- : processQuestionWithIntent(
263
- trimmed,
264
- intent,
265
- services,
266
- coordinates,
267
- metadata,
268
- {
269
- config: configForRequest,
270
- plugin,
271
- history,
272
- setMessages,
273
- },
274
- dataProductCoordinates
275
- ? {
276
- dataProductCoordinates,
277
- ...(pureExecutionContext === undefined
278
- ? {}
279
- : { pureExecutionContext }),
280
- }
281
- : undefined,
282
- ),
283
- ),
251
+ dispatchQuestion(text, (trimmed, history) => {
252
+ const operationContext = {
253
+ config: configForRequest,
254
+ plugin,
255
+ history,
256
+ setMessages,
257
+ };
258
+ if (
259
+ selectedScopes.some((scope) => scope.id === LEGEND_AI_MCP_SCOPE_ID) &&
260
+ configForRequest.orchestratorUrl &&
261
+ dataProductCoordinates
262
+ ) {
263
+ return processQuestionViaOrchestrator(
264
+ trimmed,
265
+ dataProductCoordinates,
266
+ metadata,
267
+ operationContext,
268
+ pureExecutionContext,
269
+ undefined,
270
+ modelContext,
271
+ );
272
+ }
273
+ return processQuestionWithIntent(
274
+ trimmed,
275
+ intent,
276
+ services,
277
+ coordinates,
278
+ metadata,
279
+ operationContext,
280
+ dataProductCoordinates
281
+ ? {
282
+ dataProductCoordinates,
283
+ ...(pureExecutionContext === undefined
284
+ ? {}
285
+ : { pureExecutionContext }),
286
+ }
287
+ : undefined,
288
+ modelContext,
289
+ );
290
+ }),
284
291
  [
285
292
  dispatchQuestion,
286
293
  services,
@@ -291,6 +298,7 @@ export const useLegendAIChatState = (
291
298
  dataProductCoordinates,
292
299
  pureExecutionContext,
293
300
  selectedScopes,
301
+ modelContext,
294
302
  ],
295
303
  );
296
304
 
@@ -338,6 +346,8 @@ export const useLegendAIChatState = (
338
346
  setMessages,
339
347
  },
340
348
  pureExecutionContext,
349
+ undefined,
350
+ modelContext,
341
351
  )
342
352
  .catch(noop)
343
353
  .finally(() => {
@@ -353,6 +363,7 @@ export const useLegendAIChatState = (
353
363
  plugin,
354
364
  dataProductCoordinates,
355
365
  pureExecutionContext,
366
+ modelContext,
356
367
  ],
357
368
  );
358
369
 
package/tsconfig.json CHANGED
@@ -54,6 +54,7 @@
54
54
  "./src/data-grid/index.ts",
55
55
  "./src/graph-editor/index.ts",
56
56
  "./src/legend-ai/LegendAIDocEnrichment.ts",
57
+ "./src/legend-ai/LegendAIServiceRetrieval.ts",
57
58
  "./src/legend-ai/LegendAITypes.ts",
58
59
  "./src/legend-ai/LegendAI_LegendApplicationPlugin_Extension.ts",
59
60
  "./src/legend-ai/index.ts",