Skip to content

Commit

Permalink
ua&ga
Browse files Browse the repository at this point in the history
  • Loading branch information
SuiYunsy committed Jul 20, 2024
1 parent 4f1036b commit d8d6e6d
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 2 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/freebsd-release.yml
Original file line number Diff line number Diff line change
@@ -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
1 change: 1 addition & 0 deletions controller/channel-billing.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions controller/channel-test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions providers/base/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions relay/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit d8d6e6d

Please sign in to comment.