Skip to content

Commit

Permalink
Merge pull request #110 from APIParkLab/feature/translate
Browse files Browse the repository at this point in the history
Feature/translate
  • Loading branch information
Dot-Liu authored Oct 28, 2024
2 parents d253d68 + 76872b3 commit 588cf83
Show file tree
Hide file tree
Showing 19 changed files with 302 additions and 392 deletions.
9 changes: 4 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,17 @@ body:
description: Share the steps you took so that we can reproduce the issue. Reports without proper steps details will likely be closed.
placeholder: |
1. Run APIPark via the Docker image.
2. Create a Route with the Admin API.
3. Try configuring ...
4. ...
2. Try configuring ...
3. ...
validations:
required: true
required: false
- type: textarea
id: environment
attributes:
label: Environment
description: Share your environment details. Reports without proper environment details will likely be closed.
value: |
- APIPark Dashboard version:
- APINTO Dashboard version:
- Operating system (run `uname -a`):
validations:
required: true
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/request_help.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ body:
label: Environment
description: Share your environment details. Reports without proper environment details will likely be closed.
value: |
- APIPark Dashboard version:
- APIPark version:
- Operating system (run `uname -a`):
validations:
required: true
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
echo "Build frontend..."
cd ./frontend && pnpm run build
- name: upload frontend release
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: frontend-package
path: frontend/dist
Expand All @@ -41,7 +41,7 @@ jobs:
- name: Checkout #Checkout代码
uses: actions/checkout@v3
- name: download frontend release
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: frontend-package
path: frontend/dist
Expand Down Expand Up @@ -71,7 +71,7 @@ jobs:
- uses: actions/checkout@v3

- name: download frontend release
uses: actions/download-artifact@v2
uses: actions/download-artifact@v3
with:
name: frontend-package
path: frontend/dist
Expand Down
9 changes: 0 additions & 9 deletions ai-provider/model-runtime/model-providers/openAI/openai.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
- variable: openai_organization
label:
zh_Hans: 组织 ID
en_US: Organization
type: text-input
required: false
placeholder:
zh_Hans: 在此输入您的组织 ID
en_US: Enter your Organization ID
- variable: openai_api_base
label:
zh_Hans: API Base
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ provider_credential_schema:
placeholder:
zh_Hans: 在此输入您的 API Key
en_US: Enter your API Key
address: https://api.openai.com
address: https://api.360.cn
4 changes: 2 additions & 2 deletions common/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"bytes"
"fmt"

"github.com/urfave/cli/v2"
"github.com/urfave/cli"
)

// These should be set via go build -ldflags -X 'xxxx'.
Expand All @@ -20,7 +20,7 @@ var profileInfo []byte

