mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-26 15:28:03 -05:00
Compare commits
4 Commits
fix/copilo
...
fix/copilo
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
80eb2a8aa1 | ||
|
|
315d9ee3f9 | ||
|
|
62b06d00de | ||
|
|
2a630859fb |
@@ -10,6 +10,7 @@ import {
|
|||||||
type KnowledgeBaseArgs,
|
type KnowledgeBaseArgs,
|
||||||
} from '@/lib/copilot/tools/shared/schemas'
|
} from '@/lib/copilot/tools/shared/schemas'
|
||||||
import { useCopilotStore } from '@/stores/panel/copilot/store'
|
import { useCopilotStore } from '@/stores/panel/copilot/store'
|
||||||
|
import { useWorkflowRegistry } from '@/stores/workflows/registry/store'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Client tool for knowledge base operations
|
* Client tool for knowledge base operations
|
||||||
@@ -102,7 +103,19 @@ export class KnowledgeBaseClientTool extends BaseClientTool {
|
|||||||
const logger = createLogger('KnowledgeBaseClientTool')
|
const logger = createLogger('KnowledgeBaseClientTool')
|
||||||
try {
|
try {
|
||||||
this.setState(ClientToolCallState.executing)
|
this.setState(ClientToolCallState.executing)
|
||||||
const payload: KnowledgeBaseArgs = { ...(args || { operation: 'list' }) }
|
|
||||||
|
// Get the workspace ID from the workflow registry hydration state
|
||||||
|
const { hydration } = useWorkflowRegistry.getState()
|
||||||
|
const workspaceId = hydration.workspaceId
|
||||||
|
|
||||||
|
// Build payload with workspace ID included in args
|
||||||
|
const payload: KnowledgeBaseArgs = {
|
||||||
|
...(args || { operation: 'list' }),
|
||||||
|
args: {
|
||||||
|
...(args?.args || {}),
|
||||||
|
workspaceId: args?.args?.workspaceId || workspaceId || undefined,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
const res = await fetch('/api/copilot/execute-copilot-server-tool', {
|
const res = await fetch('/api/copilot/execute-copilot-server-tool', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
|||||||
@@ -2609,9 +2609,7 @@ async function preValidateCredentialInputs(
|
|||||||
model: string
|
model: string
|
||||||
}> = []
|
}> = []
|
||||||
|
|
||||||
const hostedModelsLower = isHosted
|
const hostedModelsLower = isHosted ? new Set(getHostedModels().map((m) => m.toLowerCase())) : null
|
||||||
? new Set(getHostedModels().map((m) => m.toLowerCase()))
|
|
||||||
: null
|
|
||||||
|
|
||||||
operations.forEach((op, opIndex) => {
|
operations.forEach((op, opIndex) => {
|
||||||
if (!op.params?.inputs || !op.params?.type) return
|
if (!op.params?.inputs || !op.params?.type) return
|
||||||
@@ -2661,18 +2659,26 @@ async function preValidateCredentialInputs(
|
|||||||
// Deep clone operations so we can modify them
|
// Deep clone operations so we can modify them
|
||||||
const filteredOperations = structuredClone(operations)
|
const filteredOperations = structuredClone(operations)
|
||||||
|
|
||||||
// Filter out apiKey inputs for hosted models
|
// Filter out apiKey inputs for hosted models and add validation errors
|
||||||
if (hasHostedApiKeysToFilter) {
|
if (hasHostedApiKeysToFilter) {
|
||||||
logger.info('Filtering apiKey inputs for hosted models', { count: hostedApiKeyInputs.length })
|
logger.info('Filtering apiKey inputs for hosted models', { count: hostedApiKeyInputs.length })
|
||||||
|
|
||||||
for (const apiKeyInput of hostedApiKeyInputs) {
|
for (const apiKeyInput of hostedApiKeyInputs) {
|
||||||
const op = filteredOperations[apiKeyInput.operationIndex]
|
const op = filteredOperations[apiKeyInput.operationIndex]
|
||||||
if (op.params?.inputs?.apiKey) {
|
if (op.params?.inputs?.apiKey) {
|
||||||
delete op.params.inputs.apiKey
|
op.params.inputs.apiKey = undefined
|
||||||
logger.debug('Silently filtered apiKey for hosted model', {
|
logger.debug('Filtered apiKey for hosted model', {
|
||||||
blockId: apiKeyInput.blockId,
|
blockId: apiKeyInput.blockId,
|
||||||
model: apiKeyInput.model,
|
model: apiKeyInput.model,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
errors.push({
|
||||||
|
blockId: apiKeyInput.blockId,
|
||||||
|
blockType: apiKeyInput.blockType,
|
||||||
|
field: 'apiKey',
|
||||||
|
value: '[redacted]',
|
||||||
|
error: `Cannot set API key for hosted model "${apiKeyInput.model}" - API keys are managed by the platform when using hosted models`,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user