Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions apps/sim/executor/handlers/evaluator/evaluator-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { createLogger } from '@sim/logger'
import { eq } from 'drizzle-orm'
import { refreshTokenIfNeeded } from '@/app/api/auth/oauth/utils'
import type { BlockOutput } from '@/blocks/types'
import { BlockType, DEFAULTS, EVALUATOR, HTTP } from '@/executor/constants'
import { BlockType, DEFAULTS, EVALUATOR } from '@/executor/constants'
import type { BlockHandler, ExecutionContext } from '@/executor/types'
import { buildAPIUrl, extractAPIErrorMessage } from '@/executor/utils/http'
import { buildAPIUrl, buildAuthHeaders, extractAPIErrorMessage } from '@/executor/utils/http'
import { isJSONString, parseJSON, stringifyJSON } from '@/executor/utils/json'
import { validateModelProvider } from '@/executor/utils/permission-check'
import { calculateCost, getProviderFromModel } from '@/providers/utils'
Expand Down Expand Up @@ -143,9 +143,7 @@ export class EvaluatorBlockHandler implements BlockHandler {

const response = await fetch(url.toString(), {
method: 'POST',
headers: {
'Content-Type': HTTP.CONTENT_TYPE.JSON,
},
headers: await buildAuthHeaders(),
body: stringifyJSON(providerRequest),
})

Expand Down
10 changes: 3 additions & 7 deletions apps/sim/executor/handlers/router/router-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import type { BlockOutput } from '@/blocks/types'
import {
BlockType,
DEFAULTS,
HTTP,
isAgentBlockType,
isRouterV2BlockType,
ROUTER,
} from '@/executor/constants'
import type { BlockHandler, ExecutionContext } from '@/executor/types'
import { buildAuthHeaders } from '@/executor/utils/http'
import { validateModelProvider } from '@/executor/utils/permission-check'
import { calculateCost, getProviderFromModel } from '@/providers/utils'
import type { SerializedBlock } from '@/serializer/types'
Expand Down Expand Up @@ -118,9 +118,7 @@ export class RouterBlockHandler implements BlockHandler {

const response = await fetch(url.toString(), {
method: 'POST',
headers: {
'Content-Type': HTTP.CONTENT_TYPE.JSON,
},
headers: await buildAuthHeaders(),
body: JSON.stringify(providerRequest),
})

Expand Down Expand Up @@ -277,9 +275,7 @@ export class RouterBlockHandler implements BlockHandler {

const response = await fetch(url.toString(), {
method: 'POST',
headers: {
'Content-Type': HTTP.CONTENT_TYPE.JSON,
},
headers: await buildAuthHeaders(),
body: JSON.stringify(providerRequest),
})

Expand Down
2 changes: 1 addition & 1 deletion apps/sim/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"dependencies": {
"@a2a-js/sdk": "0.3.7",
"@anthropic-ai/sdk": "^0.39.0",
"@anthropic-ai/sdk": "0.71.2",
"@aws-sdk/client-bedrock-runtime": "3.940.0",
"@aws-sdk/client-dynamodb": "3.940.0",
"@aws-sdk/client-rds-data": "3.940.0",
Expand Down
8 changes: 3 additions & 5 deletions apps/sim/providers/anthropic/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import Anthropic from '@anthropic-ai/sdk'
import { transformJSONSchema } from '@anthropic-ai/sdk/lib/transform-json-schema'
import { createLogger } from '@sim/logger'
import type { StreamingExecution } from '@/executor/types'
import { MAX_TOOL_ITERATIONS } from '@/providers'
Expand Down Expand Up @@ -185,13 +186,10 @@ export const anthropicProvider: ProviderConfig = {
const schema = request.responseFormat.schema || request.responseFormat

if (useNativeStructuredOutputs) {
const schemaWithConstraints = {
...schema,
additionalProperties: false,
}
const transformedSchema = transformJSONSchema(schema)
payload.output_format = {
type: 'json_schema',
schema: schemaWithConstraints,
schema: transformedSchema,
}
logger.info(`Using native structured outputs for model: ${modelId}`)
} else {
Expand Down
36 changes: 22 additions & 14 deletions bun.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions packages/testing/src/mocks/executor.mock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ vi.mock('@/executor/path')
vi.mock('@/executor/resolver', () => ({
InputResolver: vi.fn(),
}))
vi.mock('@/executor/utils/http', () => ({
buildAuthHeaders: vi.fn().mockResolvedValue({ 'Content-Type': 'application/json' }),
buildAPIUrl: vi.fn((path: string) => new URL(path, 'http://localhost:3000')),
extractAPIErrorMessage: vi.fn(async (response: Response) => {
const defaultMessage = `API request failed with status ${response.status}`
try {
const errorData = await response.json()
return errorData.error || defaultMessage
} catch {
return defaultMessage
}
}),
}))

// Specific block utilities
vi.mock('@/blocks/blocks/router')
Expand Down
Loading