func init() {
buffer := &bytes.Buffer{}
fmt.Fprintf(buffer, "Apinto version: %s\n", Version)
fmt.Fprintf(buffer, "APIPark version: %s\n", Version)
fmt.Fprintf(buffer, "Golang version: %s\n", goVersion)
fmt.Fprintf(buffer, "Git commit hash: %s\n", gitCommit)
fmt.Fprintf(buffer, "Built on: %s\n", BuildTime)
Expand Down
5 changes: 3 additions & 2 deletions controller/service/iml.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,9 @@ func (i *imlServiceController) createAIService(ctx *gin.Context, teamID string,
Prompt: "You need to translate {{source_lang}} into {{target_lang}}, and the following is the content that needs to be translated.\n---\n{{text}}",
}
aiModel := &ai_api_dto.AiModel{
Id: m.ID(),
Config: m.DefaultConfig(),
Id: m.ID(),
Config: m.DefaultConfig(),
Provider: *input.Provider,
}
name := "Demo Translation API"
description := "A demo that shows you how to use a prompt to create a Translation API."
Expand Down
5 changes: 3 additions & 2 deletions controller/system/iml.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,8 +381,9 @@ func (i *imlInitController) createAIService(ctx context.Context, teamID string,
Prompt: "You need to translate {{source_lang}} into {{target_lang}}, and the following is the content that needs to be translated.\n---\n{{text}}",
}
aiModel := &ai_api_dto.AiModel{
Id: m.ID(),
Config: m.DefaultConfig(),
Id: m.ID(),
Config: m.DefaultConfig(),
Provider: providerId,
}
name := "Demo Translation API"
description := "A demo that shows you how to use a prompt to create a Translation API."
Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ go 1.21
//toolchain go1.21.1

require (
github.com/eolinker/ap-account v1.0.13
github.com/eolinker/ap-account v1.0.14
github.com/eolinker/eosc v0.17.3
github.com/eolinker/go-common v1.1.0
github.com/gabriel-vasile/mimetype v1.4.4
github.com/getkin/kin-openapi v0.127.0
github.com/gin-gonic/gin v1.10.0
github.com/google/uuid v1.6.0
github.com/influxdata/influxdb-client-go/v2 v2.14.0
github.com/urfave/cli/v2 v2.27.2
github.com/urfave/cli v1.22.16
golang.org/x/crypto v0.24.0
gopkg.in/yaml.v3 v3.0.1
gorm.io/gorm v1.25.5
Expand All @@ -26,7 +26,7 @@ require (
github.com/cespare/xxhash/v2 v2.2.0 // indirect
github.com/cloudwego/base64x v0.1.4 // indirect
github.com/cloudwego/iasm v0.2.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.4 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.5 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/dustin/go-humanize v1.0.0 // indirect
github.com/ghodss/yaml v1.0.0 // indirect
Expand Down Expand Up @@ -62,7 +62,6 @@ require (
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
github.com/ugorji/go/codec v1.2.12 // indirect
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.13 // indirect
go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.6.0 // indirect
Expand Down
15 changes: 7 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho=
github.com/RaveNoX/go-jsoncommentstrip v1.0.0/go.mod h1:78ihd09MekBnJnxpICcwzCMzGrKSKYe4AqU6PDYYpjk=
github.com/apapsch/go-jsonmerge/v2 v2.0.0 h1:axGnT1gRIfimI7gJifB699GoE/oq+F2MU7Dml6nw9rQ=
github.com/apapsch/go-jsonmerge/v2 v2.0.0/go.mod h1:lvDnEdqiQrp0O42VQGgmlKpxL1AP2+08jFMw88y4klk=
Expand All @@ -18,17 +19,17 @@ github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lVfRxZq4=
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/cpuguy83/go-md2man/v2 v2.0.5 h1:ZtcqGrnekaHpVLArFSe4HK5DoKx1T0rq2DwVB0alcyc=
github.com/cpuguy83/go-md2man/v2 v2.0.5/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/eolinker/ap-account v1.0.13 h1:6iWdyxLAIkJfgw9JvkHEq0t2m8Levpg30kSx5pTK2wY=
github.com/eolinker/ap-account v1.0.13/go.mod h1:qLKg4xervGHTNBWaGckfPkQb+FZT0XfhwPEdNpzvsjE=
github.com/eolinker/ap-account v1.0.14 h1:QE9LWx9F/t/BbTeBcjPX+Alzh3mdlHv+BVvKcBwr5dc=
github.com/eolinker/ap-account v1.0.14/go.mod h1:qLKg4xervGHTNBWaGckfPkQb+FZT0XfhwPEdNpzvsjE=
github.com/eolinker/eosc v0.17.3 h1:sr2yT+v/AsqEdciRaaZZj0zL9pTufR5RvDW6+65hraQ=
github.com/eolinker/eosc v0.17.3/go.mod h1:xgq816hpanlMXFtZw7Ztdctb1eEk9UPHchY4NfFO6Cw=
github.com/eolinker/go-common v1.1.0 h1:n/XXK7yVRen3jhNG/SfZGXJA+KNnaYf0XTDfMeviaBw=
Expand Down Expand Up @@ -139,10 +140,8 @@ github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
github.com/urfave/cli/v2 v2.27.2 h1:6e0H+AkS+zDckwPCUrZkKX38mRaau4nL2uipkJpbkcI=
github.com/urfave/cli/v2 v2.27.2/go.mod h1:g0+79LmHHATl7DAcHO99smiR/T7uGLw84w8Y42x+4eM=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913 h1:+qGGcbkzsfDQNPPe9UDgpxAWQrhbbBXOYJFQDq/dtJw=
github.com/xrash/smetrics v0.0.0-20240312152122-5f08fbb34913/go.mod h1:4aEEwZQutDLsQv2Deui4iYQ6DWTxR14g6m8Wv88+Xqk=
github.com/urfave/cli v1.22.16 h1:MH0k6uJxdwdeWQTwhSO42Pwr4YLrNLwBtg1MRgTqPdQ=
github.com/urfave/cli v1.22.16/go.mod h1:EeJR6BKodywf4zciqrdw6hpCPk68JO9z5LazXZMn5Po=
go.etcd.io/etcd/client/pkg/v3 v3.5.13 h1:RVZSAnWWWiI5IrYAXjQorajncORbS0zI48LQlE2kQWg=
go.etcd.io/etcd/client/pkg/v3 v3.5.13/go.mod h1:XxHT4u1qU12E2+po+UVPrEeL94Um6zL58ppuJWXSAB8=
go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
Expand Down
22 changes: 13 additions & 9 deletions module/ai/iml.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ func (i *imlProviderModule) Providers(ctx context.Context) ([]*ai_dto.ProviderIt
})
items := make([]*ai_dto.ProviderItem, 0, len(providers))
for _, v := range providers {
defaultLLM, has := v.DefaultModel(model_runtime.ModelTypeLLM)
if !has {
continue
}

item := &ai_dto.ProviderItem{
Id: v.ID(),
Name: v.Name(),
Expand All @@ -97,6 +94,10 @@ func (i *imlProviderModule) Providers(ctx context.Context) ([]*ai_dto.ProviderIt
Sort: v.Sort(),
}
if info, has := providerMap[v.ID()]; has {
defaultLLM, has := v.GetModel(info.DefaultLLM)
if !has {
continue
}
item.Configured = true
item.DefaultLLM = defaultLLM.ID()
item.DefaultLLMLogo = defaultLLM.Logo()
Expand Down Expand Up @@ -201,7 +202,7 @@ func (i *imlProviderModule) LLMs(ctx context.Context, driver string) ([]*ai_dto.
DefaultLLMLogo: defaultLLM.Logo(),
Logo: p.Logo(),
Configured: false,
}, err
}, nil
}

return items, &ai_dto.ProviderItem{Id: info.Id, Name: info.Name, DefaultLLM: info.DefaultLLM, Logo: p.Logo(), Configured: true}, nil
Expand Down Expand Up @@ -279,10 +280,13 @@ func (i *imlProviderModule) UpdateProviderConfig(ctx context.Context, id string,
if !errors.Is(err, gorm.ErrRecordNotFound) {
return err
}
//defaultLLm, ok := p.DefaultModel(model_runtime.ModelTypeLLM)
//if !ok {
// return fmt.Errorf("ai provider default llm not found")
//}
if input.DefaultLLM == "" {
defaultLLM, has := p.DefaultModel(model_runtime.ModelTypeLLM)
if !has {
return fmt.Errorf("ai provider default llm not found")
}
input.DefaultLLM = defaultLLM.ID()
}
info = &ai.Provider{
Id: id,
Name: p.Name(),
Expand Down
7 changes: 4 additions & 3 deletions module/team/iml.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ func (m *imlTeamModule) Create(ctx context.Context, input *team_dto.CreateTeam)
if err != nil {
return err
}
supperRole, err := m.roleService.GetSupperRole(ctx, role.GroupTeam)
superRole, err := m.roleService.GetSupperRole(ctx, role.GroupTeam)
if err != nil {
return err
}

return m.roleMemberService.Add(ctx, &role.AddMember{
Role: supperRole.Id,
Role: superRole.Id,
User: input.Master,
Target: role.TeamTarget(input.Id),
})
Expand Down Expand Up @@ -145,7 +145,8 @@ func (m *imlTeamModule) Edit(ctx context.Context, id string, input *team_dto.Edi
func (m *imlTeamModule) Delete(ctx context.Context, id string) error {
err := m.transaction.Transaction(ctx, func(ctx context.Context) error {
count, err := m.serviceService.Count(ctx, "", map[string]interface{}{
"team": id,
"team": id,
"is_delete": false,
})
if err != nil {
return err
Expand Down
Loading

0 comments on commit 588cf83

Please sign in to comment.