Skip to content

Commit c4f2666

Browse files
committed
enhance model information display with context window details
1 parent 01a09c8 commit c4f2666

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/services/copilot/get-models.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ interface ModelCapabilities {
3939
type: string
4040
}
4141

42-
interface Model {
42+
export interface Model {
4343
capabilities: ModelCapabilities
4444
id: string
4545
model_picker_enabled: boolean

src/start.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import consola from "consola"
66
import { serve, type ServerHandler } from "srvx"
77
import invariant from "tiny-invariant"
88

9+
import type { Model } from "./services/copilot/get-models"
10+
911
import { ensurePaths } from "./lib/paths"
1012
import { generateEnvScript } from "./lib/shell"
1113
import { state } from "./lib/state"
@@ -26,6 +28,13 @@ interface RunServerOptions {
2628
headerMode: string
2729
}
2830

31+
const formatModelInfo = (model: Model) => {
32+
const contextWindow = model.capabilities.limits.max_context_window_tokens
33+
const contextStr =
34+
contextWindow ? ` (${(contextWindow / 1000).toFixed(0)}K tokens)` : ""
35+
return `- ${model.id}${contextStr}`
36+
}
37+
2938
export async function runServer(options: RunServerOptions): Promise<void> {
3039
if (options.verbose) {
3140
consola.level = 5
@@ -68,7 +77,7 @@ export async function runServer(options: RunServerOptions): Promise<void> {
6877
await cacheModels()
6978

7079
consola.info(
71-
`Available models: \n${state.models?.data.map((model) => `- ${model.id}`).join("\n")}`,
80+
`Available models: \n${state.models?.data.map((model) => formatModelInfo(model)).join("\n")}`,
7281
)
7382

7483
const serverUrl = `http://localhost:${options.port}`

0 commit comments

Comments
 (0)