:hammer: [WIP] Auto set model in agent info
Browse files- configs/agents.json +8 -13
- storages/agent_storage.js +0 -1
- widgets/agent_info_widget.js +15 -0
configs/agents.json
CHANGED
@@ -2,37 +2,32 @@
|
|
2 |
{
|
3 |
"name": "默认",
|
4 |
"description": "默认",
|
|
|
|
|
5 |
"temperature": 0.5,
|
6 |
"top_p": 0.9,
|
7 |
"max_output_token": -1,
|
8 |
-
"system_prompt": "",
|
9 |
"need_protect": false
|
10 |
},
|
11 |
{
|
12 |
"name": "总结",
|
13 |
"description": "文本总结",
|
14 |
-
"
|
15 |
-
"
|
16 |
-
"max_output_token": -1,
|
17 |
-
"system_prompt": "总结下面的文本:",
|
18 |
"need_protect": false
|
19 |
},
|
20 |
{
|
21 |
"name": "翻译",
|
22 |
"description": "文本翻译",
|
23 |
-
"
|
24 |
-
"
|
25 |
-
"max_output_token": -1,
|
26 |
-
"system_prompt": "请翻译下面的文本:",
|
27 |
"need_protect": false
|
28 |
},
|
29 |
{
|
30 |
"name": "搜索",
|
31 |
"description": "网页搜索",
|
32 |
-
"
|
33 |
-
"top_p": 0.9,
|
34 |
-
"max_output_token": -1,
|
35 |
"system_prompt": "请根据下列内容搜索网页:",
|
36 |
"need_protect": false
|
37 |
}
|
38 |
-
]
|
|
|
2 |
{
|
3 |
"name": "默认",
|
4 |
"description": "默认",
|
5 |
+
"model": "",
|
6 |
+
"system_prompt": "",
|
7 |
"temperature": 0.5,
|
8 |
"top_p": 0.9,
|
9 |
"max_output_token": -1,
|
|
|
10 |
"need_protect": false
|
11 |
},
|
12 |
{
|
13 |
"name": "总结",
|
14 |
"description": "文本总结",
|
15 |
+
"model": "openchat-3.5",
|
16 |
+
"system_prompt": "请用中文总结下面的文本:",
|
|
|
|
|
17 |
"need_protect": false
|
18 |
},
|
19 |
{
|
20 |
"name": "翻译",
|
21 |
"description": "文本翻译",
|
22 |
+
"model": "openchat-3.5",
|
23 |
+
"system_prompt": "请用中文翻译下面的文本:",
|
|
|
|
|
24 |
"need_protect": false
|
25 |
},
|
26 |
{
|
27 |
"name": "搜索",
|
28 |
"description": "网页搜索",
|
29 |
+
"model": "openchat-3.5",
|
|
|
|
|
30 |
"system_prompt": "请根据下列内容搜索网页:",
|
31 |
"need_protect": false
|
32 |
}
|
33 |
+
]
|
storages/agent_storage.js
CHANGED
@@ -123,7 +123,6 @@ class AgentStorage {
|
|
123 |
}
|
124 |
get_current_agent() {
|
125 |
let current_agent_name = $("#agents-select").val();
|
126 |
-
console.log("current_agent_name:", current_agent_name);
|
127 |
return this.db.agents.get(current_agent_name);
|
128 |
}
|
129 |
set_agent_info_widget() {
|
|
|
123 |
}
|
124 |
get_current_agent() {
|
125 |
let current_agent_name = $("#agents-select").val();
|
|
|
126 |
return this.db.agents.get(current_agent_name);
|
127 |
}
|
128 |
set_agent_info_widget() {
|
widgets/agent_info_widget.js
CHANGED
@@ -47,6 +47,21 @@ export class AgentInfoWidget {
|
|
47 |
widget_id: this.model_widget_id,
|
48 |
});
|
49 |
let model_widget_parent = this.widget.find(`#${this.model_widget_id}`);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
this.model_widget.spawn_in_parent(model_widget_parent, "prepend");
|
51 |
}
|
52 |
create_system_prompt_widget() {
|
|
|
47 |
widget_id: this.model_widget_id,
|
48 |
});
|
49 |
let model_widget_parent = this.widget.find(`#${this.model_widget_id}`);
|
50 |
+
let model_select = this.widget.find(`#${this.model_widget_id}-select`);
|
51 |
+
let agent_model = this.agent.model;
|
52 |
+
let model_matched = false;
|
53 |
+
model_select.find("option").each(function () {
|
54 |
+
let option_model = $(this).val().split("|")[1];
|
55 |
+
console.log("option_model:", option_model);
|
56 |
+
if (option_model === agent_model) {
|
57 |
+
model_select.val($(this).val());
|
58 |
+
model_matched = true;
|
59 |
+
}
|
60 |
+
});
|
61 |
+
if (!model_matched) {
|
62 |
+
console.log("No model matched for:", agent_model);
|
63 |
+
}
|
64 |
+
|
65 |
this.model_widget.spawn_in_parent(model_widget_parent, "prepend");
|
66 |
}
|
67 |
create_system_prompt_widget() {
|