mirror of
https://github.com/APIParkLab/APIPark.git
synced 2026-06-14 20:41:15 +08:00
Merge branch 'feature/ai-balance' into 'main'
update ai api list See merge request apipark/APIPark!143
This commit is contained in:
@@ -30,19 +30,6 @@ type APIItem struct {
|
||||
Model ModelItem `json:"model"`
|
||||
}
|
||||
|
||||
type AIAPIItem struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Service auto.Label `json:"service" aolabel:"service"`
|
||||
Method string `json:"method"`
|
||||
RequestPath string `json:"request_path"`
|
||||
Model ModelItem `json:"model"`
|
||||
Provider ProviderItem `json:"provider"`
|
||||
UpdateTime auto.TimeLabel `json:"update_time"`
|
||||
UseToken int64 `json:"use_token"`
|
||||
Disable bool `json:"disabled"`
|
||||
}
|
||||
|
||||
type ModelItem struct {
|
||||
Id string `json:"id"`
|
||||
Logo string `json:"logo"`
|
||||
|
||||
@@ -41,6 +41,7 @@ func (i *imlKeyModule) Create(ctx context.Context, providerId string, input *ai_
|
||||
if !has {
|
||||
return fmt.Errorf("provider not found: %w", err)
|
||||
}
|
||||
p.URI()
|
||||
err = p.Check(input.Config)
|
||||
if err != nil {
|
||||
return fmt.Errorf("config check failed: %w", err)
|
||||
|
||||
@@ -78,6 +78,7 @@ type APIItem struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Service auto.Label `json:"service" aolabel:"service"`
|
||||
Team auto.Label `json:"team" aolabel:"team"`
|
||||
Method string `json:"method"`
|
||||
RequestPath string `json:"request_path"`
|
||||
Model auto.Label `json:"model"`
|
||||
|
||||
+12
-6
@@ -734,12 +734,17 @@ func (i *imlAIApiModule) APIs(ctx context.Context, keyword string, providerId st
|
||||
if err != nil {
|
||||
return nil, nil, 0, err
|
||||
}
|
||||
serviceItems := utils.SliceToSlice(services, func(e *service.Service) *ai_dto.BasicInfo {
|
||||
return &ai_dto.BasicInfo{
|
||||
Id: e.Id,
|
||||
Name: e.Name,
|
||||
}
|
||||
})
|
||||
serviceItems := make([]*ai_dto.BasicInfo, 0, len(services))
|
||||
serviceTeamMap := make(map[string]string)
|
||||
for _, s := range services {
|
||||
serviceItems = append(serviceItems, &ai_dto.BasicInfo{
|
||||
Id: s.Id,
|
||||
Name: s.Name,
|
||||
})
|
||||
serviceTeamMap[s.Id] = s.Team
|
||||
|
||||
}
|
||||
|
||||
modelItems := utils.SliceToSlice(p.Models(), func(e model_runtime.IModel) *ai_dto.BasicInfo {
|
||||
return &ai_dto.BasicInfo{
|
||||
Id: e.ID(),
|
||||
@@ -786,6 +791,7 @@ func (i *imlAIApiModule) APIs(ctx context.Context, keyword string, providerId st
|
||||
Id: e.API,
|
||||
Name: info.Name,
|
||||
Service: auto.UUID(info.Service),
|
||||
Team: auto.UUID(serviceTeamMap[info.Service]),
|
||||
Method: http.MethodPost,
|
||||
RequestPath: info.Path,
|
||||
Model: auto.Label{
|
||||
|
||||
Reference in New Issue
Block a user