mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-09-08 17:09:07 +08:00
add rechatLlmFallback config for auto reminder
This commit is contained in:
@@ -12,6 +12,7 @@
|
|||||||
"rechatLimitDay": 21,
|
"rechatLimitDay": 21,
|
||||||
"geminiApiKey": "",
|
"geminiApiKey": "",
|
||||||
"rechatContentSource": 1,
|
"rechatContentSource": 1,
|
||||||
"recentMessageQuantityForLlm": 8
|
"recentMessageQuantityForLlm": 8,
|
||||||
|
"rechatLlmFallback": 1
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,3 +13,8 @@ export enum RECHAT_CONTENT_SOURCE {
|
|||||||
LOOK_FORWARD_EMOTION = 1,
|
LOOK_FORWARD_EMOTION = 1,
|
||||||
GEMINI_WITH_CHAT_CONTEXT = 2
|
GEMINI_WITH_CHAT_CONTEXT = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum RECHAT_LLM_FALLBACK {
|
||||||
|
SEND_LOOK_FORWARD_EMOTION = 1,
|
||||||
|
EXIT_REMINDER_PROGRAM = 2
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Browser, Page } from 'puppeteer'
|
|||||||
import { sendGptContent, sendLookForwardReplyEmotion } from './boss-operation'
|
import { sendGptContent, sendLookForwardReplyEmotion } from './boss-operation'
|
||||||
import { sleep, sleepWithRandomDelay } from '@geekgeekrun/utils/sleep.mjs'
|
import { sleep, sleepWithRandomDelay } from '@geekgeekrun/utils/sleep.mjs'
|
||||||
import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerForKillSelfOnParentExited'
|
import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerForKillSelfOnParentExited'
|
||||||
import { app } from 'electron'
|
import { app, dialog } from 'electron'
|
||||||
import { initDb } from '@geekgeekrun/sqlite-plugin'
|
import { initDb } from '@geekgeekrun/sqlite-plugin'
|
||||||
import {
|
import {
|
||||||
getPublicDbFilePath,
|
getPublicDbFilePath,
|
||||||
@@ -17,7 +17,8 @@ import * as fs from 'fs'
|
|||||||
import { pipeWriteRegardlessError } from '../utils/pipe'
|
import { pipeWriteRegardlessError } from '../utils/pipe'
|
||||||
import { BossInfo } from '@geekgeekrun/sqlite-plugin/dist/entity/BossInfo'
|
import { BossInfo } from '@geekgeekrun/sqlite-plugin/dist/entity/BossInfo'
|
||||||
import { messageForSaveFilter } from '../../../common/utils/chat-list'
|
import { messageForSaveFilter } from '../../../common/utils/chat-list'
|
||||||
import { RECHAT_CONTENT_SOURCE } from '../../../common/enums/auto-start-chat'
|
import { RECHAT_CONTENT_SOURCE, RECHAT_LLM_FALLBACK } from '../../../common/enums/auto-start-chat'
|
||||||
|
import gtag from '../../utils/gtag'
|
||||||
|
|
||||||
const throttleIntervalMinutes =
|
const throttleIntervalMinutes =
|
||||||
readConfigFile('boss.json').autoReminder?.throttleIntervalMinutes ?? 10
|
readConfigFile('boss.json').autoReminder?.throttleIntervalMinutes ?? 10
|
||||||
@@ -27,6 +28,9 @@ const recentMessageQuantityForLlm =
|
|||||||
const rechatContentSource =
|
const rechatContentSource =
|
||||||
readConfigFile('boss.json').autoReminder?.rechatContentSource ??
|
readConfigFile('boss.json').autoReminder?.rechatContentSource ??
|
||||||
RECHAT_CONTENT_SOURCE.LOOK_FORWARD_EMOTION
|
RECHAT_CONTENT_SOURCE.LOOK_FORWARD_EMOTION
|
||||||
|
const rechatLlmFallback =
|
||||||
|
readConfigFile('boss.json').autoReminder?.rechatLlmFallback ??
|
||||||
|
RECHAT_LLM_FALLBACK.SEND_LOOK_FORWARD_EMOTION
|
||||||
|
|
||||||
const dbInitPromise = initDb(getPublicDbFilePath())
|
const dbInitPromise = initDb(getPublicDbFilePath())
|
||||||
|
|
||||||
@@ -286,11 +290,17 @@ const mainLoop = async () => {
|
|||||||
await sleepWithRandomDelay(3250)
|
await sleepWithRandomDelay(3250)
|
||||||
if (rechatContentSource === RECHAT_CONTENT_SOURCE.GEMINI_WITH_CHAT_CONTEXT) {
|
if (rechatContentSource === RECHAT_CONTENT_SOURCE.GEMINI_WITH_CHAT_CONTEXT) {
|
||||||
try {
|
try {
|
||||||
const messageListForGpt = historyMessageList.filter(it => it.bizType !== 101 && it.isSelf).slice(-recentMessageQuantityForLlm)
|
const messageListForGpt = historyMessageList
|
||||||
|
.filter((it) => it.bizType !== 101 && it.isSelf)
|
||||||
|
.slice(-recentMessageQuantityForLlm)
|
||||||
await sendGptContent(pageMapByName.boss!, messageListForGpt)
|
await sendGptContent(pageMapByName.boss!, messageListForGpt)
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
if (rechatLlmFallback === RECHAT_LLM_FALLBACK.SEND_LOOK_FORWARD_EMOTION) {
|
||||||
await sendLookForwardReplyEmotion(pageMapByName.boss!)
|
await sendLookForwardReplyEmotion(pageMapByName.boss!)
|
||||||
|
} else {
|
||||||
|
throw err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
await sendLookForwardReplyEmotion(pageMapByName.boss!)
|
await sendLookForwardReplyEmotion(pageMapByName.boss!)
|
||||||
@@ -354,6 +364,17 @@ export async function runEntry() {
|
|||||||
)
|
)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
if (err instanceof Error && err.message === 'CANNOT_FIND_A_USABLE_MODEL') {
|
||||||
|
gtag('cannot_find_a_usable_model')
|
||||||
|
await dialog.showMessageBox({
|
||||||
|
type: 'error',
|
||||||
|
message:
|
||||||
|
'未找到可以使用的模型,请确定您所配置的模型均可使用。重启本程序或许可以解决这个问题',
|
||||||
|
buttons: ['退出']
|
||||||
|
})
|
||||||
|
process.exit(0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
pageMapByName['boss'] = null
|
pageMapByName['boss'] = null
|
||||||
await sleep(rerunInterval)
|
await sleep(rerunInterval)
|
||||||
|
|||||||
@@ -106,6 +106,23 @@
|
|||||||
次聊天内容作为上下文生成新消息
|
次聊天内容作为上下文生成新消息
|
||||||
</div>
|
</div>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<el-form-item prop="recentMessageQuantityForLlm">
|
||||||
|
<div class="flex flex-items-center">
|
||||||
|
<span class="whitespace-nowrap">当所有模型均不可使用时 </span>
|
||||||
|
<el-select
|
||||||
|
v-model="formContent.autoReminder.rechatLlmFallback"
|
||||||
|
class="w200px"
|
||||||
|
label="name"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="option in rechatLlmFallbackOptions"
|
||||||
|
:key="option.value"
|
||||||
|
:value="option.value"
|
||||||
|
:label="option.name"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</div>
|
||||||
|
</el-form-item>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<el-form-item label="跟进间隔(分钟)" prop="throttleIntervalMinutes">
|
<el-form-item label="跟进间隔(分钟)" prop="throttleIntervalMinutes">
|
||||||
@@ -145,9 +162,12 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, nextTick, onUnmounted, ref, watch } from 'vue'
|
import { computed, nextTick, onUnmounted, ref, watch } from 'vue'
|
||||||
import { dayjs, ElForm, ElMessage, ElMessageBox } from 'element-plus'
|
import { dayjs, ElForm, ElMessage, ElMessageBox, ElSelect, ElOption } from 'element-plus'
|
||||||
import { useRouter } from 'vue-router'
|
import { useRouter } from 'vue-router'
|
||||||
import { RECHAT_CONTENT_SOURCE } from '../../../../common/enums/auto-start-chat'
|
import {
|
||||||
|
RECHAT_CONTENT_SOURCE,
|
||||||
|
RECHAT_LLM_FALLBACK
|
||||||
|
} from '../../../../common/enums/auto-start-chat'
|
||||||
import { gtagRenderer } from '@renderer/utils/gtag'
|
import { gtagRenderer } from '@renderer/utils/gtag'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
@@ -156,7 +176,8 @@ const formContent = ref({
|
|||||||
throttleIntervalMinutes: 10,
|
throttleIntervalMinutes: 10,
|
||||||
rechatLimitDay: 21,
|
rechatLimitDay: 21,
|
||||||
rechatContentSource: 1,
|
rechatContentSource: 1,
|
||||||
recentMessageQuantityForLlm: 8
|
recentMessageQuantityForLlm: 8,
|
||||||
|
rechatLlmFallback: RECHAT_LLM_FALLBACK.SEND_LOOK_FORWARD_EMOTION
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -354,6 +375,17 @@ const handleClickEditPrompt = async () => {
|
|||||||
gtagRenderer('edit_prompt_clicked')
|
gtagRenderer('edit_prompt_clicked')
|
||||||
await electron.ipcRenderer.send('no-reply-reminder-prompt-edit')
|
await electron.ipcRenderer.send('no-reply-reminder-prompt-edit')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const rechatLlmFallbackOptions = [
|
||||||
|
{
|
||||||
|
name: '发送“[盼回复]”表情',
|
||||||
|
value: RECHAT_LLM_FALLBACK.SEND_LOOK_FORWARD_EMOTION
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: '退出已读不回提醒器',
|
||||||
|
value: RECHAT_LLM_FALLBACK.EXIT_REMINDER_PROGRAM
|
||||||
|
}
|
||||||
|
]
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
Reference in New Issue
Block a user