mirror of
https://github.com/geekgeekrun/geekgeekrun.git
synced 2026-07-21 04:32:35 +08:00
add rechatLlmFallback config for auto reminder
This commit is contained in:
@@ -12,6 +12,7 @@
|
||||
"rechatLimitDay": 21,
|
||||
"geminiApiKey": "",
|
||||
"rechatContentSource": 1,
|
||||
"recentMessageQuantityForLlm": 8
|
||||
"recentMessageQuantityForLlm": 8,
|
||||
"rechatLlmFallback": 1
|
||||
}
|
||||
}
|
||||
@@ -13,3 +13,8 @@ export enum RECHAT_CONTENT_SOURCE {
|
||||
LOOK_FORWARD_EMOTION = 1,
|
||||
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 { sleep, sleepWithRandomDelay } from '@geekgeekrun/utils/sleep.mjs'
|
||||
import attachListenerForKillSelfOnParentExited from '../../utils/attachListenerForKillSelfOnParentExited'
|
||||
import { app } from 'electron'
|
||||
import { app, dialog } from 'electron'
|
||||
import { initDb } from '@geekgeekrun/sqlite-plugin'
|
||||
import {
|
||||
getPublicDbFilePath,
|
||||
@@ -17,7 +17,8 @@ import * as fs from 'fs'
|
||||
import { pipeWriteRegardlessError } from '../utils/pipe'
|
||||
import { BossInfo } from '@geekgeekrun/sqlite-plugin/dist/entity/BossInfo'
|
||||
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 =
|
||||
readConfigFile('boss.json').autoReminder?.throttleIntervalMinutes ?? 10
|
||||
@@ -27,6 +28,9 @@ const recentMessageQuantityForLlm =
|
||||
const rechatContentSource =
|
||||
readConfigFile('boss.json').autoReminder?.rechatContentSource ??
|
||||
RECHAT_CONTENT_SOURCE.LOOK_FORWARD_EMOTION
|
||||
const rechatLlmFallback =
|
||||
readConfigFile('boss.json').autoReminder?.rechatLlmFallback ??
|
||||
RECHAT_LLM_FALLBACK.SEND_LOOK_FORWARD_EMOTION
|
||||
|
||||
const dbInitPromise = initDb(getPublicDbFilePath())
|
||||
|
||||
@@ -286,11 +290,17 @@ const mainLoop = async () => {
|
||||
await sleepWithRandomDelay(3250)
|
||||
if (rechatContentSource === RECHAT_CONTENT_SOURCE.GEMINI_WITH_CHAT_CONTEXT) {
|
||||
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)
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
await sendLookForwardReplyEmotion(pageMapByName.boss!)
|
||||
if (rechatLlmFallback === RECHAT_LLM_FALLBACK.SEND_LOOK_FORWARD_EMOTION) {
|
||||
await sendLookForwardReplyEmotion(pageMapByName.boss!)
|
||||
} else {
|
||||
throw err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
await sendLookForwardReplyEmotion(pageMapByName.boss!)
|
||||
@@ -354,6 +364,17 @@ export async function runEntry() {
|
||||
)
|
||||
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 {
|
||||
pageMapByName['boss'] = null
|
||||
await sleep(rerunInterval)
|
||||
|
||||
@@ -106,6 +106,23 @@
|
||||
次聊天内容作为上下文生成新消息
|
||||
</div>
|
||||
</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>
|
||||
</div>
|
||||
<el-form-item label="跟进间隔(分钟)" prop="throttleIntervalMinutes">
|
||||
@@ -145,9 +162,12 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
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 { 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'
|
||||
|
||||
const router = useRouter()
|
||||
@@ -156,7 +176,8 @@ const formContent = ref({
|
||||
throttleIntervalMinutes: 10,
|
||||
rechatLimitDay: 21,
|
||||
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')
|
||||
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>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
||||
Reference in New Issue
Block a user