Skip to content

Commit a9393d9

Browse files
authored
Merge pull request #94 from yenche123/dev
fix: working log title & translation for drawing
2 parents 84acb6d + 73133d8 commit a9393d9

File tree

3 files changed

+38
-14
lines changed

3 files changed

+38
-14
lines changed

liubai-backends/liubai-laf/cloud-functions/ai-entrance.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2687,7 +2687,7 @@ class ToolHandler {
26872687
let imagePrompt = prompt
26882688
const num2 = valTool.getChineseCharNum(prompt)
26892689
console.warn("chinese char num: ", num2)
2690-
if(num2 > 3) {
2690+
if(num2 > 6) {
26912691
const user = this._aiParam.entry.user
26922692
const translator = new Translator(bot, user)
26932693
const res2 = await translator.run(prompt)

liubai-backends/liubai-laf/cloud-functions/ai-system-two.ts

+15-8
Original file line numberDiff line numberDiff line change
@@ -796,19 +796,20 @@ class SystemTwo {
796796

797797
// 5. working logs
798798
if(workingLogs.length > 0) {
799-
msg += (t("working_title") + "\n")
799+
msg += (t("working_log_title") + "\n")
800800
workingLogs.forEach(v => {
801801
msg += (v.textToUser + "\n")
802802
})
803803
msg += "\n"
804804
}
805-
console.log("see msg: ", msg)
806805

807806
// 6. send
808807
if(msg) {
809-
await valTool.waitMilli(900)
808+
msg = msg.trim()
809+
console.log("see msg in handleRunLogs: ", msg)
810+
await valTool.waitMilli(1500)
810811
const entry = System2Util.mockAiEntry(this._ctx.user)
811-
TellUser.text(entry, msg, { fromSystem2: true })
812+
TellUser.text(entry, msg)
812813
}
813814
}
814815

@@ -1155,6 +1156,8 @@ class SystemTwo {
11551156
content: newUserContent,
11561157
}
11571158
this._reasonerAndUs.push(userPrompt)
1159+
1160+
console.warn("tool result prompt: ", newUserContent)
11581161

11591162
return true
11601163
}
@@ -1439,7 +1442,7 @@ class ToolHandler2 {
14391442
return chatId
14401443
}
14411444

1442-
private async _replyToUser(msg: string) {
1445+
private _replyToUser(msg: string) {
14431446
const entry = System2Util.mockAiEntry(this._user)
14441447
TellUser.text(entry, msg, { fromSystem2: true })
14451448
}
@@ -1467,7 +1470,8 @@ class ToolHandler2 {
14671470
// 3. reply
14681471
const toolShared = this._toolShared
14691472
const msg = toolShared.get_msg_for_adding_note(funcJson, chatId)
1470-
await this._replyToUser(msg)
1473+
console.warn("add_note msg: ", msg)
1474+
this._replyToUser(msg)
14711475
return { pass: true }
14721476
}
14731477

@@ -1492,6 +1496,7 @@ class ToolHandler2 {
14921496
// 3. reply
14931497
const toolShared = this._toolShared
14941498
const msg = toolShared.get_msg_for_adding_todo(chatId, funcJson)
1499+
console.warn("add_todo msg: ", msg)
14951500
this._replyToUser(msg)
14961501
return { pass: true }
14971502
}
@@ -1521,7 +1526,8 @@ class ToolHandler2 {
15211526
// 3. reply
15221527
const toolShared = this._toolShared
15231528
const msg = toolShared.get_msg_for_adding_calendar(chatId, funcJson)
1524-
await this._replyToUser(msg)
1529+
console.warn("add_calendar msg: ", msg)
1530+
this._replyToUser(msg)
15251531
return { pass: true }
15261532
}
15271533

@@ -1557,7 +1563,7 @@ class ToolHandler2 {
15571563
// 2. translate if needed
15581564
let imagePrompt = prompt
15591565
const num2 = valTool.getChineseCharNum(prompt)
1560-
if(num2 > 3) {
1566+
if(num2 > 6) {
15611567
const translator = new Translator()
15621568
const res2 = await translator.run(prompt)
15631569
if(!res2) {
@@ -1618,6 +1624,7 @@ class ToolHandler2 {
16181624
data4.text = res3.prompt
16191625
}
16201626
AiShared.updateAiChat(chatId, data4)
1627+
console.warn("draw picture result: ", res3)
16211628

16221629
// 5. reply
16231630
const entry = System2Util.mockAiEntry(this._user)

liubai-backends/liubai-laf/cloud-functions/clock-one-hr.ts

+22-5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import {
3737
set as date_fn_set,
3838
addDays,
3939
} from "date-fns"
40+
import { LiuReporter } from '@/service-send'
4041

4142
const API_WECHAT_ACCESS_TOKEN = "https://api.weixin.qq.com/cgi-bin/token"
4243
const API_WX_JSAPI_TICKET = "https://api.weixin.qq.com/cgi-bin/ticket/getticket"
@@ -481,21 +482,37 @@ async function handleStatistics() {
481482
console.warn("statistic overview: ")
482483
console.log(data4)
483484

484-
// 5. fetch to nocodb
485+
// 5. define data sent to nocodb
485486
const body = {
486487
...data4,
487488
"Date": date,
488489
}
489490
const url = `${baseURL}/api/v2/tables/${tableId}/records`
490491
const headers = { "xc-token": token }
491-
const res = await liuReq(url, body, { method: "POST", headers })
492492

493-
if(res.code !== "0000" || !res.data?.Id) {
493+
// 6. define a function to add row into statistics
494+
// and try again if needed
495+
const _tryToAdd = async () => {
496+
let res6 = await liuReq(url, body, { method: "POST", headers })
497+
498+
if(res6.code !== "0000" || !res6.data?.Id) {
499+
await valTool.waitMilli(3000)
500+
res6 = await liuReq(url, body, { method: "POST", headers })
501+
}
502+
503+
return res6
504+
}
505+
506+
// 7. fetch
507+
let res7 = await _tryToAdd()
508+
if(res7.code !== "0000" || !res7.data?.Id) {
494509
console.warn("fail to add row into statistics!")
495-
console.log(res)
510+
console.log(res7)
511+
const reporter = new LiuReporter()
512+
reporter.send("Liubai: fail to add row into statistics", "Statistics Error")
496513
}
497514

498-
return res
515+
return res7
499516
}
500517

501518
// get D1 / D2 .......

0 commit comments

Comments
 (0)