Skip to content

Commit

Permalink
feat: support disable prompt lowercase (#211)
Browse files Browse the repository at this point in the history
Co-authored-by: Shigma <[email protected]>
  • Loading branch information
lgc2333 and shigma authored Oct 30, 2023
1 parent 4cbdbaa commit 816ed41
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ export interface PromptConfig {
placement?: Computed<'before' | 'after'>
latinOnly?: Computed<boolean>
translator?: boolean
lowerCase?: boolean
maxWords?: Computed<number>
}

Expand All @@ -163,6 +164,7 @@ export const PromptConfig: Schema<PromptConfig> = Schema.object({
]), options).description('默认附加标签的位置。').default('after'),
translator: Schema.boolean().description('是否启用自动翻译。').default(true),
latinOnly: Schema.computed(Schema.boolean(), options).description('是否只接受英文输入。').default(false),
lowerCase: Schema.boolean().description('是否将输入的标签转换为小写。').default(true),
maxWords: Schema.computed(Schema.natural(), options).description('允许的最大单词数量。').default(0),
}).description('输入设置')

Expand Down Expand Up @@ -422,7 +424,8 @@ export function parseInput(session: Session, input: string, config: Config, over
const tags = input.split(/,\s*/g)
if (placement === 'before') tags.reverse()
for (let tag of tags) {
tag = tag.trim().toLowerCase()
tag = tag.trim()
if (config.lowerCase) tag = tag.toLowerCase()
if (!tag || words.includes(tag)) continue
if (placement === 'before') {
words.unshift(tag)
Expand Down

0 comments on commit 816ed41

Please sign in to comment.