From e2f67a8a7fb482120650ecaf38f5fd07300e298b Mon Sep 17 00:00:00 2001 From: wood chen <95951386+woodchen-ink@users.noreply.github.com> Date: Sun, 28 Jan 2024 01:57:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=9D=E8=AF=95=E6=9C=80=E5=88=9D=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker.yml | 42 ------------------------------ .gitignore | 45 +++++++++++++++++++++++++++++++++ code/config.example.yaml | 2 +- code/handlers/msg.go | 7 +++-- code/role_list.yaml | 4 +++ code/services/openai/billing.go | 2 +- code/services/openai/gpt3.go | 25 ++---------------- 7 files changed, 56 insertions(+), 71 deletions(-) delete mode 100644 .github/workflows/docker.yml create mode 100644 .gitignore diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index df8721e..0000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Docker - -on: - push: - branches: - - main - tags: - - v* - -env: - IMAGE_NAME: oapi-feishu - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: 检出代码库 - uses: actions/checkout@v3 - - - name: 构建镜像 - run: docker build . --file Dockerfile --tag $IMAGE_NAME - - - name: 登录到镜像仓库 - run: echo "${{ secrets.ACCESS_TOKEN }}" | docker login -u woodchen --password-stdin - - - name: 推送镜像 - run: | - IMAGE_ID=woodchen/$IMAGE_NAME - IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') - - # 从 GitHub 事件负载中获取分支名 - BRANCH_NAME=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') - - # 对于除了 "main" 分支和标签以外的分支,使用 "latest" 版本号 - VERSION=$(if [ "$BRANCH_NAME" == "main" ]; then echo "latest"; else echo $BRANCH_NAME; fi) - - echo IMAGE_ID=$IMAGE_ID - echo VERSION=$VERSION - - docker tag $IMAGE_NAME $IMAGE_ID:$VERSION - docker push $IMAGE_ID:$VERSION \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..13569c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,45 @@ +### Go template +# If you prefer the allow list template instead of the deny list, see community template: +# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore +# +# Binaries for programs and plugins +*.exe +*.exe~ +*.dll +*.so +*.dylib + +# Test binary, built with `go test -c` +*.test + +# Output of the go coverage tool, specifically when used with LiteIDE +*.out + +# Dependency directories (remove the comment below to include it) +# vendor/ + +# Go workspace file +go.work +./code/target +.idea +.vscode +.s + +config.yaml + + + +/code/target/ +start-feishubot +.env + +docker.md +# Mac OS +.DS_Store +**/.DS_Store +*.pem + +pkg +# 方便在本地放一些不用上传给 github 的文档,只需要在本地建立一个 ignore 文件夹,然后把需要忽略的文件放进去就行了 +ignore +logs \ No newline at end of file diff --git a/code/config.example.yaml b/code/config.example.yaml index 8df530b..a96f3c7 100644 --- a/code/config.example.yaml +++ b/code/config.example.yaml @@ -25,7 +25,7 @@ OPENAI_HTTP_CLIENT_TIMEOUT: OPENAI_MODEL: gpt-3.5-turbo # AZURE OPENAI -AZURE_ON: false # set to true to use Azure rather than OpenAI +AZURE_ON: true # set to true to use Azure rather than OpenAI AZURE_API_VERSION: 2023-03-15-preview # 2023-03-15-preview or 2022-12-01 refer https://learn.microsoft.com/en-us/azure/cognitive-services/openai/reference#completions AZURE_RESOURCE_NAME: xxxx # you can find in endpoint url. Usually looks like https://{RESOURCE_NAME}.openai.azure.com AZURE_DEPLOYMENT_NAME: xxxx # usually looks like ...openai.azure.com/openai/deployments/{DEPLOYMENT_NAME}/chat/completions. diff --git a/code/handlers/msg.go b/code/handlers/msg.go index 7ef227e..9a7526e 100644 --- a/code/handlers/msg.go +++ b/code/handlers/msg.go @@ -6,13 +6,12 @@ import ( "encoding/base64" "errors" "fmt" - "start-feishubot/initialization" - "start-feishubot/services" - "start-feishubot/services/openai" - "github.com/google/uuid" larkcard "github.com/larksuite/oapi-sdk-go/v3/card" larkim "github.com/larksuite/oapi-sdk-go/v3/service/im/v1" + "start-feishubot/initialization" + "start-feishubot/services" + "start-feishubot/services/openai" ) type CardKind string diff --git a/code/role_list.yaml b/code/role_list.yaml index 45594b3..6c44053 100644 --- a/code/role_list.yaml +++ b/code/role_list.yaml @@ -1,3 +1,7 @@ +# 可在此处提交你认为不错的角色预设,注意保持格式一致。 +# PR 时的 tag 暂时集中在 [ "日常办公", "生活助手" ,"代码专家", "文案撰写"] +# 更多点子可参考我另一个参与的项目: https://open-gpt.app/ + - title: 周报生成 content: 请帮我把以下的工作内容填充为一篇完整的周报,用 markdown 格式以分点叙述的形式输出: example: 重新优化设计稿,和前端再次沟通 UI 细节,确保落地 diff --git a/code/services/openai/billing.go b/code/services/openai/billing.go index d3664c2..4d48eeb 100644 --- a/code/services/openai/billing.go +++ b/code/services/openai/billing.go @@ -6,7 +6,7 @@ import ( "time" ) -// https://api.openai.com/dashboard/billing/credit_grants +// https://oapi.czl.net/dashboard/billing/credit_grants type Billing struct { Object string `json:"object"` TotalGranted float64 `json:"total_granted"` diff --git a/code/services/openai/gpt3.go b/code/services/openai/gpt3.go index 5ea27bf..bdb39b8 100644 --- a/code/services/openai/gpt3.go +++ b/code/services/openai/gpt3.go @@ -5,29 +5,8 @@ import ( ) const ( - Fresh AIMode = 0.1 - Warmth AIMode = 0.4 - Balance AIMode = 0.7 - Creativity AIMode = 1.0 -) - -var AIModeMap = map[string]AIMode{ - "清新": Fresh, - "温暖": Warmth, - "平衡": Balance, - "创意": Creativity, -} - -var AIModeStrs = []string{ - "清新", - "温暖", - "平衡", - "创意", -} - -const ( - maxTokens = 4096 - engine = "gpt-4-0613" + maxTokens = 2000 + temperature = 0.7 ) type Messages struct {