Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
efc8457
修复gemini-balance测试gemini2.5pro的错误问题
kikii16 Jun 29, 2025
660180e
支持Midjourney视频任务和图片编辑
iszcz Jun 30, 2025
22e8b46
✨ feat: make TopN field in RerankRequest optional in JSON serialization
Calcium-Ion Jul 3, 2025
819290c
Merge pull request #1314 from vickyyd/main
Calcium-Ion Jul 3, 2025
bf577b8
🔌 feat(api): extend endpoint type support & expose in pricing UI
t0ng7u Jul 3, 2025
7d691f3
✨ refactor(EditChannel&EditToken): refactor Channel & Token edit page…
t0ng7u Jul 3, 2025
c0a23ff
🎨 refactor(EditTagModal): tidy imports & enhance state-sync on open
t0ng7u Jul 3, 2025
6ac7878
🔧 refactor(endpoint types): comment out unused endpoint types in cons…
Calcium-Ion Jul 4, 2025
d191eef
🐛 fix: fix the header height calculation issue in the custom HTML sty…
t0ng7u Jul 4, 2025
8945a3a
🖼️ style(RatioSync): remove the useless `rounded-full` style
t0ng7u Jul 4, 2025
3049ad4
🔢 feat(user-edit): replace add-quota input with Semi-UI InputNumber
t0ng7u Jul 4, 2025
d40fb68
📊 feat(detail): add model consumption trend & call ranking charts
t0ng7u Jul 4, 2025
30fb349
✨ feat(endpoint types): add support for image generation models in en…
Calcium-Ion Jul 5, 2025
1e25bf7
Merge remote-tracking branch 'origin/alpha' into alpha
Calcium-Ion Jul 5, 2025
5ec421d
Merge pull request #1321 from iszcz/main
Calcium-Ion Jul 5, 2025
5eba2f1
🔧 refactor(model): update context key retrieval to use token group in…
Calcium-Ion Jul 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@
<a href="https://goreportcard.com/report/github.com/Calcium-Ion/new-api">
<img src="https://goreportcard.com/badge/github.com/Calcium-Ion/new-api" alt="GoReportCard">
</a>
<a href="https://coderabbit.ai">
<img src="https://img.shields.io/coderabbit/prs/github/QuantumNous/new-api?utm_source=oss&utm_medium=github&utm_campaign=QuantumNous%2Fnew-api&labelColor=171717&color=FF570A&link=https%3A%2F%2Fcoderabbit.ai&label=CodeRabbit+Reviews" alt="CodeRabbit Pull Request Reviews">
</a>
</p>
</div>

Expand Down
12 changes: 12 additions & 0 deletions common/endpoint_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ func GetEndpointTypesByChannelType(channelType int, modelName string) []constant
switch channelType {
case constant.ChannelTypeJina:
endpointTypes = []constant.EndpointType{constant.EndpointTypeJinaRerank}
//case constant.ChannelTypeMidjourney, constant.ChannelTypeMidjourneyPlus:
// endpointTypes = []constant.EndpointType{constant.EndpointTypeMidjourney}
//case constant.ChannelTypeSunoAPI:
// endpointTypes = []constant.EndpointType{constant.EndpointTypeSuno}
//case constant.ChannelTypeKling:
// endpointTypes = []constant.EndpointType{constant.EndpointTypeKling}
//case constant.ChannelTypeJimeng:
// endpointTypes = []constant.EndpointType{constant.EndpointTypeJimeng}
case constant.ChannelTypeAws:
fallthrough
case constant.ChannelTypeAnthropic:
Expand All @@ -25,5 +33,9 @@ func GetEndpointTypesByChannelType(channelType int, modelName string) []constant
endpointTypes = []constant.EndpointType{constant.EndpointTypeOpenAI}
}
}
if IsImageGenerationModel(modelName) {
// add to first
endpointTypes = append([]constant.EndpointType{constant.EndpointTypeImageGeneration}, endpointTypes...)
}
return endpointTypes
}
23 changes: 22 additions & 1 deletion common/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,32 @@ var (
"o3-deep-research",
"o4-mini-deep-research",
}
ImageGenerationModels = []string{
"dall-e-3",
"dall-e-2",
"gpt-image-1",
"prefix:imagen-",
"flux-",
"flux.1-",
}
)

