mirror of
https://github.com/sst/opencode.git
synced 2025-07-07 16:14:59 +00:00
integrate models.dev
This commit is contained in:
parent
5e46d98c86
commit
0542cf7e69
3 changed files with 4 additions and 43 deletions
|
@ -1,37 +1,3 @@
|
|||
{
|
||||
"$schema": "https://opencode.ai/config.json",
|
||||
"provider": {
|
||||
"github-copilot": {
|
||||
"npm": "@ai-sdk/openai-compatible",
|
||||
"options": {
|
||||
"baseURL": "https://api.githubcopilot.com"
|
||||
},
|
||||
"models": {
|
||||
"gpt-4o": {
|
||||
"name": "gpt-4o"
|
||||
},
|
||||
"gpt-4.1": {
|
||||
"name": "gpt-4.1"
|
||||
},
|
||||
"claude-sonnet-4": {
|
||||
"name": "claude-sonnet-4"
|
||||
},
|
||||
"claude-3.7-sonnet": {
|
||||
"name": "claude-3.7-sonnet"
|
||||
},
|
||||
"o1": {
|
||||
"name": "o1"
|
||||
},
|
||||
"o3-mini": {
|
||||
"name": "o3-mini"
|
||||
},
|
||||
"gemini-2.5-pro": {
|
||||
"name": "gemini-2.5-pro"
|
||||
},
|
||||
"gemini-2.0-flash-001": {
|
||||
"name": "gemini-2.0-flash-001"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
"$schema": "https://opencode.ai/config.json"
|
||||
}
|
||||
|
|
|
@ -94,8 +94,7 @@ export namespace AuthGithubCopilot {
|
|||
export async function access() {
|
||||
const info = await Auth.get("github-copilot")
|
||||
if (!info || info.type !== "oauth") return
|
||||
if (info.access && info.expires > Date.now())
|
||||
return { access: info.access, api: "https://api.githubcopilot.com" }
|
||||
if (info.access && info.expires > Date.now()) return info.access
|
||||
|
||||
// Get new Copilot API token
|
||||
const response = await fetch(COPILOT_API_KEY_URL, {
|
||||
|
@ -120,10 +119,7 @@ export namespace AuthGithubCopilot {
|
|||
expires: tokenData.expires_at * 1000,
|
||||
})
|
||||
|
||||
return {
|
||||
access: tokenData.token,
|
||||
api: tokenData.endpoints.api,
|
||||
}
|
||||
return tokenData.token
|
||||
}
|
||||
|
||||
export const DeviceCodeError = NamedError.create(
|
||||
|
|
|
@ -83,13 +83,12 @@ export namespace Provider {
|
|||
return {
|
||||
options: {
|
||||
apiKey: "",
|
||||
baseURL: info.api,
|
||||
async fetch(input: any, init: any) {
|
||||
const token = await AuthGithubCopilot.access()
|
||||
if (!token) throw new Error("GitHub Copilot authentication expired")
|
||||
const headers = {
|
||||
...init.headers,
|
||||
Authorization: `Bearer ${token.access}`,
|
||||
Authorization: `Bearer ${token}`,
|
||||
"User-Agent": "GithubCopilot/1.155.0",
|
||||
"Editor-Version": "vscode/1.85.1",
|
||||
"Editor-Plugin-Version": "copilot/1.155.0",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue