Skip to content

Commit f690c10

Browse files
waleedlatif1claude
andcommitted
refactor(providers): dedupe Ollama Cloud upstream schema
ollamaCloudUpstreamResponseSchema was byte-for-byte identical to ollamaUpstreamResponseSchema (both /api/tags endpoints return the same { models: [{ name }] } shape). Drop the duplicate and reuse the shared schema. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 52a6b06 commit f690c10

2 files changed

Lines changed: 3 additions & 14 deletions

File tree

apps/sim/app/api/providers/ollama-cloud/models/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getErrorMessage } from '@sim/utils/errors'
33
import { type NextRequest, NextResponse } from 'next/server'
44
import {
55
ollamaCloudProviderModelsQuerySchema,
6-
ollamaCloudUpstreamResponseSchema,
6+
ollamaUpstreamResponseSchema,
77
providerModelsResponseSchema,
88
} from '@/lib/api/contracts/providers'
99
import { validationErrorResponse } from '@/lib/api/server'
@@ -70,7 +70,7 @@ export const GET = withRouteHandler(async (request: NextRequest) => {
7070
return NextResponse.json({ models: [] })
7171
}
7272

73-
const data = ollamaCloudUpstreamResponseSchema.parse(await response.json())
73+
const data = ollamaUpstreamResponseSchema.parse(await response.json())
7474

7575
const allModels = data.models.map((model) => `ollama-cloud/${model.name}`)
7676
const uniqueModels = Array.from(new Set(allModels))

apps/sim/lib/api/contracts/providers.ts

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ export const basetenUpstreamResponseSchema = z.object({
116116
object: z.string().optional(),
117117
})
118118

119+
// Shared by the local Ollama and Ollama Cloud /api/tags endpoints — same `{ models: [{ name }] }` shape.
119120
export const ollamaUpstreamResponseSchema = z.object({
120121
models: z
121122
.array(
@@ -128,18 +129,6 @@ export const ollamaUpstreamResponseSchema = z.object({
128129
.default([]),
129130
})
130131

131-
export const ollamaCloudUpstreamResponseSchema = z.object({
132-
models: z
133-
.array(
134-
z
135-
.object({
136-
name: z.string(),
137-
})
138-
.passthrough()
139-
)
140-
.default([]),
141-
})
142-
143132
const providerToolSchema = z
144133
.object({
145134
id: z.string(),

0 commit comments

Comments
 (0)