@stack-spot/portal-network 0.214.0 → 0.215.1-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/api/codeShift.d.ts +12 -1
- package/dist/api/codeShift.d.ts.map +1 -1
- package/dist/api/codeShift.js.map +1 -1
- package/dist/api/genAiInference.d.ts +49 -2
- package/dist/api/genAiInference.d.ts.map +1 -1
- package/dist/api/genAiInference.js +55 -2
- package/dist/api/genAiInference.js.map +1 -1
- package/dist/client/ai.d.ts +1 -3
- package/dist/client/ai.d.ts.map +1 -1
- package/dist/client/ai.js +2 -249
- package/dist/client/ai.js.map +1 -1
- package/dist/client/discover.d.ts +2 -2
- package/dist/client/discover.d.ts.map +1 -1
- package/dist/client/discover.js +4 -3
- package/dist/client/discover.js.map +1 -1
- package/dist/client/gen-ai-inference.d.ts +4 -0
- package/dist/client/gen-ai-inference.d.ts.map +1 -1
- package/dist/client/gen-ai-inference.js +267 -0
- package/dist/client/gen-ai-inference.js.map +1 -1
- package/dist/client/types.d.ts +13 -14
- package/dist/client/types.d.ts.map +1 -1
- package/dist/utils/StreamedJson.d.ts +9 -1
- package/dist/utils/StreamedJson.d.ts.map +1 -1
- package/dist/utils/StreamedJson.js +22 -2
- package/dist/utils/StreamedJson.js.map +1 -1
- package/package.json +1 -1
- package/src/api/codeShift.ts +12 -1
- package/src/api/genAiInference.ts +119 -3
- package/src/client/ai.ts +2 -265
- package/src/client/discover.ts +7 -6
- package/src/client/gen-ai-inference.ts +281 -0
- package/src/client/types.ts +14 -14
- package/src/utils/StreamedJson.tsx +19 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StreamedJson.js","sourceRoot":"","sources":["../../src/utils/StreamedJson.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AACpD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CA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OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,WAAW,CAAC,OAAO,CAAA;IACjC,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,IAAI,CAAA;IAClB,CAAC;IAED;;;;;;;OAOG;IACH,QAAQ,CAAC,QAAqC;QAC5C,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC;YAC9B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;YACnB,OAAO,GAAG,EAAE,GAAG,CAAC,CAAA;QAClB,CAAC;QACD,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QACrC,OAAO,GAAG,EAAE;YACV,MAAM,KAAK,GAAG,IAAI,CAAC,iBAAiB,EAAE,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,QAAQ,CAAC,CAAA;YACpE,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,IAAI,CAAC;gBAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;QACjF,CAAC,CAAA;IACH,CAAC;IAED,SAAS;QACP,IAAI,IAAI,CAAC,KAAK;YAAE,OAAO,OAAO,CAAA;QAC9B,IAAI,IAAI,CAAC,WAAW,CAAC,QAAQ;YAAE,OAAO,SAAS,CAAA;QAC/C,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,IAAI,CAAC,eAAe,EAAE,KAAK,CAAC,IAAI,mBAAmB,EAAE,CAAC,CAAA;IACxD,CAAC;CACF"}
|
package/package.json
CHANGED
package/src/api/codeShift.ts
CHANGED
|
@@ -335,9 +335,13 @@ export type LanguageInfoRequest = {
|
|
|
335
335
|
absolutePercentage: number;
|
|
336
336
|
relativePercentage: number;
|
|
337
337
|
};
|
|
338
|
+
export type CustomHeadersRequest = {
|
|
339
|
+
label: string;
|
|
340
|
+
value: any | null;
|
|
341
|
+
};
|
|
338
342
|
export type PutReportRequest = {
|
|
339
343
|
filesCount?: number;
|
|
340
|
-
issuesCount
|
|
344
|
+
issuesCount?: number | null;
|
|
341
345
|
totalFilesCount?: number | null;
|
|
342
346
|
analyzedFilesCount?: number | null;
|
|
343
347
|
changedFilesCount?: number | null;
|
|
@@ -353,6 +357,7 @@ export type PutReportRequest = {
|
|
|
353
357
|
languageBreakdown?: {
|
|
354
358
|
[key: string]: LanguageInfoRequest;
|
|
355
359
|
} | null;
|
|
360
|
+
customHeaders?: CustomHeadersRequest[] | null;
|
|
356
361
|
};
|
|
357
362
|
export type ModuleResponse2 = {
|
|
358
363
|
id: string;
|
|
@@ -431,6 +436,10 @@ export type LanguageResponse = {
|
|
|
431
436
|
relativePercentage: number;
|
|
432
437
|
absolutePercentage: number;
|
|
433
438
|
};
|
|
439
|
+
export type CustomHeadersResponse = {
|
|
440
|
+
label: string;
|
|
441
|
+
value: any | null;
|
|
442
|
+
};
|
|
434
443
|
export type GetReportResponse = {
|
|
435
444
|
id: string;
|
|
436
445
|
"module": ModuleResponse2 | null;
|
|
@@ -467,6 +476,7 @@ export type GetReportResponse = {
|
|
|
467
476
|
} | null;
|
|
468
477
|
customer_rating?: CustomerRatingResponse | null;
|
|
469
478
|
languages?: LanguageResponse[] | null;
|
|
479
|
+
customHeaders?: CustomHeadersResponse[] | null;
|
|
470
480
|
};
|
|
471
481
|
export type GetReportResponseRead = {
|
|
472
482
|
id: string;
|
|
@@ -504,6 +514,7 @@ export type GetReportResponseRead = {
|
|
|
504
514
|
} | null;
|
|
505
515
|
customer_rating?: CustomerRatingResponse | null;
|
|
506
516
|
languages?: LanguageResponse[] | null;
|
|
517
|
+
customHeaders?: CustomHeadersResponse[] | null;
|
|
507
518
|
};
|
|
508
519
|
export type GetPullRequest = {
|
|
509
520
|
content: string;
|
|
@@ -252,7 +252,23 @@ export type ChatRequest = {
|
|
|
252
252
|
return_ks_in_response?: boolean;
|
|
253
253
|
upload_ids?: string[];
|
|
254
254
|
execution_id?: string | null;
|
|
255
|
+
conversation_id?: string | null;
|
|
256
|
+
use_conversation?: boolean;
|
|
255
257
|
selected_model?: string | null;
|
|
258
|
+
workspace_id?: string | null;
|
|
259
|
+
stack_id?: string | null;
|
|
260
|
+
knowledge_sources?: string[];
|
|
261
|
+
deep_search_ks?: boolean;
|
|
262
|
+
show_chat_processing_state?: boolean;
|
|
263
|
+
};
|
|
264
|
+
export type PromptTokensCurrentUsageResponse = {
|
|
265
|
+
used: number;
|
|
266
|
+
limit: number;
|
|
267
|
+
renewal_date: string;
|
|
268
|
+
};
|
|
269
|
+
export type PromptTokensMonthlyUsageResponse = {
|
|
270
|
+
used: number;
|
|
271
|
+
month: number;
|
|
256
272
|
};
|
|
257
273
|
/**
|
|
258
274
|
* Health Check
|
|
@@ -582,7 +598,7 @@ export function listLlmProvidersV1LlmProvidersGet({ acceptsSelfHosted, xAccountI
|
|
|
582
598
|
/**
|
|
583
599
|
* Handle completions requests
|
|
584
600
|
*/
|
|
585
|
-
export function createCompletionsV1ChatCompletionsPost({ xAccountId, authorization, xRequestOrigin, xConversationId, xMessageId, xQcExecutionId, xQcSlug,
|
|
601
|
+
export function createCompletionsV1ChatCompletionsPost({ xAccountId, authorization, xRequestOrigin, xConversationId, xMessageId, xQcExecutionId, xQcSlug, xStackspotAiVersion, chatCompletion }: {
|
|
586
602
|
xAccountId?: string | null;
|
|
587
603
|
authorization: string;
|
|
588
604
|
xRequestOrigin?: string | null;
|
|
@@ -590,7 +606,7 @@ export function createCompletionsV1ChatCompletionsPost({ xAccountId, authorizati
|
|
|
590
606
|
xMessageId?: string | null;
|
|
591
607
|
xQcExecutionId?: string | null;
|
|
592
608
|
xQcSlug?: string | null;
|
|
593
|
-
|
|
609
|
+
xStackspotAiVersion?: string | null;
|
|
594
610
|
chatCompletion: ChatCompletion;
|
|
595
611
|
}, opts?: Oazapfts.RequestOpts) {
|
|
596
612
|
return oazapfts.ok(oazapfts.fetchJson<{
|
|
@@ -613,7 +629,7 @@ export function createCompletionsV1ChatCompletionsPost({ xAccountId, authorizati
|
|
|
613
629
|
"x-message-id": xMessageId,
|
|
614
630
|
"x-qc-execution-id": xQcExecutionId,
|
|
615
631
|
"x-qc-slug": xQcSlug,
|
|
616
|
-
"x-
|
|
632
|
+
"x-stackspot-ai-version": xStackspotAiVersion
|
|
617
633
|
})
|
|
618
634
|
})));
|
|
619
635
|
}
|
|
@@ -644,3 +660,103 @@ export function agentChatV1AgentAgentIdChatPost({ agentId, xAccountId, authoriza
|
|
|
644
660
|
})
|
|
645
661
|
})));
|
|
646
662
|
}
|
|
663
|
+
/**
|
|
664
|
+
* Total
|
|
665
|
+
*/
|
|
666
|
+
export function totalV1PromptTokensUsageTotalGet({ xAccountId, authorization }: {
|
|
667
|
+
xAccountId?: string | null;
|
|
668
|
+
authorization: string;
|
|
669
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
670
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
671
|
+
status: 200;
|
|
672
|
+
data: PromptTokensCurrentUsageResponse;
|
|
673
|
+
} | {
|
|
674
|
+
status: 404;
|
|
675
|
+
} | {
|
|
676
|
+
status: 422;
|
|
677
|
+
data: HttpValidationError;
|
|
678
|
+
}>("/v1/prompt-tokens-usage/total", {
|
|
679
|
+
...opts,
|
|
680
|
+
headers: oazapfts.mergeHeaders(opts?.headers, {
|
|
681
|
+
"x-account-id": xAccountId,
|
|
682
|
+
authorization
|
|
683
|
+
})
|
|
684
|
+
}));
|
|
685
|
+
}
|
|
686
|
+
/**
|
|
687
|
+
* Current
|
|
688
|
+
*/
|
|
689
|
+
export function currentV1PromptTokensUsageCurrentGet({ xAccountId, authorization }: {
|
|
690
|
+
xAccountId?: string | null;
|
|
691
|
+
authorization: string;
|
|
692
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
693
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
694
|
+
status: 200;
|
|
695
|
+
data: PromptTokensCurrentUsageResponse;
|
|
696
|
+
} | {
|
|
697
|
+
status: 404;
|
|
698
|
+
} | {
|
|
699
|
+
status: 422;
|
|
700
|
+
data: HttpValidationError;
|
|
701
|
+
}>("/v1/prompt-tokens-usage/current", {
|
|
702
|
+
...opts,
|
|
703
|
+
headers: oazapfts.mergeHeaders(opts?.headers, {
|
|
704
|
+
"x-account-id": xAccountId,
|
|
705
|
+
authorization
|
|
706
|
+
})
|
|
707
|
+
}));
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Monthly
|
|
711
|
+
*/
|
|
712
|
+
export function monthlyV1PromptTokensUsageMonthlyGet({ year, xAccountId, authorization }: {
|
|
713
|
+
year: number;
|
|
714
|
+
xAccountId?: string | null;
|
|
715
|
+
authorization: string;
|
|
716
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
717
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
718
|
+
status: 200;
|
|
719
|
+
data: PromptTokensMonthlyUsageResponse[];
|
|
720
|
+
} | {
|
|
721
|
+
status: 404;
|
|
722
|
+
} | {
|
|
723
|
+
status: 422;
|
|
724
|
+
data: HttpValidationError;
|
|
725
|
+
}>(`/v1/prompt-tokens-usage/monthly${QS.query(QS.explode({
|
|
726
|
+
year
|
|
727
|
+
}))}`, {
|
|
728
|
+
...opts,
|
|
729
|
+
headers: oazapfts.mergeHeaders(opts?.headers, {
|
|
730
|
+
"x-account-id": xAccountId,
|
|
731
|
+
authorization
|
|
732
|
+
})
|
|
733
|
+
}));
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Top Users
|
|
737
|
+
*/
|
|
738
|
+
export function topUsersV1PromptTokensUsageTopUsersGet({ year, month, xAccountId, authorization }: {
|
|
739
|
+
year: number;
|
|
740
|
+
month: number;
|
|
741
|
+
xAccountId?: string | null;
|
|
742
|
+
authorization: string;
|
|
743
|
+
}, opts?: Oazapfts.RequestOpts) {
|
|
744
|
+
return oazapfts.ok(oazapfts.fetchJson<{
|
|
745
|
+
status: 200;
|
|
746
|
+
data: any;
|
|
747
|
+
} | {
|
|
748
|
+
status: 404;
|
|
749
|
+
} | {
|
|
750
|
+
status: 422;
|
|
751
|
+
data: HttpValidationError;
|
|
752
|
+
}>(`/v1/prompt-tokens-usage/top-users${QS.query(QS.explode({
|
|
753
|
+
year,
|
|
754
|
+
month
|
|
755
|
+
}))}`, {
|
|
756
|
+
...opts,
|
|
757
|
+
headers: oazapfts.mergeHeaders(opts?.headers, {
|
|
758
|
+
"x-account-id": xAccountId,
|
|
759
|
+
authorization
|
|
760
|
+
})
|
|
761
|
+
}));
|
|
762
|
+
}
|
package/src/client/ai.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { HttpError } from '@oazapfts/runtime'
|
|
2
|
-
import {
|
|
2
|
+
import { isArray } from 'lodash'
|
|
3
3
|
import { getApiAddresses } from '../api-addresses'
|
|
4
4
|
import {
|
|
5
5
|
addFavoriteV1AiStacksStackIdFavoritePost,
|
|
@@ -45,9 +45,9 @@ import {
|
|
|
45
45
|
resetKnowledgeObjectsV1KnowledgeSourcesSlugObjectsDelete,
|
|
46
46
|
runFetchStepV1QuickCommandsSlugStepsStepSlugFetchRunPost,
|
|
47
47
|
searchKnowledgeSourcesV1KnowledgeSourcesSearchPost,
|
|
48
|
+
startScriptStepV1QuickCommandsSlugStepsStepSlugStartScriptPost,
|
|
48
49
|
tokensByUserV1AnalyticsTokensByUserGet,
|
|
49
50
|
tokensDailyUsageV1AnalyticsTokensDailyUsageGet,
|
|
50
|
-
startScriptStepV1QuickCommandsSlugStepsStepSlugStartScriptPost,
|
|
51
51
|
totalV1TokensUsageTotalGet,
|
|
52
52
|
updateQuickCommandV1QuickCommandsSlugPatch,
|
|
53
53
|
updateResourceReviewV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdPatch,
|
|
@@ -61,18 +61,10 @@ import { StackspotAPIError } from '../error/StackspotAPIError'
|
|
|
61
61
|
import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
|
|
62
62
|
import { removeAuthorizationParam } from '../utils/remove-authorization-param'
|
|
63
63
|
import { StreamedJson } from '../utils/StreamedJson'
|
|
64
|
-
import { formatJson } from '../utils/string'
|
|
65
|
-
import { agentToolsClient } from './agent-tools'
|
|
66
64
|
import {
|
|
67
|
-
AgentInfo,
|
|
68
|
-
ChatAgentTool,
|
|
69
|
-
ChatResponseWithSteps,
|
|
70
|
-
FixedChatRequest,
|
|
71
|
-
FixedChatResponse,
|
|
72
65
|
FixedConversationResponse,
|
|
73
66
|
FixedDependencyResponse,
|
|
74
67
|
ReplaceResult,
|
|
75
|
-
StepChatStep,
|
|
76
68
|
} from './types'
|
|
77
69
|
|
|
78
70
|
const listQAV3WithoutAuthorization = removeAuthorizationParam(listAllV3QuickCommandsGet)
|
|
@@ -340,261 +332,6 @@ class AIClient extends ReactQueryNetworkClient {
|
|
|
340
332
|
deleteReviewComment = this.mutation(
|
|
341
333
|
removeAuthorizationParam(deleteReviewCommentV1ResourcesResourceTypeSlugResourceSlugReviewsReviewIdAnswersAnswerIdDelete))
|
|
342
334
|
|
|
343
|
-
private static async toolsOfAgent(agentId?: string) {
|
|
344
|
-
try {
|
|
345
|
-
const agent = agentId ? await agentToolsClient.agent.query({ agentId }) : undefined
|
|
346
|
-
if (!agent) return []
|
|
347
|
-
const tools: (Omit<ChatAgentTool, 'duration' | 'prompt' | 'output'>)[] = []
|
|
348
|
-
agent.toolkits?.builtin_toolkits?.forEach(kit => kit.tools?.forEach(({ id, name, description }) => {
|
|
349
|
-
if (id) tools.push({ image: kit.image_url, id, name: name || id, description })
|
|
350
|
-
}))
|
|
351
|
-
agent.toolkits?.custom_toolkits?.forEach(kit => kit.tools?.forEach(({ id, name, description }) => {
|
|
352
|
-
if (id) tools.push({ image: kit.avatar ?? undefined, id, name: name || id, description })
|
|
353
|
-
}))
|
|
354
|
-
return tools
|
|
355
|
-
} catch {
|
|
356
|
-
return []
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
sendChatMessage(request: FixedChatRequest, minChangeIntervalMS?: number): StreamedJson<ChatResponseWithSteps> {
|
|
361
|
-
const abortController = new AbortController()
|
|
362
|
-
const headers = {
|
|
363
|
-
'Content-Type': 'application/json',
|
|
364
|
-
'Accept': 'text/event-stream',
|
|
365
|
-
}
|
|
366
|
-
const events = this.stream(
|
|
367
|
-
this.resolveURL('v3/chat'),
|
|
368
|
-
{ method: 'post', body: JSON.stringify(request), headers, signal: abortController.signal },
|
|
369
|
-
)
|
|
370
|
-
|
|
371
|
-
const DYNAMIC_TOOL_ID = 'dynamic'
|
|
372
|
-
function isDynamicTool(info: AgentInfo) {
|
|
373
|
-
return info.type === 'tool' && info.id === DYNAMIC_TOOL_ID
|
|
374
|
-
}
|
|
375
|
-
/**
|
|
376
|
-
* This function treats events in the streaming that deals with the execution of tools. Since these events are not concatenated like
|
|
377
|
-
* normal streamings of data, we need this separate function to deal with them. It transforms the internal data model of the
|
|
378
|
-
* StreamedJson object whenever an event is triggered.
|
|
379
|
-
*/
|
|
380
|
-
async function transform(event: Partial<FixedChatResponse>, data: Partial<ChatResponseWithSteps>) {
|
|
381
|
-
const info = event.agent_info
|
|
382
|
-
if (!info) return
|
|
383
|
-
const tools = await AIClient.toolsOfAgent(request.context?.agent_id)
|
|
384
|
-
data.steps = data.steps ? [...data.steps] : []
|
|
385
|
-
|
|
386
|
-
if (info.type === 'planning' && info.action === 'end') {
|
|
387
|
-
data.steps.push({
|
|
388
|
-
id: 'planning',
|
|
389
|
-
type: 'planning',
|
|
390
|
-
status: 'success',
|
|
391
|
-
duration: info.duration || 0,
|
|
392
|
-
steps: info.data?.steps?.map(s => s.goal) ?? [],
|
|
393
|
-
goal: info.data?.plan_goal ?? '',
|
|
394
|
-
})
|
|
395
|
-
|
|
396
|
-
info.data?.steps.forEach(s => data.steps?.push({
|
|
397
|
-
id: s.id,
|
|
398
|
-
type: 'step',
|
|
399
|
-
status: 'pending',
|
|
400
|
-
input: s.goal,
|
|
401
|
-
attempts: [{
|
|
402
|
-
tools: s.tools?.map(t => ({
|
|
403
|
-
...(tools.find(({ id }) => id === t.tool_id) ?? { id: t.tool_id, name: t.tool_id }),
|
|
404
|
-
executionId: t.tool_execution_id,
|
|
405
|
-
goal: t.goal,
|
|
406
|
-
})),
|
|
407
|
-
}],
|
|
408
|
-
}))
|
|
409
|
-
data.steps.push({ id: 'answer', type: 'answer', status: 'pending' })
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
if (info.type === 'planning' && info.action === 'awaiting_approval') {
|
|
413
|
-
data.steps.push({
|
|
414
|
-
id: 'planning',
|
|
415
|
-
type: 'planning',
|
|
416
|
-
status: 'awaiting_approval',
|
|
417
|
-
user_question: info.data?.user_question,
|
|
418
|
-
duration: info.duration || 0,
|
|
419
|
-
steps: info.data?.steps?.map(s => s.goal) ?? [],
|
|
420
|
-
goal: info.data?.plan_goal ?? '',
|
|
421
|
-
})
|
|
422
|
-
info.data?.steps.forEach(s => data.steps?.push({
|
|
423
|
-
id: s.id,
|
|
424
|
-
type: 'step',
|
|
425
|
-
status: 'pending',
|
|
426
|
-
input: s.goal,
|
|
427
|
-
attempts: [{
|
|
428
|
-
tools: s.tools?.map(t => ({
|
|
429
|
-
...(tools.find(({ id }) => id === t.tool_id) ?? { id: t.tool_id, name: t.tool_id }),
|
|
430
|
-
executionId: t.tool_execution_id,
|
|
431
|
-
goal: t.goal,
|
|
432
|
-
})),
|
|
433
|
-
}],
|
|
434
|
-
}))
|
|
435
|
-
data.steps.push({ id: 'answer', type: 'answer', status: 'pending' })
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
if (info.type === 'step' && info.action === 'start') {
|
|
439
|
-
const step = data.steps.find(s => s.id === info.id)
|
|
440
|
-
if (step) step.status = 'running'
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
if (info.type === 'step' && info.action === 'end') {
|
|
444
|
-
const step = data.steps.find(s => s.id === info.id) as StepChatStep
|
|
445
|
-
if (step) {
|
|
446
|
-
step.status = 'success'
|
|
447
|
-
step.duration = info.duration
|
|
448
|
-
const lastToolId = last(step.attempts[0].tools)?.id
|
|
449
|
-
const lastAttemptOfLastTool = findLast(step.attempts.map(a => a.tools).flat(), t => t?.id === lastToolId)
|
|
450
|
-
step.output = lastAttemptOfLastTool?.output
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
if (info.type === 'tool_calls' && info.action === 'start') {
|
|
455
|
-
const hasPlanning = data.steps.find(s => s.type === 'planning')
|
|
456
|
-
// On the first tool_calls:start, create the synthetic planning ("dynamic") step.
|
|
457
|
-
if (!hasPlanning) {
|
|
458
|
-
const userPrompt = request.user_prompt === 'string' ? request.user_prompt : JSON.stringify(request.user_prompt)
|
|
459
|
-
data.steps.push({
|
|
460
|
-
id: 'dynamic',
|
|
461
|
-
type: 'planning',
|
|
462
|
-
status: 'success',
|
|
463
|
-
steps: [],
|
|
464
|
-
goal: userPrompt,
|
|
465
|
-
user_question: userPrompt,
|
|
466
|
-
})
|
|
467
|
-
}
|
|
468
|
-
const toolsStepId = data.steps.filter(s => s.id === 'tools' || s.id.startsWith('tools-')).length + 1
|
|
469
|
-
data.steps.push({
|
|
470
|
-
id: `tools-${toolsStepId.toString()}`,
|
|
471
|
-
type: 'step',
|
|
472
|
-
status: 'running',
|
|
473
|
-
attempts: [{ tools: [] }],
|
|
474
|
-
} as StepChatStep)
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
if (info.type === 'tool_calls' && info.action === 'end') {
|
|
478
|
-
const lastStep = findLast(data.steps, s => s.id === 'tools' || s.id.startsWith('tools-')) as StepChatStep
|
|
479
|
-
if (lastStep) {
|
|
480
|
-
lastStep.status = 'success'
|
|
481
|
-
lastStep.duration = info.duration
|
|
482
|
-
const lastAttemptOfLastTool = last(lastStep.attempts.map(a => a.tools).flat())
|
|
483
|
-
lastStep.output = lastAttemptOfLastTool?.output
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
if (info.type === 'tool' && info.action === 'awaiting_approval') {
|
|
488
|
-
const tool = tools.find(({ id }) => id === info.data?.tool_id)
|
|
489
|
-
data.steps.push({
|
|
490
|
-
id: info.id,
|
|
491
|
-
type: 'tool',
|
|
492
|
-
status: 'awaiting_approval',
|
|
493
|
-
duration: info.duration || 0,
|
|
494
|
-
input: info.data?.input,
|
|
495
|
-
user_question: info.data?.user_question,
|
|
496
|
-
attempts: [{
|
|
497
|
-
tools: [{
|
|
498
|
-
executionId: info.id,
|
|
499
|
-
id: info.data?.tool_id ?? '',
|
|
500
|
-
name: tool?.name ?? '',
|
|
501
|
-
goal: tool?.goal,
|
|
502
|
-
...tool,
|
|
503
|
-
}],
|
|
504
|
-
}],
|
|
505
|
-
})
|
|
506
|
-
data.steps.push({ id: 'answer', type: 'answer', status: 'pending' })
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
if (info.type === 'tool' && info.action === 'start') {
|
|
510
|
-
if (!info.data) return
|
|
511
|
-
const input = formatJson(info.data.input)
|
|
512
|
-
const tool = findLast(tools, ({ id }) => id === info.data?.tool_id) ?? { id: info.data?.tool_id, name: info.data?.tool_id }
|
|
513
|
-
|
|
514
|
-
const currentStep = findLast(data.steps, s => s.status === 'running') as StepChatStep
|
|
515
|
-
|
|
516
|
-
//There might be a tool with status awaiting_approval, so we want to inform tool has already started
|
|
517
|
-
if (!currentStep || !currentStep?.attempts?.[0]?.tools) {
|
|
518
|
-
data.steps.push({
|
|
519
|
-
id: info.id,
|
|
520
|
-
type: 'tool',
|
|
521
|
-
status: 'running',
|
|
522
|
-
duration: info.duration || 0,
|
|
523
|
-
input: info.data?.input,
|
|
524
|
-
user_question: info.data?.user_question,
|
|
525
|
-
attempts: [{
|
|
526
|
-
tools: [{ ...tool, executionId: info.id, input }],
|
|
527
|
-
}],
|
|
528
|
-
})
|
|
529
|
-
} else {
|
|
530
|
-
const toolInFirstAttempt = findLast(currentStep?.attempts?.[0]?.tools, t => t.executionId === info.id)
|
|
531
|
-
//One step might have multiple tools. When in an approval mode, we might not have all the tools in the array yet.
|
|
532
|
-
//For dynamic tools (id === 'dynamic'), we always push a new tool, since dynamic executions can trigger
|
|
533
|
-
//multiple tool runs in the same step and do not follow the planned tool structure.
|
|
534
|
-
//So we make sure to add any tools that are not in there, or always add for dynamic tools.
|
|
535
|
-
if (!toolInFirstAttempt || isDynamicTool(info)) {
|
|
536
|
-
currentStep.attempts?.[0].tools?.push({
|
|
537
|
-
...tool,
|
|
538
|
-
executionId: info.id,
|
|
539
|
-
input,
|
|
540
|
-
status: 'running',
|
|
541
|
-
})
|
|
542
|
-
} else {
|
|
543
|
-
const input = formatJson(info.data.input)
|
|
544
|
-
if (info.data.attempt === 1) {
|
|
545
|
-
toolInFirstAttempt.input = input
|
|
546
|
-
} else {
|
|
547
|
-
currentStep.attempts[info.data.attempt - 1] ??= { tools: [] }
|
|
548
|
-
currentStep.attempts[info.data.attempt - 1].tools?.push({
|
|
549
|
-
...tool,
|
|
550
|
-
executionId: info.id,
|
|
551
|
-
input,
|
|
552
|
-
})
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
if (info.type === 'tool' && info.action === 'end') {
|
|
559
|
-
const currentStep = data.steps.find(s => s.status === 'running') as StepChatStep
|
|
560
|
-
if (!currentStep || !info.data) return
|
|
561
|
-
|
|
562
|
-
// attempt index for tool execution starts at 0 for dynamically executed tools,while for planned tools it starts at 1
|
|
563
|
-
const attempt = isDynamicTool(info) ? info.data.attempt : info.data.attempt - 1
|
|
564
|
-
const tool = last(currentStep?.attempts?.[attempt]?.tools)
|
|
565
|
-
if (tool) {
|
|
566
|
-
tool.output = formatJson(info.data.output)
|
|
567
|
-
tool.duration = info.duration
|
|
568
|
-
tool.status = 'success'
|
|
569
|
-
}
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
if (info.type === 'final_answer' && info.action === 'start') {
|
|
573
|
-
const answerStep = last(data.steps)
|
|
574
|
-
if (answerStep) answerStep.status = 'running'
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
if (info.type === 'chat' && info.action === 'end') {
|
|
579
|
-
const lastStep = last(data.steps)
|
|
580
|
-
if (lastStep?.type === 'answer') {
|
|
581
|
-
lastStep.status = 'success'
|
|
582
|
-
lastStep.duration = info.duration
|
|
583
|
-
} else {
|
|
584
|
-
data.steps.push({ id: 'answer', type: 'answer', status: 'success' })
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
return new StreamedJson({
|
|
590
|
-
eventsPromise: events,
|
|
591
|
-
abortController,
|
|
592
|
-
minChangeIntervalMS,
|
|
593
|
-
ignoreKeys: ['agent_info'],
|
|
594
|
-
transform,
|
|
595
|
-
})
|
|
596
|
-
}
|
|
597
|
-
|
|
598
335
|
contentDependencies = this.query(removeAuthorizationParam(
|
|
599
336
|
getContentDependenciesV1ContentContentTypeContentIdDependenciesGet as ReplaceResult<
|
|
600
337
|
typeof getContentDependenciesV1ContentContentTypeContentIdDependenciesGet,
|
package/src/client/discover.ts
CHANGED
|
@@ -2,16 +2,16 @@ import { HttpError } from '@oazapfts/runtime'
|
|
|
2
2
|
import { findLast, last } from 'lodash'
|
|
3
3
|
import { getApiAddresses } from '../api-addresses'
|
|
4
4
|
import { ConversationResponse } from '../api/ai'
|
|
5
|
-
import { create, create1, create2, defaults, deleteById, deleteById1, deleteById2, fetchInsights, getAll, getAll1, getAll2, getAllByHypothesis, getById, getById1, getById2, getInsightById, GetOpportunityResponse,
|
|
5
|
+
import { AiChatRequest, create, create1, create2, defaults, deleteById, deleteById1, deleteById2, fetchInsights, getAll, getAll1, getAll2, getAllByHypothesis, getById, getById1, getById2, getInsightById, GetOpportunityResponse, refreshInsights } from '../api/discover'
|
|
6
6
|
import { DefaultAPIError } from '../error/DefaultAPIError'
|
|
7
|
+
import { baseDictionary } from '../error/dictionary/base'
|
|
7
8
|
import { StackspotAPIError } from '../error/StackspotAPIError'
|
|
9
|
+
import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
|
|
8
10
|
import { StreamedJson } from '../utils/StreamedJson'
|
|
9
|
-
import { baseDictionary } from '../error/dictionary/base'
|
|
10
11
|
import { formatJson } from '../utils/string'
|
|
11
|
-
import { ReactQueryNetworkClient } from '../network/ReactQueryNetworkClient'
|
|
12
|
-
import { aiClient } from './ai'
|
|
13
|
-
import { ChatAgentTool, ChatResponseWithSteps, FixedChatResponse, StepChatStep } from './types'
|
|
14
12
|
import { agentToolsClient } from './agent-tools'
|
|
13
|
+
import { aiClient } from './ai'
|
|
14
|
+
import { AgentInfo, ChatAgentTool, ChatResponseWithSteps, FixedChatResponse, StepChatStep } from './types'
|
|
15
15
|
|
|
16
16
|
export interface ChatConversionDetails extends ConversationResponse {
|
|
17
17
|
opportunityName?: string,
|
|
@@ -137,7 +137,8 @@ class DiscoverClient extends ReactQueryNetworkClient {
|
|
|
137
137
|
* StreamedJson object whenever an event is triggered.
|
|
138
138
|
*/
|
|
139
139
|
async function transform(event: Partial<FixedChatResponse>, data: Partial<ChatResponseWithSteps>) {
|
|
140
|
-
|
|
140
|
+
// todo fix
|
|
141
|
+
const info = event.agent_info as unknown as AgentInfo
|
|
141
142
|
|
|
142
143
|
if (!info) return
|
|
143
144
|
|