mirror of
https://github.com/zhayujie/chatgpt-on-wechat.git
synced 2026-07-21 06:07:13 +08:00
fix: use dynamic model name in system prompt runtime info
This commit is contained in:
@@ -478,7 +478,14 @@ def _build_runtime_section(runtime_info: Dict[str, Any], language: str) -> List[
|
|||||||
|
|
||||||
# Add other runtime info
|
# Add other runtime info
|
||||||
runtime_parts = []
|
runtime_parts = []
|
||||||
if runtime_info.get("model"):
|
# Support dynamic model via callable, fallback to static value
|
||||||
|
if callable(runtime_info.get("_get_model")):
|
||||||
|
try:
|
||||||
|
runtime_parts.append(f"模型={runtime_info['_get_model']()}")
|
||||||
|
except Exception:
|
||||||
|
if runtime_info.get("model"):
|
||||||
|
runtime_parts.append(f"模型={runtime_info['model']}")
|
||||||
|
elif runtime_info.get("model"):
|
||||||
runtime_parts.append(f"模型={runtime_info['model']}")
|
runtime_parts.append(f"模型={runtime_info['model']}")
|
||||||
if runtime_info.get("workspace"):
|
if runtime_info.get("workspace"):
|
||||||
runtime_parts.append(f"工作空间={runtime_info['workspace']}")
|
runtime_parts.append(f"工作空间={runtime_info['workspace']}")
|
||||||
|
|||||||
@@ -465,8 +465,12 @@ class AgentInitializer:
|
|||||||
'timezone': timezone_name
|
'timezone': timezone_name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def get_model():
|
||||||
|
"""Get current model name dynamically from config"""
|
||||||
|
return conf().get("model", "unknown")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"model": conf().get("model", "unknown"),
|
"_get_model": get_model,
|
||||||
"workspace": workspace_root,
|
"workspace": workspace_root,
|
||||||
"channel": ", ".join(conf().get("channel_type")) if isinstance(conf().get("channel_type"), list) else conf().get("channel_type", "unknown"),
|
"channel": ", ".join(conf().get("channel_type")) if isinstance(conf().get("channel_type"), list) else conf().get("channel_type", "unknown"),
|
||||||
"_get_current_time": get_current_time # Dynamic time function
|
"_get_current_time": get_current_time # Dynamic time function
|
||||||
|
|||||||
Reference in New Issue
Block a user