Skip to content

Commit e77b2cf

Browse files
committed
wip: zen lite
1 parent d0ce295 commit e77b2cf

9 files changed

Lines changed: 24 additions & 6 deletions

File tree

packages/console/app/src/routes/workspace/[id]/model-section.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const getModelsInfo = query(async (workspaceID: string) => {
3636
"use server"
3737
return withActor(async () => {
3838
return {
39-
all: Object.entries(ZenData.list().models)
39+
all: Object.entries(ZenData.list("full").models)
4040
.filter(([id, _model]) => !["claude-3-5-haiku"].includes(id))
4141
.filter(([id, _model]) => !id.startsWith("alpha-"))
4242
.sort(([idA, modelA], [idB, modelB]) => {
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { APIEvent } from "@solidjs/start/server"
2+
import { handler } from "~/routes/zen/util/handler"
3+
4+
export function POST(input: APIEvent) {
5+
return handler(input, {
6+
format: "oa-compat",
7+
modelList: "lite",
8+
parseApiKey: (headers: Headers) => headers.get("authorization")?.split(" ")[1],
9+
parseModel: (url: string, body: any) => body.model,
10+
parseIsStream: (url: string, body: any) => !!body.stream,
11+
})
12+
}

packages/console/app/src/routes/zen/util/handler.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ export async function handler(
4444
input: APIEvent,
4545
opts: {
4646
format: ZenData.Format
47+
modelList: "lite" | "full"
4748
parseApiKey: (headers: Headers) => string | undefined
4849
parseModel: (url: string, body: any) => string
4950
parseIsStream: (url: string, body: any) => boolean
@@ -77,7 +78,7 @@ export async function handler(
7778
request: requestId,
7879
client: ocClient,
7980
})
80-
const zenData = ZenData.list()
81+
const zenData = ZenData.list(opts.modelList)
8182
const modelInfo = validateModel(zenData, model)
8283
const dataDumper = createDataDumper(sessionId, requestId, projectId)
8384
const trialLimiter = createTrialLimiter(modelInfo.trial, ip, ocClient)

packages/console/app/src/routes/zen/v1/chat/completions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { handler } from "~/routes/zen/util/handler"
44
export function POST(input: APIEvent) {
55
return handler(input, {
66
format: "oa-compat",
7+
modelList: "full",
78
parseApiKey: (headers: Headers) => headers.get("authorization")?.split(" ")[1],
89
parseModel: (url: string, body: any) => body.model,
910
parseIsStream: (url: string, body: any) => !!body.stream,

packages/console/app/src/routes/zen/v1/messages.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { handler } from "~/routes/zen/util/handler"
44
export function POST(input: APIEvent) {
55
return handler(input, {
66
format: "anthropic",
7+
modelList: "full",
78
parseApiKey: (headers: Headers) => headers.get("x-api-key") ?? undefined,
89
parseModel: (url: string, body: any) => body.model,
910
parseIsStream: (url: string, body: any) => !!body.stream,

packages/console/app/src/routes/zen/v1/models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export async function OPTIONS(input: APIEvent) {
1717
}
1818

1919
export async function GET(input: APIEvent) {
20-
const zenData = ZenData.list()
20+
const zenData = ZenData.list("full")
2121
const disabledModels = await authenticate()
2222

2323
return new Response(

packages/console/app/src/routes/zen/v1/models/[model].ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { handler } from "~/routes/zen/util/handler"
44
export function POST(input: APIEvent) {
55
return handler(input, {
66
format: "google",
7+
modelList: "full",
78
parseApiKey: (headers: Headers) => headers.get("x-goog-api-key") ?? undefined,
89
parseModel: (url: string, body: any) => url.split("/").pop()?.split(":")?.[0] ?? "",
910
parseIsStream: (url: string, body: any) =>

packages/console/app/src/routes/zen/v1/responses.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { handler } from "~/routes/zen/util/handler"
44
export function POST(input: APIEvent) {
55
return handler(input, {
66
format: "openai",
7+
modelList: "full",
78
parseApiKey: (headers: Headers) => headers.get("authorization")?.split(" ")[1],
89
parseModel: (url: string, body: any) => body.model,
910
parseIsStream: (url: string, body: any) => !!body.stream,

packages/console/core/src/model.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export namespace ZenData {
7373

7474
const ModelsSchema = z.object({
7575
models: z.record(z.string(), z.union([ModelSchema, z.array(ModelSchema.extend({ formatFilter: FormatSchema }))])),
76+
liteModels: z.record(z.string(), ModelSchema),
7677
providers: z.record(z.string(), ProviderSchema),
7778
providerFamilies: z.record(z.string(), ProviderFamilySchema),
7879
})
@@ -81,7 +82,7 @@ export namespace ZenData {
8182
return input
8283
})
8384

84-
export const list = fn(z.void(), () => {
85+
export const list = fn(z.enum(["lite", "full"]), (modelList) => {
8586
const json = JSON.parse(
8687
Resource.ZEN_MODELS1.value +
8788
Resource.ZEN_MODELS2.value +
@@ -114,9 +115,9 @@ export namespace ZenData {
114115
Resource.ZEN_MODELS29.value +
115116
Resource.ZEN_MODELS30.value,
116117
)
117-
const { models, providers, providerFamilies } = ModelsSchema.parse(json)
118+
const { models, liteModels, providers, providerFamilies } = ModelsSchema.parse(json)
118119
return {
119-
models,
120+
models: modelList === "lite" ? liteModels : models,
120121
providers: Object.fromEntries(
121122
Object.entries(providers).map(([id, provider]) => [
122123
id,

0 commit comments

Comments
 (0)