GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add local server provider with automatic model discovery · hmblair/opencode@a77a75d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • packages/opencode/src/provider
    • provider.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎packages/opencode/src/provider/provider.ts‎

Copy file name to clipboardExpand all lines: packages/opencode/src/provider/provider.ts
+43Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -668,6 +668,49 @@ export namespace Provider {
668668
},
669669
}
670670
},
671+
async local(input) {
672+
const baseURL = input.options?.baseURL
673+
if (!baseURL) return { autoload: false }
674+
try {
675+
const url = `${String(baseURL).replace(/\/+$/, "")}/models`
676+
const headers: Record<string, string> = { Accept: "application/json" }
677+
const apiKey = input.options?.apiKey ?? input.key
678+
if (apiKey) headers["Authorization"] = `Bearer ${apiKey}`
679+
const res = await fetch(url, { headers, signal: AbortSignal.timeout(3000) })
680+
if (!res.ok) return { autoload: false }
681+
const json = (await res.json()) as { data?: Array<{ id: string }> }
682+
if (!json.data?.length) return { autoload: false }
683+
for (const model of json.data) {
684+
if (!model.id || input.models[model.id]) continue
685+
input.models[model.id] = {
686+
id: ModelID.make(model.id),
687+
providerID: ProviderID.make("local"),
688+
name: model.id,
689+
api: { id: model.id, url: baseURL, npm: "@ai-sdk/openai-compatible" },
690+
status: "active",
691+
headers: {},
692+
options: {},
693+
cost: { input: 0, output: 0, cache: { read: 0, write: 0 } },
694+
limit: { context: 0, output: 0 },
695+
capabilities: {
696+
temperature: true,
697+
reasoning: false,
698+
attachment: false,
699+
toolcall: true,
700+
input: { text: true, audio: false, image: false, video: false, pdf: false },
701+
output: { text: true, audio: false, image: false, video: false, pdf: false },
702+
interleaved: false,
703+
},
704+
family: "",
705+
release_date: "",
706+
}
707+
}
708+
log.info("auto-discovered local models", { count: json.data.length })
709+
return { autoload: true }
710+
} catch {
711+
return { autoload: false }
712+
}
713+
},
671714
}
672715

673716
export const Model = z

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.