- 接入 gpt-5.4 模型识别与规范化,补充默认模型列表 - 增加 gpt-5.4 输入/缓存命中/输出价格与计费兜底逻辑 - 同步前端模型白名单与 OpenCode 上下文窗口(1050000/128000) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> (cherry picked from commit 924476dcac6181cd0f3ee731ec7b73672ff03793)
47 lines
2.1 KiB
Go
47 lines
2.1 KiB
Go
// Package openai provides helpers and types for OpenAI API integration.
|
|
package openai
|
|
|
|
import _ "embed"
|
|
|
|
// Model represents an OpenAI model
|
|
type Model struct {
|
|
ID string `json:"id"`
|
|
Object string `json:"object"`
|
|
Created int64 `json:"created"`
|
|
OwnedBy string `json:"owned_by"`
|
|
Type string `json:"type"`
|
|
DisplayName string `json:"display_name"`
|
|
}
|
|
|
|
// DefaultModels OpenAI models list
|
|
var DefaultModels = []Model{
|
|
{ID: "gpt-5.4", Object: "model", Created: 1738368000, OwnedBy: "openai", Type: "model", DisplayName: "GPT-5.4"},
|
|
{ID: "gpt-5.3-codex", Object: "model", Created: 1735689600, OwnedBy: "openai", Type: "model", DisplayName: "GPT-5.3 Codex"},
|
|
{ID: "gpt-5.3-codex-spark", Object: "model", Created: 1735689600, OwnedBy: "openai", Type: "model", DisplayName: "GPT-5.3 Codex Spark"},
|
|
{ID: "gpt-5.2", Object: "model", Created: 1733875200, OwnedBy: "openai", Type: "model", DisplayName: "GPT-5.2"},
|
|
{ID: "gpt-5.2-codex", Object: "model", Created: 1733011200, OwnedBy: "openai", Type: "model", DisplayName: "GPT-5.2 Codex"},
|
|
{ID: "gpt-5.1-codex-max", Object: "model", Created: 1730419200, OwnedBy: "openai", Type: "model", DisplayName: "GPT-5.1 Codex Max"},
|
|
{ID: "gpt-5.1-codex", Object: "model", Created: 1730419200, OwnedBy: "openai", Type: "model", DisplayName: "GPT-5.1 Codex"},
|
|
{ID: "gpt-5.1", Object: "model", Created: 1731456000, OwnedBy: "openai", Type: "model", DisplayName: "GPT-5.1"},
|
|
{ID: "gpt-5.1-codex-mini", Object: "model", Created: 1730419200, OwnedBy: "openai", Type: "model", DisplayName: "GPT-5.1 Codex Mini"},
|
|
{ID: "gpt-5", Object: "model", Created: 1722988800, OwnedBy: "openai", Type: "model", DisplayName: "GPT-5"},
|
|
}
|
|
|
|
// DefaultModelIDs returns the default model ID list
|
|
func DefaultModelIDs() []string {
|
|
ids := make([]string, len(DefaultModels))
|
|
for i, m := range DefaultModels {
|
|
ids[i] = m.ID
|
|
}
|
|
return ids
|
|
}
|
|
|
|
// DefaultTestModel default model for testing OpenAI accounts
|
|
const DefaultTestModel = "gpt-5.1-codex"
|
|
|
|
// DefaultInstructions default instructions for non-Codex CLI requests
|
|
// Content loaded from instructions.txt at compile time
|
|
//
|
|
//go:embed instructions.txt
|
|
var DefaultInstructions string
|