Skip to content

Commit

Permalink
feat(core): add insert positions for character-specific content
Browse files Browse the repository at this point in the history
- Add 'before_char' and 'after_char' as new insert position options
- Implement logic to handle character-specific content insertion
- Enhance flexibility for integrating character-centric narratives and LoreBooks
  • Loading branch information
dingyi222666 committed Nov 23, 2024
1 parent d847275 commit c3a527e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/core/src/llm-core/chain/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ Your goal is to craft a response that intelligently incorporates relevant knowle
insertPosition:
| PresetTemplate['loreBooks']['insertPosition']
| PresetTemplate['authorsNote']['insertPosition']
| 'before_char'
| 'after_char'
) {
if (insertPosition === 'in_chat') {
return chatHistory.length - 1
Expand All @@ -414,9 +416,11 @@ Your goal is to craft a response that intelligently incorporates relevant knowle

switch (insertPosition) {
case 'before_char_defs':
case 'before_char':
return charDefIndex !== -1 ? charDefIndex : 1

case 'after_char_defs':
case 'after_char':
if (scenarioIndex !== -1) return scenarioIndex + 1
return charDefIndex !== -1
? charDefIndex + 1
Expand Down

0 comments on commit c3a527e

Please sign in to comment.