Remove app context from AI admin flows
This commit is contained in:
@@ -1,26 +1,5 @@
|
||||
import { requestClient } from '#/api/request';
|
||||
import { streamRequestClient } from '#/api/stream-request';
|
||||
import { useAppContextStore } from '#/store/app-context';
|
||||
|
||||
/**
|
||||
* Inject current application context into AI requests.
|
||||
*/
|
||||
function injectSystemVariables(
|
||||
inputs: Record<string, any>,
|
||||
): Record<string, any> {
|
||||
const appContextStore = useAppContextStore();
|
||||
const result = { ...inputs };
|
||||
|
||||
if (appContextStore.currentApp?.id && !result.application_id) {
|
||||
result.application_id = appContextStore.currentApp.id;
|
||||
}
|
||||
|
||||
if (appContextStore.currentApp?.code && !result.application_code) {
|
||||
result.application_code = appContextStore.currentApp.code;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* AI 平台 API
|
||||
@@ -953,12 +932,9 @@ export function runWorkflowStreamApi(
|
||||
onComplete?: () => void,
|
||||
useDraft: boolean = false,
|
||||
): () => void {
|
||||
// Inject current application context.
|
||||
const finalInputs = injectSystemVariables(inputs);
|
||||
|
||||
return streamRequestClient<WorkflowStreamEvent>(
|
||||
`${BASE_URL}/workflow/${id}/run/stream`,
|
||||
{ inputs: finalInputs, use_draft: useDraft },
|
||||
{ inputs, use_draft: useDraft },
|
||||
{
|
||||
onData: onEvent,
|
||||
onError: (error) => {
|
||||
@@ -1482,12 +1458,9 @@ export function sendAgentMessageStream(
|
||||
onError?: (error: Error) => void,
|
||||
onComplete?: () => void,
|
||||
) {
|
||||
// Inject current application context.
|
||||
const finalData = injectSystemVariables(data);
|
||||
|
||||
return streamRequestClient<AgentChatEvent>(
|
||||
`${BASE_URL}/agent/${agentId}/chat`,
|
||||
finalData,
|
||||
data,
|
||||
{
|
||||
onData: onEvent,
|
||||
onError: (error) => {
|
||||
|
||||
Reference in New Issue
Block a user