Skip to content

Commit

Permalink
极少数情况下,openai的官方KEY需要伴随组织编码
Browse files Browse the repository at this point in the history
  • Loading branch information
binary-husky committed Jul 5, 2023
1 parent 3e621bb commit e5099e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@
CUSTOM_PATH = "/"


# 极少数情况下,openai的官方KEY需要伴随组织编码(格式如org-xxxxxxxxxxxxxxxxxxxxxxxx)使用
API_ORG = ""


# 如果需要使用Slack Claude,使用教程详情见 request_llm/README.md
SLACK_CLAUDE_BOT_ID = ''
SLACK_CLAUDE_USER_TOKEN = ''
Expand Down
5 changes: 3 additions & 2 deletions request_llm/bridge_chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
# config_private.py放自己的秘密如API和代理网址
# 读取时首先看是否存在私密的config_private配置文件(不受git管控),如果有,则覆盖原config文件
from toolbox import get_conf, update_ui, is_any_api_key, select_api_key, what_keys, clip_history, trimmed_format_exc
proxies, API_KEY, TIMEOUT_SECONDS, MAX_RETRY = \
get_conf('proxies', 'API_KEY', 'TIMEOUT_SECONDS', 'MAX_RETRY')
proxies, API_KEY, TIMEOUT_SECONDS, MAX_RETRY, API_ORG = \
get_conf('proxies', 'API_KEY', 'TIMEOUT_SECONDS', 'MAX_RETRY', 'API_ORG')

timeout_bot_msg = '[Local Message] Request timeout. Network error. Please check proxy settings in config.py.' + \
'网络错误,检查代理服务器是否可用,以及代理设置的格式是否正确,格式须是[协议]://[地址]:[端口],缺一不可。'
Expand Down Expand Up @@ -246,6 +246,7 @@ def generate_payload(inputs, llm_kwargs, history, system_prompt, stream):
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}
if API_ORG.startswith('org-'): headers.update({"org": API_ORG})

conversation_cnt = len(history) // 2

Expand Down

0 comments on commit e5099e1

Please sign in to comment.