Spaces:
Paused
Paused
Upload 46 files
Browse files- .github/ISSUE_TEMPLATE/bug_report.md +26 -0
- .github/ISSUE_TEMPLATE/config.yml +5 -0
- .github/ISSUE_TEMPLATE/feature_request.md +21 -0
- .github/close_issue.py +105 -0
- .github/workflows/CloseIssue.yml +24 -0
- .github/workflows/docker-image-amd64.yml +55 -0
- .github/workflows/docker-image-arm64.yml +63 -0
- .github/workflows/github-pages.yml +29 -0
- .github/workflows/linux-release.yml +46 -0
- .github/workflows/macos-release.yml +37 -0
- .github/workflows/windows-release.yml +40 -0
- .gitignore +6 -0
- Dockerfile +35 -0
- LICENSE +674 -0
- README.md +195 -11
- common/config/config.go +34 -0
- common/constants.go +48 -0
- common/env/helper.go +42 -0
- common/helper/helper.go +139 -0
- common/helper/key.go +5 -0
- common/helper/time.go +15 -0
- common/init.go +57 -0
- common/loggger/constants.go +3 -0
- common/loggger/logger.go +103 -0
- common/random/main.go +61 -0
- common/rate-limit.go +70 -0
- common/token.go +193 -0
- common/utils.go +167 -0
- controller/chat.go +1086 -0
- docker-compose.yml +15 -0
- docs/img.png +0 -0
- docs/img2.png +0 -0
- docs/img3.png +0 -0
- docs/img4.png +0 -0
- docs/img5.png +0 -0
- go.mod +51 -0
- go.sum +483 -0
- main.go +53 -0
- middleware/auth.go +63 -0
- middleware/cors.go +15 -0
- middleware/logger.go +25 -0
- middleware/rate-limit.go +36 -0
- middleware/request-id.go +18 -0
- model/openai.go +139 -0
- router/api-router.go +22 -0
- router/main.go +9 -0
.github/ISSUE_TEMPLATE/bug_report.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: 报告问题
|
| 3 |
+
about: 使用简练详细的语言描述你遇到的问题
|
| 4 |
+
title: ''
|
| 5 |
+
labels: bug
|
| 6 |
+
assignees: ''
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
**温馨提示: 未`star`项目会被自动关闭issue哦!**
|
| 11 |
+
|
| 12 |
+
**例行检查**
|
| 13 |
+
|
| 14 |
+
+ [ ] 我已确认目前没有类似 issue
|
| 15 |
+
+ [ ] 我已确认我已升级到最新版本
|
| 16 |
+
+ [ ] 我理解并愿意跟进此 issue,协助测试和提供反馈
|
| 17 |
+
+ [ ] 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭
|
| 18 |
+
|
| 19 |
+
**问题描述**
|
| 20 |
+
|
| 21 |
+
**复现步骤**
|
| 22 |
+
|
| 23 |
+
**预期结果**
|
| 24 |
+
|
| 25 |
+
**相关截图**
|
| 26 |
+
如果没有的话,请删除此节。
|
.github/ISSUE_TEMPLATE/config.yml
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
blank_issues_enabled: false
|
| 2 |
+
contact_links:
|
| 3 |
+
- name: 赞赏支持
|
| 4 |
+
# url:
|
| 5 |
+
about: 请作者喝杯咖啡,以激励作者持续开发
|
.github/ISSUE_TEMPLATE/feature_request.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: 功能请求
|
| 3 |
+
about: 使用简练详细的语言描述希望加入的新功能
|
| 4 |
+
title: ''
|
| 5 |
+
labels: enhancement
|
| 6 |
+
assignees: ''
|
| 7 |
+
|
| 8 |
+
---
|
| 9 |
+
|
| 10 |
+
**温馨提示: 未`star`项目会被自动关闭issue哦!**
|
| 11 |
+
|
| 12 |
+
**例行检查**
|
| 13 |
+
|
| 14 |
+
+ [ ] 我已确认目前没有类似 issue
|
| 15 |
+
+ [ ] 我已确认我已升级到最新版本
|
| 16 |
+
+ [ ] 我理解并愿意跟进此 issue,协助测试和提供反馈
|
| 17 |
+
+ [ ] 我理解并认可上述内容,并理解项目维护者精力有限,不遵循规则的 issue 可能会被无视或直接关闭
|
| 18 |
+
|
| 19 |
+
**功能描述**
|
| 20 |
+
|
| 21 |
+
**应用场景**
|
.github/close_issue.py
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import requests
|
| 3 |
+
|
| 4 |
+
issue_labels = ['no respect']
|
| 5 |
+
github_repo = 'deanxv/genspark2api'
|
| 6 |
+
github_token = os.getenv("GITHUB_TOKEN")
|
| 7 |
+
headers = {
|
| 8 |
+
'Authorization': 'Bearer ' + github_token,
|
| 9 |
+
'Accept': 'application/vnd.github+json',
|
| 10 |
+
'X-GitHub-Api-Version': '2022-11-28',
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def get_stargazers(repo):
|
| 15 |
+
page = 1
|
| 16 |
+
_stargazers = {}
|
| 17 |
+
while True:
|
| 18 |
+
queries = {
|
| 19 |
+
'per_page': 100,
|
| 20 |
+
'page': page,
|
| 21 |
+
}
|
| 22 |
+
url = 'https://api.github.com/repos/{}/stargazers?'.format(repo)
|
| 23 |
+
|
| 24 |
+
resp = requests.get(url, headers=headers, params=queries)
|
| 25 |
+
if resp.status_code != 200:
|
| 26 |
+
raise Exception('Error get stargazers: ' + resp.text)
|
| 27 |
+
|
| 28 |
+
data = resp.json()
|
| 29 |
+
if not data:
|
| 30 |
+
break
|
| 31 |
+
|
| 32 |
+
for stargazer in data:
|
| 33 |
+
_stargazers[stargazer['login']] = True
|
| 34 |
+
page += 1
|
| 35 |
+
|
| 36 |
+
print('list stargazers done, total: ' + str(len(_stargazers)))
|
| 37 |
+
return _stargazers
|
| 38 |
+
|
| 39 |
+
|
| 40 |
+
def get_issues(repo):
|
| 41 |
+
page = 1
|
| 42 |
+
_issues = []
|
| 43 |
+
while True:
|
| 44 |
+
queries = {
|
| 45 |
+
'state': 'open',
|
| 46 |
+
'sort': 'created',
|
| 47 |
+
'direction': 'desc',
|
| 48 |
+
'per_page': 100,
|
| 49 |
+
'page': page,
|
| 50 |
+
}
|
| 51 |
+
url = 'https://api.github.com/repos/{}/issues?'.format(repo)
|
| 52 |
+
|
| 53 |
+
resp = requests.get(url, headers=headers, params=queries)
|
| 54 |
+
if resp.status_code != 200:
|
| 55 |
+
raise Exception('Error get issues: ' + resp.text)
|
| 56 |
+
|
| 57 |
+
data = resp.json()
|
| 58 |
+
if not data:
|
| 59 |
+
break
|
| 60 |
+
|
| 61 |
+
_issues += data
|
| 62 |
+
page += 1
|
| 63 |
+
|
| 64 |
+
print('list issues done, total: ' + str(len(_issues)))
|
| 65 |
+
return _issues
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
def close_issue(repo, issue_number):
|
| 69 |
+
url = 'https://api.github.com/repos/{}/issues/{}'.format(repo, issue_number)
|
| 70 |
+
data = {
|
| 71 |
+
'state': 'closed',
|
| 72 |
+
'state_reason': 'not_planned',
|
| 73 |
+
'labels': issue_labels,
|
| 74 |
+
}
|
| 75 |
+
resp = requests.patch(url, headers=headers, json=data)
|
| 76 |
+
if resp.status_code != 200:
|
| 77 |
+
raise Exception('Error close issue: ' + resp.text)
|
| 78 |
+
|
| 79 |
+
print('issue: {} closed'.format(issue_number))
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def lock_issue(repo, issue_number):
|
| 83 |
+
url = 'https://api.github.com/repos/{}/issues/{}/lock'.format(repo, issue_number)
|
| 84 |
+
data = {
|
| 85 |
+
'lock_reason': 'spam',
|
| 86 |
+
}
|
| 87 |
+
resp = requests.put(url, headers=headers, json=data)
|
| 88 |
+
if resp.status_code != 204:
|
| 89 |
+
raise Exception('Error lock issue: ' + resp.text)
|
| 90 |
+
|
| 91 |
+
print('issue: {} locked'.format(issue_number))
|
| 92 |
+
|
| 93 |
+
|
| 94 |
+
if '__main__' == __name__:
|
| 95 |
+
stargazers = get_stargazers(github_repo)
|
| 96 |
+
|
| 97 |
+
issues = get_issues(github_repo)
|
| 98 |
+
for issue in issues:
|
| 99 |
+
login = issue['user']['login']
|
| 100 |
+
if login not in stargazers:
|
| 101 |
+
print('issue: {}, login: {} not in stargazers'.format(issue['number'], login))
|
| 102 |
+
close_issue(github_repo, issue['number'])
|
| 103 |
+
lock_issue(github_repo, issue['number'])
|
| 104 |
+
|
| 105 |
+
print('done')
|
.github/workflows/CloseIssue.yml
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: CloseIssue
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
workflow_dispatch:
|
| 5 |
+
issues:
|
| 6 |
+
types: [ opened ]
|
| 7 |
+
|
| 8 |
+
jobs:
|
| 9 |
+
run-python-script:
|
| 10 |
+
runs-on: ubuntu-latest
|
| 11 |
+
|
| 12 |
+
steps:
|
| 13 |
+
- uses: actions/checkout@v3
|
| 14 |
+
- uses: actions/setup-python@v4
|
| 15 |
+
with:
|
| 16 |
+
python-version: "3.10"
|
| 17 |
+
|
| 18 |
+
- name: Install Dependencies
|
| 19 |
+
run: pip install requests
|
| 20 |
+
|
| 21 |
+
- name: Run close_issue.py Script
|
| 22 |
+
env:
|
| 23 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
| 24 |
+
run: python .github/close_issue.py
|
.github/workflows/docker-image-amd64.yml
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Publish Docker image (amd64)
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
tags:
|
| 6 |
+
- '*'
|
| 7 |
+
workflow_dispatch:
|
| 8 |
+
inputs:
|
| 9 |
+
name:
|
| 10 |
+
description: 'reason'
|
| 11 |
+
required: false
|
| 12 |
+
jobs:
|
| 13 |
+
push_to_registries:
|
| 14 |
+
name: Push Docker image to multiple registries
|
| 15 |
+
runs-on: ubuntu-latest
|
| 16 |
+
environment: github-pages
|
| 17 |
+
permissions:
|
| 18 |
+
packages: write
|
| 19 |
+
contents: read
|
| 20 |
+
steps:
|
| 21 |
+
- name: Check out the repo
|
| 22 |
+
uses: actions/checkout@v3
|
| 23 |
+
|
| 24 |
+
- name: Save version info
|
| 25 |
+
run: |
|
| 26 |
+
git describe --tags > VERSION
|
| 27 |
+
|
| 28 |
+
- name: Log in to Docker Hub
|
| 29 |
+
uses: docker/login-action@v2
|
| 30 |
+
with:
|
| 31 |
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
| 32 |
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
| 33 |
+
|
| 34 |
+
- name: Log in to the Container registry
|
| 35 |
+
uses: docker/login-action@v2
|
| 36 |
+
with:
|
| 37 |
+
registry: ghcr.io
|
| 38 |
+
username: ${{ github.actor }}
|
| 39 |
+
password: ${{ secrets.GITHUB_TOKEN }}
|
| 40 |
+
|
| 41 |
+
- name: Extract metadata (tags, labels) for Docker
|
| 42 |
+
id: meta
|
| 43 |
+
uses: docker/metadata-action@v4
|
| 44 |
+
with:
|
| 45 |
+
images: |
|
| 46 |
+
deanxv/genspark2api
|
| 47 |
+
ghcr.io/${{ github.repository }}
|
| 48 |
+
|
| 49 |
+
- name: Build and push Docker images
|
| 50 |
+
uses: docker/build-push-action@v3
|
| 51 |
+
with:
|
| 52 |
+
context: .
|
| 53 |
+
push: true
|
| 54 |
+
tags: ${{ steps.meta.outputs.tags }}
|
| 55 |
+
labels: ${{ steps.meta.outputs.labels }}
|
.github/workflows/docker-image-arm64.yml
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Publish Docker image (arm64)
|
| 2 |
+
|
| 3 |
+
on:
|
| 4 |
+
push:
|
| 5 |
+
tags:
|
| 6 |
+
- '*'
|
| 7 |
+
- '!*-alpha*'
|
| 8 |
+
workflow_dispatch:
|
| 9 |
+
inputs:
|
| 10 |
+
name:
|
| 11 |
+
description: 'reason'
|
| 12 |
+
required: false
|
| 13 |
+
jobs:
|
| 14 |
+
push_to_registries:
|
| 15 |
+
name: Push Docker image to multiple registries
|
| 16 |
+
runs-on: ubuntu-latest
|
| 17 |
+
environment: github-pages
|
| 18 |
+
permissions:
|
| 19 |
+
packages: write
|
| 20 |
+
contents: read
|
| 21 |
+
steps:
|
| 22 |
+
- name: Check out the repo
|
| 23 |
+
uses: actions/checkout@v3
|
| 24 |
+
|
| 25 |
+
- name: Save version info
|
| 26 |
+
run: |
|
| 27 |
+
git describe --tags > VERSION
|
| 28 |
+
|
| 29 |
+
- name: Set up QEMU
|
| 30 |
+
uses: docker/setup-qemu-action@v2
|
| 31 |
+
|
| 32 |
+
- name: Set up Docker Buildx
|
| 33 |
+
uses: docker/setup-buildx-action@v2
|
| 34 |
+
|
| 35 |
+
- name: Log in to Docker Hub
|
| 36 |
+
uses: docker/login-action@v2
|
| 37 |
+
with:
|
| 38 |
+
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
| 39 |
+
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
| 40 |
+
|
| 41 |
+
- name: Log in to the Container registry
|
| 42 |
+
uses: docker/login-action@v2
|
| 43 |
+
with:
|
| 44 |
+
registry: ghcr.io
|
| 45 |
+
username: ${{ github.actor }}
|
| 46 |
+
password: ${{ secrets.GITHUB_TOKEN }}
|
| 47 |
+
|
| 48 |
+
- name: Extract metadata (tags, labels) for Docker
|
| 49 |
+
id: meta
|
| 50 |
+
uses: docker/metadata-action@v4
|
| 51 |
+
with:
|
| 52 |
+
images: |
|
| 53 |
+
deanxv/genspark2api
|
| 54 |
+
ghcr.io/${{ github.repository }}
|
| 55 |
+
|
| 56 |
+
- name: Build and push Docker images
|
| 57 |
+
uses: docker/build-push-action@v3
|
| 58 |
+
with:
|
| 59 |
+
context: .
|
| 60 |
+
platforms: linux/amd64,linux/arm64
|
| 61 |
+
push: true
|
| 62 |
+
tags: ${{ steps.meta.outputs.tags }}
|
| 63 |
+
labels: ${{ steps.meta.outputs.labels }}
|
.github/workflows/github-pages.yml
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Build GitHub Pages
|
| 2 |
+
on:
|
| 3 |
+
workflow_dispatch:
|
| 4 |
+
inputs:
|
| 5 |
+
name:
|
| 6 |
+
description: 'Reason'
|
| 7 |
+
required: false
|
| 8 |
+
jobs:
|
| 9 |
+
build-and-deploy:
|
| 10 |
+
runs-on: ubuntu-latest
|
| 11 |
+
steps:
|
| 12 |
+
- name: Checkout 🛎️
|
| 13 |
+
uses: actions/checkout@v2 # If you're using actions/checkout@v2 you must set persist-credentials to false in most cases for the deployment to work correctly.
|
| 14 |
+
with:
|
| 15 |
+
persist-credentials: false
|
| 16 |
+
- name: Install and Build 🔧 # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
|
| 17 |
+
env:
|
| 18 |
+
CI: ""
|
| 19 |
+
run: |
|
| 20 |
+
cd web
|
| 21 |
+
npm install
|
| 22 |
+
npm run build
|
| 23 |
+
|
| 24 |
+
- name: Deploy 🚀
|
| 25 |
+
uses: JamesIves/github-pages-deploy-action@releases/v3
|
| 26 |
+
with:
|
| 27 |
+
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
|
| 28 |
+
BRANCH: gh-pages # The branch the action should deploy to.
|
| 29 |
+
FOLDER: web/build # The folder the action should deploy.
|
.github/workflows/linux-release.yml
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Linux Release
|
| 2 |
+
permissions:
|
| 3 |
+
contents: write
|
| 4 |
+
|
| 5 |
+
on:
|
| 6 |
+
push:
|
| 7 |
+
tags:
|
| 8 |
+
- '*'
|
| 9 |
+
- '!*-alpha*'
|
| 10 |
+
jobs:
|
| 11 |
+
release:
|
| 12 |
+
runs-on: ubuntu-latest
|
| 13 |
+
steps:
|
| 14 |
+
- name: Checkout
|
| 15 |
+
uses: actions/checkout@v3
|
| 16 |
+
with:
|
| 17 |
+
fetch-depth: 0
|
| 18 |
+
- uses: actions/setup-node@v3
|
| 19 |
+
with:
|
| 20 |
+
node-version: 16
|
| 21 |
+
- name: Set up Go
|
| 22 |
+
uses: actions/setup-go@v3
|
| 23 |
+
with:
|
| 24 |
+
go-version: '>=1.18.0'
|
| 25 |
+
- name: Build Backend (amd64)
|
| 26 |
+
run: |
|
| 27 |
+
go mod download
|
| 28 |
+
go build -ldflags "-s -w -X 'genspark2api/common.Version=$(git describe --tags)' -extldflags '-static'" -o genspark2api
|
| 29 |
+
|
| 30 |
+
- name: Build Backend (arm64)
|
| 31 |
+
run: |
|
| 32 |
+
sudo apt-get update
|
| 33 |
+
sudo apt-get install gcc-aarch64-linux-gnu
|
| 34 |
+
CC=aarch64-linux-gnu-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm64 go build -ldflags "-s -w -X 'genspark2api/common.Version=$(git describe --tags)' -extldflags '-static'" -o genspark2api-arm64
|
| 35 |
+
|
| 36 |
+
- name: Release
|
| 37 |
+
uses: softprops/action-gh-release@v1
|
| 38 |
+
if: startsWith(github.ref, 'refs/tags/')
|
| 39 |
+
with:
|
| 40 |
+
files: |
|
| 41 |
+
genspark2api
|
| 42 |
+
genspark2api-arm64
|
| 43 |
+
draft: false
|
| 44 |
+
generate_release_notes: true
|
| 45 |
+
env:
|
| 46 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
.github/workflows/macos-release.yml
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: macOS Release
|
| 2 |
+
permissions:
|
| 3 |
+
contents: write
|
| 4 |
+
|
| 5 |
+
on:
|
| 6 |
+
push:
|
| 7 |
+
tags:
|
| 8 |
+
- '*'
|
| 9 |
+
- '!*-alpha*'
|
| 10 |
+
jobs:
|
| 11 |
+
release:
|
| 12 |
+
runs-on: macos-latest
|
| 13 |
+
steps:
|
| 14 |
+
- name: Checkout
|
| 15 |
+
uses: actions/checkout@v3
|
| 16 |
+
with:
|
| 17 |
+
fetch-depth: 0
|
| 18 |
+
- uses: actions/setup-node@v3
|
| 19 |
+
with:
|
| 20 |
+
node-version: 16
|
| 21 |
+
- name: Set up Go
|
| 22 |
+
uses: actions/setup-go@v3
|
| 23 |
+
with:
|
| 24 |
+
go-version: '>=1.18.0'
|
| 25 |
+
- name: Build Backend
|
| 26 |
+
run: |
|
| 27 |
+
go mod download
|
| 28 |
+
go build -ldflags "-X 'genspark2api/common.Version=$(git describe --tags)'" -o genspark2api-macos
|
| 29 |
+
- name: Release
|
| 30 |
+
uses: softprops/action-gh-release@v1
|
| 31 |
+
if: startsWith(github.ref, 'refs/tags/')
|
| 32 |
+
with:
|
| 33 |
+
files: genspark2api-macos
|
| 34 |
+
draft: false
|
| 35 |
+
generate_release_notes: true
|
| 36 |
+
env:
|
| 37 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
.github/workflows/windows-release.yml
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
name: Windows Release
|
| 2 |
+
permissions:
|
| 3 |
+
contents: write
|
| 4 |
+
|
| 5 |
+
on:
|
| 6 |
+
push:
|
| 7 |
+
tags:
|
| 8 |
+
- '*'
|
| 9 |
+
- '!*-alpha*'
|
| 10 |
+
jobs:
|
| 11 |
+
release:
|
| 12 |
+
runs-on: windows-latest
|
| 13 |
+
defaults:
|
| 14 |
+
run:
|
| 15 |
+
shell: bash
|
| 16 |
+
steps:
|
| 17 |
+
- name: Checkout
|
| 18 |
+
uses: actions/checkout@v3
|
| 19 |
+
with:
|
| 20 |
+
fetch-depth: 0
|
| 21 |
+
- uses: actions/setup-node@v3
|
| 22 |
+
with:
|
| 23 |
+
node-version: 16
|
| 24 |
+
- name: Set up Go
|
| 25 |
+
uses: actions/setup-go@v3
|
| 26 |
+
with:
|
| 27 |
+
go-version: '>=1.18.0'
|
| 28 |
+
- name: Build Backend
|
| 29 |
+
run: |
|
| 30 |
+
go mod download
|
| 31 |
+
go build -ldflags "-s -w -X 'genspark2api/common.Version=$(git describe --tags)'" -o genspark2api.exe
|
| 32 |
+
- name: Release
|
| 33 |
+
uses: softprops/action-gh-release@v1
|
| 34 |
+
if: startsWith(github.ref, 'refs/tags/')
|
| 35 |
+
with:
|
| 36 |
+
files: genspark2api.exe
|
| 37 |
+
draft: false
|
| 38 |
+
generate_release_notes: true
|
| 39 |
+
env:
|
| 40 |
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
.gitignore
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.idea
|
| 2 |
+
.vscode
|
| 3 |
+
upload
|
| 4 |
+
*.exe
|
| 5 |
+
*.db
|
| 6 |
+
build
|
Dockerfile
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# 使用 Golang 镜像作为构建阶段
|
| 2 |
+
FROM golang AS builder
|
| 3 |
+
|
| 4 |
+
# 设置环境变量
|
| 5 |
+
ENV GO111MODULE=on \
|
| 6 |
+
CGO_ENABLED=0 \
|
| 7 |
+
GOOS=linux
|
| 8 |
+
|
| 9 |
+
# 设置工作目录
|
| 10 |
+
WORKDIR /build
|
| 11 |
+
|
| 12 |
+
# 复制 go.mod 和 go.sum 文件,先下载依赖
|
| 13 |
+
COPY go.mod go.sum ./
|
| 14 |
+
#ENV GOPROXY=https://goproxy.cn,direct
|
| 15 |
+
RUN go mod download
|
| 16 |
+
|
| 17 |
+
# 复制整个项目并构建可执行文件
|
| 18 |
+
COPY . .
|
| 19 |
+
RUN go build -o /genspark2api
|
| 20 |
+
|
| 21 |
+
# 使用 Alpine 镜像作为最终镜像
|
| 22 |
+
FROM alpine
|
| 23 |
+
|
| 24 |
+
# 安装基本的运行时依赖
|
| 25 |
+
RUN apk --no-cache add ca-certificates tzdata
|
| 26 |
+
|
| 27 |
+
# 从构建阶段复制可执行文件
|
| 28 |
+
COPY --from=builder /genspark2api .
|
| 29 |
+
|
| 30 |
+
# 暴露端口
|
| 31 |
+
EXPOSE 7055
|
| 32 |
+
# 工作目录
|
| 33 |
+
WORKDIR /app/genspark2api/data
|
| 34 |
+
# 设置入口命令
|
| 35 |
+
ENTRYPOINT ["/genspark2api"]
|
LICENSE
ADDED
|
@@ -0,0 +1,674 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
GNU GENERAL PUBLIC LICENSE
|
| 2 |
+
Version 3, 29 June 2007
|
| 3 |
+
|
| 4 |
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
| 5 |
+
Everyone is permitted to copy and distribute verbatim copies
|
| 6 |
+
of this license document, but changing it is not allowed.
|
| 7 |
+
|
| 8 |
+
Preamble
|
| 9 |
+
|
| 10 |
+
The GNU General Public License is a free, copyleft license for
|
| 11 |
+
software and other kinds of works.
|
| 12 |
+
|
| 13 |
+
The licenses for most software and other practical works are designed
|
| 14 |
+
to take away your freedom to share and change the works. By contrast,
|
| 15 |
+
the GNU General Public License is intended to guarantee your freedom to
|
| 16 |
+
share and change all versions of a program--to make sure it remains free
|
| 17 |
+
software for all its users. We, the Free Software Foundation, use the
|
| 18 |
+
GNU General Public License for most of our software; it applies also to
|
| 19 |
+
any other work released this way by its authors. You can apply it to
|
| 20 |
+
your programs, too.
|
| 21 |
+
|
| 22 |
+
When we speak of free software, we are referring to freedom, not
|
| 23 |
+
price. Our General Public Licenses are designed to make sure that you
|
| 24 |
+
have the freedom to distribute copies of free software (and charge for
|
| 25 |
+
them if you wish), that you receive source code or can get it if you
|
| 26 |
+
want it, that you can change the software or use pieces of it in new
|
| 27 |
+
free programs, and that you know you can do these things.
|
| 28 |
+
|
| 29 |
+
To protect your rights, we need to prevent others from denying you
|
| 30 |
+
these rights or asking you to surrender the rights. Therefore, you have
|
| 31 |
+
certain responsibilities if you distribute copies of the software, or if
|
| 32 |
+
you modify it: responsibilities to respect the freedom of others.
|
| 33 |
+
|
| 34 |
+
For example, if you distribute copies of such a program, whether
|
| 35 |
+
gratis or for a fee, you must pass on to the recipients the same
|
| 36 |
+
freedoms that you received. You must make sure that they, too, receive
|
| 37 |
+
or can get the source code. And you must show them these terms so they
|
| 38 |
+
know their rights.
|
| 39 |
+
|
| 40 |
+
Developers that use the GNU GPL protect your rights with two steps:
|
| 41 |
+
(1) assert copyright on the software, and (2) offer you this License
|
| 42 |
+
giving you legal permission to copy, distribute and/or modify it.
|
| 43 |
+
|
| 44 |
+
For the developers' and authors' protection, the GPL clearly explains
|
| 45 |
+
that there is no warranty for this free software. For both users' and
|
| 46 |
+
authors' sake, the GPL requires that modified versions be marked as
|
| 47 |
+
changed, so that their problems will not be attributed erroneously to
|
| 48 |
+
authors of previous versions.
|
| 49 |
+
|
| 50 |
+
Some devices are designed to deny users access to install or run
|
| 51 |
+
modified versions of the software inside them, although the manufacturer
|
| 52 |
+
can do so. This is fundamentally incompatible with the aim of
|
| 53 |
+
protecting users' freedom to change the software. The systematic
|
| 54 |
+
pattern of such abuse occurs in the area of products for individuals to
|
| 55 |
+
use, which is precisely where it is most unacceptable. Therefore, we
|
| 56 |
+
have designed this version of the GPL to prohibit the practice for those
|
| 57 |
+
products. If such problems arise substantially in other domains, we
|
| 58 |
+
stand ready to extend this provision to those domains in future versions
|
| 59 |
+
of the GPL, as needed to protect the freedom of users.
|
| 60 |
+
|
| 61 |
+
Finally, every program is threatened constantly by software patents.
|
| 62 |
+
States should not allow patents to restrict development and use of
|
| 63 |
+
software on general-purpose computers, but in those that do, we wish to
|
| 64 |
+
avoid the special danger that patents applied to a free program could
|
| 65 |
+
make it effectively proprietary. To prevent this, the GPL assures that
|
| 66 |
+
patents cannot be used to render the program non-free.
|
| 67 |
+
|
| 68 |
+
The precise terms and conditions for copying, distribution and
|
| 69 |
+
modification follow.
|
| 70 |
+
|
| 71 |
+
TERMS AND CONDITIONS
|
| 72 |
+
|
| 73 |
+
0. Definitions.
|
| 74 |
+
|
| 75 |
+
"This License" refers to version 3 of the GNU General Public License.
|
| 76 |
+
|
| 77 |
+
"Copyright" also means copyright-like laws that apply to other kinds of
|
| 78 |
+
works, such as semiconductor masks.
|
| 79 |
+
|
| 80 |
+
"The Program" refers to any copyrightable work licensed under this
|
| 81 |
+
License. Each licensee is addressed as "you". "Licensees" and
|
| 82 |
+
"recipients" may be individuals or organizations.
|
| 83 |
+
|
| 84 |
+
To "modify" a work means to copy from or adapt all or part of the work
|
| 85 |
+
in a fashion requiring copyright permission, other than the making of an
|
| 86 |
+
exact copy. The resulting work is called a "modified version" of the
|
| 87 |
+
earlier work or a work "based on" the earlier work.
|
| 88 |
+
|
| 89 |
+
A "covered work" means either the unmodified Program or a work based
|
| 90 |
+
on the Program.
|
| 91 |
+
|
| 92 |
+
To "propagate" a work means to do anything with it that, without
|
| 93 |
+
permission, would make you directly or secondarily liable for
|
| 94 |
+
infringement under applicable copyright law, except executing it on a
|
| 95 |
+
computer or modifying a private copy. Propagation includes copying,
|
| 96 |
+
distribution (with or without modification), making available to the
|
| 97 |
+
public, and in some countries other activities as well.
|
| 98 |
+
|
| 99 |
+
To "convey" a work means any kind of propagation that enables other
|
| 100 |
+
parties to make or receive copies. Mere interaction with a user through
|
| 101 |
+
a computer network, with no transfer of a copy, is not conveying.
|
| 102 |
+
|
| 103 |
+
An interactive user interface displays "Appropriate Legal Notices"
|
| 104 |
+
to the extent that it includes a convenient and prominently visible
|
| 105 |
+
feature that (1) displays an appropriate copyright notice, and (2)
|
| 106 |
+
tells the user that there is no warranty for the work (except to the
|
| 107 |
+
extent that warranties are provided), that licensees may convey the
|
| 108 |
+
work under this License, and how to view a copy of this License. If
|
| 109 |
+
the interface presents a list of user commands or options, such as a
|
| 110 |
+
menu, a prominent item in the list meets this criterion.
|
| 111 |
+
|
| 112 |
+
1. Source Code.
|
| 113 |
+
|
| 114 |
+
The "source code" for a work means the preferred form of the work
|
| 115 |
+
for making modifications to it. "Object code" means any non-source
|
| 116 |
+
form of a work.
|
| 117 |
+
|
| 118 |
+
A "Standard Interface" means an interface that either is an official
|
| 119 |
+
standard defined by a recognized standards body, or, in the case of
|
| 120 |
+
interfaces specified for a particular programming language, one that
|
| 121 |
+
is widely used among developers working in that language.
|
| 122 |
+
|
| 123 |
+
The "System Libraries" of an executable work include anything, other
|
| 124 |
+
than the work as a whole, that (a) is included in the normal form of
|
| 125 |
+
packaging a Major Component, but which is not part of that Major
|
| 126 |
+
Component, and (b) serves only to enable use of the work with that
|
| 127 |
+
Major Component, or to implement a Standard Interface for which an
|
| 128 |
+
implementation is available to the public in source code form. A
|
| 129 |
+
"Major Component", in this context, means a major essential component
|
| 130 |
+
(kernel, window system, and so on) of the specific operating system
|
| 131 |
+
(if any) on which the executable work runs, or a compiler used to
|
| 132 |
+
produce the work, or an object code interpreter used to run it.
|
| 133 |
+
|
| 134 |
+
The "Corresponding Source" for a work in object code form means all
|
| 135 |
+
the source code needed to generate, install, and (for an executable
|
| 136 |
+
work) run the object code and to modify the work, including scripts to
|
| 137 |
+
control those activities. However, it does not include the work's
|
| 138 |
+
System Libraries, or general-purpose tools or generally available free
|
| 139 |
+
programs which are used unmodified in performing those activities but
|
| 140 |
+
which are not part of the work. For example, Corresponding Source
|
| 141 |
+
includes interface definition files associated with source files for
|
| 142 |
+
the work, and the source code for shared libraries and dynamically
|
| 143 |
+
linked subprograms that the work is specifically designed to require,
|
| 144 |
+
such as by intimate data communication or control flow between those
|
| 145 |
+
subprograms and other parts of the work.
|
| 146 |
+
|
| 147 |
+
The Corresponding Source need not include anything that users
|
| 148 |
+
can regenerate automatically from other parts of the Corresponding
|
| 149 |
+
Source.
|
| 150 |
+
|
| 151 |
+
The Corresponding Source for a work in source code form is that
|
| 152 |
+
same work.
|
| 153 |
+
|
| 154 |
+
2. Basic Permissions.
|
| 155 |
+
|
| 156 |
+
All rights granted under this License are granted for the term of
|
| 157 |
+
copyright on the Program, and are irrevocable provided the stated
|
| 158 |
+
conditions are met. This License explicitly affirms your unlimited
|
| 159 |
+
permission to run the unmodified Program. The output from running a
|
| 160 |
+
covered work is covered by this License only if the output, given its
|
| 161 |
+
content, constitutes a covered work. This License acknowledges your
|
| 162 |
+
rights of fair use or other equivalent, as provided by copyright law.
|
| 163 |
+
|
| 164 |
+
You may make, run and propagate covered works that you do not
|
| 165 |
+
convey, without conditions so long as your license otherwise remains
|
| 166 |
+
in force. You may convey covered works to others for the sole purpose
|
| 167 |
+
of having them make modifications exclusively for you, or provide you
|
| 168 |
+
with facilities for running those works, provided that you comply with
|
| 169 |
+
the terms of this License in conveying all material for which you do
|
| 170 |
+
not control copyright. Those thus making or running the covered works
|
| 171 |
+
for you must do so exclusively on your behalf, under your direction
|
| 172 |
+
and control, on terms that prohibit them from making any copies of
|
| 173 |
+
your copyrighted material outside their relationship with you.
|
| 174 |
+
|
| 175 |
+
Conveying under any other circumstances is permitted solely under
|
| 176 |
+
the conditions stated below. Sublicensing is not allowed; section 10
|
| 177 |
+
makes it unnecessary.
|
| 178 |
+
|
| 179 |
+
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
| 180 |
+
|
| 181 |
+
No covered work shall be deemed part of an effective technological
|
| 182 |
+
measure under any applicable law fulfilling obligations under article
|
| 183 |
+
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
| 184 |
+
similar laws prohibiting or restricting circumvention of such
|
| 185 |
+
measures.
|
| 186 |
+
|
| 187 |
+
When you convey a covered work, you waive any legal power to forbid
|
| 188 |
+
circumvention of technological measures to the extent such circumvention
|
| 189 |
+
is effected by exercising rights under this License with respect to
|
| 190 |
+
the covered work, and you disclaim any intention to limit operation or
|
| 191 |
+
modification of the work as a means of enforcing, against the work's
|
| 192 |
+
users, your or third parties' legal rights to forbid circumvention of
|
| 193 |
+
technological measures.
|
| 194 |
+
|
| 195 |
+
4. Conveying Verbatim Copies.
|
| 196 |
+
|
| 197 |
+
You may convey verbatim copies of the Program's source code as you
|
| 198 |
+
receive it, in any medium, provided that you conspicuously and
|
| 199 |
+
appropriately publish on each copy an appropriate copyright notice;
|
| 200 |
+
keep intact all notices stating that this License and any
|
| 201 |
+
non-permissive terms added in accord with section 7 apply to the code;
|
| 202 |
+
keep intact all notices of the absence of any warranty; and give all
|
| 203 |
+
recipients a copy of this License along with the Program.
|
| 204 |
+
|
| 205 |
+
You may charge any price or no price for each copy that you convey,
|
| 206 |
+
and you may offer support or warranty protection for a fee.
|
| 207 |
+
|
| 208 |
+
5. Conveying Modified Source Versions.
|
| 209 |
+
|
| 210 |
+
You may convey a work based on the Program, or the modifications to
|
| 211 |
+
produce it from the Program, in the form of source code under the
|
| 212 |
+
terms of section 4, provided that you also meet all of these conditions:
|
| 213 |
+
|
| 214 |
+
a) The work must carry prominent notices stating that you modified
|
| 215 |
+
it, and giving a relevant date.
|
| 216 |
+
|
| 217 |
+
b) The work must carry prominent notices stating that it is
|
| 218 |
+
released under this License and any conditions added under section
|
| 219 |
+
7. This requirement modifies the requirement in section 4 to
|
| 220 |
+
"keep intact all notices".
|
| 221 |
+
|
| 222 |
+
c) You must license the entire work, as a whole, under this
|
| 223 |
+
License to anyone who comes into possession of a copy. This
|
| 224 |
+
License will therefore apply, along with any applicable section 7
|
| 225 |
+
additional terms, to the whole of the work, and all its parts,
|
| 226 |
+
regardless of how they are packaged. This License gives no
|
| 227 |
+
permission to license the work in any other way, but it does not
|
| 228 |
+
invalidate such permission if you have separately received it.
|
| 229 |
+
|
| 230 |
+
d) If the work has interactive user interfaces, each must display
|
| 231 |
+
Appropriate Legal Notices; however, if the Program has interactive
|
| 232 |
+
interfaces that do not display Appropriate Legal Notices, your
|
| 233 |
+
work need not make them do so.
|
| 234 |
+
|
| 235 |
+
A compilation of a covered work with other separate and independent
|
| 236 |
+
works, which are not by their nature extensions of the covered work,
|
| 237 |
+
and which are not combined with it such as to form a larger program,
|
| 238 |
+
in or on a volume of a storage or distribution medium, is called an
|
| 239 |
+
"aggregate" if the compilation and its resulting copyright are not
|
| 240 |
+
used to limit the access or legal rights of the compilation's users
|
| 241 |
+
beyond what the individual works permit. Inclusion of a covered work
|
| 242 |
+
in an aggregate does not cause this License to apply to the other
|
| 243 |
+
parts of the aggregate.
|
| 244 |
+
|
| 245 |
+
6. Conveying Non-Source Forms.
|
| 246 |
+
|
| 247 |
+
You may convey a covered work in object code form under the terms
|
| 248 |
+
of sections 4 and 5, provided that you also convey the
|
| 249 |
+
machine-readable Corresponding Source under the terms of this License,
|
| 250 |
+
in one of these ways:
|
| 251 |
+
|
| 252 |
+
a) Convey the object code in, or embodied in, a physical product
|
| 253 |
+
(including a physical distribution medium), accompanied by the
|
| 254 |
+
Corresponding Source fixed on a durable physical medium
|
| 255 |
+
customarily used for software interchange.
|
| 256 |
+
|
| 257 |
+
b) Convey the object code in, or embodied in, a physical product
|
| 258 |
+
(including a physical distribution medium), accompanied by a
|
| 259 |
+
written offer, valid for at least three years and valid for as
|
| 260 |
+
long as you offer spare parts or customer support for that product
|
| 261 |
+
model, to give anyone who possesses the object code either (1) a
|
| 262 |
+
copy of the Corresponding Source for all the software in the
|
| 263 |
+
product that is covered by this License, on a durable physical
|
| 264 |
+
medium customarily used for software interchange, for a price no
|
| 265 |
+
more than your reasonable cost of physically performing this
|
| 266 |
+
conveying of source, or (2) access to copy the
|
| 267 |
+
Corresponding Source from a network server at no charge.
|
| 268 |
+
|
| 269 |
+
c) Convey individual copies of the object code with a copy of the
|
| 270 |
+
written offer to provide the Corresponding Source. This
|
| 271 |
+
alternative is allowed only occasionally and noncommercially, and
|
| 272 |
+
only if you received the object code with such an offer, in accord
|
| 273 |
+
with subsection 6b.
|
| 274 |
+
|
| 275 |
+
d) Convey the object code by offering access from a designated
|
| 276 |
+
place (gratis or for a charge), and offer equivalent access to the
|
| 277 |
+
Corresponding Source in the same way through the same place at no
|
| 278 |
+
further charge. You need not require recipients to copy the
|
| 279 |
+
Corresponding Source along with the object code. If the place to
|
| 280 |
+
copy the object code is a network server, the Corresponding Source
|
| 281 |
+
may be on a different server (operated by you or a third party)
|
| 282 |
+
that supports equivalent copying facilities, provided you maintain
|
| 283 |
+
clear directions next to the object code saying where to find the
|
| 284 |
+
Corresponding Source. Regardless of what server hosts the
|
| 285 |
+
Corresponding Source, you remain obligated to ensure that it is
|
| 286 |
+
available for as long as needed to satisfy these requirements.
|
| 287 |
+
|
| 288 |
+
e) Convey the object code using peer-to-peer transmission, provided
|
| 289 |
+
you inform other peers where the object code and Corresponding
|
| 290 |
+
Source of the work are being offered to the general public at no
|
| 291 |
+
charge under subsection 6d.
|
| 292 |
+
|
| 293 |
+
A separable portion of the object code, whose source code is excluded
|
| 294 |
+
from the Corresponding Source as a System Library, need not be
|
| 295 |
+
included in conveying the object code work.
|
| 296 |
+
|
| 297 |
+
A "User Product" is either (1) a "consumer product", which means any
|
| 298 |
+
tangible personal property which is normally used for personal, family,
|
| 299 |
+
or household purposes, or (2) anything designed or sold for incorporation
|
| 300 |
+
into a dwelling. In determining whether a product is a consumer product,
|
| 301 |
+
doubtful cases shall be resolved in favor of coverage. For a particular
|
| 302 |
+
product received by a particular user, "normally used" refers to a
|
| 303 |
+
typical or common use of that class of product, regardless of the status
|
| 304 |
+
of the particular user or of the way in which the particular user
|
| 305 |
+
actually uses, or expects or is expected to use, the product. A product
|
| 306 |
+
is a consumer product regardless of whether the product has substantial
|
| 307 |
+
commercial, industrial or non-consumer uses, unless such uses represent
|
| 308 |
+
the only significant mode of use of the product.
|
| 309 |
+
|
| 310 |
+
"Installation Information" for a User Product means any methods,
|
| 311 |
+
procedures, authorization keys, or other information required to install
|
| 312 |
+
and execute modified versions of a covered work in that User Product from
|
| 313 |
+
a modified version of its Corresponding Source. The information must
|
| 314 |
+
suffice to ensure that the continued functioning of the modified object
|
| 315 |
+
code is in no case prevented or interfered with solely because
|
| 316 |
+
modification has been made.
|
| 317 |
+
|
| 318 |
+
If you convey an object code work under this section in, or with, or
|
| 319 |
+
specifically for use in, a User Product, and the conveying occurs as
|
| 320 |
+
part of a transaction in which the right of possession and use of the
|
| 321 |
+
User Product is transferred to the recipient in perpetuity or for a
|
| 322 |
+
fixed term (regardless of how the transaction is characterized), the
|
| 323 |
+
Corresponding Source conveyed under this section must be accompanied
|
| 324 |
+
by the Installation Information. But this requirement does not apply
|
| 325 |
+
if neither you nor any third party retains the ability to install
|
| 326 |
+
modified object code on the User Product (for example, the work has
|
| 327 |
+
been installed in ROM).
|
| 328 |
+
|
| 329 |
+
The requirement to provide Installation Information does not include a
|
| 330 |
+
requirement to continue to provide support service, warranty, or updates
|
| 331 |
+
for a work that has been modified or installed by the recipient, or for
|
| 332 |
+
the User Product in which it has been modified or installed. Access to a
|
| 333 |
+
network may be denied when the modification itself materially and
|
| 334 |
+
adversely affects the operation of the network or violates the rules and
|
| 335 |
+
protocols for communication across the network.
|
| 336 |
+
|
| 337 |
+
Corresponding Source conveyed, and Installation Information provided,
|
| 338 |
+
in accord with this section must be in a format that is publicly
|
| 339 |
+
documented (and with an implementation available to the public in
|
| 340 |
+
source code form), and must require no special password or key for
|
| 341 |
+
unpacking, reading or copying.
|
| 342 |
+
|
| 343 |
+
7. Additional Terms.
|
| 344 |
+
|
| 345 |
+
"Additional permissions" are terms that supplement the terms of this
|
| 346 |
+
License by making exceptions from one or more of its conditions.
|
| 347 |
+
Additional permissions that are applicable to the entire Program shall
|
| 348 |
+
be treated as though they were included in this License, to the extent
|
| 349 |
+
that they are valid under applicable law. If additional permissions
|
| 350 |
+
apply only to part of the Program, that part may be used separately
|
| 351 |
+
under those permissions, but the entire Program remains governed by
|
| 352 |
+
this License without regard to the additional permissions.
|
| 353 |
+
|
| 354 |
+
When you convey a copy of a covered work, you may at your option
|
| 355 |
+
remove any additional permissions from that copy, or from any part of
|
| 356 |
+
it. (Additional permissions may be written to require their own
|
| 357 |
+
removal in certain cases when you modify the work.) You may place
|
| 358 |
+
additional permissions on material, added by you to a covered work,
|
| 359 |
+
for which you have or can give appropriate copyright permission.
|
| 360 |
+
|
| 361 |
+
Notwithstanding any other provision of this License, for material you
|
| 362 |
+
add to a covered work, you may (if authorized by the copyright holders of
|
| 363 |
+
that material) supplement the terms of this License with terms:
|
| 364 |
+
|
| 365 |
+
a) Disclaiming warranty or limiting liability differently from the
|
| 366 |
+
terms of sections 15 and 16 of this License; or
|
| 367 |
+
|
| 368 |
+
b) Requiring preservation of specified reasonable legal notices or
|
| 369 |
+
author attributions in that material or in the Appropriate Legal
|
| 370 |
+
Notices displayed by works containing it; or
|
| 371 |
+
|
| 372 |
+
c) Prohibiting misrepresentation of the origin of that material, or
|
| 373 |
+
requiring that modified versions of such material be marked in
|
| 374 |
+
reasonable ways as different from the original version; or
|
| 375 |
+
|
| 376 |
+
d) Limiting the use for publicity purposes of names of licensors or
|
| 377 |
+
authors of the material; or
|
| 378 |
+
|
| 379 |
+
e) Declining to grant rights under trademark law for use of some
|
| 380 |
+
trade names, trademarks, or service marks; or
|
| 381 |
+
|
| 382 |
+
f) Requiring indemnification of licensors and authors of that
|
| 383 |
+
material by anyone who conveys the material (or modified versions of
|
| 384 |
+
it) with contractual assumptions of liability to the recipient, for
|
| 385 |
+
any liability that these contractual assumptions directly impose on
|
| 386 |
+
those licensors and authors.
|
| 387 |
+
|
| 388 |
+
All other non-permissive additional terms are considered "further
|
| 389 |
+
restrictions" within the meaning of section 10. If the Program as you
|
| 390 |
+
received it, or any part of it, contains a notice stating that it is
|
| 391 |
+
governed by this License along with a term that is a further
|
| 392 |
+
restriction, you may remove that term. If a license document contains
|
| 393 |
+
a further restriction but permits relicensing or conveying under this
|
| 394 |
+
License, you may add to a covered work material governed by the terms
|
| 395 |
+
of that license document, provided that the further restriction does
|
| 396 |
+
not survive such relicensing or conveying.
|
| 397 |
+
|
| 398 |
+
If you add terms to a covered work in accord with this section, you
|
| 399 |
+
must place, in the relevant source files, a statement of the
|
| 400 |
+
additional terms that apply to those files, or a notice indicating
|
| 401 |
+
where to find the applicable terms.
|
| 402 |
+
|
| 403 |
+
Additional terms, permissive or non-permissive, may be stated in the
|
| 404 |
+
form of a separately written license, or stated as exceptions;
|
| 405 |
+
the above requirements apply either way.
|
| 406 |
+
|
| 407 |
+
8. Termination.
|
| 408 |
+
|
| 409 |
+
You may not propagate or modify a covered work except as expressly
|
| 410 |
+
provided under this License. Any attempt otherwise to propagate or
|
| 411 |
+
modify it is void, and will automatically terminate your rights under
|
| 412 |
+
this License (including any patent licenses granted under the third
|
| 413 |
+
paragraph of section 11).
|
| 414 |
+
|
| 415 |
+
However, if you cease all violation of this License, then your
|
| 416 |
+
license from a particular copyright holder is reinstated (a)
|
| 417 |
+
provisionally, unless and until the copyright holder explicitly and
|
| 418 |
+
finally terminates your license, and (b) permanently, if the copyright
|
| 419 |
+
holder fails to notify you of the violation by some reasonable means
|
| 420 |
+
prior to 60 days after the cessation.
|
| 421 |
+
|
| 422 |
+
Moreover, your license from a particular copyright holder is
|
| 423 |
+
reinstated permanently if the copyright holder notifies you of the
|
| 424 |
+
violation by some reasonable means, this is the first time you have
|
| 425 |
+
received notice of violation of this License (for any work) from that
|
| 426 |
+
copyright holder, and you cure the violation prior to 30 days after
|
| 427 |
+
your receipt of the notice.
|
| 428 |
+
|
| 429 |
+
Termination of your rights under this section does not terminate the
|
| 430 |
+
licenses of parties who have received copies or rights from you under
|
| 431 |
+
this License. If your rights have been terminated and not permanently
|
| 432 |
+
reinstated, you do not qualify to receive new licenses for the same
|
| 433 |
+
material under section 10.
|
| 434 |
+
|
| 435 |
+
9. Acceptance Not Required for Having Copies.
|
| 436 |
+
|
| 437 |
+
You are not required to accept this License in order to receive or
|
| 438 |
+
run a copy of the Program. Ancillary propagation of a covered work
|
| 439 |
+
occurring solely as a consequence of using peer-to-peer transmission
|
| 440 |
+
to receive a copy likewise does not require acceptance. However,
|
| 441 |
+
nothing other than this License grants you permission to propagate or
|
| 442 |
+
modify any covered work. These actions infringe copyright if you do
|
| 443 |
+
not accept this License. Therefore, by modifying or propagating a
|
| 444 |
+
covered work, you indicate your acceptance of this License to do so.
|
| 445 |
+
|
| 446 |
+
10. Automatic Licensing of Downstream Recipients.
|
| 447 |
+
|
| 448 |
+
Each time you convey a covered work, the recipient automatically
|
| 449 |
+
receives a license from the original licensors, to run, modify and
|
| 450 |
+
propagate that work, subject to this License. You are not responsible
|
| 451 |
+
for enforcing compliance by third parties with this License.
|
| 452 |
+
|
| 453 |
+
An "entity transaction" is a transaction transferring control of an
|
| 454 |
+
organization, or substantially all assets of one, or subdividing an
|
| 455 |
+
organization, or merging organizations. If propagation of a covered
|
| 456 |
+
work results from an entity transaction, each party to that
|
| 457 |
+
transaction who receives a copy of the work also receives whatever
|
| 458 |
+
licenses to the work the party's predecessor in interest had or could
|
| 459 |
+
give under the previous paragraph, plus a right to possession of the
|
| 460 |
+
Corresponding Source of the work from the predecessor in interest, if
|
| 461 |
+
the predecessor has it or can get it with reasonable efforts.
|
| 462 |
+
|
| 463 |
+
You may not impose any further restrictions on the exercise of the
|
| 464 |
+
rights granted or affirmed under this License. For example, you may
|
| 465 |
+
not impose a license fee, royalty, or other charge for exercise of
|
| 466 |
+
rights granted under this License, and you may not initiate litigation
|
| 467 |
+
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
| 468 |
+
any patent claim is infringed by making, using, selling, offering for
|
| 469 |
+
sale, or importing the Program or any portion of it.
|
| 470 |
+
|
| 471 |
+
11. Patents.
|
| 472 |
+
|
| 473 |
+
A "contributor" is a copyright holder who authorizes use under this
|
| 474 |
+
License of the Program or a work on which the Program is based. The
|
| 475 |
+
work thus licensed is called the contributor's "contributor version".
|
| 476 |
+
|
| 477 |
+
A contributor's "essential patent claims" are all patent claims
|
| 478 |
+
owned or controlled by the contributor, whether already acquired or
|
| 479 |
+
hereafter acquired, that would be infringed by some manner, permitted
|
| 480 |
+
by this License, of making, using, or selling its contributor version,
|
| 481 |
+
but do not include claims that would be infringed only as a
|
| 482 |
+
consequence of further modification of the contributor version. For
|
| 483 |
+
purposes of this definition, "control" includes the right to grant
|
| 484 |
+
patent sublicenses in a manner consistent with the requirements of
|
| 485 |
+
this License.
|
| 486 |
+
|
| 487 |
+
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
| 488 |
+
patent license under the contributor's essential patent claims, to
|
| 489 |
+
make, use, sell, offer for sale, import and otherwise run, modify and
|
| 490 |
+
propagate the contents of its contributor version.
|
| 491 |
+
|
| 492 |
+
In the following three paragraphs, a "patent license" is any express
|
| 493 |
+
agreement or commitment, however denominated, not to enforce a patent
|
| 494 |
+
(such as an express permission to practice a patent or covenant not to
|
| 495 |
+
sue for patent infringement). To "grant" such a patent license to a
|
| 496 |
+
party means to make such an agreement or commitment not to enforce a
|
| 497 |
+
patent against the party.
|
| 498 |
+
|
| 499 |
+
If you convey a covered work, knowingly relying on a patent license,
|
| 500 |
+
and the Corresponding Source of the work is not available for anyone
|
| 501 |
+
to copy, free of charge and under the terms of this License, through a
|
| 502 |
+
publicly available network server or other readily accessible means,
|
| 503 |
+
then you must either (1) cause the Corresponding Source to be so
|
| 504 |
+
available, or (2) arrange to deprive yourself of the benefit of the
|
| 505 |
+
patent license for this particular work, or (3) arrange, in a manner
|
| 506 |
+
consistent with the requirements of this License, to extend the patent
|
| 507 |
+
license to downstream recipients. "Knowingly relying" means you have
|
| 508 |
+
actual knowledge that, but for the patent license, your conveying the
|
| 509 |
+
covered work in a country, or your recipient's use of the covered work
|
| 510 |
+
in a country, would infringe one or more identifiable patents in that
|
| 511 |
+
country that you have reason to believe are valid.
|
| 512 |
+
|
| 513 |
+
If, pursuant to or in connection with a single transaction or
|
| 514 |
+
arrangement, you convey, or propagate by procuring conveyance of, a
|
| 515 |
+
covered work, and grant a patent license to some of the parties
|
| 516 |
+
receiving the covered work authorizing them to use, propagate, modify
|
| 517 |
+
or convey a specific copy of the covered work, then the patent license
|
| 518 |
+
you grant is automatically extended to all recipients of the covered
|
| 519 |
+
work and works based on it.
|
| 520 |
+
|
| 521 |
+
A patent license is "discriminatory" if it does not include within
|
| 522 |
+
the scope of its coverage, prohibits the exercise of, or is
|
| 523 |
+
conditioned on the non-exercise of one or more of the rights that are
|
| 524 |
+
specifically granted under this License. You may not convey a covered
|
| 525 |
+
work if you are a party to an arrangement with a third party that is
|
| 526 |
+
in the business of distributing software, under which you make payment
|
| 527 |
+
to the third party based on the extent of your activity of conveying
|
| 528 |
+
the work, and under which the third party grants, to any of the
|
| 529 |
+
parties who would receive the covered work from you, a discriminatory
|
| 530 |
+
patent license (a) in connection with copies of the covered work
|
| 531 |
+
conveyed by you (or copies made from those copies), or (b) primarily
|
| 532 |
+
for and in connection with specific products or compilations that
|
| 533 |
+
contain the covered work, unless you entered into that arrangement,
|
| 534 |
+
or that patent license was granted, prior to 28 March 2007.
|
| 535 |
+
|
| 536 |
+
Nothing in this License shall be construed as excluding or limiting
|
| 537 |
+
any implied license or other defenses to infringement that may
|
| 538 |
+
otherwise be available to you under applicable patent law.
|
| 539 |
+
|
| 540 |
+
12. No Surrender of Others' Freedom.
|
| 541 |
+
|
| 542 |
+
If conditions are imposed on you (whether by court order, agreement or
|
| 543 |
+
otherwise) that contradict the conditions of this License, they do not
|
| 544 |
+
excuse you from the conditions of this License. If you cannot convey a
|
| 545 |
+
covered work so as to satisfy simultaneously your obligations under this
|
| 546 |
+
License and any other pertinent obligations, then as a consequence you may
|
| 547 |
+
not convey it at all. For example, if you agree to terms that obligate you
|
| 548 |
+
to collect a royalty for further conveying from those to whom you convey
|
| 549 |
+
the Program, the only way you could satisfy both those terms and this
|
| 550 |
+
License would be to refrain entirely from conveying the Program.
|
| 551 |
+
|
| 552 |
+
13. Use with the GNU Affero General Public License.
|
| 553 |
+
|
| 554 |
+
Notwithstanding any other provision of this License, you have
|
| 555 |
+
permission to link or combine any covered work with a work licensed
|
| 556 |
+
under version 3 of the GNU Affero General Public License into a single
|
| 557 |
+
combined work, and to convey the resulting work. The terms of this
|
| 558 |
+
License will continue to apply to the part which is the covered work,
|
| 559 |
+
but the special requirements of the GNU Affero General Public License,
|
| 560 |
+
section 13, concerning interaction through a network will apply to the
|
| 561 |
+
combination as such.
|
| 562 |
+
|
| 563 |
+
14. Revised Versions of this License.
|
| 564 |
+
|
| 565 |
+
The Free Software Foundation may publish revised and/or new versions of
|
| 566 |
+
the GNU General Public License from time to time. Such new versions will
|
| 567 |
+
be similar in spirit to the present version, but may differ in detail to
|
| 568 |
+
address new problems or concerns.
|
| 569 |
+
|
| 570 |
+
Each version is given a distinguishing version number. If the
|
| 571 |
+
Program specifies that a certain numbered version of the GNU General
|
| 572 |
+
Public License "or any later version" applies to it, you have the
|
| 573 |
+
option of following the terms and conditions either of that numbered
|
| 574 |
+
version or of any later version published by the Free Software
|
| 575 |
+
Foundation. If the Program does not specify a version number of the
|
| 576 |
+
GNU General Public License, you may choose any version ever published
|
| 577 |
+
by the Free Software Foundation.
|
| 578 |
+
|
| 579 |
+
If the Program specifies that a proxy can decide which future
|
| 580 |
+
versions of the GNU General Public License can be used, that proxy's
|
| 581 |
+
public statement of acceptance of a version permanently authorizes you
|
| 582 |
+
to choose that version for the Program.
|
| 583 |
+
|
| 584 |
+
Later license versions may give you additional or different
|
| 585 |
+
permissions. However, no additional obligations are imposed on any
|
| 586 |
+
author or copyright holder as a result of your choosing to follow a
|
| 587 |
+
later version.
|
| 588 |
+
|
| 589 |
+
15. Disclaimer of Warranty.
|
| 590 |
+
|
| 591 |
+
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
| 592 |
+
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
| 593 |
+
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
| 594 |
+
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
| 595 |
+
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
| 596 |
+
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
| 597 |
+
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
| 598 |
+
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
| 599 |
+
|
| 600 |
+
16. Limitation of Liability.
|
| 601 |
+
|
| 602 |
+
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
| 603 |
+
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
| 604 |
+
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
| 605 |
+
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
| 606 |
+
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
| 607 |
+
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
| 608 |
+
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
| 609 |
+
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
| 610 |
+
SUCH DAMAGES.
|
| 611 |
+
|
| 612 |
+
17. Interpretation of Sections 15 and 16.
|
| 613 |
+
|
| 614 |
+
If the disclaimer of warranty and limitation of liability provided
|
| 615 |
+
above cannot be given local legal effect according to their terms,
|
| 616 |
+
reviewing courts shall apply local law that most closely approximates
|
| 617 |
+
an absolute waiver of all civil liability in connection with the
|
| 618 |
+
Program, unless a warranty or assumption of liability accompanies a
|
| 619 |
+
copy of the Program in return for a fee.
|
| 620 |
+
|
| 621 |
+
END OF TERMS AND CONDITIONS
|
| 622 |
+
|
| 623 |
+
How to Apply These Terms to Your New Programs
|
| 624 |
+
|
| 625 |
+
If you develop a new program, and you want it to be of the greatest
|
| 626 |
+
possible use to the public, the best way to achieve this is to make it
|
| 627 |
+
free software which everyone can redistribute and change under these terms.
|
| 628 |
+
|
| 629 |
+
To do so, attach the following notices to the program. It is safest
|
| 630 |
+
to attach them to the start of each source file to most effectively
|
| 631 |
+
state the exclusion of warranty; and each file should have at least
|
| 632 |
+
the "copyright" line and a pointer to where the full notice is found.
|
| 633 |
+
|
| 634 |
+
<one line to give the program's name and a brief idea of what it does.>
|
| 635 |
+
Copyright (C) <year> <name of author>
|
| 636 |
+
|
| 637 |
+
This program is free software: you can redistribute it and/or modify
|
| 638 |
+
it under the terms of the GNU General Public License as published by
|
| 639 |
+
the Free Software Foundation, either version 3 of the License, or
|
| 640 |
+
(at your option) any later version.
|
| 641 |
+
|
| 642 |
+
This program is distributed in the hope that it will be useful,
|
| 643 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 644 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
| 645 |
+
GNU General Public License for more details.
|
| 646 |
+
|
| 647 |
+
You should have received a copy of the GNU General Public License
|
| 648 |
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
| 649 |
+
|
| 650 |
+
Also add information on how to contact you by electronic and paper mail.
|
| 651 |
+
|
| 652 |
+
If the program does terminal interaction, make it output a short
|
| 653 |
+
notice like this when it starts in an interactive mode:
|
| 654 |
+
|
| 655 |
+
<program> Copyright (C) <year> <name of author>
|
| 656 |
+
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
| 657 |
+
This is free software, and you are welcome to redistribute it
|
| 658 |
+
under certain conditions; type `show c' for details.
|
| 659 |
+
|
| 660 |
+
The hypothetical commands `show w' and `show c' should show the appropriate
|
| 661 |
+
parts of the General Public License. Of course, your program's commands
|
| 662 |
+
might be different; for a GUI interface, you would use an "about box".
|
| 663 |
+
|
| 664 |
+
You should also get your employer (if you work as a programmer) or school,
|
| 665 |
+
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
| 666 |
+
For more information on this, and how to apply and follow the GNU GPL, see
|
| 667 |
+
<https://www.gnu.org/licenses/>.
|
| 668 |
+
|
| 669 |
+
The GNU General Public License does not permit incorporating your program
|
| 670 |
+
into proprietary programs. If your program is a subroutine library, you
|
| 671 |
+
may consider it more useful to permit linking proprietary applications with
|
| 672 |
+
the library. If this is what you want to do, use the GNU Lesser General
|
| 673 |
+
Public License instead of this License. But first, please read
|
| 674 |
+
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
README.md
CHANGED
|
@@ -1,11 +1,195 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<p align="right">
|
| 2 |
+
<strong>中文</strong>
|
| 3 |
+
</p>
|
| 4 |
+
|
| 5 |
+
<div align="center">
|
| 6 |
+
|
| 7 |
+
# Genspark2API
|
| 8 |
+
|
| 9 |
+
_觉得有点意思的话 别忘了点个🌟_
|
| 10 |
+
|
| 11 |
+
</div>
|
| 12 |
+
|
| 13 |
+
## 功能
|
| 14 |
+
|
| 15 |
+
- [x] 支持对话接口(流式/非流式)(`/chat/completions`)(请求非以下列表的模型会触发`Mixture-of-Agents`模式)
|
| 16 |
+
- **gpt-4o**
|
| 17 |
+
- **gpt-4o-mini**
|
| 18 |
+
- **o1-preview**
|
| 19 |
+
- **claude-3-5-sonnet**
|
| 20 |
+
- **claude-3-5-haiku**
|
| 21 |
+
- **gemini-1.5-pro**
|
| 22 |
+
- **gemini-1.5-flash**
|
| 23 |
+
- [x] 支持识别**图片**/**文件**多轮对话
|
| 24 |
+
- [x] 支持文生图接口(`/images/generations`)
|
| 25 |
+
- **flux**
|
| 26 |
+
- **flux-speed**
|
| 27 |
+
- **flux-pro/ultra**
|
| 28 |
+
- **ideogram**
|
| 29 |
+
- **recraft-v3**
|
| 30 |
+
- **dall-e-3**
|
| 31 |
+
- [x] 支持自定义请求头校验值(Authorization)
|
| 32 |
+
- [x] 支持cookie池(随机)
|
| 33 |
+
- [x] 可配置自动删除对话记录
|
| 34 |
+
- [x] 可配置代理请求(环境变量`PROXY_URL`)
|
| 35 |
+
- [x] 可配置Model绑定Chat(解决模型自动切换导致**降智**),详细请看[进阶配置](#进阶配置)。
|
| 36 |
+
|
| 37 |
+
### 接口文档:
|
| 38 |
+
|
| 39 |
+
略
|
| 40 |
+
|
| 41 |
+
### 示例:
|
| 42 |
+
|
| 43 |
+
<span><img src="docs/img2.png" width="800"/></span>
|
| 44 |
+
|
| 45 |
+
## 如何使用
|
| 46 |
+
|
| 47 |
+
略
|
| 48 |
+
|
| 49 |
+
## 如何集成NextChat
|
| 50 |
+
|
| 51 |
+
填 接口地址(ip:端口/域名) 及 API-Key(`PROXY_SECRET`),其它的随便填随便选。
|
| 52 |
+
|
| 53 |
+
> 如果自己没有搭建NextChat面板,这里有个已经搭建好的可以使用 [NeatChat](https://ai.aytsao.cn/)
|
| 54 |
+
|
| 55 |
+
<span><img src="docs/img5.png" width="800"/></span>
|
| 56 |
+
|
| 57 |
+
## 如何集成one-api
|
| 58 |
+
|
| 59 |
+
填 `BaseURL`(ip:端口/域名) 及 密钥(`PROXY_SECRET`),其它的随便填随便选。
|
| 60 |
+
|
| 61 |
+
<span><img src="docs/img3.png" width="800"/></span>
|
| 62 |
+
|
| 63 |
+
## 部署
|
| 64 |
+
|
| 65 |
+
### 基于 Docker-Compose(All In One) 进行部署
|
| 66 |
+
|
| 67 |
+
```shell
|
| 68 |
+
docker-compose pull && docker-compose up -d
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
#### docker-compose.yml
|
| 72 |
+
|
| 73 |
+
```docker
|
| 74 |
+
version: '3.4'
|
| 75 |
+
|
| 76 |
+
services:
|
| 77 |
+
genspark2api:
|
| 78 |
+
image: deanxv/genspark2api:latest
|
| 79 |
+
container_name: genspark2api
|
| 80 |
+
restart: always
|
| 81 |
+
ports:
|
| 82 |
+
- "7055:7055"
|
| 83 |
+
volumes:
|
| 84 |
+
- ./data:/app/genspark2api/data
|
| 85 |
+
environment:
|
| 86 |
+
- GS_COOKIE=****** # cookie (多个请以,分隔)
|
| 87 |
+
- API_SECRET=123456 # [可选]接口密钥-修改此行为请求头校验的值(多个请以,分隔)
|
| 88 |
+
- TZ=Asia/Shanghai
|
| 89 |
+
```
|
| 90 |
+
|
| 91 |
+
### 基于 Docker 进行部署
|
| 92 |
+
|
| 93 |
+
```docker
|
| 94 |
+
docker run --name genspark2api -d --restart always \
|
| 95 |
+
-p 7055:7055 \
|
| 96 |
+
-v $(pwd)/data:/app/genspark2api/data \
|
| 97 |
+
-e GS_COOKIE=***** \
|
| 98 |
+
-e API_SECRET="123456" \
|
| 99 |
+
-e TZ=Asia/Shanghai \
|
| 100 |
+
deanxv/genspark2api
|
| 101 |
+
```
|
| 102 |
+
|
| 103 |
+
其中`API_SECRET`、`GS_COOKIE`修改为自己的。
|
| 104 |
+
|
| 105 |
+
如果上面的镜像无法拉取,可以尝试使用 GitHub 的 Docker 镜像,将上面的`deanxv/genspark2api`替换为`ghcr.io/deanxv/genspark2api`即可。
|
| 106 |
+
|
| 107 |
+
### 部署到第三方平台
|
| 108 |
+
|
| 109 |
+
<details>
|
| 110 |
+
<summary><strong>部署到 Zeabur</strong></summary>
|
| 111 |
+
<div>
|
| 112 |
+
|
| 113 |
+
> Zeabur 的服务器在国外,自动解决了网络的问题,~~同时免费的额度也足够个人使用~~
|
| 114 |
+
|
| 115 |
+
1. 首先 **fork** 一份代码。
|
| 116 |
+
2. 进入 [Zeabur](https://zeabur.com?referralCode=deanxv),使用github登录,进入控制台。
|
| 117 |
+
3. 在 Service -> Add Service,选择 Git(第一次使用需要先授权),选择你 fork 的仓库。
|
| 118 |
+
4. Deploy 会自动开始,先取消。
|
| 119 |
+
5. 添加环境变量
|
| 120 |
+
|
| 121 |
+
`GS_COOKIE:******` cookie (多个请以,分隔)
|
| 122 |
+
|
| 123 |
+
`API_SECRET:123456` [可选]接口密钥-修改此行为请求头校验的值(多个请以,分隔)(与openai-API-KEY用法一致)
|
| 124 |
+
|
| 125 |
+
保存。
|
| 126 |
+
|
| 127 |
+
6. 选择 Redeploy。
|
| 128 |
+
|
| 129 |
+
</div>
|
| 130 |
+
|
| 131 |
+
|
| 132 |
+
</details>
|
| 133 |
+
|
| 134 |
+
<details>
|
| 135 |
+
<summary><strong>部署到 Render</strong></summary>
|
| 136 |
+
<div>
|
| 137 |
+
|
| 138 |
+
> Render 提供免费额度,绑卡后可以进一步提升额度
|
| 139 |
+
|
| 140 |
+
Render 可以直接部署 docker 镜像,不需要 fork 仓库:[Render](https://dashboard.render.com)
|
| 141 |
+
|
| 142 |
+
</div>
|
| 143 |
+
</details>
|
| 144 |
+
|
| 145 |
+
## 配置
|
| 146 |
+
|
| 147 |
+
### 环境变量
|
| 148 |
+
|
| 149 |
+
1. `PORT=7055` [可选]端口,默认为7055
|
| 150 |
+
2. `DEBUG=true` [可选]DEBUG模式,可打印更多信息[true:打开、false:关闭]
|
| 151 |
+
3. `API_SECRET=123456` [可选]接口密钥-修改此行为请求头(Authorization)校验的值(同API-KEY)(多个请以,分隔)
|
| 152 |
+
4. `GS_COOKIE=******` cookie (多个请以,分隔)
|
| 153 |
+
5. `AUTO_DEL_CHAT=0` [可选]对话完成自动删除[0:关闭,1:开启]
|
| 154 |
+
6. `REQUEST_RATE_LIMIT=60` [可选]每分钟下的单ip请求速率限制,默认:60次/min
|
| 155 |
+
7. `PROXY_URL=http://127.0.0.1:10801` [可选]代理
|
| 156 |
+
8. `MODEL_CHAT_MAP=claude-3-5-sonnet=a649******00fa,gpt-4o=su74******47hd` [可选]Model绑定Chat(多个请以,分隔),详细请看[进阶配置](#进阶配置)
|
| 157 |
+
|
| 158 |
+
### cookie获取方式
|
| 159 |
+
|
| 160 |
+
1. 打开**F12**开发者工具。
|
| 161 |
+
2. 发起对话。
|
| 162 |
+
3. 点击ask请求,请求头中的**cookie**即为环境变量**GS_COOKIE**所需值。
|
| 163 |
+
|
| 164 |
+
> **【注】** 其中`session_id=f9c60******cb6d`是必须的,其他内容可要可不要,即环境变量`GS_COOKIE=session_id=f9c60******cb6d`
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+

|
| 168 |
+
|
| 169 |
+
## 进阶配置
|
| 170 |
+
|
| 171 |
+
### 配置环境变量 MODEL_CHAT_MAP
|
| 172 |
+
|
| 173 |
+
> 【作用】指定对话,解决模型自动切换导致降智问题。
|
| 174 |
+
|
| 175 |
+
1. 打开**F12**开发者工具。
|
| 176 |
+
2. 选择需要绑定的对话的模型(示例:`claude-3-5-sonnet`),发起对话。
|
| 177 |
+
3. 点击ask请求,此时最上方url中的`id`(或响应中的`id`)即为此对话唯一id。
|
| 178 |
+

|
| 179 |
+
4. 配置环境变量 `MODEL_CHAT_MAP=claude-3-5-sonnet=3cdcc******474c5` (多个请以,分隔)
|
| 180 |
+
|
| 181 |
+
## 报错排查
|
| 182 |
+
|
| 183 |
+
> `Detected Cloudflare Challenge Page`
|
| 184 |
+
>
|
| 185 |
+
被Cloudflare拦截出5s盾,可配置`PROXY_URL`。([IProyal](https://iproyal.cn/?r=244330))
|
| 186 |
+
|
| 187 |
+
> `Cookie has reached the rate Limit`:
|
| 188 |
+
>
|
| 189 |
+
当前用户(cookie)到达速率限制,可降低并发。
|
| 190 |
+
|
| 191 |
+
|
| 192 |
+
## 其他
|
| 193 |
+
|
| 194 |
+
**Genspark**(
|
| 195 |
+
注册领取1个月Plus): [https://www.genspark.ai](https://www.genspark.ai/invite?invite_code=YjVjMGRkYWVMZmE4YUw5MDc0TDM1ODlMZDYwMzQ4OTJlNmEx)
|
common/config/config.go
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package config
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"genspark2api/common/env"
|
| 5 |
+
"os"
|
| 6 |
+
"strings"
|
| 7 |
+
"time"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
var ApiSecret = os.Getenv("API_SECRET")
|
| 11 |
+
var ApiSecrets = strings.Split(os.Getenv("API_SECRET"), ",")
|
| 12 |
+
var GSCookie = os.Getenv("GS_COOKIE")
|
| 13 |
+
var GSCookies = strings.Split(os.Getenv("GS_COOKIE"), ",")
|
| 14 |
+
var AutoDelChat = env.Int("AUTO_DEL_CHAT", 0)
|
| 15 |
+
var ProxyUrl = env.String("PROXY_URL", "")
|
| 16 |
+
var ModelChatMapStr = env.String("MODEL_CHAT_MAP", "")
|
| 17 |
+
var ModelChatMap = make(map[string]string)
|
| 18 |
+
|
| 19 |
+
var AllDialogRecordEnable = os.Getenv("ALL_DIALOG_RECORD_ENABLE")
|
| 20 |
+
var RequestOutTime = os.Getenv("REQUEST_OUT_TIME")
|
| 21 |
+
var StreamRequestOutTime = os.Getenv("STREAM_REQUEST_OUT_TIME")
|
| 22 |
+
var SwaggerEnable = os.Getenv("SWAGGER_ENABLE")
|
| 23 |
+
var OnlyOpenaiApi = os.Getenv("ONLY_OPENAI_API")
|
| 24 |
+
|
| 25 |
+
var DebugEnabled = os.Getenv("DEBUG") == "true"
|
| 26 |
+
|
| 27 |
+
var RateLimitKeyExpirationDuration = 20 * time.Minute
|
| 28 |
+
|
| 29 |
+
var RequestOutTimeDuration = 5 * time.Minute
|
| 30 |
+
|
| 31 |
+
var (
|
| 32 |
+
RequestRateLimitNum = env.Int("REQUEST_RATE_LIMIT", 60)
|
| 33 |
+
RequestRateLimitDuration int64 = 1 * 60
|
| 34 |
+
)
|
common/constants.go
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package common
|
| 2 |
+
|
| 3 |
+
import "time"
|
| 4 |
+
|
| 5 |
+
var StartTime = time.Now().Unix() // unit: second
|
| 6 |
+
var Version = "v1.5.4" // this hard coding will be replaced automatically when building, no need to manually change
|
| 7 |
+
|
| 8 |
+
var DefaultOpenaiModelList = []string{
|
| 9 |
+
"gpt-4o",
|
| 10 |
+
"gpt-4o-mini",
|
| 11 |
+
"o1-preview",
|
| 12 |
+
"claude-3-5-sonnet",
|
| 13 |
+
"claude-3-5-haiku",
|
| 14 |
+
"gemini-1.5-pro",
|
| 15 |
+
"gemini-1.5-flash",
|
| 16 |
+
|
| 17 |
+
"flux",
|
| 18 |
+
"flux-speed",
|
| 19 |
+
"flux-pro/ultra",
|
| 20 |
+
"ideogram",
|
| 21 |
+
"recraft-v3",
|
| 22 |
+
"dall-e-3",
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
var TextModelList = []string{
|
| 26 |
+
"gpt-4o",
|
| 27 |
+
"gpt-4o-mini",
|
| 28 |
+
"o1-preview",
|
| 29 |
+
"claude-3-5-sonnet",
|
| 30 |
+
"claude-3-5-haiku",
|
| 31 |
+
"gemini-1.5-pro",
|
| 32 |
+
"gemini-1.5-flash",
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
var MixtureModelList = []string{
|
| 36 |
+
"gpt-4o",
|
| 37 |
+
"claude-3-5-sonnet",
|
| 38 |
+
"gemini-1.5-pro",
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
var ImageModelList = []string{
|
| 42 |
+
"flux",
|
| 43 |
+
"flux-speed",
|
| 44 |
+
"flux-pro/ultra",
|
| 45 |
+
"ideogram",
|
| 46 |
+
"recraft-v3",
|
| 47 |
+
"dall-e-3",
|
| 48 |
+
}
|
common/env/helper.go
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package env
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"os"
|
| 5 |
+
"strconv"
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
func Bool(env string, defaultValue bool) bool {
|
| 9 |
+
if env == "" || os.Getenv(env) == "" {
|
| 10 |
+
return defaultValue
|
| 11 |
+
}
|
| 12 |
+
return os.Getenv(env) == "true"
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
func Int(env string, defaultValue int) int {
|
| 16 |
+
if env == "" || os.Getenv(env) == "" {
|
| 17 |
+
return defaultValue
|
| 18 |
+
}
|
| 19 |
+
num, err := strconv.Atoi(os.Getenv(env))
|
| 20 |
+
if err != nil {
|
| 21 |
+
return defaultValue
|
| 22 |
+
}
|
| 23 |
+
return num
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
func Float64(env string, defaultValue float64) float64 {
|
| 27 |
+
if env == "" || os.Getenv(env) == "" {
|
| 28 |
+
return defaultValue
|
| 29 |
+
}
|
| 30 |
+
num, err := strconv.ParseFloat(os.Getenv(env), 64)
|
| 31 |
+
if err != nil {
|
| 32 |
+
return defaultValue
|
| 33 |
+
}
|
| 34 |
+
return num
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
func String(env string, defaultValue string) string {
|
| 38 |
+
if env == "" || os.Getenv(env) == "" {
|
| 39 |
+
return defaultValue
|
| 40 |
+
}
|
| 41 |
+
return os.Getenv(env)
|
| 42 |
+
}
|
common/helper/helper.go
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package helper
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"fmt"
|
| 5 |
+
"genspark2api/common/random"
|
| 6 |
+
"github.com/gin-gonic/gin"
|
| 7 |
+
"html/template"
|
| 8 |
+
"log"
|
| 9 |
+
"net"
|
| 10 |
+
"os/exec"
|
| 11 |
+
"runtime"
|
| 12 |
+
"strconv"
|
| 13 |
+
"strings"
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
func OpenBrowser(url string) {
|
| 17 |
+
var err error
|
| 18 |
+
|
| 19 |
+
switch runtime.GOOS {
|
| 20 |
+
case "linux":
|
| 21 |
+
err = exec.Command("xdg-open", url).Start()
|
| 22 |
+
case "windows":
|
| 23 |
+
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
|
| 24 |
+
case "darwin":
|
| 25 |
+
err = exec.Command("open", url).Start()
|
| 26 |
+
}
|
| 27 |
+
if err != nil {
|
| 28 |
+
log.Println(err)
|
| 29 |
+
}
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
func GetIp() (ip string) {
|
| 33 |
+
ips, err := net.InterfaceAddrs()
|
| 34 |
+
if err != nil {
|
| 35 |
+
log.Println(err)
|
| 36 |
+
return ip
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
for _, a := range ips {
|
| 40 |
+
if ipNet, ok := a.(*net.IPNet); ok && !ipNet.IP.IsLoopback() {
|
| 41 |
+
if ipNet.IP.To4() != nil {
|
| 42 |
+
ip = ipNet.IP.String()
|
| 43 |
+
if strings.HasPrefix(ip, "10") {
|
| 44 |
+
return
|
| 45 |
+
}
|
| 46 |
+
if strings.HasPrefix(ip, "172") {
|
| 47 |
+
return
|
| 48 |
+
}
|
| 49 |
+
if strings.HasPrefix(ip, "192.168") {
|
| 50 |
+
return
|
| 51 |
+
}
|
| 52 |
+
ip = ""
|
| 53 |
+
}
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
return
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
var sizeKB = 1024
|
| 60 |
+
var sizeMB = sizeKB * 1024
|
| 61 |
+
var sizeGB = sizeMB * 1024
|
| 62 |
+
|
| 63 |
+
func Bytes2Size(num int64) string {
|
| 64 |
+
numStr := ""
|
| 65 |
+
unit := "B"
|
| 66 |
+
if num/int64(sizeGB) > 1 {
|
| 67 |
+
numStr = fmt.Sprintf("%.2f", float64(num)/float64(sizeGB))
|
| 68 |
+
unit = "GB"
|
| 69 |
+
} else if num/int64(sizeMB) > 1 {
|
| 70 |
+
numStr = fmt.Sprintf("%d", int(float64(num)/float64(sizeMB)))
|
| 71 |
+
unit = "MB"
|
| 72 |
+
} else if num/int64(sizeKB) > 1 {
|
| 73 |
+
numStr = fmt.Sprintf("%d", int(float64(num)/float64(sizeKB)))
|
| 74 |
+
unit = "KB"
|
| 75 |
+
} else {
|
| 76 |
+
numStr = fmt.Sprintf("%d", num)
|
| 77 |
+
}
|
| 78 |
+
return numStr + " " + unit
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
func Interface2String(inter interface{}) string {
|
| 82 |
+
switch inter := inter.(type) {
|
| 83 |
+
case string:
|
| 84 |
+
return inter
|
| 85 |
+
case int:
|
| 86 |
+
return fmt.Sprintf("%d", inter)
|
| 87 |
+
case float64:
|
| 88 |
+
return fmt.Sprintf("%f", inter)
|
| 89 |
+
}
|
| 90 |
+
return "Not Implemented"
|
| 91 |
+
}
|
| 92 |
+
|
| 93 |
+
func UnescapeHTML(x string) interface{} {
|
| 94 |
+
return template.HTML(x)
|
| 95 |
+
}
|
| 96 |
+
|
| 97 |
+
func IntMax(a int, b int) int {
|
| 98 |
+
if a >= b {
|
| 99 |
+
return a
|
| 100 |
+
} else {
|
| 101 |
+
return b
|
| 102 |
+
}
|
| 103 |
+
}
|
| 104 |
+
|
| 105 |
+
func GenRequestID() string {
|
| 106 |
+
return GetTimeString() + random.GetRandomNumberString(8)
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
func GetResponseID(c *gin.Context) string {
|
| 110 |
+
logID := c.GetString(RequestIdKey)
|
| 111 |
+
return fmt.Sprintf("chatcmpl-%s", logID)
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
func Max(a int, b int) int {
|
| 115 |
+
if a >= b {
|
| 116 |
+
return a
|
| 117 |
+
} else {
|
| 118 |
+
return b
|
| 119 |
+
}
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
func AssignOrDefault(value string, defaultValue string) string {
|
| 123 |
+
if len(value) != 0 {
|
| 124 |
+
return value
|
| 125 |
+
}
|
| 126 |
+
return defaultValue
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
func MessageWithRequestId(message string, id string) string {
|
| 130 |
+
return fmt.Sprintf("%s (request id: %s)", message, id)
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
func String2Int(str string) int {
|
| 134 |
+
num, err := strconv.Atoi(str)
|
| 135 |
+
if err != nil {
|
| 136 |
+
return 0
|
| 137 |
+
}
|
| 138 |
+
return num
|
| 139 |
+
}
|
common/helper/key.go
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package helper
|
| 2 |
+
|
| 3 |
+
const (
|
| 4 |
+
RequestIdKey = "X-Request-Id"
|
| 5 |
+
)
|
common/helper/time.go
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package helper
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"fmt"
|
| 5 |
+
"time"
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
func GetTimestamp() int64 {
|
| 9 |
+
return time.Now().Unix()
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
func GetTimeString() string {
|
| 13 |
+
now := time.Now()
|
| 14 |
+
return fmt.Sprintf("%s%d", now.Format("20060102150405"), now.UnixNano()%1e9)
|
| 15 |
+
}
|
common/init.go
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package common
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"flag"
|
| 5 |
+
"fmt"
|
| 6 |
+
"log"
|
| 7 |
+
"os"
|
| 8 |
+
"path/filepath"
|
| 9 |
+
)
|
| 10 |
+
|
| 11 |
+
var (
|
| 12 |
+
Port = flag.Int("port", 7055, "the listening port")
|
| 13 |
+
PrintVersion = flag.Bool("version", false, "print version and exit")
|
| 14 |
+
PrintHelp = flag.Bool("help", false, "print help and exit")
|
| 15 |
+
LogDir = flag.String("log-dir", "", "specify the log directory")
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
// UploadPath Maybe override by ENV_VAR
|
| 19 |
+
var UploadPath = "upload"
|
| 20 |
+
|
| 21 |
+
func printHelp() {
|
| 22 |
+
fmt.Println("genspark2api" + Version + "")
|
| 23 |
+
fmt.Println("Copyright (C) 2024 Dean. All rights reserved.")
|
| 24 |
+
fmt.Println("GitHub: https://github.com/deanxv/genspark2api ")
|
| 25 |
+
fmt.Println("Usage: genspark2api [--port <port>] [--log-dir <log directory>] [--version] [--help]")
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
func init() {
|
| 29 |
+
flag.Parse()
|
| 30 |
+
|
| 31 |
+
if *PrintVersion {
|
| 32 |
+
fmt.Println(Version)
|
| 33 |
+
os.Exit(0)
|
| 34 |
+
}
|
| 35 |
+
|
| 36 |
+
if *PrintHelp {
|
| 37 |
+
printHelp()
|
| 38 |
+
os.Exit(0)
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
if os.Getenv("UPLOAD_PATH") != "" {
|
| 42 |
+
UploadPath = os.Getenv("UPLOAD_PATH")
|
| 43 |
+
}
|
| 44 |
+
if *LogDir != "" {
|
| 45 |
+
var err error
|
| 46 |
+
*LogDir, err = filepath.Abs(*LogDir)
|
| 47 |
+
if err != nil {
|
| 48 |
+
log.Fatal(err)
|
| 49 |
+
}
|
| 50 |
+
if _, err := os.Stat(*LogDir); os.IsNotExist(err) {
|
| 51 |
+
err = os.Mkdir(*LogDir, 0777)
|
| 52 |
+
if err != nil {
|
| 53 |
+
log.Fatal(err)
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
}
|
| 57 |
+
}
|
common/loggger/constants.go
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package logger
|
| 2 |
+
|
| 3 |
+
var LogDir string
|
common/loggger/logger.go
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package logger
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"context"
|
| 5 |
+
"fmt"
|
| 6 |
+
"genspark2api/common/config"
|
| 7 |
+
"genspark2api/common/helper"
|
| 8 |
+
"io"
|
| 9 |
+
"log"
|
| 10 |
+
"os"
|
| 11 |
+
"path/filepath"
|
| 12 |
+
"sync"
|
| 13 |
+
"time"
|
| 14 |
+
|
| 15 |
+
"github.com/gin-gonic/gin"
|
| 16 |
+
)
|
| 17 |
+
|
| 18 |
+
const (
|
| 19 |
+
loggerDEBUG = "DEBUG"
|
| 20 |
+
loggerINFO = "INFO"
|
| 21 |
+
loggerWarn = "WARN"
|
| 22 |
+
loggerError = "ERR"
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
var setupLogOnce sync.Once
|
| 26 |
+
|
| 27 |
+
func SetupLogger() {
|
| 28 |
+
setupLogOnce.Do(func() {
|
| 29 |
+
if LogDir != "" {
|
| 30 |
+
logPath := filepath.Join(LogDir, fmt.Sprintf("genspark2api-%s.log", time.Now().Format("20060102")))
|
| 31 |
+
fd, err := os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
|
| 32 |
+
if err != nil {
|
| 33 |
+
log.Fatal("failed to open log file")
|
| 34 |
+
}
|
| 35 |
+
gin.DefaultWriter = io.MultiWriter(os.Stdout, fd)
|
| 36 |
+
gin.DefaultErrorWriter = io.MultiWriter(os.Stderr, fd)
|
| 37 |
+
}
|
| 38 |
+
})
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
func SysLog(s string) {
|
| 42 |
+
t := time.Now()
|
| 43 |
+
_, _ = fmt.Fprintf(gin.DefaultWriter, "[SYS] %v | %s \n", t.Format("2006/01/02 - 15:04:05"), s)
|
| 44 |
+
}
|
| 45 |
+
|
| 46 |
+
func SysError(s string) {
|
| 47 |
+
t := time.Now()
|
| 48 |
+
_, _ = fmt.Fprintf(gin.DefaultErrorWriter, "[SYS] %v | %s \n", t.Format("2006/01/02 - 15:04:05"), s)
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
func Debug(ctx context.Context, msg string) {
|
| 52 |
+
if config.DebugEnabled {
|
| 53 |
+
logHelper(ctx, loggerDEBUG, msg)
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
func Info(ctx context.Context, msg string) {
|
| 58 |
+
logHelper(ctx, loggerINFO, msg)
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
func Warn(ctx context.Context, msg string) {
|
| 62 |
+
logHelper(ctx, loggerWarn, msg)
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
func Error(ctx context.Context, msg string) {
|
| 66 |
+
logHelper(ctx, loggerError, msg)
|
| 67 |
+
}
|
| 68 |
+
|
| 69 |
+
func Debugf(ctx context.Context, format string, a ...any) {
|
| 70 |
+
Debug(ctx, fmt.Sprintf(format, a...))
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
func Infof(ctx context.Context, format string, a ...any) {
|
| 74 |
+
Info(ctx, fmt.Sprintf(format, a...))
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
func Warnf(ctx context.Context, format string, a ...any) {
|
| 78 |
+
Warn(ctx, fmt.Sprintf(format, a...))
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
func Errorf(ctx context.Context, format string, a ...any) {
|
| 82 |
+
Error(ctx, fmt.Sprintf(format, a...))
|
| 83 |
+
}
|
| 84 |
+
|
| 85 |
+
func logHelper(ctx context.Context, level string, msg string) {
|
| 86 |
+
writer := gin.DefaultErrorWriter
|
| 87 |
+
if level == loggerINFO {
|
| 88 |
+
writer = gin.DefaultWriter
|
| 89 |
+
}
|
| 90 |
+
id := ctx.Value(helper.RequestIdKey)
|
| 91 |
+
if id == nil {
|
| 92 |
+
id = helper.GenRequestID()
|
| 93 |
+
}
|
| 94 |
+
now := time.Now()
|
| 95 |
+
_, _ = fmt.Fprintf(writer, "[%s] %v | %s | %s \n", level, now.Format("2006/01/02 - 15:04:05"), id, msg)
|
| 96 |
+
SetupLogger()
|
| 97 |
+
}
|
| 98 |
+
|
| 99 |
+
func FatalLog(v ...any) {
|
| 100 |
+
t := time.Now()
|
| 101 |
+
_, _ = fmt.Fprintf(gin.DefaultErrorWriter, "[FATAL] %v | %v \n", t.Format("2006/01/02 - 15:04:05"), v)
|
| 102 |
+
os.Exit(1)
|
| 103 |
+
}
|
common/random/main.go
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package random
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/google/uuid"
|
| 5 |
+
"math/rand"
|
| 6 |
+
"strings"
|
| 7 |
+
"time"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
func GetUUID() string {
|
| 11 |
+
code := uuid.New().String()
|
| 12 |
+
code = strings.Replace(code, "-", "", -1)
|
| 13 |
+
return code
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
const keyChars = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
| 17 |
+
const keyNumbers = "0123456789"
|
| 18 |
+
|
| 19 |
+
func init() {
|
| 20 |
+
rand.Seed(time.Now().UnixNano())
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
func GenerateKey() string {
|
| 24 |
+
rand.Seed(time.Now().UnixNano())
|
| 25 |
+
key := make([]byte, 48)
|
| 26 |
+
for i := 0; i < 16; i++ {
|
| 27 |
+
key[i] = keyChars[rand.Intn(len(keyChars))]
|
| 28 |
+
}
|
| 29 |
+
uuid_ := GetUUID()
|
| 30 |
+
for i := 0; i < 32; i++ {
|
| 31 |
+
c := uuid_[i]
|
| 32 |
+
if i%2 == 0 && c >= 'a' && c <= 'z' {
|
| 33 |
+
c = c - 'a' + 'A'
|
| 34 |
+
}
|
| 35 |
+
key[i+16] = c
|
| 36 |
+
}
|
| 37 |
+
return string(key)
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
func GetRandomString(length int) string {
|
| 41 |
+
rand.Seed(time.Now().UnixNano())
|
| 42 |
+
key := make([]byte, length)
|
| 43 |
+
for i := 0; i < length; i++ {
|
| 44 |
+
key[i] = keyChars[rand.Intn(len(keyChars))]
|
| 45 |
+
}
|
| 46 |
+
return string(key)
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
func GetRandomNumberString(length int) string {
|
| 50 |
+
rand.Seed(time.Now().UnixNano())
|
| 51 |
+
key := make([]byte, length)
|
| 52 |
+
for i := 0; i < length; i++ {
|
| 53 |
+
key[i] = keyNumbers[rand.Intn(len(keyNumbers))]
|
| 54 |
+
}
|
| 55 |
+
return string(key)
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
// RandRange returns a random number between min and max (max is not included)
|
| 59 |
+
func RandRange(min, max int) int {
|
| 60 |
+
return min + rand.Intn(max-min)
|
| 61 |
+
}
|
common/rate-limit.go
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package common
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"sync"
|
| 5 |
+
"time"
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
type InMemoryRateLimiter struct {
|
| 9 |
+
store map[string]*[]int64
|
| 10 |
+
mutex sync.Mutex
|
| 11 |
+
expirationDuration time.Duration
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
func (l *InMemoryRateLimiter) Init(expirationDuration time.Duration) {
|
| 15 |
+
if l.store == nil {
|
| 16 |
+
l.mutex.Lock()
|
| 17 |
+
if l.store == nil {
|
| 18 |
+
l.store = make(map[string]*[]int64)
|
| 19 |
+
l.expirationDuration = expirationDuration
|
| 20 |
+
if expirationDuration > 0 {
|
| 21 |
+
go l.clearExpiredItems()
|
| 22 |
+
}
|
| 23 |
+
}
|
| 24 |
+
l.mutex.Unlock()
|
| 25 |
+
}
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
func (l *InMemoryRateLimiter) clearExpiredItems() {
|
| 29 |
+
for {
|
| 30 |
+
time.Sleep(l.expirationDuration)
|
| 31 |
+
l.mutex.Lock()
|
| 32 |
+
now := time.Now().Unix()
|
| 33 |
+
for key := range l.store {
|
| 34 |
+
queue := l.store[key]
|
| 35 |
+
size := len(*queue)
|
| 36 |
+
if size == 0 || now-(*queue)[size-1] > int64(l.expirationDuration.Seconds()) {
|
| 37 |
+
delete(l.store, key)
|
| 38 |
+
}
|
| 39 |
+
}
|
| 40 |
+
l.mutex.Unlock()
|
| 41 |
+
}
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
// Request parameter duration's unit is seconds
|
| 45 |
+
func (l *InMemoryRateLimiter) Request(key string, maxRequestNum int, duration int64) bool {
|
| 46 |
+
l.mutex.Lock()
|
| 47 |
+
defer l.mutex.Unlock()
|
| 48 |
+
// [old <-- new]
|
| 49 |
+
queue, ok := l.store[key]
|
| 50 |
+
now := time.Now().Unix()
|
| 51 |
+
if ok {
|
| 52 |
+
if len(*queue) < maxRequestNum {
|
| 53 |
+
*queue = append(*queue, now)
|
| 54 |
+
return true
|
| 55 |
+
} else {
|
| 56 |
+
if now-(*queue)[0] >= duration {
|
| 57 |
+
*queue = (*queue)[1:]
|
| 58 |
+
*queue = append(*queue, now)
|
| 59 |
+
return true
|
| 60 |
+
} else {
|
| 61 |
+
return false
|
| 62 |
+
}
|
| 63 |
+
}
|
| 64 |
+
} else {
|
| 65 |
+
s := make([]int64, 0, maxRequestNum)
|
| 66 |
+
l.store[key] = &s
|
| 67 |
+
*(l.store[key]) = append(*(l.store[key]), now)
|
| 68 |
+
}
|
| 69 |
+
return true
|
| 70 |
+
}
|
common/token.go
ADDED
|
@@ -0,0 +1,193 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package common
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"errors"
|
| 5 |
+
"fmt"
|
| 6 |
+
logger "genspark2api/common/loggger"
|
| 7 |
+
"genspark2api/model"
|
| 8 |
+
"github.com/pkoukk/tiktoken-go"
|
| 9 |
+
"strings"
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
// tokenEncoderMap won't grow after initialization
|
| 13 |
+
var tokenEncoderMap = map[string]*tiktoken.Tiktoken{}
|
| 14 |
+
var defaultTokenEncoder *tiktoken.Tiktoken
|
| 15 |
+
|
| 16 |
+
func InitTokenEncoders() {
|
| 17 |
+
logger.SysLog("initializing token encoders...")
|
| 18 |
+
gpt35TokenEncoder, err := tiktoken.EncodingForModel("gpt-3.5-turbo")
|
| 19 |
+
if err != nil {
|
| 20 |
+
logger.FatalLog(fmt.Sprintf("failed to get gpt-3.5-turbo token encoder: %s", err.Error()))
|
| 21 |
+
}
|
| 22 |
+
defaultTokenEncoder = gpt35TokenEncoder
|
| 23 |
+
gpt4oTokenEncoder, err := tiktoken.EncodingForModel("gpt-4o")
|
| 24 |
+
if err != nil {
|
| 25 |
+
logger.FatalLog(fmt.Sprintf("failed to get gpt-4o token encoder: %s", err.Error()))
|
| 26 |
+
}
|
| 27 |
+
gpt4TokenEncoder, err := tiktoken.EncodingForModel("gpt-4")
|
| 28 |
+
if err != nil {
|
| 29 |
+
logger.FatalLog(fmt.Sprintf("failed to get gpt-4 token encoder: %s", err.Error()))
|
| 30 |
+
}
|
| 31 |
+
for _, model := range DefaultOpenaiModelList {
|
| 32 |
+
if strings.HasPrefix(model, "gpt-3.5") {
|
| 33 |
+
tokenEncoderMap[model] = gpt35TokenEncoder
|
| 34 |
+
} else if strings.HasPrefix(model, "gpt-4o") {
|
| 35 |
+
tokenEncoderMap[model] = gpt4oTokenEncoder
|
| 36 |
+
} else if strings.HasPrefix(model, "gpt-4") {
|
| 37 |
+
tokenEncoderMap[model] = gpt4TokenEncoder
|
| 38 |
+
} else {
|
| 39 |
+
tokenEncoderMap[model] = nil
|
| 40 |
+
}
|
| 41 |
+
}
|
| 42 |
+
logger.SysLog("token encoders initialized.")
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
func getTokenEncoder(model string) *tiktoken.Tiktoken {
|
| 46 |
+
tokenEncoder, ok := tokenEncoderMap[model]
|
| 47 |
+
if ok && tokenEncoder != nil {
|
| 48 |
+
return tokenEncoder
|
| 49 |
+
}
|
| 50 |
+
if ok {
|
| 51 |
+
tokenEncoder, err := tiktoken.EncodingForModel(model)
|
| 52 |
+
if err != nil {
|
| 53 |
+
logger.SysError(fmt.Sprintf("failed to get token encoder for model %s: %s, using encoder for gpt-3.5-turbo", model, err.Error()))
|
| 54 |
+
tokenEncoder = defaultTokenEncoder
|
| 55 |
+
}
|
| 56 |
+
tokenEncoderMap[model] = tokenEncoder
|
| 57 |
+
return tokenEncoder
|
| 58 |
+
}
|
| 59 |
+
return defaultTokenEncoder
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
func getTokenNum(tokenEncoder *tiktoken.Tiktoken, text string) int {
|
| 63 |
+
return len(tokenEncoder.Encode(text, nil, nil))
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
func CountTokenMessages(messages []model.OpenAIChatMessage, model string) int {
|
| 67 |
+
tokenEncoder := getTokenEncoder(model)
|
| 68 |
+
// Reference:
|
| 69 |
+
// https://github.com/openai/openai-cookbook/blob/main/examples/How_to_count_tokens_with_tiktoken.ipynb
|
| 70 |
+
// https://github.com/pkoukk/tiktoken-go/issues/6
|
| 71 |
+
//
|
| 72 |
+
// Every message follows <|start|>{role/name}\n{content}<|end|>\n
|
| 73 |
+
var tokensPerMessage int
|
| 74 |
+
if model == "gpt-3.5-turbo-0301" {
|
| 75 |
+
tokensPerMessage = 4
|
| 76 |
+
} else {
|
| 77 |
+
tokensPerMessage = 3
|
| 78 |
+
}
|
| 79 |
+
tokenNum := 0
|
| 80 |
+
for _, message := range messages {
|
| 81 |
+
tokenNum += tokensPerMessage
|
| 82 |
+
switch v := message.Content.(type) {
|
| 83 |
+
case string:
|
| 84 |
+
tokenNum += getTokenNum(tokenEncoder, v)
|
| 85 |
+
case []any:
|
| 86 |
+
for _, it := range v {
|
| 87 |
+
m := it.(map[string]any)
|
| 88 |
+
switch m["type"] {
|
| 89 |
+
case "text":
|
| 90 |
+
if textValue, ok := m["text"]; ok {
|
| 91 |
+
if textString, ok := textValue.(string); ok {
|
| 92 |
+
tokenNum += getTokenNum(tokenEncoder, textString)
|
| 93 |
+
}
|
| 94 |
+
}
|
| 95 |
+
case "image_url":
|
| 96 |
+
imageUrl, ok := m["image_url"].(map[string]any)
|
| 97 |
+
if ok {
|
| 98 |
+
url := imageUrl["url"].(string)
|
| 99 |
+
detail := ""
|
| 100 |
+
if imageUrl["detail"] != nil {
|
| 101 |
+
detail = imageUrl["detail"].(string)
|
| 102 |
+
}
|
| 103 |
+
imageTokens, err := countImageTokens(url, detail, model)
|
| 104 |
+
if err != nil {
|
| 105 |
+
logger.SysError("error counting image tokens: " + err.Error())
|
| 106 |
+
} else {
|
| 107 |
+
tokenNum += imageTokens
|
| 108 |
+
}
|
| 109 |
+
}
|
| 110 |
+
}
|
| 111 |
+
}
|
| 112 |
+
}
|
| 113 |
+
tokenNum += getTokenNum(tokenEncoder, message.Role)
|
| 114 |
+
}
|
| 115 |
+
tokenNum += 3 // Every reply is primed with <|start|>assistant<|message|>
|
| 116 |
+
return tokenNum
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
const (
|
| 120 |
+
lowDetailCost = 85
|
| 121 |
+
highDetailCostPerTile = 170
|
| 122 |
+
additionalCost = 85
|
| 123 |
+
// gpt-4o-mini cost higher than other model
|
| 124 |
+
gpt4oMiniLowDetailCost = 2833
|
| 125 |
+
gpt4oMiniHighDetailCost = 5667
|
| 126 |
+
gpt4oMiniAdditionalCost = 2833
|
| 127 |
+
)
|
| 128 |
+
|
| 129 |
+
// https://platform.openai.com/docs/guides/vision/calculating-costs
|
| 130 |
+
// https://github.com/openai/openai-cookbook/blob/05e3f9be4c7a2ae7ecf029a7c32065b024730ebe/examples/How_to_count_tokens_with_tiktoken.ipynb
|
| 131 |
+
func countImageTokens(url string, detail string, model string) (_ int, err error) {
|
| 132 |
+
// Reference: https://platform.openai.com/docs/guides/vision/low-or-high-fidelity-image-understanding
|
| 133 |
+
// detail == "auto" is undocumented on how it works, it just said the model will use the auto setting which will look at the image input size and decide if it should use the low or high setting.
|
| 134 |
+
// According to the official guide, "low" disable the high-res model,
|
| 135 |
+
// and only receive low-res 512px x 512px version of the image, indicating
|
| 136 |
+
// that image is treated as low-res when size is smaller than 512px x 512px,
|
| 137 |
+
// then we can assume that image size larger than 512px x 512px is treated
|
| 138 |
+
// as high-res. Then we have the following logic:
|
| 139 |
+
// if detail == "" || detail == "auto" {
|
| 140 |
+
// width, height, err = image.GetImageSize(url)
|
| 141 |
+
// if err != nil {
|
| 142 |
+
// return 0, err
|
| 143 |
+
// }
|
| 144 |
+
// fetchSize = false
|
| 145 |
+
// // not sure if this is correct
|
| 146 |
+
// if width > 512 || height > 512 {
|
| 147 |
+
// detail = "high"
|
| 148 |
+
// } else {
|
| 149 |
+
// detail = "low"
|
| 150 |
+
// }
|
| 151 |
+
// }
|
| 152 |
+
|
| 153 |
+
// However, in my test, it seems to be always the same as "high".
|
| 154 |
+
// The following image, which is 125x50, is still treated as high-res, taken
|
| 155 |
+
// 255 tokens in the response of non-stream chat completion api.
|
| 156 |
+
// https://upload.wikimedia.org/wikipedia/commons/1/10/18_Infantry_Division_Messina.jpg
|
| 157 |
+
if detail == "" || detail == "auto" {
|
| 158 |
+
// assume by test, not sure if this is correct
|
| 159 |
+
detail = "low"
|
| 160 |
+
}
|
| 161 |
+
switch detail {
|
| 162 |
+
case "low":
|
| 163 |
+
if strings.HasPrefix(model, "gpt-4o-mini") {
|
| 164 |
+
return gpt4oMiniLowDetailCost, nil
|
| 165 |
+
}
|
| 166 |
+
return lowDetailCost, nil
|
| 167 |
+
default:
|
| 168 |
+
return 0, errors.New("invalid detail option")
|
| 169 |
+
}
|
| 170 |
+
}
|
| 171 |
+
|
| 172 |
+
func CountTokenInput(input any, model string) int {
|
| 173 |
+
switch v := input.(type) {
|
| 174 |
+
case string:
|
| 175 |
+
return CountTokenText(v, model)
|
| 176 |
+
case []string:
|
| 177 |
+
text := ""
|
| 178 |
+
for _, s := range v {
|
| 179 |
+
text += s
|
| 180 |
+
}
|
| 181 |
+
return CountTokenText(text, model)
|
| 182 |
+
}
|
| 183 |
+
return 0
|
| 184 |
+
}
|
| 185 |
+
|
| 186 |
+
func CountTokenText(text string, model string) int {
|
| 187 |
+
tokenEncoder := getTokenEncoder(model)
|
| 188 |
+
return getTokenNum(tokenEncoder, text)
|
| 189 |
+
}
|
| 190 |
+
|
| 191 |
+
func CountToken(text string) int {
|
| 192 |
+
return CountTokenInput(text, "gpt-3.5-turbo")
|
| 193 |
+
}
|
common/utils.go
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package common
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"encoding/base64"
|
| 5 |
+
"fmt"
|
| 6 |
+
"github.com/google/uuid"
|
| 7 |
+
jsoniter "github.com/json-iterator/go"
|
| 8 |
+
_ "github.com/pkoukk/tiktoken-go"
|
| 9 |
+
"math/rand"
|
| 10 |
+
"regexp"
|
| 11 |
+
"strings"
|
| 12 |
+
"time"
|
| 13 |
+
"unicode/utf8"
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
// splitStringByBytes 将字符串按照指定的字节数进行切割
|
| 17 |
+
func SplitStringByBytes(s string, size int) []string {
|
| 18 |
+
var result []string
|
| 19 |
+
|
| 20 |
+
for len(s) > 0 {
|
| 21 |
+
// 初始切割点
|
| 22 |
+
l := size
|
| 23 |
+
if l > len(s) {
|
| 24 |
+
l = len(s)
|
| 25 |
+
}
|
| 26 |
+
|
| 27 |
+
// 确保不在字符中间切割
|
| 28 |
+
for l > 0 && !utf8.ValidString(s[:l]) {
|
| 29 |
+
l--
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
// 如果 l 减到 0,说明 size 太小,无法容纳一个完整的字符
|
| 33 |
+
if l == 0 {
|
| 34 |
+
l = len(s)
|
| 35 |
+
for l > 0 && !utf8.ValidString(s[:l]) {
|
| 36 |
+
l--
|
| 37 |
+
}
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
result = append(result, s[:l])
|
| 41 |
+
s = s[l:]
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
return result
|
| 45 |
+
}
|
| 46 |
+
|
| 47 |
+
func Obj2Bytes(obj interface{}) ([]byte, error) {
|
| 48 |
+
// 创建一个jsonIter的Encoder
|
| 49 |
+
configCompatibleWithStandardLibrary := jsoniter.ConfigCompatibleWithStandardLibrary
|
| 50 |
+
// 将结构体转换为JSON文本并保持顺序
|
| 51 |
+
bytes, err := configCompatibleWithStandardLibrary.Marshal(obj)
|
| 52 |
+
if err != nil {
|
| 53 |
+
return nil, err
|
| 54 |
+
}
|
| 55 |
+
return bytes, nil
|
| 56 |
+
}
|
| 57 |
+
|
| 58 |
+
func GetUUID() string {
|
| 59 |
+
code := uuid.New().String()
|
| 60 |
+
code = strings.Replace(code, "-", "", -1)
|
| 61 |
+
return code
|
| 62 |
+
}
|
| 63 |
+
|
| 64 |
+
// RandomElement 返回给定切片中的随机元素
|
| 65 |
+
func RandomElement[T any](slice []T) (T, error) {
|
| 66 |
+
if len(slice) == 0 {
|
| 67 |
+
var zero T
|
| 68 |
+
return zero, fmt.Errorf("empty slice")
|
| 69 |
+
}
|
| 70 |
+
|
| 71 |
+
// 确保每次随机都不一样
|
| 72 |
+
rand.Seed(time.Now().UnixNano())
|
| 73 |
+
|
| 74 |
+
// 随机选择一个索引
|
| 75 |
+
index := rand.Intn(len(slice))
|
| 76 |
+
return slice[index], nil
|
| 77 |
+
}
|
| 78 |
+
|
| 79 |
+
func SliceContains(slice []string, str string) bool {
|
| 80 |
+
for _, item := range slice {
|
| 81 |
+
if strings.Contains(str, item) {
|
| 82 |
+
return true
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
return false
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
func IsImageBase64(s string) bool {
|
| 89 |
+
// 检查字符串是否符合数据URL的格式
|
| 90 |
+
if !strings.HasPrefix(s, "data:image/") || !strings.Contains(s, ";base64,") {
|
| 91 |
+
return false
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
if !strings.Contains(s, ";base64,") {
|
| 95 |
+
return false
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
// 获取";base64,"后的Base64编码部分
|
| 99 |
+
dataParts := strings.Split(s, ";base64,")
|
| 100 |
+
if len(dataParts) != 2 {
|
| 101 |
+
return false
|
| 102 |
+
}
|
| 103 |
+
base64Data := dataParts[1]
|
| 104 |
+
|
| 105 |
+
// 尝试Base64解码
|
| 106 |
+
_, err := base64.StdEncoding.DecodeString(base64Data)
|
| 107 |
+
return err == nil
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
+
func IsBase64(s string) bool {
|
| 111 |
+
// 检查字符串是否符合数据URL的格式
|
| 112 |
+
//if !strings.HasPrefix(s, "data:image/") || !strings.Contains(s, ";base64,") {
|
| 113 |
+
// return false
|
| 114 |
+
//}
|
| 115 |
+
|
| 116 |
+
if !strings.Contains(s, ";base64,") {
|
| 117 |
+
return false
|
| 118 |
+
}
|
| 119 |
+
|
| 120 |
+
// 获取";base64,"后的Base64编码部分
|
| 121 |
+
dataParts := strings.Split(s, ";base64,")
|
| 122 |
+
if len(dataParts) != 2 {
|
| 123 |
+
return false
|
| 124 |
+
}
|
| 125 |
+
base64Data := dataParts[1]
|
| 126 |
+
|
| 127 |
+
// 尝试Base64解码
|
| 128 |
+
_, err := base64.StdEncoding.DecodeString(base64Data)
|
| 129 |
+
return err == nil
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
func IsCloudflareChallenge(data string) bool {
|
| 133 |
+
// 检查基本的 HTML 结构
|
| 134 |
+
htmlPattern := `^<!DOCTYPE html><html.*?><head>.*?</head><body.*?>.*?</body></html>$`
|
| 135 |
+
|
| 136 |
+
// 检查 Cloudflare 特征
|
| 137 |
+
cfPatterns := []string{
|
| 138 |
+
`<title>Just a moment\.\.\.</title>`, // 标题特征
|
| 139 |
+
`window\._cf_chl_opt`, // CF 配置对象
|
| 140 |
+
`challenge-platform/h/b/orchestrate/chl_page`, // CF challenge 路径
|
| 141 |
+
`cdn-cgi/challenge-platform`, // CDN 路径特征
|
| 142 |
+
`<meta http-equiv="refresh" content="\d+">`, // 刷新 meta 标签
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
// 首先检查整体 HTML 结构
|
| 146 |
+
matched, _ := regexp.MatchString(htmlPattern, strings.TrimSpace(data))
|
| 147 |
+
if !matched {
|
| 148 |
+
return false
|
| 149 |
+
}
|
| 150 |
+
|
| 151 |
+
// 检查是否包含 Cloudflare 特征
|
| 152 |
+
for _, pattern := range cfPatterns {
|
| 153 |
+
if matched, _ := regexp.MatchString(pattern, data); matched {
|
| 154 |
+
return true
|
| 155 |
+
}
|
| 156 |
+
}
|
| 157 |
+
|
| 158 |
+
return false
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
func IsRateLimit(data string) bool {
|
| 162 |
+
if data == "Rate limit exceeded cf1" || data == "Rate limit exceeded cf2" {
|
| 163 |
+
return true
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
return false
|
| 167 |
+
}
|
controller/chat.go
ADDED
|
@@ -0,0 +1,1086 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package controller
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"bufio"
|
| 5 |
+
"encoding/base64"
|
| 6 |
+
"encoding/json"
|
| 7 |
+
"fmt"
|
| 8 |
+
"genspark2api/common"
|
| 9 |
+
"genspark2api/common/config"
|
| 10 |
+
logger "genspark2api/common/loggger"
|
| 11 |
+
"genspark2api/model"
|
| 12 |
+
"github.com/deanxv/CycleTLS/cycletls"
|
| 13 |
+
"github.com/gin-gonic/gin"
|
| 14 |
+
"github.com/samber/lo"
|
| 15 |
+
"io"
|
| 16 |
+
"io/ioutil"
|
| 17 |
+
"net/http"
|
| 18 |
+
"strings"
|
| 19 |
+
"time"
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
const (
|
| 23 |
+
baseURL = "https://www.genspark.ai"
|
| 24 |
+
apiEndpoint = baseURL + "/api/copilot/ask"
|
| 25 |
+
deleteEndpoint = baseURL + "/api/project/delete?project_id=%s"
|
| 26 |
+
uploadEndpoint = baseURL + "/api/get_upload_personal_image_url"
|
| 27 |
+
chatType = "COPILOT_MOA_CHAT"
|
| 28 |
+
imageType = "COPILOT_MOA_IMAGE"
|
| 29 |
+
responseIDFormat = "chatcmpl-%s"
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
type OpenAIChatMessage struct {
|
| 33 |
+
Role string `json:"role"`
|
| 34 |
+
Content interface{} `json:"content"`
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
type OpenAIChatCompletionRequest struct {
|
| 38 |
+
Messages []OpenAIChatMessage
|
| 39 |
+
Model string
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
// ChatForOpenAI 处理OpenAI聊天请求
|
| 43 |
+
func ChatForOpenAI(c *gin.Context) {
|
| 44 |
+
client := cycletls.Init()
|
| 45 |
+
defer safeClose(client)
|
| 46 |
+
|
| 47 |
+
var openAIReq model.OpenAIChatCompletionRequest
|
| 48 |
+
if err := c.BindJSON(&openAIReq); err != nil {
|
| 49 |
+
logger.Errorf(c.Request.Context(), err.Error())
|
| 50 |
+
c.JSON(http.StatusInternalServerError, model.OpenAIErrorResponse{
|
| 51 |
+
OpenAIError: model.OpenAIError{
|
| 52 |
+
Message: "Invalid request parameters",
|
| 53 |
+
Type: "request_error",
|
| 54 |
+
Code: "500",
|
| 55 |
+
},
|
| 56 |
+
})
|
| 57 |
+
return
|
| 58 |
+
}
|
| 59 |
+
cookie, err := common.RandomElement(config.GSCookies)
|
| 60 |
+
if err != nil {
|
| 61 |
+
logger.Errorf(c.Request.Context(), err.Error())
|
| 62 |
+
c.JSON(http.StatusInternalServerError, model.OpenAIErrorResponse{
|
| 63 |
+
OpenAIError: model.OpenAIError{
|
| 64 |
+
Message: err.Error(),
|
| 65 |
+
Type: "request_error",
|
| 66 |
+
Code: "500",
|
| 67 |
+
},
|
| 68 |
+
})
|
| 69 |
+
return
|
| 70 |
+
}
|
| 71 |
+
|
| 72 |
+
if lo.Contains(common.ImageModelList, openAIReq.Model) {
|
| 73 |
+
responseId := fmt.Sprintf(responseIDFormat, time.Now().Format("20060102150405"))
|
| 74 |
+
|
| 75 |
+
if len(openAIReq.GetUserContent()) == 0 {
|
| 76 |
+
logger.Errorf(c.Request.Context(), "user content is null")
|
| 77 |
+
c.JSON(http.StatusInternalServerError, model.OpenAIErrorResponse{
|
| 78 |
+
OpenAIError: model.OpenAIError{
|
| 79 |
+
Message: "Invalid request parameters",
|
| 80 |
+
Type: "request_error",
|
| 81 |
+
Code: "500",
|
| 82 |
+
},
|
| 83 |
+
})
|
| 84 |
+
return
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
jsonData, err := json.Marshal(openAIReq.GetUserContent()[0])
|
| 88 |
+
if err != nil {
|
| 89 |
+
logger.Errorf(c.Request.Context(), err.Error())
|
| 90 |
+
c.JSON(500, gin.H{"error": "Failed to marshal request body"})
|
| 91 |
+
return
|
| 92 |
+
}
|
| 93 |
+
resp, err := ImageProcess(c, client, cookie, model.OpenAIImagesGenerationRequest{
|
| 94 |
+
Model: openAIReq.Model,
|
| 95 |
+
Prompt: openAIReq.GetUserContent()[0],
|
| 96 |
+
})
|
| 97 |
+
|
| 98 |
+
if err != nil {
|
| 99 |
+
logger.Errorf(c.Request.Context(), err.Error())
|
| 100 |
+
c.JSON(http.StatusInternalServerError, model.OpenAIErrorResponse{
|
| 101 |
+
OpenAIError: model.OpenAIError{
|
| 102 |
+
Message: err.Error(),
|
| 103 |
+
Type: "request_error",
|
| 104 |
+
Code: "500",
|
| 105 |
+
},
|
| 106 |
+
})
|
| 107 |
+
return
|
| 108 |
+
} else {
|
| 109 |
+
data := resp.Data
|
| 110 |
+
var content []string
|
| 111 |
+
for _, item := range data {
|
| 112 |
+
content = append(content, fmt.Sprintf("", item.URL))
|
| 113 |
+
}
|
| 114 |
+
|
| 115 |
+
if openAIReq.Stream {
|
| 116 |
+
streamResp := createStreamResponse(responseId, openAIReq.Model, jsonData, model.OpenAIDelta{Content: strings.Join(content, "\n"), Role: "assistant"}, nil)
|
| 117 |
+
err := sendSSEvent(c, streamResp)
|
| 118 |
+
if err != nil {
|
| 119 |
+
logger.Errorf(c.Request.Context(), err.Error())
|
| 120 |
+
c.JSON(http.StatusInternalServerError, model.OpenAIErrorResponse{
|
| 121 |
+
OpenAIError: model.OpenAIError{
|
| 122 |
+
Message: err.Error(),
|
| 123 |
+
Type: "request_error",
|
| 124 |
+
Code: "500",
|
| 125 |
+
},
|
| 126 |
+
})
|
| 127 |
+
return
|
| 128 |
+
}
|
| 129 |
+
c.SSEvent("", " [DONE]")
|
| 130 |
+
return
|
| 131 |
+
} else {
|
| 132 |
+
|
| 133 |
+
jsonBytes, _ := json.Marshal(openAIReq.Messages)
|
| 134 |
+
promptTokens := common.CountTokenText(string(jsonBytes), openAIReq.Model)
|
| 135 |
+
completionTokens := common.CountTokenText(strings.Join(content, "\n"), openAIReq.Model)
|
| 136 |
+
|
| 137 |
+
finishReason := "stop"
|
| 138 |
+
// 创建并返回 OpenAIChatCompletionResponse 结构
|
| 139 |
+
resp := model.OpenAIChatCompletionResponse{
|
| 140 |
+
ID: fmt.Sprintf(responseIDFormat, time.Now().Format("20060102150405")),
|
| 141 |
+
Object: "chat.completion",
|
| 142 |
+
Created: time.Now().Unix(),
|
| 143 |
+
Model: openAIReq.Model,
|
| 144 |
+
Choices: []model.OpenAIChoice{
|
| 145 |
+
{
|
| 146 |
+
Message: model.OpenAIMessage{
|
| 147 |
+
Role: "assistant",
|
| 148 |
+
Content: strings.Join(content, "\n"),
|
| 149 |
+
},
|
| 150 |
+
FinishReason: &finishReason,
|
| 151 |
+
},
|
| 152 |
+
},
|
| 153 |
+
Usage: model.OpenAIUsage{
|
| 154 |
+
PromptTokens: promptTokens,
|
| 155 |
+
CompletionTokens: completionTokens,
|
| 156 |
+
TotalTokens: promptTokens + completionTokens,
|
| 157 |
+
},
|
| 158 |
+
}
|
| 159 |
+
c.JSON(200, resp)
|
| 160 |
+
return
|
| 161 |
+
}
|
| 162 |
+
|
| 163 |
+
}
|
| 164 |
+
}
|
| 165 |
+
|
| 166 |
+
requestBody, err := createRequestBody(c, client, cookie, &openAIReq)
|
| 167 |
+
|
| 168 |
+
if err != nil {
|
| 169 |
+
c.JSON(500, gin.H{"error": err.Error()})
|
| 170 |
+
return
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
jsonData, err := json.Marshal(requestBody)
|
| 174 |
+
if err != nil {
|
| 175 |
+
c.JSON(500, gin.H{"error": "Failed to marshal request body"})
|
| 176 |
+
return
|
| 177 |
+
}
|
| 178 |
+
|
| 179 |
+
if openAIReq.Stream {
|
| 180 |
+
handleStreamRequest(c, client, cookie, jsonData, openAIReq.Model)
|
| 181 |
+
} else {
|
| 182 |
+
handleNonStreamRequest(c, client, cookie, jsonData, openAIReq.Model)
|
| 183 |
+
}
|
| 184 |
+
|
| 185 |
+
}
|
| 186 |
+
|
| 187 |
+
func processMessages(c *gin.Context, client cycletls.CycleTLS, cookie string, messages []model.OpenAIChatMessage) error {
|
| 188 |
+
//client := cycletls.Init()
|
| 189 |
+
//defer client.Close()
|
| 190 |
+
|
| 191 |
+
for i, message := range messages {
|
| 192 |
+
if contentArray, ok := message.Content.([]interface{}); ok {
|
| 193 |
+
for j, content := range contentArray {
|
| 194 |
+
if contentMap, ok := content.(map[string]interface{}); ok {
|
| 195 |
+
if contentType, ok := contentMap["type"].(string); ok && contentType == "image_url" {
|
| 196 |
+
if imageMap, ok := contentMap["image_url"].(map[string]interface{}); ok {
|
| 197 |
+
if url, ok := imageMap["url"].(string); ok {
|
| 198 |
+
err := processUrl(c, client, cookie, url, imageMap, j, contentArray)
|
| 199 |
+
if err != nil {
|
| 200 |
+
logger.Errorf(c.Request.Context(), fmt.Sprintf("processUrl err %v\n", err))
|
| 201 |
+
return fmt.Errorf("processUrl err: %v", err)
|
| 202 |
+
}
|
| 203 |
+
}
|
| 204 |
+
}
|
| 205 |
+
}
|
| 206 |
+
}
|
| 207 |
+
}
|
| 208 |
+
messages[i].Content = contentArray
|
| 209 |
+
}
|
| 210 |
+
}
|
| 211 |
+
return nil
|
| 212 |
+
}
|
| 213 |
+
func processUrl(c *gin.Context, client cycletls.CycleTLS, cookie string, url string, imageMap map[string]interface{}, index int, contentArray []interface{}) error {
|
| 214 |
+
// 判断是否为URL
|
| 215 |
+
if strings.HasPrefix(url, "http://") || strings.HasPrefix(url, "https://") {
|
| 216 |
+
// 下载文件
|
| 217 |
+
bytes, err := fetchImageBytes(url)
|
| 218 |
+
if err != nil {
|
| 219 |
+
logger.Errorf(c.Request.Context(), fmt.Sprintf("fetchImageBytes err %v\n", err))
|
| 220 |
+
return fmt.Errorf("fetchImageBytes err %v\n", err)
|
| 221 |
+
}
|
| 222 |
+
|
| 223 |
+
err = processBytes(c, client, cookie, bytes, imageMap, index, contentArray)
|
| 224 |
+
if err != nil {
|
| 225 |
+
logger.Errorf(c.Request.Context(), fmt.Sprintf("processBytes err %v\n", err))
|
| 226 |
+
return fmt.Errorf("processBytes err %v\n", err)
|
| 227 |
+
}
|
| 228 |
+
} else {
|
| 229 |
+
// 尝试解析base64
|
| 230 |
+
var bytes []byte
|
| 231 |
+
var err error
|
| 232 |
+
|
| 233 |
+
// 处理可能包含 data:image/ 前缀的base64
|
| 234 |
+
base64Str := url
|
| 235 |
+
if strings.Contains(url, ";base64,") {
|
| 236 |
+
base64Str = strings.Split(url, ";base64,")[1]
|
| 237 |
+
}
|
| 238 |
+
|
| 239 |
+
bytes, err = base64.StdEncoding.DecodeString(base64Str)
|
| 240 |
+
if err != nil {
|
| 241 |
+
logger.Errorf(c.Request.Context(), fmt.Sprintf("base64.StdEncoding.DecodeString err %v\n", err))
|
| 242 |
+
return fmt.Errorf("base64.StdEncoding.DecodeString err: %v\n", err)
|
| 243 |
+
}
|
| 244 |
+
|
| 245 |
+
err = processBytes(c, client, cookie, bytes, imageMap, index, contentArray)
|
| 246 |
+
if err != nil {
|
| 247 |
+
logger.Errorf(c.Request.Context(), fmt.Sprintf("processBytes err %v\n", err))
|
| 248 |
+
return fmt.Errorf("processBytes err: %v\n", err)
|
| 249 |
+
}
|
| 250 |
+
}
|
| 251 |
+
return nil
|
| 252 |
+
}
|
| 253 |
+
|
| 254 |
+
func processBytes(c *gin.Context, client cycletls.CycleTLS, cookie string, bytes []byte, imageMap map[string]interface{}, index int, contentArray []interface{}) error {
|
| 255 |
+
// 检查是否为图片类型
|
| 256 |
+
contentType := http.DetectContentType(bytes)
|
| 257 |
+
if strings.HasPrefix(contentType, "image/") {
|
| 258 |
+
// 是图片类型,转换为base64
|
| 259 |
+
base64Data := "data:image/jpeg;base64," + base64.StdEncoding.EncodeToString(bytes)
|
| 260 |
+
imageMap["url"] = base64Data
|
| 261 |
+
} else {
|
| 262 |
+
response, err := makeGetUploadUrlRequest(client, cookie)
|
| 263 |
+
if err != nil {
|
| 264 |
+
logger.Errorf(c.Request.Context(), fmt.Sprintf("makeGetUploadUrlRequest err %v\n", err))
|
| 265 |
+
return fmt.Errorf("makeGetUploadUrlRequest err: %v\n", err)
|
| 266 |
+
}
|
| 267 |
+
|
| 268 |
+
var jsonResponse map[string]interface{}
|
| 269 |
+
if err := json.Unmarshal([]byte(response.Body), &jsonResponse); err != nil {
|
| 270 |
+
logger.Errorf(c.Request.Context(), fmt.Sprintf("Unmarshal err %v\n", err))
|
| 271 |
+
return fmt.Errorf("Unmarshal err: %v\n", err)
|
| 272 |
+
}
|
| 273 |
+
|
| 274 |
+
uploadImageUrl, ok := jsonResponse["data"].(map[string]interface{})["upload_image_url"].(string)
|
| 275 |
+
privateStorageUrl, ok := jsonResponse["data"].(map[string]interface{})["private_storage_url"].(string)
|
| 276 |
+
|
| 277 |
+
if !ok {
|
| 278 |
+
//fmt.Println("Failed to extract upload_image_url")
|
| 279 |
+
return fmt.Errorf("Failed to extract upload_image_url")
|
| 280 |
+
}
|
| 281 |
+
|
| 282 |
+
// 发送OPTIONS预检请求
|
| 283 |
+
//_, err = makeOptionsRequest(client, uploadImageUrl)
|
| 284 |
+
//if err != nil {
|
| 285 |
+
// return
|
| 286 |
+
//}
|
| 287 |
+
// 上传文件
|
| 288 |
+
_, err = makeUploadRequest(client, uploadImageUrl, bytes)
|
| 289 |
+
if err != nil {
|
| 290 |
+
logger.Errorf(c.Request.Context(), fmt.Sprintf("makeUploadRequest err %v\n", err))
|
| 291 |
+
return fmt.Errorf("makeUploadRequest err: %v\n", err)
|
| 292 |
+
}
|
| 293 |
+
//fmt.Println(resp)
|
| 294 |
+
|
| 295 |
+
// 创建新的 private_file 格式的内容
|
| 296 |
+
privateFile := map[string]interface{}{
|
| 297 |
+
"type": "private_file",
|
| 298 |
+
"private_file": map[string]interface{}{
|
| 299 |
+
"name": "file", // 你可能需要从原始文件名或其他地方获取
|
| 300 |
+
"type": contentType,
|
| 301 |
+
"size": len(bytes),
|
| 302 |
+
"ext": strings.Split(contentType, "/")[1], // 简单处理,可能需要更复杂的逻辑
|
| 303 |
+
"private_storage_url": privateStorageUrl,
|
| 304 |
+
},
|
| 305 |
+
}
|
| 306 |
+
|
| 307 |
+
// 替换数组中的元素
|
| 308 |
+
contentArray[index] = privateFile
|
| 309 |
+
}
|
| 310 |
+
return nil
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
// 获取文件字节数组的函数
|
| 314 |
+
func fetchImageBytes(url string) ([]byte, error) {
|
| 315 |
+
resp, err := http.Get(url)
|
| 316 |
+
if err != nil {
|
| 317 |
+
return nil, fmt.Errorf("http.Get err: %v\n", err)
|
| 318 |
+
}
|
| 319 |
+
defer resp.Body.Close()
|
| 320 |
+
|
| 321 |
+
return ioutil.ReadAll(resp.Body)
|
| 322 |
+
}
|
| 323 |
+
|
| 324 |
+
func createRequestBody(c *gin.Context, client cycletls.CycleTLS, cookie string, openAIReq *model.OpenAIChatCompletionRequest) (map[string]interface{}, error) {
|
| 325 |
+
// 处理消息中的图像 URL
|
| 326 |
+
err := processMessages(c, client, cookie, openAIReq.Messages)
|
| 327 |
+
if err != nil {
|
| 328 |
+
logger.Errorf(c.Request.Context(), "processMessages err: %v", err)
|
| 329 |
+
return nil, fmt.Errorf("processMessages err: %v", err)
|
| 330 |
+
}
|
| 331 |
+
|
| 332 |
+
currentQueryString := fmt.Sprintf("type=%s", chatType)
|
| 333 |
+
// 查找 key 对应的 value
|
| 334 |
+
if chatId, ok := config.ModelChatMap[openAIReq.Model]; ok {
|
| 335 |
+
currentQueryString = fmt.Sprintf("id=%s&type=%s", chatId, chatType)
|
| 336 |
+
}
|
| 337 |
+
|
| 338 |
+
models := []string{openAIReq.Model}
|
| 339 |
+
if !lo.Contains(common.TextModelList, openAIReq.Model) {
|
| 340 |
+
models = common.MixtureModelList
|
| 341 |
+
}
|
| 342 |
+
|
| 343 |
+
// 创建请求体
|
| 344 |
+
return map[string]interface{}{
|
| 345 |
+
"type": chatType,
|
| 346 |
+
//"current_query_string": fmt.Sprintf("&type=%s", chatType),
|
| 347 |
+
"current_query_string": currentQueryString,
|
| 348 |
+
"messages": openAIReq.Messages,
|
| 349 |
+
//"user_s_input": "100字的量子力学文章",
|
| 350 |
+
"action_params": map[string]interface{}{},
|
| 351 |
+
"extra_data": map[string]interface{}{
|
| 352 |
+
"models": models,
|
| 353 |
+
"run_with_another_model": false,
|
| 354 |
+
"writingContent": nil,
|
| 355 |
+
},
|
| 356 |
+
//"g_recaptcha_token": helper.GetTimeString(),
|
| 357 |
+
}, nil
|
| 358 |
+
}
|
| 359 |
+
func createImageRequestBody(c *gin.Context, cookie string, openAIReq *model.OpenAIImagesGenerationRequest) (map[string]interface{}, error) {
|
| 360 |
+
|
| 361 |
+
if openAIReq.Model == "dall-e-3" {
|
| 362 |
+
openAIReq.Model = "dalle-3"
|
| 363 |
+
}
|
| 364 |
+
// 创建模型配置
|
| 365 |
+
modelConfigs := []map[string]interface{}{
|
| 366 |
+
{
|
| 367 |
+
"model": openAIReq.Model,
|
| 368 |
+
"aspect_ratio": "auto",
|
| 369 |
+
"use_personalized_models": false,
|
| 370 |
+
"fashion_profile_id": nil,
|
| 371 |
+
"hd": false,
|
| 372 |
+
"reflection_enabled": false,
|
| 373 |
+
"style": "auto",
|
| 374 |
+
},
|
| 375 |
+
}
|
| 376 |
+
|
| 377 |
+
// 创建消息数组
|
| 378 |
+
var messages []map[string]interface{}
|
| 379 |
+
|
| 380 |
+
if openAIReq.Image != "" {
|
| 381 |
+
var base64Data string
|
| 382 |
+
|
| 383 |
+
if strings.HasPrefix(openAIReq.Image, "http://") || strings.HasPrefix(openAIReq.Image, "https://") {
|
| 384 |
+
// 下载文件
|
| 385 |
+
bytes, err := fetchImageBytes(openAIReq.Image)
|
| 386 |
+
if err != nil {
|
| 387 |
+
logger.Errorf(c.Request.Context(), fmt.Sprintf("fetchImageBytes err %v\n", err))
|
| 388 |
+
return nil, fmt.Errorf("fetchImageBytes err %v\n", err)
|
| 389 |
+
}
|
| 390 |
+
|
| 391 |
+
contentType := http.DetectContentType(bytes)
|
| 392 |
+
if strings.HasPrefix(contentType, "image/") {
|
| 393 |
+
// 是图片类型,转换为base64
|
| 394 |
+
base64Data = "data:image/jpeg;base64," + base64.StdEncoding.EncodeToString(bytes)
|
| 395 |
+
}
|
| 396 |
+
} else if common.IsImageBase64(openAIReq.Image) {
|
| 397 |
+
// 如果已经是 base64 格式
|
| 398 |
+
if !strings.HasPrefix(openAIReq.Image, "data:image") {
|
| 399 |
+
base64Data = "data:image/jpeg;base64," + openAIReq.Image
|
| 400 |
+
} else {
|
| 401 |
+
base64Data = openAIReq.Image
|
| 402 |
+
}
|
| 403 |
+
}
|
| 404 |
+
|
| 405 |
+
// 构建包含图片的消息
|
| 406 |
+
if base64Data != "" {
|
| 407 |
+
messages = []map[string]interface{}{
|
| 408 |
+
{
|
| 409 |
+
"role": "user",
|
| 410 |
+
"content": []map[string]interface{}{
|
| 411 |
+
{
|
| 412 |
+
"type": "image_url",
|
| 413 |
+
"image_url": map[string]interface{}{
|
| 414 |
+
"url": base64Data,
|
| 415 |
+
},
|
| 416 |
+
},
|
| 417 |
+
{
|
| 418 |
+
"type": "text",
|
| 419 |
+
"text": openAIReq.Prompt,
|
| 420 |
+
},
|
| 421 |
+
},
|
| 422 |
+
},
|
| 423 |
+
}
|
| 424 |
+
}
|
| 425 |
+
}
|
| 426 |
+
|
| 427 |
+
// 如果没有图片或处理图片失败,使用纯文本消息
|
| 428 |
+
if len(messages) == 0 {
|
| 429 |
+
messages = []map[string]interface{}{
|
| 430 |
+
{
|
| 431 |
+
"role": "user",
|
| 432 |
+
"content": openAIReq.Prompt,
|
| 433 |
+
},
|
| 434 |
+
}
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
// 创建请求体
|
| 438 |
+
return map[string]interface{}{
|
| 439 |
+
"type": "COPILOT_MOA_IMAGE",
|
| 440 |
+
"current_query_string": "type=COPILOT_MOA_IMAGE",
|
| 441 |
+
"messages": messages,
|
| 442 |
+
"user_s_input": openAIReq.Prompt,
|
| 443 |
+
"action_params": map[string]interface{}{},
|
| 444 |
+
"extra_data": map[string]interface{}{
|
| 445 |
+
"model_configs": modelConfigs,
|
| 446 |
+
"llm_model": "gpt-4o",
|
| 447 |
+
"imageModelMap": map[string]interface{}{},
|
| 448 |
+
"writingContent": nil,
|
| 449 |
+
},
|
| 450 |
+
}, nil
|
| 451 |
+
}
|
| 452 |
+
|
| 453 |
+
// createStreamResponse 创建流式响应
|
| 454 |
+
func createStreamResponse(responseId, modelName string, jsonData []byte, delta model.OpenAIDelta, finishReason *string) model.OpenAIChatCompletionResponse {
|
| 455 |
+
promptTokens := common.CountTokenText(string(jsonData), modelName)
|
| 456 |
+
completionTokens := common.CountTokenText(delta.Content, modelName)
|
| 457 |
+
return model.OpenAIChatCompletionResponse{
|
| 458 |
+
ID: responseId,
|
| 459 |
+
Object: "chat.completion.chunk",
|
| 460 |
+
Created: time.Now().Unix(),
|
| 461 |
+
Model: modelName,
|
| 462 |
+
Choices: []model.OpenAIChoice{
|
| 463 |
+
{
|
| 464 |
+
Index: 0,
|
| 465 |
+
Delta: delta,
|
| 466 |
+
FinishReason: finishReason,
|
| 467 |
+
},
|
| 468 |
+
},
|
| 469 |
+
Usage: model.OpenAIUsage{
|
| 470 |
+
PromptTokens: promptTokens,
|
| 471 |
+
CompletionTokens: completionTokens,
|
| 472 |
+
TotalTokens: promptTokens + completionTokens,
|
| 473 |
+
},
|
| 474 |
+
}
|
| 475 |
+
}
|
| 476 |
+
|
| 477 |
+
// handleStreamResponse 处理流式响应
|
| 478 |
+
func handleStreamResponse(c *gin.Context, sseChan <-chan cycletls.SSEResponse, responseId, cookie, model string, jsonData []byte) bool {
|
| 479 |
+
var projectId string
|
| 480 |
+
|
| 481 |
+
for response := range sseChan {
|
| 482 |
+
if response.Done {
|
| 483 |
+
break
|
| 484 |
+
}
|
| 485 |
+
|
| 486 |
+
data := response.Data
|
| 487 |
+
if data == "" {
|
| 488 |
+
continue
|
| 489 |
+
}
|
| 490 |
+
|
| 491 |
+
logger.Debug(c.Request.Context(), strings.TrimSpace(data))
|
| 492 |
+
|
| 493 |
+
if common.IsCloudflareChallenge(data) {
|
| 494 |
+
logger.Errorf(c.Request.Context(), "Detected Cloudflare Challenge Page")
|
| 495 |
+
c.JSON(500, gin.H{"error": "Detected Cloudflare Challenge Page"})
|
| 496 |
+
return false
|
| 497 |
+
}
|
| 498 |
+
|
| 499 |
+
if common.IsRateLimit(data) {
|
| 500 |
+
logger.Errorf(c.Request.Context(), "Cookie has reached the rate Limit")
|
| 501 |
+
c.JSON(500, gin.H{"error": "Cookie has reached the rate Limit"})
|
| 502 |
+
return false
|
| 503 |
+
}
|
| 504 |
+
|
| 505 |
+
// 处理 "data: " 前缀
|
| 506 |
+
data = strings.TrimSpace(data)
|
| 507 |
+
if !strings.HasPrefix(data, "data: ") {
|
| 508 |
+
continue
|
| 509 |
+
}
|
| 510 |
+
data = strings.TrimPrefix(data, "data: ")
|
| 511 |
+
|
| 512 |
+
var event map[string]interface{}
|
| 513 |
+
if err := json.Unmarshal([]byte(data), &event); err != nil {
|
| 514 |
+
logger.Warnf(c.Request.Context(), "Failed to unmarshal event: %v", err)
|
| 515 |
+
continue
|
| 516 |
+
}
|
| 517 |
+
|
| 518 |
+
eventType, ok := event["type"].(string)
|
| 519 |
+
if !ok {
|
| 520 |
+
continue
|
| 521 |
+
}
|
| 522 |
+
|
| 523 |
+
switch eventType {
|
| 524 |
+
case "project_start":
|
| 525 |
+
projectId, _ = event["id"].(string)
|
| 526 |
+
case "message_field_delta":
|
| 527 |
+
if err := handleMessageFieldDelta(c, event, responseId, model, jsonData); err != nil {
|
| 528 |
+
logger.Warnf(c.Request.Context(), "handleMessageFieldDelta err: %v", err)
|
| 529 |
+
return false
|
| 530 |
+
}
|
| 531 |
+
case "message_result":
|
| 532 |
+
// 删除临时会话
|
| 533 |
+
if config.AutoDelChat == 1 {
|
| 534 |
+
go func() {
|
| 535 |
+
client := cycletls.Init()
|
| 536 |
+
defer safeClose(client)
|
| 537 |
+
makeDeleteRequest(client, cookie, projectId)
|
| 538 |
+
}()
|
| 539 |
+
}
|
| 540 |
+
return handleMessageResult(c, responseId, model, jsonData)
|
| 541 |
+
}
|
| 542 |
+
}
|
| 543 |
+
return false
|
| 544 |
+
}
|
| 545 |
+
|
| 546 |
+
// handleMessageFieldDelta 处理消息字段增量
|
| 547 |
+
func handleMessageFieldDelta(c *gin.Context, event map[string]interface{}, responseId, modelName string, jsonData []byte) error {
|
| 548 |
+
fieldName, ok := event["field_name"].(string)
|
| 549 |
+
if !ok || fieldName != "session_state.answer" {
|
| 550 |
+
return nil
|
| 551 |
+
}
|
| 552 |
+
|
| 553 |
+
delta, ok := event["delta"].(string)
|
| 554 |
+
|
| 555 |
+
if !ok {
|
| 556 |
+
return nil
|
| 557 |
+
}
|
| 558 |
+
|
| 559 |
+
streamResp := createStreamResponse(responseId, modelName, jsonData, model.OpenAIDelta{Content: delta, Role: "assistant"}, nil)
|
| 560 |
+
return sendSSEvent(c, streamResp)
|
| 561 |
+
}
|
| 562 |
+
|
| 563 |
+
// handleMessageResult 处理消息结果
|
| 564 |
+
func handleMessageResult(c *gin.Context, responseId, modelName string, jsonData []byte) bool {
|
| 565 |
+
finishReason := "stop"
|
| 566 |
+
|
| 567 |
+
streamResp := createStreamResponse(responseId, modelName, jsonData, model.OpenAIDelta{}, &finishReason)
|
| 568 |
+
if err := sendSSEvent(c, streamResp); err != nil {
|
| 569 |
+
logger.Warnf(c.Request.Context(), "sendSSEvent err: %v", err)
|
| 570 |
+
return false
|
| 571 |
+
}
|
| 572 |
+
c.SSEvent("", " [DONE]")
|
| 573 |
+
return false
|
| 574 |
+
}
|
| 575 |
+
|
| 576 |
+
// sendSSEvent 发送SSE事件
|
| 577 |
+
func sendSSEvent(c *gin.Context, response model.OpenAIChatCompletionResponse) error {
|
| 578 |
+
jsonResp, err := json.Marshal(response)
|
| 579 |
+
if err != nil {
|
| 580 |
+
logger.Errorf(c.Request.Context(), "Failed to marshal response: %v", err)
|
| 581 |
+
return err
|
| 582 |
+
}
|
| 583 |
+
c.SSEvent("", " "+string(jsonResp))
|
| 584 |
+
c.Writer.Flush()
|
| 585 |
+
return nil
|
| 586 |
+
}
|
| 587 |
+
|
| 588 |
+
// makeRequest 发送HTTP请求
|
| 589 |
+
func makeRequest(client cycletls.CycleTLS, jsonData []byte, cookie string, isStream bool) (cycletls.Response, error) {
|
| 590 |
+
accept := "application/json"
|
| 591 |
+
if isStream {
|
| 592 |
+
accept = "text/event-stream"
|
| 593 |
+
}
|
| 594 |
+
|
| 595 |
+
return client.Do(apiEndpoint, cycletls.Options{
|
| 596 |
+
Timeout: 10 * 60 * 60,
|
| 597 |
+
Proxy: config.ProxyUrl, // 在每个请求中设置代理
|
| 598 |
+
Body: string(jsonData),
|
| 599 |
+
Method: "POST",
|
| 600 |
+
Headers: map[string]string{
|
| 601 |
+
"Content-Type": "application/json",
|
| 602 |
+
"Accept": accept,
|
| 603 |
+
"Origin": baseURL,
|
| 604 |
+
"Referer": baseURL + "/",
|
| 605 |
+
"Cookie": cookie,
|
| 606 |
+
},
|
| 607 |
+
}, "POST")
|
| 608 |
+
}
|
| 609 |
+
|
| 610 |
+
// makeRequest 发送HTTP请求
|
| 611 |
+
func makeImageRequest(client cycletls.CycleTLS, jsonData []byte, cookie string) (cycletls.Response, error) {
|
| 612 |
+
accept := "*/*"
|
| 613 |
+
|
| 614 |
+
return client.Do(apiEndpoint, cycletls.Options{
|
| 615 |
+
Timeout: 10 * 60 * 60,
|
| 616 |
+
Proxy: config.ProxyUrl, // 在每个请求中设置代理
|
| 617 |
+
Body: string(jsonData),
|
| 618 |
+
Method: "POST",
|
| 619 |
+
Headers: map[string]string{
|
| 620 |
+
"Content-Type": "application/json",
|
| 621 |
+
"Accept": accept,
|
| 622 |
+
"Origin": baseURL,
|
| 623 |
+
"Referer": baseURL + "/",
|
| 624 |
+
"Cookie": cookie,
|
| 625 |
+
},
|
| 626 |
+
}, "POST")
|
| 627 |
+
}
|
| 628 |
+
|
| 629 |
+
func makeDeleteRequest(client cycletls.CycleTLS, cookie, projectId string) (cycletls.Response, error) {
|
| 630 |
+
|
| 631 |
+
// 不删除环境变量中的map中的对话
|
| 632 |
+
|
| 633 |
+
for _, v := range config.ModelChatMap {
|
| 634 |
+
if v == projectId {
|
| 635 |
+
return cycletls.Response{}, nil
|
| 636 |
+
}
|
| 637 |
+
}
|
| 638 |
+
|
| 639 |
+
accept := "application/json"
|
| 640 |
+
|
| 641 |
+
return client.Do(fmt.Sprintf(deleteEndpoint, projectId), cycletls.Options{
|
| 642 |
+
Timeout: 10 * 60 * 60,
|
| 643 |
+
Proxy: config.ProxyUrl, // 在每个请求中设置代理
|
| 644 |
+
Method: "GET",
|
| 645 |
+
Headers: map[string]string{
|
| 646 |
+
"Content-Type": "application/json",
|
| 647 |
+
"Accept": accept,
|
| 648 |
+
"Origin": baseURL,
|
| 649 |
+
"Referer": baseURL + "/",
|
| 650 |
+
"Cookie": cookie,
|
| 651 |
+
},
|
| 652 |
+
}, "GET")
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
func makeGetUploadUrlRequest(client cycletls.CycleTLS, cookie string) (cycletls.Response, error) {
|
| 656 |
+
|
| 657 |
+
accept := "*/*"
|
| 658 |
+
|
| 659 |
+
return client.Do(fmt.Sprintf(uploadEndpoint), cycletls.Options{
|
| 660 |
+
Timeout: 10 * 60 * 60,
|
| 661 |
+
Proxy: config.ProxyUrl, // 在每个请求中设置代理
|
| 662 |
+
Method: "GET",
|
| 663 |
+
Headers: map[string]string{
|
| 664 |
+
"Content-Type": "application/json",
|
| 665 |
+
"Accept": accept,
|
| 666 |
+
"Origin": baseURL,
|
| 667 |
+
"Referer": baseURL + "/",
|
| 668 |
+
"Cookie": cookie,
|
| 669 |
+
},
|
| 670 |
+
}, "GET")
|
| 671 |
+
}
|
| 672 |
+
|
| 673 |
+
//func makeOptionsRequest(client cycletls.CycleTLS, uploadUrl string) (cycletls.Response, error) {
|
| 674 |
+
// return client.Do(uploadUrl, cycletls.Options{
|
| 675 |
+
// Method: "OPTIONS",
|
| 676 |
+
// Headers: map[string]string{
|
| 677 |
+
// "Accept": "*/*",
|
| 678 |
+
// "Access-Control-Request-Headers": "x-ms-blob-type",
|
| 679 |
+
// "Access-Control-Request-Method": "PUT",
|
| 680 |
+
// "Origin": "https://www.genspark.ai",
|
| 681 |
+
// "Sec-Fetch-Dest": "empty",
|
| 682 |
+
// "Sec-Fetch-Mode": "cors",
|
| 683 |
+
// "Sec-Fetch-Site": "cross-site",
|
| 684 |
+
// },
|
| 685 |
+
// UserAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36",
|
| 686 |
+
// }, "OPTIONS")
|
| 687 |
+
//}
|
| 688 |
+
|
| 689 |
+
func makeUploadRequest(client cycletls.CycleTLS, uploadUrl string, fileBytes []byte) (cycletls.Response, error) {
|
| 690 |
+
return client.Do(uploadUrl, cycletls.Options{
|
| 691 |
+
Timeout: 10 * 60 * 60,
|
| 692 |
+
Proxy: config.ProxyUrl, // 在每个请求中设置代理
|
| 693 |
+
Method: "PUT",
|
| 694 |
+
Body: string(fileBytes),
|
| 695 |
+
Headers: map[string]string{
|
| 696 |
+
"Accept": "*/*",
|
| 697 |
+
"x-ms-blob-type": "BlockBlob",
|
| 698 |
+
"Content-Type": "application/octet-stream",
|
| 699 |
+
"Content-Length": fmt.Sprintf("%d", len(fileBytes)),
|
| 700 |
+
"Origin": "https://www.genspark.ai",
|
| 701 |
+
"Sec-Fetch-Dest": "empty",
|
| 702 |
+
"Sec-Fetch-Mode": "cors",
|
| 703 |
+
"Sec-Fetch-Site": "cross-site",
|
| 704 |
+
},
|
| 705 |
+
}, "PUT")
|
| 706 |
+
}
|
| 707 |
+
|
| 708 |
+
// handleStreamRequest 处理流式请求
|
| 709 |
+
func handleStreamRequest(c *gin.Context, client cycletls.CycleTLS, cookie string, jsonData []byte, model string) {
|
| 710 |
+
c.Header("Content-Type", "text/event-stream")
|
| 711 |
+
c.Header("Cache-Control", "no-cache")
|
| 712 |
+
c.Header("Connection", "keep-alive")
|
| 713 |
+
|
| 714 |
+
responseId := fmt.Sprintf(responseIDFormat, time.Now().Format("20060102150405"))
|
| 715 |
+
|
| 716 |
+
c.Stream(func(w io.Writer) bool {
|
| 717 |
+
sseChan, err := makeStreamRequest(c, client, jsonData, cookie)
|
| 718 |
+
if err != nil {
|
| 719 |
+
logger.Errorf(c.Request.Context(), "makeStreamRequest err: %v", err)
|
| 720 |
+
return false
|
| 721 |
+
}
|
| 722 |
+
|
| 723 |
+
return handleStreamResponse(c, sseChan, responseId, cookie, model, jsonData)
|
| 724 |
+
})
|
| 725 |
+
}
|
| 726 |
+
|
| 727 |
+
func makeStreamRequest(c *gin.Context, client cycletls.CycleTLS, jsonData []byte, cookie string) (<-chan cycletls.SSEResponse, error) {
|
| 728 |
+
options := cycletls.Options{
|
| 729 |
+
Timeout: 10 * 60 * 60,
|
| 730 |
+
Proxy: config.ProxyUrl, // 在每个请求中设置代理
|
| 731 |
+
Body: string(jsonData),
|
| 732 |
+
Method: "POST",
|
| 733 |
+
Headers: map[string]string{
|
| 734 |
+
"Content-Type": "application/json",
|
| 735 |
+
"Accept": "text/event-stream",
|
| 736 |
+
"Origin": baseURL,
|
| 737 |
+
"Referer": baseURL + "/",
|
| 738 |
+
"Cookie": cookie,
|
| 739 |
+
},
|
| 740 |
+
}
|
| 741 |
+
|
| 742 |
+
logger.Debug(c.Request.Context(), fmt.Sprintf("options: %v", options))
|
| 743 |
+
|
| 744 |
+
sseChan, err := client.DoSSE(apiEndpoint, options, "POST")
|
| 745 |
+
if err != nil {
|
| 746 |
+
logger.Errorf(c, "Failed to make stream request: %v", err)
|
| 747 |
+
return nil, fmt.Errorf("Failed to make stream request: %v", err)
|
| 748 |
+
}
|
| 749 |
+
return sseChan, nil
|
| 750 |
+
}
|
| 751 |
+
|
| 752 |
+
// handleNonStreamRequest 处理非流式请求
|
| 753 |
+
func handleNonStreamRequest(c *gin.Context, client cycletls.CycleTLS, cookie string, jsonData []byte, modelName string) {
|
| 754 |
+
response, err := makeRequest(client, jsonData, cookie, false)
|
| 755 |
+
if err != nil {
|
| 756 |
+
logger.Errorf(c.Request.Context(), "makeRequest err: %v", err)
|
| 757 |
+
c.JSON(500, gin.H{"error": err.Error()})
|
| 758 |
+
return
|
| 759 |
+
}
|
| 760 |
+
|
| 761 |
+
reader := strings.NewReader(response.Body)
|
| 762 |
+
scanner := bufio.NewScanner(reader)
|
| 763 |
+
|
| 764 |
+
var content string
|
| 765 |
+
for scanner.Scan() {
|
| 766 |
+
line := scanner.Text()
|
| 767 |
+
logger.Debug(c.Request.Context(), strings.TrimSpace(line))
|
| 768 |
+
|
| 769 |
+
if common.IsCloudflareChallenge(line) {
|
| 770 |
+
logger.Errorf(c.Request.Context(), "Detected Cloudflare Challenge Page")
|
| 771 |
+
c.JSON(500, gin.H{"error": "Detected Cloudflare Challenge Page"})
|
| 772 |
+
return
|
| 773 |
+
}
|
| 774 |
+
|
| 775 |
+
if common.IsRateLimit(line) {
|
| 776 |
+
logger.Errorf(c.Request.Context(), "Cookie has reached the rate Limit")
|
| 777 |
+
c.JSON(500, gin.H{"error": "Cookie has reached the rate Limit"})
|
| 778 |
+
return
|
| 779 |
+
}
|
| 780 |
+
|
| 781 |
+
if strings.HasPrefix(line, "data: ") {
|
| 782 |
+
data := strings.TrimPrefix(line, "data: ")
|
| 783 |
+
var parsedResponse struct {
|
| 784 |
+
Type string `json:"type"`
|
| 785 |
+
FieldName string `json:"field_name"`
|
| 786 |
+
Content string `json:"content"`
|
| 787 |
+
}
|
| 788 |
+
if err := json.Unmarshal([]byte(data), &parsedResponse); err != nil {
|
| 789 |
+
logger.Warnf(c.Request.Context(), "Failed to unmarshal response: %v", err)
|
| 790 |
+
continue
|
| 791 |
+
}
|
| 792 |
+
if parsedResponse.Type == "message_result" {
|
| 793 |
+
content = parsedResponse.Content
|
| 794 |
+
break
|
| 795 |
+
}
|
| 796 |
+
}
|
| 797 |
+
}
|
| 798 |
+
|
| 799 |
+
if content == "" {
|
| 800 |
+
c.JSON(500, gin.H{"error": "No valid response content"})
|
| 801 |
+
return
|
| 802 |
+
}
|
| 803 |
+
|
| 804 |
+
promptTokens := common.CountTokenText(string(jsonData), modelName)
|
| 805 |
+
completionTokens := common.CountTokenText(content, modelName)
|
| 806 |
+
|
| 807 |
+
finishReason := "stop"
|
| 808 |
+
// 创建并返回 OpenAIChatCompletionResponse 结构
|
| 809 |
+
resp := model.OpenAIChatCompletionResponse{
|
| 810 |
+
ID: fmt.Sprintf(responseIDFormat, time.Now().Format("20060102150405")),
|
| 811 |
+
Object: "chat.completion",
|
| 812 |
+
Created: time.Now().Unix(),
|
| 813 |
+
Model: modelName,
|
| 814 |
+
Choices: []model.OpenAIChoice{
|
| 815 |
+
{
|
| 816 |
+
Message: model.OpenAIMessage{
|
| 817 |
+
Role: "assistant",
|
| 818 |
+
Content: content,
|
| 819 |
+
},
|
| 820 |
+
FinishReason: &finishReason,
|
| 821 |
+
},
|
| 822 |
+
},
|
| 823 |
+
Usage: model.OpenAIUsage{
|
| 824 |
+
PromptTokens: promptTokens,
|
| 825 |
+
CompletionTokens: completionTokens,
|
| 826 |
+
TotalTokens: promptTokens + completionTokens,
|
| 827 |
+
},
|
| 828 |
+
}
|
| 829 |
+
|
| 830 |
+
c.JSON(200, resp)
|
| 831 |
+
}
|
| 832 |
+
|
| 833 |
+
func OpenaiModels(c *gin.Context) {
|
| 834 |
+
var modelsResp []string
|
| 835 |
+
|
| 836 |
+
modelsResp = common.DefaultOpenaiModelList
|
| 837 |
+
|
| 838 |
+
var openaiModelListResponse model.OpenaiModelListResponse
|
| 839 |
+
var openaiModelResponse []model.OpenaiModelResponse
|
| 840 |
+
openaiModelListResponse.Object = "list"
|
| 841 |
+
|
| 842 |
+
for _, modelResp := range modelsResp {
|
| 843 |
+
openaiModelResponse = append(openaiModelResponse, model.OpenaiModelResponse{
|
| 844 |
+
ID: modelResp,
|
| 845 |
+
Object: "model",
|
| 846 |
+
})
|
| 847 |
+
}
|
| 848 |
+
openaiModelListResponse.Data = openaiModelResponse
|
| 849 |
+
c.JSON(http.StatusOK, openaiModelListResponse)
|
| 850 |
+
return
|
| 851 |
+
}
|
| 852 |
+
|
| 853 |
+
func ImagesForOpenAI(c *gin.Context) {
|
| 854 |
+
|
| 855 |
+
client := cycletls.Init()
|
| 856 |
+
defer safeClose(client)
|
| 857 |
+
|
| 858 |
+
var openAIReq model.OpenAIImagesGenerationRequest
|
| 859 |
+
if err := c.BindJSON(&openAIReq); err != nil {
|
| 860 |
+
c.JSON(400, gin.H{"error": err.Error()})
|
| 861 |
+
return
|
| 862 |
+
}
|
| 863 |
+
cookie, err := common.RandomElement(config.GSCookies)
|
| 864 |
+
if err != nil {
|
| 865 |
+
logger.Errorf(c.Request.Context(), err.Error())
|
| 866 |
+
return
|
| 867 |
+
}
|
| 868 |
+
|
| 869 |
+
resp, err := ImageProcess(c, client, cookie, openAIReq)
|
| 870 |
+
if err != nil {
|
| 871 |
+
logger.Errorf(c.Request.Context(), fmt.Sprintf("ImageProcess err %v\n", err))
|
| 872 |
+
c.JSON(http.StatusInternalServerError, model.OpenAIErrorResponse{
|
| 873 |
+
OpenAIError: model.OpenAIError{
|
| 874 |
+
Message: err.Error(),
|
| 875 |
+
Type: "request_error",
|
| 876 |
+
Code: "500",
|
| 877 |
+
},
|
| 878 |
+
})
|
| 879 |
+
return
|
| 880 |
+
} else {
|
| 881 |
+
c.JSON(200, resp)
|
| 882 |
+
}
|
| 883 |
+
|
| 884 |
+
}
|
| 885 |
+
|
| 886 |
+
func ImageProcess(c *gin.Context, client cycletls.CycleTLS, cookie string, openAIReq model.OpenAIImagesGenerationRequest) (*model.OpenAIImagesGenerationResponse, error) {
|
| 887 |
+
requestBody, err := createImageRequestBody(c, cookie, &openAIReq)
|
| 888 |
+
if err != nil {
|
| 889 |
+
return nil, err
|
| 890 |
+
}
|
| 891 |
+
jsonData, err := json.Marshal(requestBody)
|
| 892 |
+
if err != nil {
|
| 893 |
+
//c.JSON(500, gin.H{"error": "Failed to marshal request body"})
|
| 894 |
+
return nil, err
|
| 895 |
+
}
|
| 896 |
+
|
| 897 |
+
//client := cycletls.Init()
|
| 898 |
+
//defer client.Close()
|
| 899 |
+
|
| 900 |
+
response, err := makeImageRequest(client, jsonData, cookie)
|
| 901 |
+
|
| 902 |
+
if err != nil {
|
| 903 |
+
return nil, err
|
| 904 |
+
} else {
|
| 905 |
+
// 解析响应获取task_ids
|
| 906 |
+
projectId, taskIDs := extractTaskIDs(response.Body)
|
| 907 |
+
if len(taskIDs) == 0 {
|
| 908 |
+
return nil, fmt.Errorf("no task IDs found")
|
| 909 |
+
}
|
| 910 |
+
|
| 911 |
+
// 获取所有图片URL
|
| 912 |
+
imageURLs := pollTaskStatus(c, client, taskIDs, cookie)
|
| 913 |
+
|
| 914 |
+
// 创建响应对象
|
| 915 |
+
response := &model.OpenAIImagesGenerationResponse{
|
| 916 |
+
Created: time.Now().Unix(),
|
| 917 |
+
Data: make([]*model.OpenAIImagesGenerationDataResponse, 0, len(imageURLs)),
|
| 918 |
+
}
|
| 919 |
+
|
| 920 |
+
// 遍历 imageURLs 组装数据
|
| 921 |
+
for _, url := range imageURLs {
|
| 922 |
+
data := &model.OpenAIImagesGenerationDataResponse{
|
| 923 |
+
URL: url,
|
| 924 |
+
RevisedPrompt: openAIReq.Prompt,
|
| 925 |
+
}
|
| 926 |
+
|
| 927 |
+
if openAIReq.ResponseFormat == "b64_json" {
|
| 928 |
+
base64Str, err := getBase64ByUrl(data.URL)
|
| 929 |
+
if err != nil {
|
| 930 |
+
logger.Errorf(c.Request.Context(), fmt.Sprintf("getBase64ByUrl err %v\n", err))
|
| 931 |
+
return nil, fmt.Errorf("getBase64ByUrl err: %v\n", err)
|
| 932 |
+
}
|
| 933 |
+
data.B64Json = "data:image/webp;base64," + base64Str
|
| 934 |
+
}
|
| 935 |
+
response.Data = append(response.Data, data)
|
| 936 |
+
}
|
| 937 |
+
|
| 938 |
+
// 删除临时会话
|
| 939 |
+
if config.AutoDelChat == 1 {
|
| 940 |
+
go func() {
|
| 941 |
+
client := cycletls.Init()
|
| 942 |
+
defer safeClose(client)
|
| 943 |
+
makeDeleteRequest(client, cookie, projectId)
|
| 944 |
+
}()
|
| 945 |
+
}
|
| 946 |
+
|
| 947 |
+
//c.JSON(200, response)
|
| 948 |
+
return response, nil
|
| 949 |
+
}
|
| 950 |
+
}
|
| 951 |
+
|
| 952 |
+
func extractTaskIDs(responseBody string) (string, []string) {
|
| 953 |
+
var taskIDs []string
|
| 954 |
+
var projectId string
|
| 955 |
+
|
| 956 |
+
// 分行处理响应
|
| 957 |
+
lines := strings.Split(responseBody, "\n")
|
| 958 |
+
for _, line := range lines {
|
| 959 |
+
|
| 960 |
+
// 找到包含project_id的行
|
| 961 |
+
if strings.Contains(line, "project_start") {
|
| 962 |
+
// 去掉"data: "前缀
|
| 963 |
+
jsonStr := strings.TrimPrefix(line, "data: ")
|
| 964 |
+
|
| 965 |
+
// 解析JSON
|
| 966 |
+
var jsonResp struct {
|
| 967 |
+
ProjectID string `json:"id"`
|
| 968 |
+
}
|
| 969 |
+
if err := json.Unmarshal([]byte(jsonStr), &jsonResp); err != nil {
|
| 970 |
+
continue
|
| 971 |
+
}
|
| 972 |
+
|
| 973 |
+
// 保存project_id
|
| 974 |
+
projectId = jsonResp.ProjectID
|
| 975 |
+
}
|
| 976 |
+
|
| 977 |
+
// 找到包含task_id的行
|
| 978 |
+
if strings.Contains(line, "task_id") {
|
| 979 |
+
// 去掉"data: "前缀
|
| 980 |
+
jsonStr := strings.TrimPrefix(line, "data: ")
|
| 981 |
+
|
| 982 |
+
// 解析外层JSON
|
| 983 |
+
var outerJSON struct {
|
| 984 |
+
Content string `json:"content"`
|
| 985 |
+
}
|
| 986 |
+
if err := json.Unmarshal([]byte(jsonStr), &outerJSON); err != nil {
|
| 987 |
+
continue
|
| 988 |
+
}
|
| 989 |
+
|
| 990 |
+
// 解析内层JSON (content字段)
|
| 991 |
+
var innerJSON struct {
|
| 992 |
+
GeneratedImages []struct {
|
| 993 |
+
TaskID string `json:"task_id"`
|
| 994 |
+
} `json:"generated_images"`
|
| 995 |
+
}
|
| 996 |
+
if err := json.Unmarshal([]byte(outerJSON.Content), &innerJSON); err != nil {
|
| 997 |
+
continue
|
| 998 |
+
}
|
| 999 |
+
|
| 1000 |
+
// 提取所有task_id
|
| 1001 |
+
for _, img := range innerJSON.GeneratedImages {
|
| 1002 |
+
if img.TaskID != "" {
|
| 1003 |
+
taskIDs = append(taskIDs, img.TaskID)
|
| 1004 |
+
}
|
| 1005 |
+
}
|
| 1006 |
+
}
|
| 1007 |
+
}
|
| 1008 |
+
return projectId, taskIDs
|
| 1009 |
+
}
|
| 1010 |
+
|
| 1011 |
+
func pollTaskStatus(c *gin.Context, client cycletls.CycleTLS, taskIDs []string, cookie string) []string {
|
| 1012 |
+
var imageURLs []string
|
| 1013 |
+
|
| 1014 |
+
for _, taskID := range taskIDs {
|
| 1015 |
+
for {
|
| 1016 |
+
// 构建请求URL
|
| 1017 |
+
url := fmt.Sprintf("https://www.genspark.ai/api/spark/image_generation_task_status?task_id=%s", taskID)
|
| 1018 |
+
|
| 1019 |
+
// 发送请求
|
| 1020 |
+
response, err := client.Do(url, cycletls.Options{
|
| 1021 |
+
Timeout: 10 * 60 * 60,
|
| 1022 |
+
Proxy: config.ProxyUrl, // 在每个请求中设置代理
|
| 1023 |
+
Method: "GET",
|
| 1024 |
+
Headers: map[string]string{
|
| 1025 |
+
"Cookie": cookie,
|
| 1026 |
+
},
|
| 1027 |
+
}, "GET")
|
| 1028 |
+
|
| 1029 |
+
if err != nil {
|
| 1030 |
+
continue
|
| 1031 |
+
}
|
| 1032 |
+
|
| 1033 |
+
var result struct {
|
| 1034 |
+
Data struct {
|
| 1035 |
+
ImageURLsNowatermark []string `json:"image_urls_nowatermark"`
|
| 1036 |
+
Status string `json:"status"`
|
| 1037 |
+
}
|
| 1038 |
+
}
|
| 1039 |
+
|
| 1040 |
+
if err := json.Unmarshal([]byte(response.Body), &result); err != nil {
|
| 1041 |
+
continue
|
| 1042 |
+
}
|
| 1043 |
+
|
| 1044 |
+
// 如果状态成功且有图片URL
|
| 1045 |
+
if result.Data.Status == "SUCCESS" && len(result.Data.ImageURLsNowatermark) > 0 {
|
| 1046 |
+
imageURLs = append(imageURLs, result.Data.ImageURLsNowatermark...)
|
| 1047 |
+
break
|
| 1048 |
+
}
|
| 1049 |
+
|
| 1050 |
+
// 等待1秒后重试
|
| 1051 |
+
time.Sleep(500 * time.Millisecond)
|
| 1052 |
+
}
|
| 1053 |
+
}
|
| 1054 |
+
|
| 1055 |
+
return imageURLs
|
| 1056 |
+
}
|
| 1057 |
+
|
| 1058 |
+
func getBase64ByUrl(url string) (string, error) {
|
| 1059 |
+
resp, err := http.Get(url)
|
| 1060 |
+
if err != nil {
|
| 1061 |
+
return "", fmt.Errorf("failed to fetch image: %w", err)
|
| 1062 |
+
}
|
| 1063 |
+
defer resp.Body.Close()
|
| 1064 |
+
|
| 1065 |
+
if resp.StatusCode != http.StatusOK {
|
| 1066 |
+
return "", fmt.Errorf("received non-200 status code: %d", resp.StatusCode)
|
| 1067 |
+
}
|
| 1068 |
+
|
| 1069 |
+
imgData, err := io.ReadAll(resp.Body)
|
| 1070 |
+
if err != nil {
|
| 1071 |
+
return "", fmt.Errorf("failed to read image data: %w", err)
|
| 1072 |
+
}
|
| 1073 |
+
|
| 1074 |
+
// Encode the image data to Base64
|
| 1075 |
+
base64Str := base64.StdEncoding.EncodeToString(imgData)
|
| 1076 |
+
return base64Str, nil
|
| 1077 |
+
}
|
| 1078 |
+
|
| 1079 |
+
func safeClose(client cycletls.CycleTLS) {
|
| 1080 |
+
if client.ReqChan != nil {
|
| 1081 |
+
close(client.ReqChan)
|
| 1082 |
+
}
|
| 1083 |
+
if client.RespChan != nil {
|
| 1084 |
+
close(client.RespChan)
|
| 1085 |
+
}
|
| 1086 |
+
}
|
docker-compose.yml
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version: '3.4'
|
| 2 |
+
|
| 3 |
+
services:
|
| 4 |
+
genspark2api:
|
| 5 |
+
image: deanxv/genspark2api:latest
|
| 6 |
+
container_name: genspark2api
|
| 7 |
+
restart: always
|
| 8 |
+
ports:
|
| 9 |
+
- "7055:7055"
|
| 10 |
+
volumes:
|
| 11 |
+
- ./data:/app/genspark2api/data
|
| 12 |
+
environment:
|
| 13 |
+
- GS_COOKIE=****** # cookie (多个请以,分隔)
|
| 14 |
+
- API_SECRET=123456 # [可选]接口密钥-修改此行为请求头校验的值(多个请以,分隔)
|
| 15 |
+
- TZ=Asia/Shanghai
|
docs/img.png
ADDED
|
docs/img2.png
ADDED
|
docs/img3.png
ADDED
|
docs/img4.png
ADDED
|
docs/img5.png
ADDED
|
go.mod
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
module genspark2api
|
| 2 |
+
|
| 3 |
+
go 1.23
|
| 4 |
+
|
| 5 |
+
require (
|
| 6 |
+
github.com/deanxv/CycleTLS/cycletls v0.0.0-20241224120349-dbd0a00a5095
|
| 7 |
+
github.com/gin-contrib/cors v1.7.2
|
| 8 |
+
github.com/gin-gonic/gin v1.10.0
|
| 9 |
+
github.com/google/uuid v1.6.0
|
| 10 |
+
github.com/json-iterator/go v1.1.12
|
| 11 |
+
github.com/pkoukk/tiktoken-go v0.1.7
|
| 12 |
+
github.com/samber/lo v1.47.0
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
require (
|
| 16 |
+
github.com/Danny-Dasilva/fhttp v0.0.0-20240217042913-eeeb0b347ce1 // indirect
|
| 17 |
+
github.com/andybalholm/brotli v1.1.0 // indirect
|
| 18 |
+
github.com/bytedance/sonic v1.11.6 // indirect
|
| 19 |
+
github.com/bytedance/sonic/loader v0.1.1 // indirect
|
| 20 |
+
github.com/cloudflare/circl v1.3.7 // indirect
|
| 21 |
+
github.com/cloudwego/base64x v0.1.4 // indirect
|
| 22 |
+
github.com/cloudwego/iasm v0.2.0 // indirect
|
| 23 |
+
github.com/dlclark/regexp2 v1.10.0 // indirect
|
| 24 |
+
github.com/gabriel-vasile/mimetype v1.4.3 // indirect
|
| 25 |
+
github.com/gin-contrib/sse v0.1.0 // indirect
|
| 26 |
+
github.com/go-playground/locales v0.14.1 // indirect
|
| 27 |
+
github.com/go-playground/universal-translator v0.18.1 // indirect
|
| 28 |
+
github.com/go-playground/validator/v10 v10.20.0 // indirect
|
| 29 |
+
github.com/goccy/go-json v0.10.2 // indirect
|
| 30 |
+
github.com/gorilla/websocket v1.5.1 // indirect
|
| 31 |
+
github.com/klauspost/compress v1.17.7 // indirect
|
| 32 |
+
github.com/klauspost/cpuid/v2 v2.2.7 // indirect
|
| 33 |
+
github.com/kr/text v0.2.0 // indirect
|
| 34 |
+
github.com/leodido/go-urn v1.4.0 // indirect
|
| 35 |
+
github.com/mattn/go-isatty v0.0.20 // indirect
|
| 36 |
+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
| 37 |
+
github.com/modern-go/reflect2 v1.0.2 // indirect
|
| 38 |
+
github.com/pelletier/go-toml/v2 v2.2.2 // indirect
|
| 39 |
+
github.com/quic-go/quic-go v0.41.0 // indirect
|
| 40 |
+
github.com/refraction-networking/utls v1.6.2 // indirect
|
| 41 |
+
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
| 42 |
+
github.com/ugorji/go/codec v1.2.12 // indirect
|
| 43 |
+
golang.org/x/arch v0.8.0 // indirect
|
| 44 |
+
golang.org/x/crypto v0.23.0 // indirect
|
| 45 |
+
golang.org/x/net v0.25.0 // indirect
|
| 46 |
+
golang.org/x/sys v0.20.0 // indirect
|
| 47 |
+
golang.org/x/text v0.16.0 // indirect
|
| 48 |
+
google.golang.org/protobuf v1.34.1 // indirect
|
| 49 |
+
gopkg.in/yaml.v3 v3.0.1 // indirect
|
| 50 |
+
h12.io/socks v1.0.3 // indirect
|
| 51 |
+
)
|
go.sum
ADDED
|
@@ -0,0 +1,483 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
| 2 |
+
cloud.google.com/go v0.31.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
| 3 |
+
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
| 4 |
+
cloud.google.com/go v0.37.0/go.mod h1:TS1dMSSfndXH133OKGwekG838Om/cQT0BUHV3HcBgoo=
|
| 5 |
+
dmitri.shuralyov.com/app/changes v0.0.0-20180602232624-0a106ad413e3/go.mod h1:Yl+fi1br7+Rr3LqpNJf1/uxUdtRUV+Tnj0o93V2B9MU=
|
| 6 |
+
dmitri.shuralyov.com/html/belt v0.0.0-20180602232347-f7d459c86be0/go.mod h1:JLBrvjyP0v+ecvNYvCpyZgu5/xkfAUhi6wJj28eUfSU=
|
| 7 |
+
dmitri.shuralyov.com/service/change v0.0.0-20181023043359-a85b471d5412/go.mod h1:a1inKt/atXimZ4Mv927x+r7UpyzRUf4emIoiiSC2TN4=
|
| 8 |
+
dmitri.shuralyov.com/state v0.0.0-20180228185332-28bcc343414c/go.mod h1:0PRwlb0D6DFvNNtx+9ybjezNCa8XF0xaYcETyp6rHWU=
|
| 9 |
+
git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGynbRyZ4dJvy6G277gSllfV2HJqblrnkyeyg=
|
| 10 |
+
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
| 11 |
+
github.com/Danny-Dasilva/fhttp v0.0.0-20240217042913-eeeb0b347ce1 h1:/lqhaiz7xdPr6kuaW1tQ/8DdpWdxkdyd9W/6EHz4oRw=
|
| 12 |
+
github.com/Danny-Dasilva/fhttp v0.0.0-20240217042913-eeeb0b347ce1/go.mod h1:Hvab/V/YKCDXsEpKYKHjAXH5IFOmoq9FsfxjztEqvDc=
|
| 13 |
+
github.com/andybalholm/brotli v1.0.5/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
| 14 |
+
github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
|
| 15 |
+
github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
|
| 16 |
+
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
|
| 17 |
+
github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
|
| 18 |
+
github.com/bradfitz/go-smtpd v0.0.0-20170404230938-deb6d6237625/go.mod h1:HYsPBTaaSFSlLx/70C2HPIMNZpVV8+vt/A+FMnYP11g=
|
| 19 |
+
github.com/buger/jsonparser v0.0.0-20181115193947-bf1c66bbce23/go.mod h1:bbYlZJ7hK1yFx9hf58LP0zeX7UjIGs20ufpu3evjr+s=
|
| 20 |
+
github.com/bwesterb/go-ristretto v1.2.3/go.mod h1:fUIoIZaG73pV5biE2Blr2xEzDoMj7NFEuV9ekS419A0=
|
| 21 |
+
github.com/bytedance/sonic v1.11.6 h1:oUp34TzMlL+OY1OUWxHqsdkgC/Zfc85zGqw9siXjrc0=
|
| 22 |
+
github.com/bytedance/sonic v1.11.6/go.mod h1:LysEHSvpvDySVdC2f87zGWf6CIKJcAvqab1ZaiQtds4=
|
| 23 |
+
github.com/bytedance/sonic/loader v0.1.1 h1:c+e5Pt1k/cy5wMveRDyk2X4B9hF4g7an8N3zCYjJFNM=
|
| 24 |
+
github.com/bytedance/sonic/loader v0.1.1/go.mod h1:ncP89zfokxS5LZrJxl5z0UJcsk4M4yY2JpfqGeCtNLU=
|
| 25 |
+
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
| 26 |
+
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
| 27 |
+
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
| 28 |
+
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
| 29 |
+
github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=
|
| 30 |
+
github.com/cloudflare/circl v1.3.7 h1:qlCDlTPz2n9fu58M0Nh1J/JzcFpfgkFHHX3O35r5vcU=
|
| 31 |
+
github.com/cloudflare/circl v1.3.7/go.mod h1:sRTcRWXGLrKw6yIGJ+l7amYJFfAXbZG0kBSc8r4zxgA=
|
| 32 |
+
github.com/cloudwego/base64x v0.1.4 h1:jwCgWpFanWmN8xoIUHa2rtzmkd5J2plF/dnLS6Xd/0Y=
|
| 33 |
+
github.com/cloudwego/base64x v0.1.4/go.mod h1:0zlkT4Wn5C6NdauXdJRhSKRlJvmclQ1hhJgA0rcu/8w=
|
| 34 |
+
github.com/cloudwego/iasm v0.2.0 h1:1KNIy1I1H9hNNFEEH3DVnI4UujN+1zjpuk6gwHLTssg=
|
| 35 |
+
github.com/cloudwego/iasm v0.2.0/go.mod h1:8rXZaNYT2n95jn+zTI1sDr+IgcD2GVs0nlbbQPiEFhY=
|
| 36 |
+
github.com/coreos/go-systemd v0.0.0-20181012123002-c6f51f82210d/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
| 37 |
+
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
| 38 |
+
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
| 39 |
+
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
| 40 |
+
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
| 41 |
+
github.com/deanxv/CycleTLS/cycletls v0.0.0-20241224120349-dbd0a00a5095 h1:uQYgdsARoT2h/GyCjXZP2FLthdOZCM9uMK9alCOE5ok=
|
| 42 |
+
github.com/deanxv/CycleTLS/cycletls v0.0.0-20241224120349-dbd0a00a5095/go.mod h1:eAyIp7Lbyq6WnJDGicqf7nYr0bTj5FQ0HXQbIesuuJ8=
|
| 43 |
+
github.com/dlclark/regexp2 v1.10.0 h1:+/GIL799phkJqYW+3YbOd8LCcbHzT0Pbo8zl70MHsq0=
|
| 44 |
+
github.com/dlclark/regexp2 v1.10.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
| 45 |
+
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
| 46 |
+
github.com/flynn/go-shlex v0.0.0-20150515145356-3f9db97f8568/go.mod h1:xEzjJPgXI435gkrCt3MPfRiAkVrwSbHsst4LCFVfpJc=
|
| 47 |
+
github.com/francoispqt/gojay v1.2.13/go.mod h1:ehT5mTG4ua4581f1++1WLG0vPdaA9HaiDsoyrBGkyDY=
|
| 48 |
+
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
| 49 |
+
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
| 50 |
+
github.com/gabriel-vasile/mimetype v1.4.3 h1:in2uUcidCuFcDKtdcBxlR0rJ1+fsokWf+uqxgUFjbI0=
|
| 51 |
+
github.com/gabriel-vasile/mimetype v1.4.3/go.mod h1:d8uq/6HKRL6CGdk+aubisF/M5GcPfT7nKyLpA0lbSSk=
|
| 52 |
+
github.com/gaukas/godicttls v0.0.4/go.mod h1:l6EenT4TLWgTdwslVb4sEMOCf7Bv0JAK67deKr9/NCI=
|
| 53 |
+
github.com/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04=
|
| 54 |
+
github.com/gin-contrib/cors v1.7.2 h1:oLDHxdg8W/XDoN/8zamqk/Drgt4oVZDvaV0YmvVICQw=
|
| 55 |
+
github.com/gin-contrib/cors v1.7.2/go.mod h1:SUJVARKgQ40dmrzgXEVxj2m7Ig1v1qIboQkPDTQ9t2E=
|
| 56 |
+
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
| 57 |
+
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
| 58 |
+
github.com/gin-gonic/gin v1.10.0 h1:nTuyha1TYqgedzytsKYqna+DfLos46nTv2ygFy86HFU=
|
| 59 |
+
github.com/gin-gonic/gin v1.10.0/go.mod h1:4PMNQiOhvDRa013RKVbsiNwoyezlm2rm0uX/T7kzp5Y=
|
| 60 |
+
github.com/gliderlabs/ssh v0.1.1/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
|
| 61 |
+
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
|
| 62 |
+
github.com/go-logr/logr v1.2.3/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
| 63 |
+
github.com/go-logr/logr v1.2.4 h1:g01GSCwiDw2xSZfjJ2/T9M+S6pFdcNtFYsp+Y43HYDQ=
|
| 64 |
+
github.com/go-logr/logr v1.2.4/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A=
|
| 65 |
+
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
| 66 |
+
github.com/go-playground/assert/v2 v2.2.0/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
| 67 |
+
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
| 68 |
+
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
| 69 |
+
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
| 70 |
+
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
| 71 |
+
github.com/go-playground/validator/v10 v10.20.0 h1:K9ISHbSaI0lyB2eWMPJo+kOS/FBExVwjEviJTixqxL8=
|
| 72 |
+
github.com/go-playground/validator/v10 v10.20.0/go.mod h1:dbuPbCMFw/DrkbEynArYaCwl3amGuJotoKCe95atGMM=
|
| 73 |
+
github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
| 74 |
+
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI=
|
| 75 |
+
github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls=
|
| 76 |
+
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
| 77 |
+
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
| 78 |
+
github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ=
|
| 79 |
+
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
| 80 |
+
github.com/golang/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:tluoj9z5200jBnyusfRPU2LqT6J+DAorxEvtC7LHB+E=
|
| 81 |
+
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
| 82 |
+
github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
| 83 |
+
github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs=
|
| 84 |
+
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
| 85 |
+
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
| 86 |
+
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
| 87 |
+
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
| 88 |
+
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
| 89 |
+
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
| 90 |
+
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
| 91 |
+
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
| 92 |
+
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
| 93 |
+
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
| 94 |
+
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
| 95 |
+
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
|
| 96 |
+
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
| 97 |
+
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
| 98 |
+
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
| 99 |
+
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
| 100 |
+
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
| 101 |
+
github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
| 102 |
+
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
| 103 |
+
github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
|
| 104 |
+
github.com/google/go-github v17.0.0+incompatible/go.mod h1:zLgOLi98H3fifZn+44m+umXrS52loVEgC2AApnigrVQ=
|
| 105 |
+
github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck=
|
| 106 |
+
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
| 107 |
+
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
| 108 |
+
github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc=
|
| 109 |
+
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38 h1:yAJXTCF9TqKcTiHJAE8dj7HMvPfh66eeA2JYW7eFpSE=
|
| 110 |
+
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
| 111 |
+
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
| 112 |
+
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
| 113 |
+
github.com/googleapis/gax-go v2.0.0+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY=
|
| 114 |
+
github.com/googleapis/gax-go/v2 v2.0.3/go.mod h1:LLvjysVCY1JZeum8Z6l8qUty8fiNwE08qbEPm1M08qg=
|
| 115 |
+
github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY=
|
| 116 |
+
github.com/gorilla/websocket v1.5.1 h1:gmztn0JnHVt9JZquRuzLw3g4wouNVzKL15iLr/zn/QY=
|
| 117 |
+
github.com/gorilla/websocket v1.5.1/go.mod h1:x3kM2JMyaluk02fnUJpQuwD2dCS5NDG2ZHL0uE0tcaY=
|
| 118 |
+
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
|
| 119 |
+
github.com/grpc-ecosystem/grpc-gateway v1.5.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw=
|
| 120 |
+
github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364 h1:5XxdakFhqd9dnXoAZy1Mb2R/DZ6D1e+0bGC/JhucGYI=
|
| 121 |
+
github.com/h12w/go-socks5 v0.0.0-20200522160539-76189e178364/go.mod h1:eDJQioIyy4Yn3MVivT7rv/39gAJTrA7lgmYr8EW950c=
|
| 122 |
+
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
| 123 |
+
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
| 124 |
+
github.com/jellevandenhooff/dkim v0.0.0-20150330215556-f50fe3d243e1/go.mod h1:E0B/fFc00Y+Rasa88328GlI/XbtyysCtTHZS8h7IrBU=
|
| 125 |
+
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=
|
| 126 |
+
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
| 127 |
+
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
| 128 |
+
github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU=
|
| 129 |
+
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
| 130 |
+
github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
| 131 |
+
github.com/klauspost/compress v1.17.7 h1:ehO88t2UGzQK66LMdE8tibEd1ErmzZjNEqWkjLAKQQg=
|
| 132 |
+
github.com/klauspost/compress v1.17.7/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw=
|
| 133 |
+
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
| 134 |
+
github.com/klauspost/cpuid/v2 v2.2.7 h1:ZWSB3igEs+d0qvnxR/ZBzXVmxkgt8DdzP6m9pfuVLDM=
|
| 135 |
+
github.com/klauspost/cpuid/v2 v2.2.7/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
| 136 |
+
github.com/knz/go-libedit v1.10.1/go.mod h1:MZTVkCWyz0oBc7JOWP3wNAzd002ZbM/5hgShxwh4x8M=
|
| 137 |
+
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
| 138 |
+
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
|
| 139 |
+
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
| 140 |
+
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
| 141 |
+
github.com/kr/pty v1.1.3/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
| 142 |
+
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
| 143 |
+
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
| 144 |
+
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
| 145 |
+
github.com/leodido/go-urn v1.4.0 h1:WT9HwE9SGECu3lg4d/dIA+jxlljEa1/ffXKmRjqdmIQ=
|
| 146 |
+
github.com/leodido/go-urn v1.4.0/go.mod h1:bvxc+MVxLKB4z00jd1z+Dvzr47oO32F/QSNjSBOlFxI=
|
| 147 |
+
github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI=
|
| 148 |
+
github.com/mailru/easyjson v0.0.0-20190312143242-1de009706dbe/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
| 149 |
+
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
| 150 |
+
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
| 151 |
+
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
|
| 152 |
+
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
|
| 153 |
+
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
| 154 |
+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
| 155 |
+
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
| 156 |
+
github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0=
|
| 157 |
+
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
| 158 |
+
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
| 159 |
+
github.com/neelance/astrewrite v0.0.0-20160511093645-99348263ae86/go.mod h1:kHJEU3ofeGjhHklVoIGuVj85JJwZ6kWPaJwCIxgnFmo=
|
| 160 |
+
github.com/neelance/sourcemap v0.0.0-20151028013722-8c68805598ab/go.mod h1:Qr6/a/Q4r9LP1IltGz7tA7iOK1WonHEYhu1HRBA7ZiM=
|
| 161 |
+
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
| 162 |
+
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
| 163 |
+
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
| 164 |
+
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
| 165 |
+
github.com/onsi/ginkgo v1.16.4 h1:29JGrr5oVBm5ulCWet69zQkzWipVXIol6ygQUe/EzNc=
|
| 166 |
+
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
| 167 |
+
github.com/onsi/ginkgo/v2 v2.1.3/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
|
| 168 |
+
github.com/onsi/ginkgo/v2 v2.1.4/go.mod h1:um6tUpWM/cxCK3/FK8BXqEiUMUwRgSM4JXG47RKZmLU=
|
| 169 |
+
github.com/onsi/ginkgo/v2 v2.1.6/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk=
|
| 170 |
+
github.com/onsi/ginkgo/v2 v2.2.0/go.mod h1:MEH45j8TBi6u9BMogfbp0stKC5cdGjumZj5Y7AG4VIk=
|
| 171 |
+
github.com/onsi/ginkgo/v2 v2.3.0/go.mod h1:Eew0uilEqZmIEZr8JrvYlvOM7Rr6xzTmMV8AyFNU9d0=
|
| 172 |
+
github.com/onsi/ginkgo/v2 v2.4.0/go.mod h1:iHkDK1fKGcBoEHT5W7YBq4RFWaQulw+caOMkAt4OrFo=
|
| 173 |
+
github.com/onsi/ginkgo/v2 v2.5.0/go.mod h1:Luc4sArBICYCS8THh8v3i3i5CuSZO+RaQRaJoeNwomw=
|
| 174 |
+
github.com/onsi/ginkgo/v2 v2.7.0/go.mod h1:yjiuMwPokqY1XauOgju45q3sJt6VzQ/Fict1LFVcsAo=
|
| 175 |
+
github.com/onsi/ginkgo/v2 v2.8.1/go.mod h1:N1/NbDngAFcSLdyZ+/aYTYGSlq9qMCS/cNKGJjy+csc=
|
| 176 |
+
github.com/onsi/ginkgo/v2 v2.9.0/go.mod h1:4xkjoL/tZv4SMWeww56BU5kAt19mVB47gTWxmrTcxyk=
|
| 177 |
+
github.com/onsi/ginkgo/v2 v2.9.1/go.mod h1:FEcmzVcCHl+4o9bQZVab+4dC9+j+91t2FHSzmGAPfuo=
|
| 178 |
+
github.com/onsi/ginkgo/v2 v2.9.2/go.mod h1:WHcJJG2dIlcCqVfBAwUCrJxSPFb6v4azBwgxeMeDuts=
|
| 179 |
+
github.com/onsi/ginkgo/v2 v2.9.5 h1:+6Hr4uxzP4XIUyAkg61dWBw8lb/gc4/X5luuxN/EC+Q=
|
| 180 |
+
github.com/onsi/ginkgo/v2 v2.9.5/go.mod h1:tvAoo1QUJwNEU2ITftXTpR7R1RbCzoZUOs3RonqW57k=
|
| 181 |
+
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
| 182 |
+
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
| 183 |
+
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
| 184 |
+
github.com/onsi/gomega v1.19.0/go.mod h1:LY+I3pBVzYsTBU1AnDwOSxaYi9WoWiqgwooUqq9yPro=
|
| 185 |
+
github.com/onsi/gomega v1.20.1/go.mod h1:DtrZpjmvpn2mPm4YWQa0/ALMDj9v4YxLgojwPeREyVo=
|
| 186 |
+
github.com/onsi/gomega v1.21.1/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8luStNc=
|
| 187 |
+
github.com/onsi/gomega v1.22.1/go.mod h1:x6n7VNe4hw0vkyYUM4mjIXx3JbLiPaBPNgB7PRQ1tuM=
|
| 188 |
+
github.com/onsi/gomega v1.24.0/go.mod h1:Z/NWtiqwBrwUt4/2loMmHL63EDLnYHmVbuBpDr2vQAg=
|
| 189 |
+
github.com/onsi/gomega v1.24.1/go.mod h1:3AOiACssS3/MajrniINInwbfOOtfZvplPzuRSmvt1jM=
|
| 190 |
+
github.com/onsi/gomega v1.26.0/go.mod h1:r+zV744Re+DiYCIPRlYOTxn0YkOLcAnW8k1xXdMPGhM=
|
| 191 |
+
github.com/onsi/gomega v1.27.1/go.mod h1:aHX5xOykVYzWOV4WqQy0sy8BQptgukenXpCXfadcIAw=
|
| 192 |
+
github.com/onsi/gomega v1.27.3/go.mod h1:5vG284IBtfDAmDyrK+eGyZmUgUlmi+Wngqo557cZ6Gw=
|
| 193 |
+
github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ=
|
| 194 |
+
github.com/onsi/gomega v1.27.6 h1:ENqfyGeS5AX/rlXDd/ETokDz93u0YufY1Pgxuy/PvWE=
|
| 195 |
+
github.com/onsi/gomega v1.27.6/go.mod h1:PIQNjfQwkP3aQAH7lf7j87O/5FiNr+ZR8+ipb+qQlhg=
|
| 196 |
+
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
|
| 197 |
+
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
|
| 198 |
+
github.com/pelletier/go-toml/v2 v2.2.2/go.mod h1:1t835xjRzz80PqgE6HHgN2JOsmgYu/h4qDAS4n929Rs=
|
| 199 |
+
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 h1:JhzVVoYvbOACxoUmOs6V/G4D5nPVUW73rKvXxP4XUJc=
|
| 200 |
+
github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2/go.mod h1:iIss55rKnNBTvrwdmkUpLnDpZoAHvWaiq5+iMmen4AE=
|
| 201 |
+
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
| 202 |
+
github.com/pkoukk/tiktoken-go v0.1.7 h1:qOBHXX4PHtvIvmOtyg1EeKlwFRiMKAcoMp4Q+bLQDmw=
|
| 203 |
+
github.com/pkoukk/tiktoken-go v0.1.7/go.mod h1:9NiV+i9mJKGj1rYOT+njbv+ZwA/zJxYdewGl6qVatpg=
|
| 204 |
+
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
| 205 |
+
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
| 206 |
+
github.com/prometheus/client_golang v0.8.0/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
|
| 207 |
+
github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo=
|
| 208 |
+
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
|
| 209 |
+
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
|
| 210 |
+
github.com/quic-go/qpack v0.4.0/go.mod h1:UZVnYIfi5GRk+zI9UMaCPsmZ2xKJP7XBUvVyT1Knj9A=
|
| 211 |
+
github.com/quic-go/qtls-go1-20 v0.3.1/go.mod h1:X9Nh97ZL80Z+bX/gUXMbipO6OxdiDi58b/fMC9mAL+k=
|
| 212 |
+
github.com/quic-go/quic-go v0.37.4/go.mod h1:YsbH1r4mSHPJcLF4k4zruUkLBqctEMBDR6VPvcYjIsU=
|
| 213 |
+
github.com/quic-go/quic-go v0.41.0 h1:aD8MmHfgqTURWNJy48IYFg2OnxwHT3JL7ahGs73lb4k=
|
| 214 |
+
github.com/quic-go/quic-go v0.41.0/go.mod h1:qCkNjqczPEvgsOnxZ0eCD14lv+B2LHlFAB++CNOh9hA=
|
| 215 |
+
github.com/refraction-networking/utls v1.5.4/go.mod h1:SPuDbBmgLGp8s+HLNc83FuavwZCFoMmExj+ltUHiHUw=
|
| 216 |
+
github.com/refraction-networking/utls v1.6.2 h1:iTeeGY0o6nMNcGyirxkD5bFIsVctP5InGZ3E0HrzS7k=
|
| 217 |
+
github.com/refraction-networking/utls v1.6.2/go.mod h1:yil9+7qSl+gBwJqztoQseO6Pr3h62pQoY1lXiNR/FPs=
|
| 218 |
+
github.com/rogpeppe/go-internal v1.8.0 h1:FCbCCtXNOY3UtUuHUYaghJg4y7Fd14rXifAYUAtL9R8=
|
| 219 |
+
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
| 220 |
+
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
| 221 |
+
github.com/samber/lo v1.47.0 h1:z7RynLwP5nbyRscyvcD043DWYoOcYRv3mV8lBeqOCLc=
|
| 222 |
+
github.com/samber/lo v1.47.0/go.mod h1:RmDH9Ct32Qy3gduHQuKJ3gW1fMHAnE/fAzQuf6He5cU=
|
| 223 |
+
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
| 224 |
+
github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY=
|
| 225 |
+
github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM=
|
| 226 |
+
github.com/shurcooL/github_flavored_markdown v0.0.0-20181002035957-2122de532470/go.mod h1:2dOwnU2uBioM+SGy2aZoq1f/Sd1l9OkAeAUvjSyvgU0=
|
| 227 |
+
github.com/shurcooL/go v0.0.0-20180423040247-9e1955d9fb6e/go.mod h1:TDJrrUr11Vxrven61rcy3hJMUqaf/CLWYhHNPmT14Lk=
|
| 228 |
+
github.com/shurcooL/go-goon v0.0.0-20170922171312-37c2f522c041/go.mod h1:N5mDOmsrJOB+vfqUK+7DmDyjhSLIIBnXo9lvZJj3MWQ=
|
| 229 |
+
github.com/shurcooL/gofontwoff v0.0.0-20180329035133-29b52fc0a18d/go.mod h1:05UtEgK5zq39gLST6uB0cf3NEHjETfB4Fgr3Gx5R9Vw=
|
| 230 |
+
github.com/shurcooL/gopherjslib v0.0.0-20160914041154-feb6d3990c2c/go.mod h1:8d3azKNyqcHP1GaQE/c6dDgjkgSx2BZ4IoEi4F1reUI=
|
| 231 |
+
github.com/shurcooL/highlight_diff v0.0.0-20170515013008-09bb4053de1b/go.mod h1:ZpfEhSmds4ytuByIcDnOLkTHGUI6KNqRNPDLHDk+mUU=
|
| 232 |
+
github.com/shurcooL/highlight_go v0.0.0-20181028180052-98c3abbbae20/go.mod h1:UDKB5a1T23gOMUJrI+uSuH0VRDStOiUVSjBTRDVBVag=
|
| 233 |
+
github.com/shurcooL/home v0.0.0-20181020052607-80b7ffcb30f9/go.mod h1:+rgNQw2P9ARFAs37qieuu7ohDNQ3gds9msbT2yn85sg=
|
| 234 |
+
github.com/shurcooL/htmlg v0.0.0-20170918183704-d01228ac9e50/go.mod h1:zPn1wHpTIePGnXSHpsVPWEktKXHr6+SS6x/IKRb7cpw=
|
| 235 |
+
github.com/shurcooL/httperror v0.0.0-20170206035902-86b7830d14cc/go.mod h1:aYMfkZ6DWSJPJ6c4Wwz3QtW22G7mf/PEgaB9k/ik5+Y=
|
| 236 |
+
github.com/shurcooL/httpfs v0.0.0-20171119174359-809beceb2371/go.mod h1:ZY1cvUeJuFPAdZ/B6v7RHavJWZn2YPVFQ1OSXhCGOkg=
|
| 237 |
+
github.com/shurcooL/httpgzip v0.0.0-20180522190206-b1c53ac65af9/go.mod h1:919LwcH0M7/W4fcZ0/jy0qGght1GIhqyS/EgWGH2j5Q=
|
| 238 |
+
github.com/shurcooL/issues v0.0.0-20181008053335-6292fdc1e191/go.mod h1:e2qWDig5bLteJ4fwvDAc2NHzqFEthkqn7aOZAOpj+PQ=
|
| 239 |
+
github.com/shurcooL/issuesapp v0.0.0-20180602232740-048589ce2241/go.mod h1:NPpHK2TI7iSaM0buivtFUc9offApnI0Alt/K8hcHy0I=
|
| 240 |
+
github.com/shurcooL/notifications v0.0.0-20181007000457-627ab5aea122/go.mod h1:b5uSkrEVM1jQUspwbixRBhaIjIzL2xazXp6kntxYle0=
|
| 241 |
+
github.com/shurcooL/octicon v0.0.0-20181028054416-fa4f57f9efb2/go.mod h1:eWdoE5JD4R5UVWDucdOPg1g2fqQRq78IQa9zlOV1vpQ=
|
| 242 |
+
github.com/shurcooL/reactions v0.0.0-20181006231557-f2e0b4ca5b82/go.mod h1:TCR1lToEk4d2s07G3XGfz2QrgHXg4RJBvjrOozvoWfk=
|
| 243 |
+
github.com/shurcooL/sanitized_anchor_name v0.0.0-20170918181015-86672fcb3f95/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc=
|
| 244 |
+
github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
|
| 245 |
+
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
|
| 246 |
+
github.com/sourcegraph/annotate v0.0.0-20160123013949-f4cad6c6324d/go.mod h1:UdhH50NIW0fCiwBSr0co2m7BnFLdv4fQTgdqdJTHFeE=
|
| 247 |
+
github.com/sourcegraph/syntaxhighlight v0.0.0-20170531221838-bd320f5d308e/go.mod h1:HuIsMU8RRBOtsCgI77wP899iHVBQpCmg4ErYMZB+2IA=
|
| 248 |
+
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
| 249 |
+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
| 250 |
+
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
| 251 |
+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
|
| 252 |
+
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
| 253 |
+
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
| 254 |
+
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
| 255 |
+
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
| 256 |
+
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
| 257 |
+
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
| 258 |
+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
| 259 |
+
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
| 260 |
+
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
| 261 |
+
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
| 262 |
+
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
| 263 |
+
github.com/tarm/serial v0.0.0-20180830185346-98f6abe2eb07/go.mod h1:kDXzergiv9cbyO7IOYJZWg1U88JhDg3PB6klq9Hg2pA=
|
| 264 |
+
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
| 265 |
+
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
| 266 |
+
github.com/ugorji/go/codec v1.2.12 h1:9LC83zGrHhuUA9l16C9AHXAqEV/2wBQ4nkvumAE65EE=
|
| 267 |
+
github.com/ugorji/go/codec v1.2.12/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
| 268 |
+
github.com/viant/assertly v0.4.8/go.mod h1:aGifi++jvCrUaklKEKT0BU95igDNaqkvz+49uaYMPRU=
|
| 269 |
+
github.com/viant/toolbox v0.24.0/go.mod h1:OxMCG57V0PXuIP2HNQrtJf2CjqdmbrOx5EkMILuUhzM=
|
| 270 |
+
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
| 271 |
+
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
| 272 |
+
github.com/yuin/goldmark v1.4.1/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
| 273 |
+
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
| 274 |
+
go.opencensus.io v0.18.0/go.mod h1:vKdFvxhtzZ9onBp9VKHK8z/sRpBMnKAsufL7wlDrCOA=
|
| 275 |
+
go4.org v0.0.0-20180809161055-417644f6feb5/go.mod h1:MkTOUMDaeVYJUOUsaDXIhWPZYa1yOyC1qaOBpL57BhE=
|
| 276 |
+
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
| 277 |
+
golang.org/x/arch v0.8.0 h1:3wRIsP3pM4yUptoR96otTUOXI367OS0+c9eeRi9doIc=
|
| 278 |
+
golang.org/x/arch v0.8.0/go.mod h1:FEVrYAQjsQXMVJ1nsMoVVXPZg6p2JE2mx8psSWTDQys=
|
| 279 |
+
golang.org/x/build v0.0.0-20190111050920-041ab4dc3f9d/go.mod h1:OWs+y06UdEOHN4y+MfF/py+xQ/tYqIWW03b70/CG9Rw=
|
| 280 |
+
golang.org/x/crypto v0.0.0-20181030102418-4d3f4d9ffa16/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
| 281 |
+
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
| 282 |
+
golang.org/x/crypto v0.0.0-20190313024323-a1f597ede03a/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
| 283 |
+
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
| 284 |
+
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
| 285 |
+
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
| 286 |
+
golang.org/x/crypto v0.1.0/go.mod h1:RecgLatLF4+eUMCP1PoPZQb+cVrJcOPbHkTkbkB9sbw=
|
| 287 |
+
golang.org/x/crypto v0.3.1-0.20221117191849-2c476679df9a/go.mod h1:hebNnKkNXi2UzZN1eVRvBB7co0a+JxK6XbPiWVs/3J4=
|
| 288 |
+
golang.org/x/crypto v0.4.0/go.mod h1:3quD/ATkf6oY+rnes5c3ExXTbLc8mueNue5/DoinL80=
|
| 289 |
+
golang.org/x/crypto v0.12.0/go.mod h1:NF0Gs7EO5K4qLn+Ylc+fih8BSTeIjAP05siRnAh98yw=
|
| 290 |
+
golang.org/x/crypto v0.23.0 h1:dIJU/v2J8Mdglj/8rJ6UUOM3Zc9zLZxVZwwxMooUSAI=
|
| 291 |
+
golang.org/x/crypto v0.23.0/go.mod h1:CKFgDieR+mRhux2Lsu27y0fO304Db0wZe70UKqHu0v8=
|
| 292 |
+
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
| 293 |
+
golang.org/x/exp v0.0.0-20221205204356-47842c84f3db/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc=
|
| 294 |
+
golang.org/x/lint v0.0.0-20180702182130-06c8688daad7/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
| 295 |
+
golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
| 296 |
+
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
| 297 |
+
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
| 298 |
+
golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
| 299 |
+
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3/go.mod h1:3p9vT2HGsQu2K1YbXdKPJLVgG5VJdoTa1poYQBtP1AY=
|
| 300 |
+
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
| 301 |
+
golang.org/x/mod v0.6.0/go.mod h1:4mET923SAdbXp2ki8ey+zGs1SLqsuM2Y0uvdZR/fUNI=
|
| 302 |
+
golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
| 303 |
+
golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
| 304 |
+
golang.org/x/mod v0.9.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
| 305 |
+
golang.org/x/mod v0.10.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs=
|
| 306 |
+
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
| 307 |
+
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
| 308 |
+
golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
| 309 |
+
golang.org/x/net v0.0.0-20181029044818-c44066c5c816/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
| 310 |
+
golang.org/x/net v0.0.0-20181106065722-10aee1819953/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
| 311 |
+
golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
| 312 |
+
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
| 313 |
+
golang.org/x/net v0.0.0-20190313220215-9f648a60d977/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
| 314 |
+
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
| 315 |
+
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
| 316 |
+
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
| 317 |
+
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
| 318 |
+
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
| 319 |
+
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
| 320 |
+
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
| 321 |
+
golang.org/x/net v0.0.0-20211015210444-4f30a5c0130f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
| 322 |
+
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
| 323 |
+
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
| 324 |
+
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
| 325 |
+
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
| 326 |
+
golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY=
|
| 327 |
+
golang.org/x/net v0.3.0/go.mod h1:MBQ8lrhLObU/6UmLb4fmbmk5OcyYmqtbGd/9yIeKjEE=
|
| 328 |
+
golang.org/x/net v0.5.0/go.mod h1:DivGGAXEgPSlEBzxGzZI+ZLohi+xUj054jfeKui00ws=
|
| 329 |
+
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
| 330 |
+
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
| 331 |
+
golang.org/x/net v0.8.0/go.mod h1:QVkue5JL9kW//ek3r6jTKnTFis1tRmNAW2P1shuFdJc=
|
| 332 |
+
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
| 333 |
+
golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI=
|
| 334 |
+
golang.org/x/net v0.25.0 h1:d/OCCoBEUq33pjydKrGQhw7IlUPI2Oylr+8qLx49kac=
|
| 335 |
+
golang.org/x/net v0.25.0/go.mod h1:JkAGAh7GEvH74S6FOH42FLoXpXbE/aqXSrIQjXgsiwM=
|
| 336 |
+
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
| 337 |
+
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
| 338 |
+
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
| 339 |
+
golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw=
|
| 340 |
+
golang.org/x/perf v0.0.0-20180704124530-6e6d33e29852/go.mod h1:JLpeXjPJfIyPr5TlbXLkXWLhP8nz10XfvxElABhCtcw=
|
| 341 |
+
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
| 342 |
+
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
| 343 |
+
golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
| 344 |
+
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
| 345 |
+
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
| 346 |
+
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
| 347 |
+
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
| 348 |
+
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
| 349 |
+
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
| 350 |
+
golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
| 351 |
+
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
| 352 |
+
golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
| 353 |
+
golang.org/x/sys v0.0.0-20181029174526-d69651ed3497/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
| 354 |
+
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
| 355 |
+
golang.org/x/sys v0.0.0-20190316082340-a2f829d7f35f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 356 |
+
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 357 |
+
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 358 |
+
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 359 |
+
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 360 |
+
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 361 |
+
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 362 |
+
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 363 |
+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 364 |
+
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 365 |
+
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 366 |
+
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
| 367 |
+
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 368 |
+
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 369 |
+
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 370 |
+
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 371 |
+
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 372 |
+
golang.org/x/sys v0.0.0-20220422013727-9388b58f7150/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 373 |
+
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 374 |
+
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 375 |
+
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 376 |
+
golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 377 |
+
golang.org/x/sys v0.3.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 378 |
+
golang.org/x/sys v0.4.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 379 |
+
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 380 |
+
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 381 |
+
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 382 |
+
golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
| 383 |
+
golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
|
| 384 |
+
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
| 385 |
+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
| 386 |
+
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
| 387 |
+
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
| 388 |
+
golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc=
|
| 389 |
+
golang.org/x/term v0.3.0/go.mod h1:q750SLmJuPmVoN1blW3UFBPREJfb1KmY3vwxfr+nFDA=
|
| 390 |
+
golang.org/x/term v0.4.0/go.mod h1:9P2UbLfCdcvo3p/nzKvsmas4TnlujnuoV9hGgYzW1lQ=
|
| 391 |
+
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
| 392 |
+
golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U=
|
| 393 |
+
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
| 394 |
+
golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU=
|
| 395 |
+
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
| 396 |
+
golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
| 397 |
+
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
| 398 |
+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
| 399 |
+
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
| 400 |
+
golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
| 401 |
+
golang.org/x/text v0.5.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
| 402 |
+
golang.org/x/text v0.6.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
| 403 |
+
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
| 404 |
+
golang.org/x/text v0.8.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
| 405 |
+
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
| 406 |
+
golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
| 407 |
+
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
| 408 |
+
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
| 409 |
+
golang.org/x/time v0.0.0-20180412165947-fbb02b2291d2/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
| 410 |
+
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
| 411 |
+
golang.org/x/tools v0.0.0-20180828015842-6cd1fcedba52/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
| 412 |
+
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
| 413 |
+
golang.org/x/tools v0.0.0-20181030000716-a0a13e073c7b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
| 414 |
+
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
| 415 |
+
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
| 416 |
+
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
| 417 |
+
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
| 418 |
+
golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
| 419 |
+
golang.org/x/tools v0.1.10/go.mod h1:Uh6Zz+xoGYZom868N8YTex3t7RhtHDBrE8Gzo9bV56E=
|
| 420 |
+
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
| 421 |
+
golang.org/x/tools v0.2.0/go.mod h1:y4OqIKeOV/fWJetJ8bXPU1sEVniLMIyDAZWeHdV+NTA=
|
| 422 |
+
golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ=
|
| 423 |
+
golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU=
|
| 424 |
+
golang.org/x/tools v0.7.0/go.mod h1:4pg6aUX35JBAogB10C9AtvVL+qowtN4pT3CGSQex14s=
|
| 425 |
+
golang.org/x/tools v0.9.1/go.mod h1:owI94Op576fPu3cIGQeHs3joujW/2Oc6MtlxbF5dfNc=
|
| 426 |
+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
|
| 427 |
+
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
| 428 |
+
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
| 429 |
+
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
| 430 |
+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
| 431 |
+
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
| 432 |
+
google.golang.org/api v0.0.0-20180910000450-7ca32eb868bf/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
|
| 433 |
+
google.golang.org/api v0.0.0-20181030000543-1d582fd0359e/go.mod h1:4mhQ8q/RsB7i+udVvVy5NUi08OU8ZlA0gRVgrF7VFY0=
|
| 434 |
+
google.golang.org/api v0.1.0/go.mod h1:UGEZY7KEX120AnNLIHFMKIo4obdJhkp2tPbaPlQx13Y=
|
| 435 |
+
google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
| 436 |
+
google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
| 437 |
+
google.golang.org/appengine v1.3.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
| 438 |
+
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
| 439 |
+
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
| 440 |
+
google.golang.org/genproto v0.0.0-20180831171423-11092d34479b/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
| 441 |
+
google.golang.org/genproto v0.0.0-20181029155118-b69ba1387ce2/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
| 442 |
+
google.golang.org/genproto v0.0.0-20181202183823-bd91e49a0898/go.mod h1:7Ep/1NZk928CDR8SjdVbjWNpdIf6nzjE3BTgJDr2Atg=
|
| 443 |
+
google.golang.org/genproto v0.0.0-20190306203927-b5d61aea6440/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
| 444 |
+
google.golang.org/grpc v1.14.0/go.mod h1:yo6s7OP7yaDglbqo1J04qKzAhqBH6lvTonzMVmEdcZw=
|
| 445 |
+
google.golang.org/grpc v1.16.0/go.mod h1:0JHn/cJsOMiMfNA9+DeHDlAU7KAAB5GDlYFpa9MZMio=
|
| 446 |
+
google.golang.org/grpc v1.17.0/go.mod h1:6QZJwpn2B+Zp71q/5VxRsJ6NXXVCE5NRUHRo+f3cWCs=
|
| 447 |
+
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
| 448 |
+
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
| 449 |
+
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
| 450 |
+
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
| 451 |
+
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
| 452 |
+
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
| 453 |
+
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
| 454 |
+
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
| 455 |
+
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
| 456 |
+
google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
| 457 |
+
google.golang.org/protobuf v1.34.1 h1:9ddQBjfCyZPOHPUiPxpYESBLc+T8P3E+Vo4IbKZgFWg=
|
| 458 |
+
google.golang.org/protobuf v1.34.1/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
| 459 |
+
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
| 460 |
+
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
| 461 |
+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
| 462 |
+
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
| 463 |
+
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
| 464 |
+
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
|
| 465 |
+
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
| 466 |
+
gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
| 467 |
+
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
| 468 |
+
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
| 469 |
+
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
| 470 |
+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
| 471 |
+
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
| 472 |
+
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
| 473 |
+
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
| 474 |
+
grpc.go4.org v0.0.0-20170609214715-11d0a25b4919/go.mod h1:77eQGdRu53HpSqPFJFmuJdjuHRquDANNeA4x7B8WQ9o=
|
| 475 |
+
h12.io/socks v1.0.3 h1:Ka3qaQewws4j4/eDQnOdpr4wXsC//dXtWvftlIcCQUo=
|
| 476 |
+
h12.io/socks v1.0.3/go.mod h1:AIhxy1jOId/XCz9BO+EIgNL2rQiPTBNnOfnVnQ+3Eck=
|
| 477 |
+
honnef.co/go/tools v0.0.0-20180728063816-88497007e858/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
| 478 |
+
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
| 479 |
+
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
| 480 |
+
nullprogram.com/x/optparse v1.0.0/go.mod h1:KdyPE+Igbe0jQUrVfMqDMeJQIJZEuyV7pjYmp6pbG50=
|
| 481 |
+
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
| 482 |
+
sourcegraph.com/sourcegraph/go-diff v0.5.0/go.mod h1:kuch7UrkMzY0X+p9CRK03kfuPQ2zzQcaEFbx8wA8rck=
|
| 483 |
+
sourcegraph.com/sqs/pbtypes v0.0.0-20180604144634-d3ebe8f20ae4/go.mod h1:ketZ/q3QxT9HOBeFhu6RdvsftgpsbFHBF5Cas6cDKZ0=
|
main.go
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package main
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"fmt"
|
| 5 |
+
"genspark2api/check"
|
| 6 |
+
"genspark2api/common"
|
| 7 |
+
"genspark2api/common/config"
|
| 8 |
+
logger "genspark2api/common/loggger"
|
| 9 |
+
"genspark2api/middleware"
|
| 10 |
+
"genspark2api/router"
|
| 11 |
+
"github.com/gin-gonic/gin"
|
| 12 |
+
"os"
|
| 13 |
+
"strconv"
|
| 14 |
+
)
|
| 15 |
+
|
| 16 |
+
func main() {
|
| 17 |
+
logger.SetupLogger()
|
| 18 |
+
logger.SysLog(fmt.Sprintf("genspark2api %s starting...", common.Version))
|
| 19 |
+
|
| 20 |
+
check.CheckEnvVariable()
|
| 21 |
+
|
| 22 |
+
if os.Getenv("GIN_MODE") != "debug" {
|
| 23 |
+
gin.SetMode(gin.ReleaseMode)
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
var err error
|
| 27 |
+
|
| 28 |
+
common.InitTokenEncoders()
|
| 29 |
+
|
| 30 |
+
server := gin.New()
|
| 31 |
+
server.Use(gin.Recovery())
|
| 32 |
+
server.Use(middleware.RequestId())
|
| 33 |
+
middleware.SetUpLogger(server)
|
| 34 |
+
|
| 35 |
+
router.SetRouter(server)
|
| 36 |
+
var port = os.Getenv("PORT")
|
| 37 |
+
if port == "" {
|
| 38 |
+
port = strconv.Itoa(*common.Port)
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
if config.DebugEnabled {
|
| 42 |
+
logger.SysLog("running in DEBUG mode.")
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
logger.SysLog("genspark2api start success. enjoy it! ^_^\n")
|
| 46 |
+
|
| 47 |
+
err = server.Run(":" + port)
|
| 48 |
+
|
| 49 |
+
if err != nil {
|
| 50 |
+
logger.FatalLog("failed to start HTTP server: " + err.Error())
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
}
|
middleware/auth.go
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package middleware
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"genspark2api/common/config"
|
| 5 |
+
"genspark2api/model"
|
| 6 |
+
"github.com/gin-gonic/gin"
|
| 7 |
+
"github.com/samber/lo"
|
| 8 |
+
"net/http"
|
| 9 |
+
"strings"
|
| 10 |
+
)
|
| 11 |
+
|
| 12 |
+
func isValidSecret(secret string) bool {
|
| 13 |
+
return config.ApiSecret != "" && !lo.Contains(config.ApiSecrets, secret)
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
func authHelper(c *gin.Context) {
|
| 17 |
+
secret := c.Request.Header.Get("proxy-secret")
|
| 18 |
+
if isValidSecret(secret) {
|
| 19 |
+
c.JSON(http.StatusUnauthorized, gin.H{
|
| 20 |
+
"success": false,
|
| 21 |
+
"message": "无权进行此操作,未提供正确的 api-secret",
|
| 22 |
+
})
|
| 23 |
+
c.Abort()
|
| 24 |
+
return
|
| 25 |
+
}
|
| 26 |
+
c.Next()
|
| 27 |
+
return
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
func authHelperForOpenai(c *gin.Context) {
|
| 31 |
+
secret := c.Request.Header.Get("Authorization")
|
| 32 |
+
secret = strings.Replace(secret, "Bearer ", "", 1)
|
| 33 |
+
if isValidSecret(secret) {
|
| 34 |
+
c.JSON(http.StatusUnauthorized, model.OpenAIErrorResponse{
|
| 35 |
+
OpenAIError: model.OpenAIError{
|
| 36 |
+
Message: "authorization(api-secret)校验失败",
|
| 37 |
+
Type: "invalid_request_error",
|
| 38 |
+
Code: "invalid_authorization",
|
| 39 |
+
},
|
| 40 |
+
})
|
| 41 |
+
c.Abort()
|
| 42 |
+
return
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
if config.ApiSecret == "" {
|
| 46 |
+
c.Request.Header.Set("Authorization", "")
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
c.Next()
|
| 50 |
+
return
|
| 51 |
+
}
|
| 52 |
+
|
| 53 |
+
func Auth() func(c *gin.Context) {
|
| 54 |
+
return func(c *gin.Context) {
|
| 55 |
+
authHelper(c)
|
| 56 |
+
}
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
func OpenAIAuth() func(c *gin.Context) {
|
| 60 |
+
return func(c *gin.Context) {
|
| 61 |
+
authHelperForOpenai(c)
|
| 62 |
+
}
|
| 63 |
+
}
|
middleware/cors.go
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package middleware
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-contrib/cors"
|
| 5 |
+
"github.com/gin-gonic/gin"
|
| 6 |
+
)
|
| 7 |
+
|
| 8 |
+
func CORS() gin.HandlerFunc {
|
| 9 |
+
config := cors.DefaultConfig()
|
| 10 |
+
config.AllowAllOrigins = true
|
| 11 |
+
config.AllowCredentials = true
|
| 12 |
+
config.AllowMethods = []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"}
|
| 13 |
+
config.AllowHeaders = []string{"*"}
|
| 14 |
+
return cors.New(config)
|
| 15 |
+
}
|
middleware/logger.go
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package middleware
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"fmt"
|
| 5 |
+
"genspark2api/common/helper"
|
| 6 |
+
"github.com/gin-gonic/gin"
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
func SetUpLogger(server *gin.Engine) {
|
| 10 |
+
server.Use(gin.LoggerWithFormatter(func(param gin.LogFormatterParams) string {
|
| 11 |
+
var requestID string
|
| 12 |
+
if param.Keys != nil {
|
| 13 |
+
requestID = param.Keys[helper.RequestIdKey].(string)
|
| 14 |
+
}
|
| 15 |
+
return fmt.Sprintf("[GIN] %s | %s | %3d | %13v | %15s | %7s %s\n",
|
| 16 |
+
param.TimeStamp.Format("2006/01/02 - 15:04:05"),
|
| 17 |
+
requestID,
|
| 18 |
+
param.StatusCode,
|
| 19 |
+
param.Latency,
|
| 20 |
+
param.ClientIP,
|
| 21 |
+
param.Method,
|
| 22 |
+
param.Path,
|
| 23 |
+
)
|
| 24 |
+
}))
|
| 25 |
+
}
|
middleware/rate-limit.go
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package middleware
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"genspark2api/common"
|
| 5 |
+
"genspark2api/common/config"
|
| 6 |
+
"github.com/gin-gonic/gin"
|
| 7 |
+
"net/http"
|
| 8 |
+
)
|
| 9 |
+
|
| 10 |
+
var timeFormat = "2006-01-02T15:04:05.000Z"
|
| 11 |
+
|
| 12 |
+
var inMemoryRateLimiter common.InMemoryRateLimiter
|
| 13 |
+
|
| 14 |
+
func memoryRateLimiter(c *gin.Context, maxRequestNum int, duration int64, mark string) {
|
| 15 |
+
key := mark + c.ClientIP()
|
| 16 |
+
if !inMemoryRateLimiter.Request(key, maxRequestNum, duration) {
|
| 17 |
+
c.JSON(http.StatusTooManyRequests, gin.H{
|
| 18 |
+
"success": false,
|
| 19 |
+
"message": "请求过于频繁,请稍后再试",
|
| 20 |
+
})
|
| 21 |
+
c.Abort()
|
| 22 |
+
return
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
func rateLimitFactory(maxRequestNum int, duration int64, mark string) func(c *gin.Context) {
|
| 27 |
+
// It's safe to call multi times.
|
| 28 |
+
inMemoryRateLimiter.Init(config.RateLimitKeyExpirationDuration)
|
| 29 |
+
return func(c *gin.Context) {
|
| 30 |
+
memoryRateLimiter(c, maxRequestNum, duration, mark)
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
func RequestRateLimit() func(c *gin.Context) {
|
| 35 |
+
return rateLimitFactory(config.RequestRateLimitNum, config.RequestRateLimitDuration, "REQUEST_RATE_LIMIT")
|
| 36 |
+
}
|
middleware/request-id.go
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package middleware
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"context"
|
| 5 |
+
"genspark2api/common/helper"
|
| 6 |
+
"github.com/gin-gonic/gin"
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
func RequestId() func(c *gin.Context) {
|
| 10 |
+
return func(c *gin.Context) {
|
| 11 |
+
id := helper.GenRequestID()
|
| 12 |
+
c.Set(helper.RequestIdKey, id)
|
| 13 |
+
ctx := context.WithValue(c.Request.Context(), helper.RequestIdKey, id)
|
| 14 |
+
c.Request = c.Request.WithContext(ctx)
|
| 15 |
+
c.Header(helper.RequestIdKey, id)
|
| 16 |
+
c.Next()
|
| 17 |
+
}
|
| 18 |
+
}
|
model/openai.go
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package model
|
| 2 |
+
|
| 3 |
+
type OpenAIChatCompletionRequest struct {
|
| 4 |
+
Model string `json:"model"`
|
| 5 |
+
Stream bool `json:"stream"`
|
| 6 |
+
Messages []OpenAIChatMessage `json:"messages"`
|
| 7 |
+
OpenAIChatCompletionExtraRequest
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
type OpenAIChatCompletionExtraRequest struct {
|
| 11 |
+
ChannelId *string `json:"channelId"`
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
type OpenAIChatMessage struct {
|
| 15 |
+
Role string `json:"role"`
|
| 16 |
+
Content interface{} `json:"content"`
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
type OpenAIErrorResponse struct {
|
| 20 |
+
OpenAIError OpenAIError `json:"error"`
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
type OpenAIError struct {
|
| 24 |
+
Message string `json:"message"`
|
| 25 |
+
Type string `json:"type"`
|
| 26 |
+
Param string `json:"param"`
|
| 27 |
+
Code string `json:"code"`
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
type OpenAIChatCompletionResponse struct {
|
| 31 |
+
ID string `json:"id"`
|
| 32 |
+
Object string `json:"object"`
|
| 33 |
+
Created int64 `json:"created"`
|
| 34 |
+
Model string `json:"model"`
|
| 35 |
+
Choices []OpenAIChoice `json:"choices"`
|
| 36 |
+
Usage OpenAIUsage `json:"usage"`
|
| 37 |
+
SystemFingerprint *string `json:"system_fingerprint"`
|
| 38 |
+
Suggestions []string `json:"suggestions"`
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
type OpenAIChoice struct {
|
| 42 |
+
Index int `json:"index"`
|
| 43 |
+
Message OpenAIMessage `json:"message"`
|
| 44 |
+
LogProbs *string `json:"logprobs"`
|
| 45 |
+
FinishReason *string `json:"finish_reason"`
|
| 46 |
+
Delta OpenAIDelta `json:"delta"`
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
type OpenAIMessage struct {
|
| 50 |
+
Role string `json:"role"`
|
| 51 |
+
Content string `json:"content"`
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
type OpenAIUsage struct {
|
| 55 |
+
PromptTokens int `json:"prompt_tokens"`
|
| 56 |
+
CompletionTokens int `json:"completion_tokens"`
|
| 57 |
+
TotalTokens int `json:"total_tokens"`
|
| 58 |
+
}
|
| 59 |
+
|
| 60 |
+
type OpenAIDelta struct {
|
| 61 |
+
Content string `json:"content"`
|
| 62 |
+
Role string `json:"role"`
|
| 63 |
+
}
|
| 64 |
+
|
| 65 |
+
type OpenAIImagesGenerationRequest struct {
|
| 66 |
+
OpenAIChatCompletionExtraRequest
|
| 67 |
+
Model string `json:"model"`
|
| 68 |
+
Prompt string `json:"prompt"`
|
| 69 |
+
ResponseFormat string `json:"response_format"`
|
| 70 |
+
Image string `json:"image"`
|
| 71 |
+
}
|
| 72 |
+
|
| 73 |
+
type OpenAIImagesGenerationResponse struct {
|
| 74 |
+
Created int64 `json:"created"`
|
| 75 |
+
DailyLimit bool `json:"dailyLimit"`
|
| 76 |
+
Data []*OpenAIImagesGenerationDataResponse `json:"data"`
|
| 77 |
+
Suggestions []string `json:"suggestions"`
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
type OpenAIImagesGenerationDataResponse struct {
|
| 81 |
+
URL string `json:"url"`
|
| 82 |
+
RevisedPrompt string `json:"revised_prompt"`
|
| 83 |
+
B64Json string `json:"b64_json"`
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
type OpenAIGPT4VImagesReq struct {
|
| 87 |
+
Type string `json:"type"`
|
| 88 |
+
Text string `json:"text"`
|
| 89 |
+
ImageURL struct {
|
| 90 |
+
URL string `json:"url"`
|
| 91 |
+
} `json:"image_url"`
|
| 92 |
+
}
|
| 93 |
+
|
| 94 |
+
type GetUserContent interface {
|
| 95 |
+
GetUserContent() []string
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
type OpenAIModerationRequest struct {
|
| 99 |
+
Input string `json:"input"`
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
type OpenAIModerationResponse struct {
|
| 103 |
+
ID string `json:"id"`
|
| 104 |
+
Model string `json:"model"`
|
| 105 |
+
Results []struct {
|
| 106 |
+
Flagged bool `json:"flagged"`
|
| 107 |
+
Categories map[string]bool `json:"categories"`
|
| 108 |
+
CategoryScores map[string]float64 `json:"category_scores"`
|
| 109 |
+
} `json:"results"`
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
type OpenaiModelResponse struct {
|
| 113 |
+
ID string `json:"id"`
|
| 114 |
+
Object string `json:"object"`
|
| 115 |
+
//Created time.Time `json:"created"`
|
| 116 |
+
//OwnedBy string `json:"owned_by"`
|
| 117 |
+
}
|
| 118 |
+
|
| 119 |
+
// ModelList represents a list of models.
|
| 120 |
+
type OpenaiModelListResponse struct {
|
| 121 |
+
Object string `json:"object"`
|
| 122 |
+
Data []OpenaiModelResponse `json:"data"`
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
func (r OpenAIChatCompletionRequest) GetUserContent() []string {
|
| 126 |
+
var userContent []string
|
| 127 |
+
|
| 128 |
+
for i := len(r.Messages) - 1; i >= 0; i-- {
|
| 129 |
+
if r.Messages[i].Role == "user" {
|
| 130 |
+
switch contentObj := r.Messages[i].Content.(type) {
|
| 131 |
+
case string:
|
| 132 |
+
userContent = append(userContent, contentObj)
|
| 133 |
+
}
|
| 134 |
+
break
|
| 135 |
+
}
|
| 136 |
+
}
|
| 137 |
+
|
| 138 |
+
return userContent
|
| 139 |
+
}
|
router/api-router.go
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package router
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"genspark2api/controller"
|
| 5 |
+
"genspark2api/middleware"
|
| 6 |
+
"github.com/gin-gonic/gin"
|
| 7 |
+
)
|
| 8 |
+
|
| 9 |
+
func SetApiRouter(router *gin.Engine) {
|
| 10 |
+
router.Use(middleware.CORS())
|
| 11 |
+
//router.Use(gzip.Gzip(gzip.DefaultCompression))
|
| 12 |
+
router.Use(middleware.RequestRateLimit())
|
| 13 |
+
|
| 14 |
+
router.GET("/")
|
| 15 |
+
|
| 16 |
+
//https://api.openai.com/v1/images/generations
|
| 17 |
+
v1Router := router.Group("/v1")
|
| 18 |
+
v1Router.Use(middleware.OpenAIAuth())
|
| 19 |
+
v1Router.POST("/chat/completions", controller.ChatForOpenAI)
|
| 20 |
+
v1Router.POST("/images/generations", controller.ImagesForOpenAI)
|
| 21 |
+
v1Router.GET("/models", controller.OpenaiModels)
|
| 22 |
+
}
|
router/main.go
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
package router
|
| 2 |
+
|
| 3 |
+
import (
|
| 4 |
+
"github.com/gin-gonic/gin"
|
| 5 |
+
)
|
| 6 |
+
|
| 7 |
+
func SetRouter(router *gin.Engine) {
|
| 8 |
+
SetApiRouter(router)
|
| 9 |
+
}
|