增加 Prompt 变量支持
Some checks are pending
Build / build (push) Waiting to run

This commit is contained in:
Twilight 2024-09-17 14:49:40 +08:00
parent 8aaae0a6f0
commit 4d58c87945
4 changed files with 31 additions and 10 deletions

View File

@ -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

View File

@ -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}

View File

@ -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;

View File

@ -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"