mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2025-12-28 05:11:24 +08:00
feat(OrchestrateService): 添加提示变量替换功能
在调用API前替换assistant.prompt中的变量,以支持动态提示内容
This commit is contained in:
parent
b5c1530d97
commit
3d131dc213
@ -1,5 +1,6 @@
|
||||
import { Assistant, Message } from '@renderer/types'
|
||||
import { Chunk, ChunkType } from '@renderer/types/chunk'
|
||||
import { replacePromptVariables } from '@renderer/utils/prompt'
|
||||
|
||||
import { fetchChatCompletion } from './ApiService'
|
||||
import { ConversationService } from './ConversationService'
|
||||
@ -71,6 +72,9 @@ export async function transformMessagesAndFetch(
|
||||
try {
|
||||
const llmMessages = await ConversationService.prepareMessagesForModel(messages, assistant)
|
||||
|
||||
// replace prompt variables
|
||||
assistant.prompt = await replacePromptVariables(assistant.prompt, assistant.model?.name)
|
||||
|
||||
await fetchChatCompletion({
|
||||
messages: llmMessages,
|
||||
assistant: assistant,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user