Skip to content

Commit

Permalink
Copilot API
Browse files Browse the repository at this point in the history
  • Loading branch information
nighca committed Dec 26, 2024
1 parent b64a5ab commit 8d0e553
Show file tree
Hide file tree
Showing 24 changed files with 944 additions and 132 deletions.
4 changes: 4 additions & 0 deletions spx-backend/.env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,7 @@ Iw==
-----END CERTIFICATE-----"
GOP_CASDOOR_ORGANIZATIONNAME="GoPlus"
GOP_CASDOOR_APPLICATIONNAME="application_x8aevk"

# Anthropic Service
ANTHROPIC_ENDPOINT=
ANTHROPIC_API_KEY=
49 changes: 48 additions & 1 deletion spx-backend/cmd/spx-backend/gop_autogen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions spx-backend/cmd/spx-backend/post_copilot_message.yap
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Generate a message by sending a list of input messages.
//
// Request:
// POST /copilot/message

import (
"github.com/goplus/builder/spx-backend/internal/controller"
)

ctx := &Context
if _, isAuthed := ensureAuthedUser(ctx); !isAuthed {
return
}

params := &controller.GenerateMessageParams{}
if !parseJSON(ctx, params) {
return
}
if ok, msg := params.Validate(); !ok {
replyWithCodeMsg(ctx, errorInvalidArgs, msg)
return
}

result, err := ctrl.GenerateMessage(ctx.Context(), params)
if err != nil {
replyWithInnerError(ctx, err)
return
}
json result
29 changes: 16 additions & 13 deletions spx-backend/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ require (
github.com/qiniu/x v1.13.10
gocloud.dev v0.36.0 // indirect
golang.org/x/mod v0.17.0
golang.org/x/tools v0.19.0
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d
)

require (
github.com/DATA-DOG/go-sqlmock v1.5.2
github.com/anthropics/anthropic-sdk-go v0.2.0-alpha.8
github.com/casdoor/casdoor-go-sdk v0.36.0
github.com/goplus/gop v1.2.6
github.com/qiniu/go-sdk/v7 v7.18.0
Expand All @@ -28,23 +29,25 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang-jwt/jwt/v4 v4.5.0 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/googleapis/gax-go/v2 v2.12.0 // indirect
github.com/googleapis/gax-go/v2 v2.12.5 // indirect
github.com/goplus/gogen v1.15.2 // indirect
github.com/jinzhu/inflection v1.0.0 // indirect
github.com/jinzhu/now v1.1.5 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/tidwall/gjson v1.14.4 // indirect
github.com/tidwall/match v1.1.1 // indirect
github.com/tidwall/pretty v1.2.1 // indirect
github.com/tidwall/sjson v1.2.5 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/oauth2 v0.14.0 // indirect
golang.org/x/sync v0.6.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/net v0.27.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
google.golang.org/api v0.151.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/grpc v1.59.0 // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/api v0.189.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240722135656-d784300faade // indirect
google.golang.org/grpc v1.64.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading

0 comments on commit 8d0e553

Please sign in to comment.