mirror of
https://github.com/CherryHQ/cherry-studio.git
synced 2026-01-08 06:19:05 +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 { Assistant, Message } from '@renderer/types'
|
||||||
import { Chunk, ChunkType } from '@renderer/types/chunk'
|
import { Chunk, ChunkType } from '@renderer/types/chunk'
|
||||||
|
import { replacePromptVariables } from '@renderer/utils/prompt'
|
||||||
|
|
||||||
import { fetchChatCompletion } from './ApiService'
|
import { fetchChatCompletion } from './ApiService'
|
||||||
import { ConversationService } from './ConversationService'
|
import { ConversationService } from './ConversationService'
|
||||||
@ -71,6 +72,9 @@ export async function transformMessagesAndFetch(
|
|||||||
try {
|
try {
|
||||||
const llmMessages = await ConversationService.prepareMessagesForModel(messages, assistant)
|
const llmMessages = await ConversationService.prepareMessagesForModel(messages, assistant)
|
||||||
|
|
||||||
|
// replace prompt variables
|
||||||
|
assistant.prompt = await replacePromptVariables(assistant.prompt, assistant.model?.name)
|
||||||
|
|
||||||
await fetchChatCompletion({
|
await fetchChatCompletion({
|
||||||
messages: llmMessages,
|
messages: llmMessages,
|
||||||
assistant: assistant,
|
assistant: assistant,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user