Skip to content

Commit bb05078

Browse files
committed
APIAuto: 优化 AI 问答的 prompt,未输入提问时默认用 Response JSON 提问
1 parent 0551569 commit bb05078

File tree

1 file changed

+18
-1
lines changed
  • APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/js

1 file changed

+18
-1
lines changed

APIJSON-Java-Server/APIJSONBoot-MultiDataSource/src/main/resources/static/api/js/main.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7507,7 +7507,21 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
75077507

75087508
if (type == 'ask') {
75097509
if (isEnter) {
7510+
var isRes = false;
7511+
if (StringUtil.isEmpty(vAskAI.value) && StringUtil.isNotEmpty(this.jsoncon, true) ) {
7512+
var res = JSON.parse(this.jsoncon);
7513+
// res = this.removeDebugInfo(res);
7514+
delete res['trace:stack']
7515+
delete res['debug:info|help']
7516+
vAskAI.value = JSON.stringify(res)
7517+
isRes = true;
7518+
}
7519+
75107520
const user_query = StringUtil.trim(vAskAI.value);
7521+
if (StringUtil.isEmpty(user_query)) {
7522+
return;
7523+
}
7524+
75117525
function onMessage(item) {
75127526
var data2 = item == null ? null : item.data
75137527
if (data2 == null || item.type != 'chunk') {
@@ -7554,6 +7568,9 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
75547568
vOutput.value = answer;
75557569
markdownToHTML(answer); // vOutput.value)
75567570
})
7571+
7572+
App.uuid = null; // 解决第一次后的都不生效
7573+
vAskAI.value = '';
75577574
}
75587575

75597576
function askAI() {
@@ -7605,7 +7622,7 @@ Content-Type: ` + contentType) + (StringUtil.isEmpty(headerStr, true) ? '' : hea
76057622
this.uuid = crypto.randomUUID();
76067623
this.request(true, REQUEST_TYPE_POST, REQUEST_TYPE_JSON, 'https://api.devin.ai/ada/query', {
76077624
"engine_id": "multihop",
7608-
"user_query": "<relevant_context>This query was sent from the wiki page: Overview.</relevant_context>" + user_query,
7625+
"user_query": "<relevant_context>" + (isRes ? "这是用 HTTP 接口工具 TommyLemon/APIAuto 发请求后的响应结果,分析并" : "") + "用中文回答:</relevant_context>" + user_query,
76097626
"keywords": [],
76107627
"repo_names": [
76117628
"Tencent/APIJSON"

0 commit comments

Comments
 (0)