Skip to content

Commit 4588b41

Browse files
committed
add gemini prefix
1 parent 003ec3f commit 4588b41

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

src/modules/llms/helpers.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const MAX_TRIES = 3
3535
const LLAMA_PREFIX_LIST = ['* ']
3636
const BARD_PREFIX_LIST = ['b. ', 'B. ']
3737
const CLAUDE_OPUS_PREFIX_LIST = ['c. ']
38+
const GEMINI_PREFIX_LIST = ['g. ']
3839

3940
export const isMentioned = (
4041
ctx: OnMessageContext | OnCallBackQueryData
@@ -82,6 +83,16 @@ export const hasClaudeOpusPrefix = (prompt: string): string => {
8283
return ''
8384
}
8485

86+
export const hasGeminiPrefix = (prompt: string): string => {
87+
const prefixList = GEMINI_PREFIX_LIST
88+
for (let i = 0; i < prefixList.length; i++) {
89+
if (prompt.toLocaleLowerCase().startsWith(prefixList[i])) {
90+
return prefixList[i]
91+
}
92+
}
93+
return ''
94+
}
95+
8596
export const hasUrl = (
8697
ctx: OnMessageContext | OnCallBackQueryData,
8798
prompt: string
@@ -213,7 +224,7 @@ export const sendMessage = async (
213224

214225
export const hasPrefix = (prompt: string): string => {
215226
return (
216-
hasBardPrefix(prompt) || hasLlamaPrefix(prompt) || hasClaudeOpusPrefix(prompt)
227+
hasBardPrefix(prompt) || hasLlamaPrefix(prompt) || hasClaudeOpusPrefix(prompt) || hasGeminiPrefix(prompt)
217228
)
218229
}
219230

src/modules/llms/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import {
2222
getPromptPrice,
2323
hasBardPrefix,
2424
hasClaudeOpusPrefix,
25+
hasGeminiPrefix,
2526
hasLlamaPrefix,
2627
hasPrefix,
2728
hasUrl,
@@ -129,7 +130,7 @@ export class LlmsBot implements PayableBot {
129130
await this.onChat(ctx, LlmsModelsEnum.BISON)
130131
return
131132
}
132-
if (ctx.hasCommand(SupportedCommands.gemini) || ctx.hasCommand(SupportedCommands.gShort)) {
133+
if (ctx.hasCommand([SupportedCommands.gemini, SupportedCommands.gShort]) || (hasGeminiPrefix(ctx.message?.text ?? '') !== '')) {
133134
await this.onChat(ctx, LlmsModelsEnum.GEMINI)
134135
return
135136
}

0 commit comments

Comments
 (0)