diff --git a/.github/workflows/freebsd-release.yml b/.github/workflows/freebsd-release.yml new file mode 100644 index 000000000..7eda92cd9 --- /dev/null +++ b/.github/workflows/freebsd-release.yml @@ -0,0 +1,48 @@ +name: FreeBSD Release + +on: workflow_dispatch + +jobs: + release: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Set up node.js + uses: actions/setup-node@v3 + with: + node-version: 22.4.1 + - name: Generate release tag + id: tag + run: echo "release_tag=$(wget -qO- https://api.github.com/repos/MartialBE/one-hub/tags | gawk -F '["v]' '/name/{print "v"$5;exit}')" >> $GITHUB_OUTPUT + - name: Build frontend + env: + CI: "" + run: | + cd web + yarn install + REACT_APP_VERSION=${{ steps.tag.outputs.release_tag }} yarn run build + cd .. + - name: Build binary + uses: vmactions/freebsd-vm@v1 + with: + usesh: true + release: 13.2 + prepare: | + pkg install -y wget curl git gcc bash gawk gsed + wget https://dl.google.com/go/go1.22.0.freebsd-amd64.tar.gz + tar -C /usr/local -xzf go1.22.0.freebsd-amd64.tar.gz + ln -s /usr/local/go/bin/go /usr/local/bin/go + run: | + git config --global --add safe.directory /home/runner/work/one-hub/one-hub + cd /home/runner/work/one-hub/one-hub + go build -ldflags "-s -w -X 'one-api/common/config.Version=${{ steps.tag.outputs.release_tag }}' -extldflags '-static'" -o one-api + - name: Create release + uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ steps.tag.outputs.release_tag }} + files: /home/runner/work/one-hub/one-hub/one-api \ No newline at end of file diff --git a/controller/channel-billing.go b/controller/channel-billing.go index 17ba4c636..8e5dc4a02 100644 --- a/controller/channel-billing.go +++ b/controller/channel-billing.go @@ -56,6 +56,7 @@ func updateChannelBalance(channel *model.Channel) (float64, error) { c.Request = req req.Header.Set("Content-Type", "application/json") + req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36") provider := providers.GetProvider(channel, c) if provider == nil { diff --git a/controller/channel-test.go b/controller/channel-test.go index 5d278d24e..b124587fa 100644 --- a/controller/channel-test.go +++ b/controller/channel-test.go @@ -32,6 +32,7 @@ func testChannel(channel *model.Channel, testModel string) (err error, openaiErr return err, nil } req.Header.Set("Content-Type", "application/json") + req.Header.Set("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36") w := httptest.NewRecorder() c, _ := gin.CreateTestContext(w) @@ -81,11 +82,11 @@ func buildTestRequest() *types.ChatCompletionRequest { Messages: []types.ChatCompletionMessage{ { Role: "user", - Content: "You just need to output 'hi' next.", + Content: "say 1", }, }, Model: "", - MaxTokens: 2, + MaxTokens: 10, Stream: false, } return testRequest diff --git a/providers/base/common.go b/providers/base/common.go index 337ed45aa..bd932d090 100644 --- a/providers/base/common.go +++ b/providers/base/common.go @@ -64,6 +64,7 @@ func (p *BaseProvider) CommonRequestHeaders(headers map[string]string) { if headers["Content-Type"] == "" { headers["Content-Type"] = "application/json" } + headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36" } func (p *BaseProvider) GetUsage() *types.Usage { diff --git a/relay/relay.go b/relay/relay.go index c6e3889ec..dd7197d17 100644 --- a/relay/relay.go +++ b/relay/relay.go @@ -50,6 +50,7 @@ func RelayOnly(c *gin.Context) { } mapHeaders[k] = strings.Join(v, ", ") } + mapHeaders["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36" requester := provider.GetRequester() req, err := requester.NewRequest(c.Request.Method, url, requester.WithBody(c.Request.Body), requester.WithHeader(mapHeaders))