Skip to content

Commit

Permalink
增加默认命名模型设置(可选) (#1164)
Browse files Browse the repository at this point in the history
* Update presets.py

添加增长后的3.5 turbo

* 修复了api-host在DALLE3中的问题

创建了IMAGES_COMPLETION_URL
大幅修改了DALLE3文件

* 允许设置启动时是否自动打开浏览器

增加了一个启动时是否自动打开浏览器的设置

* 增加默认命名模型设置(可选)

* Update config.py
  • Loading branch information
slideslide authored Sep 22, 2024
1 parent 20b2e02 commit c91dbfc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions config_example.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
// "sk-xxxxxxxxxxxxxxxxxxxxxxxx2",
// "sk-xxxxxxxxxxxxxxxxxxxxxxxx3"
// ],
// "rename_model": "GPT-4o-mini", //指定默认命名模型
// 自定义OpenAI API Base
// "openai_api_base": "https://api.openai.com",
// 自定义使用代理(请替换代理URL)
Expand Down
12 changes: 12 additions & 0 deletions modules/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,18 @@ def update_doc_config(two_column_pdf):
share = config.get("share", False)
autobrowser = config.get("autobrowser", True)

#设置默认命名model
rename_model = config.get("rename_model", None)
try:
if rename_model is not None:
if rename_model in presets.MODELS:
presets.RENAME_MODEL = presets.MODELS.index(rename_model)
else:
presets.RENAME_MODEL = presets.MODELS.index(next((k for k, v in presets.MODEL_METADATA.items() if v.get("model_name") == rename_model), None))
logging.info("默认命名模型设置为了:" + str(presets.MODELS[presets.RENAME_MODEL]))
except ValueError:
logging.error("你填写的默认命名模型" + rename_model + "不存在!请从下面的列表中挑一个填写:" + str(presets.MODELS))

# avatar
bot_avatar = config.get("bot_avatar", "default")
user_avatar = config.get("user_avatar", "default")
Expand Down
2 changes: 1 addition & 1 deletion modules/models/OpenAIVision.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ def _single_query_at_once(self, history, temperature=1.0):
"temperature": f"{temperature}",
}
payload = {
"model": self.model_name,
"model": RENAME_MODEL if RENAME_MODEL is not None else self.model_name,
"messages": history,
}

Expand Down
2 changes: 2 additions & 0 deletions modules/presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,8 @@

DEFAULT_MODEL = 0

RENAME_MODEL = 0

os.makedirs("models", exist_ok=True)
os.makedirs("lora", exist_ok=True)
os.makedirs("history", exist_ok=True)
Expand Down

0 comments on commit c91dbfc

Please sign in to comment.