Skip to content
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

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

Merged
merged 8 commits into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
slideslide marked this conversation as resolved.
Show resolved Hide resolved
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