Add support for creating online models and integrating custom model providers

This commit is contained in:
sunanzhi
2025-03-06 17:42:17 +08:00
parent 0aa526b6d4
commit eca864a80b
53 changed files with 1796 additions and 33 deletions
+1
View File
@@ -22,6 +22,7 @@ type IProviderController interface {
UpdateProviderDefaultLLM(ctx *gin.Context, id string, input *ai_dto.UpdateLLM) error
Delete(ctx *gin.Context, id string) error
//Sort(ctx *gin.Context, input *ai_dto.Sort) error
AddProvider(ctx *gin.Context, input *ai_dto.NewProvider) (*ai_dto.SimpleProvider, error)
}
type IStatisticController interface {
+12
View File
@@ -2,7 +2,9 @@ package ai
import (
"encoding/json"
"fmt"
"strconv"
"strings"
"github.com/APIParkLab/APIPark/module/ai"
ai_dto "github.com/APIParkLab/APIPark/module/ai/dto"
@@ -21,6 +23,13 @@ func (i *imlProviderController) Delete(ctx *gin.Context, id string) error {
return i.module.Delete(ctx, id)
}
func (i *imlProviderController) AddProvider(ctx *gin.Context, input *ai_dto.NewProvider) (*ai_dto.SimpleProvider, error) {
if strings.TrimSpace(input.Name) == "" {
return nil, fmt.Errorf("name is empty")
}
return i.module.AddProvider(ctx, input)
}
//func (i *imlProviderController) Sort(ctx *gin.Context, input *ai_dto.Sort) error {
// return i.module.Sort(ctx, input)
//}
@@ -67,6 +76,9 @@ func (i *imlProviderController) Disable(ctx *gin.Context, id string) error {
}
func (i *imlProviderController) UpdateProviderConfig(ctx *gin.Context, id string, input *ai_dto.UpdateConfig) error {
if strings.TrimSpace(id) == "" {
return fmt.Errorf("id is empty")
}
return i.module.UpdateProviderConfig(ctx, id, input)
}