- 前端 API 新增 customSystemPrompt 参数,agentId 变为可选 - 聊天抽屉支持自定义提示词时传递参数并调整宽度 - 我的收藏模态框返回提示词内容供聊天使用 - 后端 Dify 服务优先使用自定义提示词,支持无 agentId 的对话 - Dify 请求 VO 中 agentId 改为非必填,新增 customSystemPrompt 字段
This commit is contained in:
@@ -21,10 +21,11 @@ export function getAgentList() {
|
||||
/**
|
||||
* 流式对话(SSE)
|
||||
* @param {Object} options - 请求配置
|
||||
* @param {number} options.agentId - 智能体ID
|
||||
* @param {number} [options.agentId] - 智能体ID(使用 customSystemPrompt 时可不传)
|
||||
* @param {string} options.content - 用户输入内容
|
||||
* @param {string} [options.conversationId] - 会话ID(可选,首次对话不传)
|
||||
* @param {string} [options.modelMode] - 模型模式:pro-深度版 standard-标准版
|
||||
* @param {string} [options.customSystemPrompt] - 自定义系统提示词(使用用户自建风格时传入)
|
||||
* @param {AbortController} [options.ctrl] - 取消控制器
|
||||
* @param {Function} options.onMessage - 消息回调
|
||||
* @param {Function} [options.onError] - 错误回调
|
||||
@@ -36,6 +37,7 @@ export async function sendChatStream(options) {
|
||||
content,
|
||||
conversationId,
|
||||
modelMode = 'pro',
|
||||
customSystemPrompt,
|
||||
ctrl,
|
||||
onMessage,
|
||||
onError,
|
||||
@@ -56,7 +58,8 @@ export async function sendChatStream(options) {
|
||||
agentId,
|
||||
content,
|
||||
conversationId,
|
||||
modelMode
|
||||
modelMode,
|
||||
customSystemPrompt
|
||||
}),
|
||||
onmessage: (event) => {
|
||||
if (typeof onMessage === 'function') {
|
||||
|
||||
@@ -123,7 +123,8 @@ const executeStreamRequest = async (prompt) => {
|
||||
|
||||
try {
|
||||
await sendChatStream({
|
||||
agentId: props.agent?.id,
|
||||
agentId: props.agent?.customSystemPrompt ? undefined : props.agent?.id,
|
||||
customSystemPrompt: props.agent?.customSystemPrompt,
|
||||
content: prompt,
|
||||
modelMode: modelMode.value,
|
||||
ctrl: abortController.value,
|
||||
@@ -170,7 +171,7 @@ watch(() => props.visible, (val) => {
|
||||
|
||||
<template>
|
||||
<Sheet :open="visible" @update:open="handleClose">
|
||||
<SheetContent side="right" class="w-full sm:w-[420px] md:w-[560px] lg:w-[640px] p-0 flex flex-col bg-background">
|
||||
<SheetContent side="right" class="w-full sm:w-[520px] md:w-[680px] lg:w-[800px] p-0 flex flex-col bg-background">
|
||||
<!-- Header -->
|
||||
<SheetHeader class="shrink-0">
|
||||
<ChatDrawerHeader :agent="agent" @history="openHistory" />
|
||||
|
||||
@@ -60,6 +60,7 @@ async function loadList() {
|
||||
promptList.value = res.data.map(item => ({
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
content: item.content,
|
||||
category: item.category,
|
||||
useCount: item.useCount || 0
|
||||
}))
|
||||
@@ -95,7 +96,8 @@ function handleUse(item) {
|
||||
emit('chat', {
|
||||
id: item.id,
|
||||
name: item.name,
|
||||
categoryName: item.category || '我的风格'
|
||||
categoryName: item.category || '我的风格',
|
||||
customSystemPrompt: item.content
|
||||
})
|
||||
handleClose()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user