This commit is contained in:
Dax Raad
2025-05-29 11:38:55 -04:00
parent a96c2ce65c
commit 48f81fe4d3
5 changed files with 118 additions and 154 deletions

View File

@@ -11,25 +11,33 @@ export namespace Config {
return result;
});
export const Model = z.object({
name: z.string().optional(),
cost: z.object({
input: z.number(),
inputCached: z.number(),
output: z.number(),
outputCached: z.number(),
}),
contextWindow: z.number(),
maxTokens: z.number().optional(),
attachment: z.boolean(),
reasoning: z.boolean().optional(),
});
export const Model = z
.object({
name: z.string().optional(),
cost: z.object({
input: z.number(),
inputCached: z.number(),
output: z.number(),
outputCached: z.number(),
}),
contextWindow: z.number(),
maxTokens: z.number().optional(),
attachment: z.boolean(),
reasoning: z.boolean().optional(),
})
.openapi({
ref: "model",
});
export type Model = z.output<typeof Model>;
export const Provider = z.object({
options: z.record(z.string(), z.any()).optional(),
models: z.record(z.string(), Model),
});
export const Provider = z
.object({
options: z.record(z.string(), z.any()).optional(),
models: z.record(z.string(), Model),
})
.openapi({
ref: "provider",
});
export type Provider = z.output<typeof Provider>;
export const Info = z

View File

@@ -10,16 +10,6 @@ import { Config } from "../app/config";
import { LLM } from "../llm/llm";
import { Message } from "../session/message";
const SessionInfo = Session.Info.openapi({
ref: "Session.Info",
});
const ProviderInfo = Config.Provider.openapi({
ref: "Provider.Info",
});
type ProviderInfo = z.output<typeof ProviderInfo>;
export namespace Server {
const log = Log.create({ service: "server" });
const PORT = 16713;
@@ -92,7 +82,7 @@ export namespace Server {
description: "Successfully created session",
content: {
"application/json": {
schema: resolver(SessionInfo),
schema: resolver(Session.Info),
},
},
},
@@ -112,7 +102,7 @@ export namespace Server {
description: "Successfully shared session",
content: {
"application/json": {
schema: resolver(SessionInfo),
schema: resolver(Session.Info),
},
},
},
@@ -244,7 +234,7 @@ export namespace Server {
description: "List of providers",
content: {
"application/json": {
schema: resolver(z.record(z.string(), ProviderInfo)),
schema: resolver(z.record(z.string(), Config.Provider)),
},
},
},
@@ -252,7 +242,7 @@ export namespace Server {
}),
async (c) => {
const providers = await LLM.providers();
const result: Record<string, ProviderInfo> = {};
const result: Record<string, Config.Provider> = {};
for (const [providerID, provider] of Object.entries(providers)) {
result[providerID] = provider.info;
}

View File

@@ -24,11 +24,15 @@ import { Bus } from "../bus";
export namespace Session {
const log = Log.create({ service: "session" });
export const Info = z.object({
id: Identifier.schema("session"),
shareID: z.string().optional(),
title: z.string(),
});
export const Info = z
.object({
id: Identifier.schema("session"),
shareID: z.string().optional(),
title: z.string(),
})
.openapi({
ref: "session.info",
});
export type Info = z.output<typeof Info>;
export const Event = {