refactor(instructions): share instruction template rendering via @d3ro/core
This commit is contained in:
parent
d311e8123f
commit
ba0dbbd813
11 changed files with 423 additions and 36 deletions
|
|
@ -94,7 +94,8 @@ export function buildBuiltinCommandPrompt(
|
|||
if (normalizedInput.length === 0 || normalizedInput.length > COMMAND_INPUT_MAX_CHARS) {
|
||||
throw new CommandExecutionError('INVALID_REQUEST', false)
|
||||
}
|
||||
const prompt = command.prompt.replace('{{text}}', normalizedInput)
|
||||
// 함수 replacer: 문자열 replacer는 입력의 `$&`, `$'`, `$$`를 치환 패턴으로 해석해 훼손한다.
|
||||
const prompt = command.prompt.replace('{{text}}', () => normalizedInput)
|
||||
if (prompt.length > 8_000) {
|
||||
throw new CommandExecutionError('INVALID_REQUEST', false)
|
||||
}
|
||||
|
|
@ -402,7 +403,7 @@ export function buildSyncedCommandPrompt(command: SyncedCommand, input: string):
|
|||
throw new CommandExecutionError('INVALID_REQUEST', false)
|
||||
}
|
||||
const prompt = command.prompt.includes('{{text}}')
|
||||
? command.prompt.replace('{{text}}', normalizedInput)
|
||||
? command.prompt.replace('{{text}}', () => normalizedInput)
|
||||
: `${command.prompt}\n\n${normalizedInput}`
|
||||
if (prompt.length > 8_000) throw new CommandExecutionError('INVALID_REQUEST', false)
|
||||
return prompt
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue