-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: aiproxy service init * fix: go work use * fix: golang lint * fix: golang lint * fix: aiproxy deploy cluster * fix: deploy service ns * fix: foreignkey * fix: get channel * fix: search key str to int * fix: big int * chore: add index * fix: marshal json alias use pointer * feat: str fmt lint and message conv to en * fix: baidu conv frequency penalty -2.0-2.0 to 1.0-2.0 * fix: fast conv message
- Loading branch information
1 parent
0d3f8b0
commit 1c05beb
Showing
203 changed files
with
18,911 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
FROM gcr.io/distroless/static:nonroot | ||
ARG TARGETARCH | ||
COPY bin/service-aiproxy-$TARGETARCH /manager | ||
EXPOSE 3000 | ||
USER 65532:65532 | ||
|
||
ENTRYPOINT ["/manager"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
IMG ?= ghcr.io/labring/sealos-aiproxy-service:latest | ||
|
||
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set) | ||
ifeq (,$(shell go env GOBIN)) | ||
GOBIN=$(shell go env GOPATH)/bin | ||
else | ||
GOBIN=$(shell go env GOBIN) | ||
endif | ||
|
||
# only support linux, non cgo | ||
PLATFORMS ?= linux_arm64 linux_amd64 | ||
GOOS=linux | ||
GOARCH=$(shell go env GOARCH) | ||
|
||
.PHONY: all | ||
all: build | ||
|
||
##@ General | ||
|
||
# The help target prints out all targets with their descriptions organized | ||
# beneath their categories. The categories are represented by '##@' and the | ||
# target descriptions by '##'. The awk commands is responsible for reading the | ||
# entire set of makefiles included in this invocation, looking for lines of the | ||
# file as xyz: ## something, and then pretty-format the target and help. Then, | ||
# if there's a line with ##@ something, that gets pretty-printed as a category. | ||
# More info on the usage of ANSI control characters for terminal formatting: | ||
# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters | ||
# More info on the awk command: | ||
# http://linuxcommand.org/lc3_adv_awk.php | ||
|
||
.PHONY: help | ||
help: ## Display this help. | ||
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) | ||
|
||
##@ Build | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -f $(SERVICE_NAME) | ||
|
||
.PHONY: build | ||
build: ## Build service-hub binary. | ||
LD_FLAGS="-s -w -extldflags '-static'"; \ | ||
CGO_ENABLED=0 GOOS=linux go build -tags "jsoniter" -ldflags "$${LD_FLAGS}" -trimpath -o bin/manager main.go | ||
|
||
.PHONY: docker-build | ||
docker-build: build | ||
mv bin/manager bin/service-aiproxy-${TARGETARCH} | ||
docker build -t $(IMG) . | ||
|
||
.PHONY: docker-push | ||
docker-push: | ||
docker push $(IMG) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package balance | ||
|
||
import "context" | ||
|
||
type GroupBalance interface { | ||
GetGroupRemainBalance(ctx context.Context, group string) (float64, PostGroupConsumer, error) | ||
} | ||
|
||
type PostGroupConsumer interface { | ||
PostGroupConsume(ctx context.Context, tokenName string, usage float64) (float64, error) | ||
GetBalance(ctx context.Context) (float64, error) | ||
} | ||
|
||
var Default GroupBalance = NewMockGroupBalance() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package balance | ||
|
||
import "context" | ||
|
||
var _ GroupBalance = (*MockGroupBalance)(nil) | ||
|
||
const ( | ||
mockBalance = 10000000 | ||
) | ||
|
||
type MockGroupBalance struct{} | ||
|
||
func NewMockGroupBalance() *MockGroupBalance { | ||
return &MockGroupBalance{} | ||
} | ||
|
||
func (q *MockGroupBalance) GetGroupRemainBalance(_ context.Context, _ string) (float64, PostGroupConsumer, error) { | ||
return mockBalance, q, nil | ||
} | ||
|
||
func (q *MockGroupBalance) PostGroupConsume(_ context.Context, _ string, usage float64) (float64, error) { | ||
return usage, nil | ||
} | ||
|
||
func (q *MockGroupBalance) GetBalance(_ context.Context) (float64, error) { | ||
return mockBalance, nil | ||
} |
Oops, something went wrong.