wanggaokun преди 2 месеца
родител
ревизия
f49c3eaaec
променени са 2 файла, в които са добавени 42 реда и са изтрити 77 реда
  1. 0 40
      src/views/chat/edit.vue
  2. 42 37
      src/views/chat/index.vue

+ 0 - 40
src/views/chat/edit.vue

@@ -1,40 +0,0 @@
-<template>
-	<div ref="divRef" style="height: 700px" />
-</template>
-
-<script setup lang="ts">
-import { AiEditor } from "aieditor";
-import "aieditor/dist/style.css";
-import { onMounted, onUnmounted, ref } from "vue";
-
-const divRef = ref();
-let aiEditor: AiEditor | null = null;
-
-onMounted(() => {
-	aiEditor = new AiEditor({
-		element: divRef.value as Element,
-		placeholder: "点击输入内容...",
-		content:
-			"AiEditor 是一个面向 AI 的开源富 \n###### 文本编辑器。 \n ```  \n const a = 1; \n ``` \n 你好,世界!",
-		contentIsMarkdown: true,
-		// theme: "dark", // light
-		// codeBlock: {
-		//     languages: [
-		//         {name: 'Auto', value: 'auto'},
-		//         {name: 'Plain Text', value: 'plaintext', alias: ['text', 'txt']},
-		//         {name: 'Bash', value: 'bash', alias: ['sh']},
-		//         {name: 'BASIC', value: 'basic', alias: []},
-		//         {name: 'C', value: 'c', alias: ['h']},
-		//         {name: 'Clojure', value: 'clojure', alias: ['clj', 'edn']},
-		//         {name: 'CMake', value: 'cmake', alias: ['cmake.in']},
-		//     ],
-		// codeExplainPrompt: "帮我对这个代码进行解释,返回代码的解释内容,注意,不需要对代码的注释进行解释",
-		// codeCommentsPrompt: "帮我对这个代码添加一些注释,并返回添加注释的代码,只返回代码",
-		// },
-	});
-});
-
-onUnmounted(() => {
-	aiEditor && aiEditor.destroy();
-});
-</script>

+ 42 - 37
src/views/chat/index.vue

@@ -449,42 +449,47 @@ function handleEdit(index: number) {
 			},
 			ai: {
 				models: {
-					custom: {
-						url: "http://127.0.0.1:6039/chat/send",
-						headers: () => {
-							return {
-								"Content-Type": "application/json;charset=UTF-8",
-								Authorization: "Bearer " + getToken(),
-								Accept: "text/event-stream ",
-							};
-						},
-						wrapPayload: (message: string) => {
-							return JSON.stringify({
-								messages: [
-									{
-										role: "user",
-										content: message,
-									},
-								],
-								model: nGptStore.value.modelLabel,
-							});
-						},
-						parseMessage: (message: any) => {
-							const data = JSON.parse(message);
-							const msg =
-								data.choices[0].delta?.content ??
-								data.choices[0].delta?.reasoning_content ??
-								"";
-							return {
-								role: "assistant",
-								content: msg,
-								// index: number,
-								// //0 代表首个文本结果;1 代表中间文本结果;2 代表最后一个文本结果。
-								// status: 0|1|2,
-							};
-						},
-						protocol: "sse",
+					openai: {
+						endpoint: "https://dashscope.aliyuncs.com/compatible-mode",
+						model: "deepseek-v3",
+						apiKey: "sk-4a781ddcd68246f38c57dceefa21592a"
 					},
+					// custom: {
+					// 	url: "http://127.0.0.1:6039/chat/send",
+					// 	headers: () => {
+					// 		return {
+					// 			"Content-Type": "application/json;charset=UTF-8",
+					// 			Authorization: "Bearer " + getToken(),
+					// 			Accept: "text/event-stream ",
+					// 		};
+					// 	},
+					// 	wrapPayload: (message: string) => {
+					// 		return JSON.stringify({
+					// 			messages: [
+					// 				{
+					// 					role: "user",
+					// 					content: message,
+					// 				},
+					// 			],
+					// 			model: nGptStore.value.modelLabel,
+					// 		});
+					// 	},
+					// 	parseMessage: (message: any) => {
+					// 		const data = JSON.parse(message);
+					// 		const msg =
+					// 			data.choices[0].delta?.content ??
+					// 			data.choices[0].delta?.reasoning_content ??
+					// 			"";
+					// 		return {
+					// 			role: "assistant",
+					// 			content: msg,
+					// 			// index: number,
+					// 			// //0 代表首个文本结果;1 代表中间文本结果;2 代表最后一个文本结果。
+					// 			// status: 0|1|2,
+					// 		};
+					// 	},
+					// 	protocol: "sse",
+					// },
 				},
 				bubblePanelMenus: [
 					{
@@ -747,8 +752,8 @@ load();
 		style="width: 80%"
 		preset="dialog"
 		positive-text="确认"
-		negative-text="算了"
-		title="确认"
+		negative-text="取消"
+		title="AI 编辑"
 		@positive-click="submitCallback"
 		@negative-click="showDialog = false"
 	>