feat:单个agent配置各自的apiurl、apimodel、apikey

This commit is contained in:
liailing1026
2025-12-18 09:43:15 +08:00
parent 5ef86c6fa9
commit b42ab5aedd
7 changed files with 145 additions and 911 deletions

View File

@@ -271,13 +271,29 @@ def Handle_saveRequestCashe():
@app.route("/setAgents", methods=["POST"])
def set_agents():
global AgentBoard, AgentProfile_Dict
global AgentBoard, AgentProfile_Dict,yaml_data
AgentBoard = request.json
AgentProfile_Dict = {}
for item in AgentBoard:
name = item["Name"]
profile = item["Profile"]
AgentProfile_Dict[name] = profile
if all(item.get(field) for field in ["apiUrl","apiKey","apiModel"]):
agent_config = {
"profile": item["Profile"],
"apiUrl": item["apiUrl"],
"apiKey": item["apiKey"],
"apiModel": item["apiModel"],
"useCustomAPI":True
}
else:
agent_config = {
"profile": item["Profile"],
"apiUrl": yaml_data.get("OPENAI_API_BASE"),
"apiKey": yaml_data.get("OPENAI_API_KEY"),
"apiModel": yaml_data.get("OPENAI_API_MODEL"),
"useCustomAPI":False
}
AgentProfile_Dict[name] = agent_config
return jsonify({"code": 200, "content": "set agentboard successfully"})