This commit is contained in:
parent
8aaae0a6f0
commit
4d58c87945
@ -389,6 +389,10 @@ definitions:
|
||||
- assistant
|
||||
- image
|
||||
type: string
|
||||
variables:
|
||||
additionalProperties:
|
||||
type: string
|
||||
type: object
|
||||
required:
|
||||
- message
|
||||
- role
|
||||
@ -2103,8 +2107,7 @@ paths:
|
||||
in: header
|
||||
name: X-User-IP
|
||||
type: string
|
||||
- description: Chat stream id
|
||||
in: path
|
||||
- in: path
|
||||
name: stream_id
|
||||
required: true
|
||||
type: string
|
||||
|
@ -1584,6 +1584,12 @@ export interface SchemaChatMessageAddRequest {
|
||||
* @memberof SchemaChatMessageAddRequest
|
||||
*/
|
||||
'role': SchemaChatMessageAddRequestRoleEnum;
|
||||
/**
|
||||
*
|
||||
* @type {{ [key: string]: string; }}
|
||||
* @memberof SchemaChatMessageAddRequest
|
||||
*/
|
||||
'variables'?: { [key: string]: string; };
|
||||
}
|
||||
|
||||
export const SchemaChatMessageAddRequestRoleEnum = {
|
||||
@ -3893,7 +3899,7 @@ export const ChatMessageApiAxiosParamCreator = function (configuration?: Configu
|
||||
/**
|
||||
* 将会通过 SSE 的方式来流式传输内容,不建议使用本文档生成的代码来获取,第三方库有更好的解决方案。
|
||||
* @summary 流式传输文本
|
||||
* @param {string} streamId Chat stream id
|
||||
* @param {string} streamId
|
||||
* @param {string} [xUserIP] 指定聊天中的用户 IP 地址,不指定则自动获取。此 IP 地址只会增加至 Prompt 中,如果不希望增加,请关闭系统自带 Prompt 选项
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
@ -3996,7 +4002,7 @@ export const ChatMessageApiFp = function(configuration?: Configuration) {
|
||||
/**
|
||||
* 将会通过 SSE 的方式来流式传输内容,不建议使用本文档生成的代码来获取,第三方库有更好的解决方案。
|
||||
* @summary 流式传输文本
|
||||
* @param {string} streamId Chat stream id
|
||||
* @param {string} streamId
|
||||
* @param {string} [xUserIP] 指定聊天中的用户 IP 地址,不指定则自动获取。此 IP 地址只会增加至 Prompt 中,如果不希望增加,请关闭系统自带 Prompt 选项
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
@ -4062,7 +4068,7 @@ export const ChatMessageApiFactory = function (configuration?: Configuration, ba
|
||||
/**
|
||||
* 将会通过 SSE 的方式来流式传输内容,不建议使用本文档生成的代码来获取,第三方库有更好的解决方案。
|
||||
* @summary 流式传输文本
|
||||
* @param {string} streamId Chat stream id
|
||||
* @param {string} streamId
|
||||
* @param {string} [xUserIP] 指定聊天中的用户 IP 地址,不指定则自动获取。此 IP 地址只会增加至 Prompt 中,如果不希望增加,请关闭系统自带 Prompt 选项
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
@ -4133,7 +4139,7 @@ export class ChatMessageApi extends BaseAPI {
|
||||
/**
|
||||
* 将会通过 SSE 的方式来流式传输内容,不建议使用本文档生成的代码来获取,第三方库有更好的解决方案。
|
||||
* @summary 流式传输文本
|
||||
* @param {string} streamId Chat stream id
|
||||
* @param {string} streamId
|
||||
* @param {string} [xUserIP] 指定聊天中的用户 IP 地址,不指定则自动获取。此 IP 地址只会增加至 Prompt 中,如果不希望增加,请关闭系统自带 Prompt 选项
|
||||
* @param {*} [options] Override http request option.
|
||||
* @throws {RequiredError}
|
||||
|
@ -210,7 +210,7 @@ const autoScroll = ref(true);
|
||||
const appStore = useAppStore();
|
||||
const dialog = useDialog();
|
||||
const assistantStore = useAssistantStore();
|
||||
const message = useMessage()
|
||||
const message = useMessage();
|
||||
|
||||
function onKeydown(e: KeyboardEvent) {
|
||||
// 如果是 Esc
|
||||
@ -346,7 +346,8 @@ function sendText() {
|
||||
|
||||
async function sendMessage(
|
||||
role: SchemaChatMessageAddRequestRoleEnum,
|
||||
text: string
|
||||
text: string,
|
||||
variables: any = {}
|
||||
) {
|
||||
if (processing.value) {
|
||||
return;
|
||||
@ -376,9 +377,20 @@ async function sendMessage(
|
||||
});
|
||||
}
|
||||
|
||||
let chatVariables = {
|
||||
"now": new Date().toLocaleString(),
|
||||
};
|
||||
|
||||
// 合并
|
||||
chatVariables = {
|
||||
...chatVariables,
|
||||
...variables,
|
||||
};
|
||||
|
||||
let payload: SchemaChatMessageAddRequest = {
|
||||
message: text,
|
||||
role: role,
|
||||
variables: chatVariables,
|
||||
};
|
||||
if (chatStore.currentAssistantId) {
|
||||
payload = {
|
||||
@ -488,7 +500,7 @@ function streamChat(streamId: String, redirect = false) {
|
||||
content: "目前无法完成推理,请稍后再试。",
|
||||
positiveText: "好",
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
let messageAdded = false;
|
||||
|
||||
|
@ -67,7 +67,7 @@
|
||||
/>
|
||||
</n-form-item>
|
||||
|
||||
<n-form-item label="提示词">
|
||||
<n-form-item label="提示词(支持模板, 使用 {foo} 作为变量)">
|
||||
<n-input
|
||||
type="textarea"
|
||||
v-model:value="currentAssistant.prompt"
|
||||
|
Loading…
Reference in New Issue
Block a user