-
Notifications
You must be signed in to change notification settings - Fork 8.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Bug]: 支持sess开头api-key及中转商 #1525
Comments
binary-husky
changed the title
[Bug]: 不支持sess开头的api-key
[Bug]: 如何支持sess开头的api-key,以及第三方的api-key
Feb 1, 2024
Important 高危设置! 常规情况下不要修改! flowchart LR
A["请使用且仅使用一种方法配置本项目"]
A --> D["(最最高优先级)修改环境变量"]
D --> F["直接运行:通过当前终端环境的环境变量"]
F --> F2["Linux下使用export命令"]
F --> F1["Windows下使用set命令"]
D --> E["Docker运行:修改docker-compose.yml(等价于修改容器内部的环境变量)"]
A --> C["(高优先级)创建并修改config_private.py"]
A --> B["(低优先级)直接修改config.py"]
一、格式解释1. 如果api-key符合官方格式或azure格式解释:apikey满足openai或者azure官方格式 # (通过修改config.py或config_private.py)
LLM_MODEL = "gpt-3.5-turbo"
API_KEY = 'sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
API_URL_REDIRECT = {"https://api.openai.com/v1/chat/completions":"https://xxxx.yyyy.zzzz/v1/chat/completions"}
# 极少数情况下,openai的官方KEY需要伴随组织编码(格式如org-xxxxxxxxxxxxxxxxxxxxxxxx)使用
API_ORG = "" flowchart LR
A["配置选项"]
A --> D1["API_KEY"] --> B1["OpenAI的秘钥"]
A --> D2["API_URL_REDIRECT"] --> B2["终结点Endpoint的重新定向"]
A --> D3["API_ORG"] --> B3["极少数情况下,openai的官方KEY需要伴随组织编码"]
# (通过修改docker-compose.yml)
version: '3'
services:
gpt_academic_full_capability:
image: ghcr.io/binary-husky/gpt_academic_with_all_capacity:master
environment:
# 请查阅 `config.py`或者 github wiki 以查看所有的配置信息
LLM_MODEL: 'gpt-3.5-turbo'
API_KEY: 'sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
API_URL_REDIRECT: '{"https://api.openai.com/v1/chat/completions": "https://xxxx.yyyy.zzzz/v1/chat/completions"}'
API_ORG: '' 有些官方key是API_KEY = "sess-wg61ZafYHpNz7FFwIH7HGZlbVqUVaeV5tatHCWpl"格式的, 这样的APIKEY可以通过修改CUSTOM_API_KEY_PATTERN实现兼容: # (通过修改config.py或config_private.py)
LLM_MODEL = "gpt-3.5-turbo"
API_KEY = 'sess-wg61ZafYHpNz7FFwIH7HGZlbVqUVaeV5tatHCWpl'
CUSTOM_API_KEY_PATTERN = r"sess-[a-zA-Z0-9]{40}"
API_URL_REDIRECT = {"https://api.openai.com/v1/chat/completions":"https://xxxx.yyyy.zzzz/v1/chat/completions"} 2. 如果api-key不符合官方格式解释:apikey不满足官方格式或azure格式 # (通过修改config.py或config_private.py)
LLM_MODEL = "gpt-3.5-turbo"
API_KEY = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
CUSTOM_API_KEY_PATTERN = "用于匹配异形APIKEY的正则表达式"
API_URL_REDIRECT = {"https://api.openai.com/v1/chat/completions":"https://xxxx.yyyy.zzzz/v1/chat/completions"} flowchart LR
A["配置选项"]
A --> D1["API_KEY"] --> B1["OpenAI的秘钥"]
A --> D2["CUSTOM_API_KEY_PATTERN"] --> B2["API_KEY的正则表达式,或者重复填写一遍API_KEY亦可"]
A --> D3["API_URL_REDIRECT"] --> B3["终结点Endpoint的重新定向"]
# (通过修改docker-compose.yml)
version: '3'
services:
gpt_academic_full_capability:
image: ghcr.io/binary-husky/gpt_academic_with_all_capacity:master
environment:
# 请查阅 `config.py`或者 github wiki 以查看所有的配置信息
LLM_MODEL: 'gpt-3.5-turbo'
API_KEY: 'abcdefg-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
CUSTOM_API_KEY_PATTERN: 'your_regex_expression__or__simply_repeat_your_key_here'
API_URL_REDIRECT: '{"https://api.openai.com/v1/chat/completions": "https://xxxx.yyyy.zzzz/v1/chat/completions"}' 二、举例例. 第三方接口 bltcy# (通过修改config.py或config_private.py)
LLM_MODEL = "gpt-3.5-turbo"
API_KEY = 'sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
API_URL_REDIRECT = {"https://api.openai.com/v1/chat/completions": "https://one-api.bltcy.top/v1/chat/completions"} # (通过修改docker-compose.yml)
version: '3'
services:
gpt_academic_full_capability:
image: ghcr.io/binary-husky/gpt_academic_with_all_capacity:master
environment:
# 请查阅 `config.py`或者 github wiki 以查看所有的配置信息
LLM_MODEL: 'gpt-3.5-turbo'
API_KEY: 'sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
API_URL_REDIRECT: '{"https://api.openai.com/v1/chat/completions": "https://one-api.bltcy.top/v1/chat/completions"}' 例. 第三方接口 API2D# (通过修改config.py或config_private.py)
LLM_MODEL = "gpt-3.5-turbo"
API_KEY = 'fk195831-IaP9Pa3WaaCMUIbQwVX6MaSiyawqybyS'
CUSTOM_API_KEY_PATTERN = "fk[a-zA-Z0-9]{6}-[a-zA-Z0-9]{32}$"
API_URL_REDIRECT = {"https://api.openai.com/v1/chat/completions":"https://openai.api2d.net/v1/chat/completions"} 例:第三方接口 fakeopen# (通过修改config.py或config_private.py)
API_KEY = "fk-77ZFXnp2DMjJm9609uI54zNwFrzqf77-UM1kAHIhoqk"
CUSTOM_API_KEY_PATTERN = "fk-77ZFXnp2DMjJm9609uI54zNwFrzqf77-UM1kAHIhoqk"
API_URL_REDIRECT = {"https://api.openai.com/v1/chat/completions": "https://ai.fakeopen.com/v1/chat/completions"} 例. 第三方接口 zeroai# (通过修改config.py或config_private.py)
LLM_MODEL = "gpt-3.5-turbo"
API_KEY = 'sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
API_URL_REDIRECT = {"https://api.openai.com/v1/chat/completions": "https://api.zeroai.link/v1/chat/completions"} |
binary-husky
changed the title
[Bug]: 如何支持sess开头的api-key,以及第三方的api-key
[Bug]: 如何支持sess开头的api-key以及中转商
Feb 1, 2024
binary-husky
changed the title
[Bug]: 如何支持sess开头的api-key以及中转商
[Bug]: 支持sess开头api-key及中转商
Feb 1, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation Method | 安装方法与平台
Others (Please Describe)
Version | 版本
Latest | 最新版
OS | 操作系统
Windows
Describe the bug | 简述
sess开头的api-key和sk开头的api-key使用方式完全相同,为啥用不了
Screen Shot | 有帮助的截图
Terminal Traceback & Material to Help Reproduce Bugs | 终端traceback(如有) + 帮助我们复现的测试材料样本(如有)
The text was updated successfully, but these errors were encountered: