mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-25 19:54:22 +01:00
sync
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 = {
|
||||
|
||||
Reference in New Issue
Block a user