Skip to content

Commit f31a2b8

Browse files
committed
fix error of gurdrail step never marking as complete
1 parent 51fa662 commit f31a2b8

2 files changed

Lines changed: 23 additions & 5 deletions

File tree

  • platform-api/internal/service
  • portals/ai-workspace/src/pages/appShell/appShellPages/quickStart/lllmStepBanner

platform-api/internal/service/llm.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,14 @@ func (s *LLMProviderTemplateService) Update(orgUUID, handle, updatedBy string, r
356356
return nil, apperror.ValidationFailed.New("The template version cannot be changed via update; use the versions endpoint.")
357357
}
358358

359+
if req.Metadata != nil {
360+
if endpointURL := strings.TrimSpace(utils.ValueOrEmpty(req.Metadata.EndpointUrl)); endpointURL != "" {
361+
if err := utils.ValidateURL(endpointURL); err != nil {
362+
return nil, apperror.ValidationFailed.New("The metadata endpointUrl must be a valid URL.")
363+
}
364+
}
365+
}
366+
359367
managedBy := existing.ManagedBy
360368
if req.ManagedBy != nil {
361369
managedBy = defaultTemplateManagedBy(req.ManagedBy)

portals/ai-workspace/src/pages/appShell/appShellPages/quickStart/lllmStepBanner/LLLMStepBanner.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import {
4040
} from '../../../../../apis/llmProviderApis';
4141
import { useAppShell } from '../../../../../contexts/AppShellContext';
4242
import { useAIEntity } from '../../../../../contexts/AIEntitiesContext';
43+
import { useLLMProvider } from '../../../../../contexts/llmProvider';
4344
import { PLATFORM_API_BASE_URL } from '../../../../../config.env';
4445
import type { LLMProvider } from '../../../../../utils/types';
4546

@@ -66,6 +67,7 @@ type LLLMStepBannerProps = {
6667
};
6768

6869
const DEFAULT_TOTAL_STEPS = 4;
70+
const DEFAULT_TRACKING_POLICY_NAME = 'llm-cost';
6971

7072
export default function LLLMStepBanner({
7173
providerName,
@@ -80,15 +82,23 @@ export default function LLLMStepBanner({
8082
hasConsumptions: false,
8183
});
8284
const { entityType, entity } = useAIEntity();
85+
const { provider: liveProvider } = useLLMProvider();
8386
const { currentOrganization } = useAppShell();
84-
const selectedProvider =
87+
const entityProvider =
8588
entityType === 'llm-provider' ? (entity as LLMProvider | null) : null;
89+
const selectedProvider = liveProvider ?? entityProvider;
8690
const selectedProviderId = selectedProvider?.id ?? '';
8791
const organizationId = currentOrganization?.uuid ?? '';
88-
const hasGuardrails =
89-
(selectedProvider?.policies?.filter(
90-
(p) => !(p.name === 'llm-cost' && p.version === 'v1')
91-
).length ?? 0) > 0;
92+
93+
const hasGuardrails = useMemo(
94+
() =>
95+
[
96+
...(selectedProvider?.globalPolicies ?? []),
97+
...(selectedProvider?.operationPolicies ?? []),
98+
...(selectedProvider?.policies ?? []),
99+
].some((policy) => policy.name !== DEFAULT_TRACKING_POLICY_NAME),
100+
[selectedProvider]
101+
);
92102
const resolvedProviderName = providerName?.trim() || 'LLM Provider';
93103

94104
useEffect(() => {

0 commit comments

Comments
 (0)