From a4281f9226a2fe28b3590114b96d09e107d69a5c Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Sun, 6 Apr 2025 14:30:16 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E7=A4=BA=E8=AF=8D=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=8E=86=E5=8F=B2=E6=9F=A5=E8=AF=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/system/prompt-gen.vue | 60 ++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 5 deletions(-) diff --git a/src/views/system/prompt-gen.vue b/src/views/system/prompt-gen.vue index 7d471c4..28810e2 100644 --- a/src/views/system/prompt-gen.vue +++ b/src/views/system/prompt-gen.vue @@ -24,8 +24,8 @@ 生成Prompt

Prompt 模板

- 模板新增 -
+ +
{{ template.title }}
{{ template.desc }}
@@ -74,6 +74,15 @@
+ + + 历史提示词 + +
+
{{ session.Name }}
+ +
+
@@ -83,6 +92,9 @@ import { WSMessage} from "@/types/im"; import { FindModelListByFunctionName } from "@/api/function"; import { Model } from "@/types/model"; import { ElMessage } from "element-plus"; +import { GetMessageService } from "@/api/im"; +import { FindSessionService } from "@/api/session"; +import { Session } from '@/types/session'; // 任务输入和结果Prompt const taskInput = ref(''); const resultPrompt = ref(''); @@ -111,6 +123,8 @@ const topP = ref(0.7); // 会话ID const sessionID = ref(0); +const isShowSession = ref(false); +const sessionList = ref([]); // Prompt模板 const templates = ref([ @@ -133,9 +147,10 @@ const generatePrompt = () => { }; // 新增模板方法 -const addTemplate = () => { +const addTemplate = (template) => { // 这里添加新增模板的逻辑,例如弹出输入框让用户输入模板内容 - console.log('添加模板功能待实现'); + console.log('添加模板功能待实现:', template); + taskInput.value = template.desc; }; // 选择模型方法 @@ -198,8 +213,10 @@ const sendMessage = () => { const GetModelListByFunctionName = async () => { let req = { - function: "gen-ai-chat", + function: "gen-prompt", token: localStorage.getItem("token"), + temperature: temperature.value, + top_p: topP.value, }; try{ let result = await FindModelListByFunctionName(req); @@ -246,6 +263,39 @@ const GetModelListByFunctionName = async () => { GetModelListByFunctionName(); +const showSession = async () => { + //获取历史会话 + let req = { + token: localStorage.getItem("token"), + type: "UserID", + session_type: 2, //提示词会话 + }; + let result = await FindSessionService(req); + if (result["code"] === 0) { + sessionList.value = result["data"]; + console.log("session_list:", sessionList.value); + } else { + ElMessage.error(result["msg"]); + } + isShowSession.value = true; +}; + +const selectSession = async (session: Session) => { + let req = { + token: localStorage.getItem("token"), + session_id: session.ID, + }; + let result = await GetMessageService(req); + if (result["code"] === 0) { + taskInput.value = result["data"][0].Msg; + resultPrompt.value = result["data"][1].Msg; + console.log("session_list:", result["data"]); + } else { + ElMessage.error(result["msg"]); + } + +}; + onUnmounted(() => { if (socket.value) {