func IsOpenAIResponseOnlyModel(modelName string) bool {
for _, m := range OpenAIResponseOnlyModels {
if strings.Contains(m, modelName) {
if strings.Contains(modelName, m) {
return true
}
}
return false
}

func IsImageGenerationModel(modelName string) bool {
modelName = strings.ToLower(modelName)
for _, m := range ImageGenerationModels {
if strings.Contains(modelName, m) {
return true
}
if strings.HasPrefix(m, "prefix:") && strings.HasPrefix(modelName, strings.TrimPrefix(m, "prefix:")) {
return true
}
}
Expand Down
15 changes: 10 additions & 5 deletions constant/endpoint_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ package constant
type EndpointType string

const (
EndpointTypeOpenAI EndpointType = "openai"
EndpointTypeOpenAIResponse EndpointType = "openai-response"
EndpointTypeAnthropic EndpointType = "anthropic"
EndpointTypeGemini EndpointType = "gemini"
EndpointTypeJinaRerank EndpointType = "jina-rerank"
EndpointTypeOpenAI EndpointType = "openai"
EndpointTypeOpenAIResponse EndpointType = "openai-response"
EndpointTypeAnthropic EndpointType = "anthropic"
EndpointTypeGemini EndpointType = "gemini"
EndpointTypeJinaRerank EndpointType = "jina-rerank"
EndpointTypeImageGeneration EndpointType = "image-generation"
//EndpointTypeMidjourney EndpointType = "midjourney-proxy"
//EndpointTypeSuno EndpointType = "suno-proxy"
//EndpointTypeKling EndpointType = "kling"
//EndpointTypeJimeng EndpointType = "jimeng"
)
4 changes: 4 additions & 0 deletions constant/midjourney.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ const (
MjActionPan = "PAN"
MjActionSwapFace = "SWAP_FACE"
MjActionUpload = "UPLOAD"
MjActionVideo = "VIDEO"
MjActionEdits = "EDITS"
)

var MidjourneyModel2Action = map[string]string{
Expand All @@ -41,4 +43,6 @@ var MidjourneyModel2Action = map[string]string{
"mj_pan": MjActionPan,
"swap_face": MjActionSwapFace,
"mj_upload": MjActionUpload,
"mj_video": MjActionVideo,
"mj_edits": MjActionEdits,
}
2 changes: 1 addition & 1 deletion controller/channel-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ func buildTestRequest(model string) *dto.GeneralOpenAIRequest {
testRequest.MaxTokens = 50
}
} else if strings.Contains(model, "gemini") {
testRequest.MaxTokens = 300
testRequest.MaxTokens = 3000
} else {
testRequest.MaxTokens = 10
}
Expand Down
2 changes: 1 addition & 1 deletion controller/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ func ListModels(c *gin.Context) {
return
}
group := userGroup
tokenGroup := common.GetContextKeyString(c, constant.ContextKeyUserGroup)
tokenGroup := common.GetContextKeyString(c, constant.ContextKeyTokenGroup)
if tokenGroup != "" {
group = tokenGroup
}
Expand Down
6 changes: 6 additions & 0 deletions dto/midjourney.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ type MidjourneyDto struct {
StartTime int64 `json:"startTime"`
FinishTime int64 `json:"finishTime"`
ImageUrl string `json:"imageUrl"`
VideoUrl string `json:"videoUrl"`
VideoUrls []ImgUrls `json:"videoUrls"`
Status string `json:"status"`
Progress string `json:"progress"`
FailReason string `json:"failReason"`
Expand All @@ -65,6 +67,10 @@ type MidjourneyDto struct {
Properties *Properties `json:"properties"`
}

type ImgUrls struct {
Url string `json:"url"`
}

type MidjourneyStatus struct {
Status int `json:"status"`
}
Expand Down
2 changes: 1 addition & 1 deletion dto/rerank.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ type RerankRequest struct {
Documents []any `json:"documents"`
Query string `json:"query"`
Model string `json:"model"`
TopN int `json:"top_n"`
TopN int `json:"top_n,omitempty"`
ReturnDocuments *bool `json:"return_documents,omitempty"`
MaxChunkPerDoc int `json:"max_chunk_per_doc,omitempty"`
OverLapTokens int `json:"overlap_tokens,omitempty"`
Expand Down
Loading
Loading