mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-04 10:13:53 +08:00
Local model compatibility testing completed
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
ai_provider_local "github.com/APIParkLab/APIPark/ai-provider/local"
|
||||
|
||||
"github.com/APIParkLab/APIPark/model/plugin_model"
|
||||
ai_api "github.com/APIParkLab/APIPark/module/ai-api"
|
||||
ai_api_dto "github.com/APIParkLab/APIPark/module/ai-api/dto"
|
||||
@@ -48,7 +50,7 @@ func (i *imlAPIController) Create(ctx *gin.Context, serviceId string, input *ai_
|
||||
}
|
||||
}
|
||||
if input.AiModel != nil {
|
||||
provider := "ollama"
|
||||
provider := ai_provider_local.ProviderLocal
|
||||
if input.AiModel.Type != "local" {
|
||||
provider = input.AiModel.Provider
|
||||
}
|
||||
@@ -107,7 +109,7 @@ func (i *imlAPIController) Edit(ctx *gin.Context, serviceId string, apiId string
|
||||
}
|
||||
//var upstream *string
|
||||
if input.AiModel != nil {
|
||||
provider := "ollama"
|
||||
provider := ai_provider_local.ProviderLocal
|
||||
if input.AiModel.Type != "local" {
|
||||
provider = input.AiModel.Provider
|
||||
}
|
||||
|
||||
@@ -245,7 +245,7 @@ func (i *imlLocalModelController) initAILocalService(ctx context.Context, model
|
||||
}
|
||||
serviceId := uuid.NewString()
|
||||
prefix := fmt.Sprintf("/%s", serviceId[:8])
|
||||
providerId := "ollama"
|
||||
providerId := ai_provider_local.ProviderLocal
|
||||
err = i.transaction.Transaction(ctx, func(ctx context.Context) error {
|
||||
_, err = i.serviceModule.Create(ctx, teamID, &service_dto.CreateService{
|
||||
Id: serviceId,
|
||||
@@ -276,7 +276,7 @@ func (i *imlLocalModelController) initAILocalService(ctx context.Context, model
|
||||
}
|
||||
aiModel := &ai_api_dto.AiModel{
|
||||
Id: model,
|
||||
Config: ai_provider_local.OllamaConfig,
|
||||
Config: ai_provider_local.LocalConfig,
|
||||
Provider: providerId,
|
||||
Type: "local",
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ func (i *imlServiceController) editAIService(ctx *gin.Context, id string, input
|
||||
if input.Provider == nil {
|
||||
return nil, fmt.Errorf("provider is required")
|
||||
}
|
||||
if *input.Provider != "ollama" {
|
||||
if *input.Provider != ai_provider_local.ProviderLocal {
|
||||
_, has := model_runtime.GetProvider(*input.Provider)
|
||||
if !has {
|
||||
return nil, fmt.Errorf("provider not found")
|
||||
@@ -330,7 +330,7 @@ func (i *imlServiceController) createAIService(ctx *gin.Context, teamID string,
|
||||
modelId := ""
|
||||
modelCfg := ""
|
||||
modelType := "online"
|
||||
if *input.Provider == "ollama" {
|
||||
if *input.Provider == ai_provider_local.ProviderLocal {
|
||||
modelType = "local"
|
||||
list, err := i.aiLocalModel.SimpleList(ctx)
|
||||
if err != nil {
|
||||
@@ -340,7 +340,7 @@ func (i *imlServiceController) createAIService(ctx *gin.Context, teamID string,
|
||||
return nil, fmt.Errorf("no local model")
|
||||
}
|
||||
modelId = list[0].Id
|
||||
modelCfg = ai_provider_local.OllamaConfig
|
||||
modelCfg = ai_provider_local.LocalConfig
|
||||
} else {
|
||||
pv, err := i.providerModule.Provider(ctx, *input.Provider)
|
||||
if err != nil {
|
||||
@@ -367,7 +367,7 @@ func (i *imlServiceController) createAIService(ctx *gin.Context, teamID string,
|
||||
return err
|
||||
}
|
||||
prefix := strings.Replace(input.Prefix, ":", "_", -1)
|
||||
path := fmt.Sprintf("/%s/chat", strings.Trim(prefix, "/"))
|
||||
path := fmt.Sprintf("/%s/chat/completions", strings.Trim(prefix, "/"))
|
||||
timeout := 300000
|
||||
retry := 0
|
||||
aiPrompt := &ai_api_dto.AiPrompt{
|
||||
|
||||
Reference in New Issue
Block a user