diff --git a/renderer/src/components/main-panel/chat/index.vue b/renderer/src/components/main-panel/chat/index.vue index 52d9e3d..ec031a8 100644 --- a/renderer/src/components/main-panel/chat/index.vue +++ b/renderer/src/components/main-panel/chat/index.vue @@ -10,84 +10,17 @@
-
-
- {{ message.content }} -
+
-
Agent
-
-
-
- +
-
- Agent - - 正在使用工具 - - - -
-
-
- -
-
-
- {{ call.function.name }} - {{ 'tool' }} - - - -
-
-
-
-
-
-
-
- - -
-
- {{ "响应" }} - - - -
-
-
-
-
-
-
- -
- -
{{ item.text }}
-
{{ JSON.stringify(item) }}
-
-
-
-
-
-
- +
@@ -125,7 +58,7 @@ - + @@ -148,16 +81,16 @@ import { ref, onMounted, defineComponent, defineProps, onUnmounted, computed, ne import { useI18n } from 'vue-i18n'; import { ElMessage, ScrollbarInstance } from 'element-plus'; import { tabs } from '../panel'; -import { ChatMessage, ChatStorage, getToolSchema, IExtraInfo, ToolCall } from './chat'; - +import { ChatMessage, ChatStorage, IExtraInfo, ToolCall } from './chat'; import Setting from './setting.vue'; -import MessageMeta from './message-meta.vue'; // 引入 markdown.ts 中的函数 -import { markdownToHtml, copyToClipboard } from './markdown'; -import { ChatCompletionChunk, TaskLoop } from './task-loop'; -import { createTest, llmManager, llms } from '@/views/setting/llm'; +import { markdownToHtml } from './markdown'; +import { TaskLoop } from './task-loop'; +import { llmManager, llms } from '@/views/setting/llm'; + +import * as Message from './message'; defineComponent({ name: 'chat' }); @@ -377,26 +310,9 @@ onUnmounted(() => { window.removeEventListener('resize', updateScrollHeight); }); -// 新增辅助函数检查是否为有效JSON -const isValidJSON = (str: string) => { - try { - JSON.parse(str); - return true; - } catch { - return false; - } -}; - -const jsonResultToHtml = (jsonString: string) => { - const formattedJson = JSON.stringify(JSON.parse(jsonString), null, 2); - const html = markdownToHtml('```json\n' + formattedJson + '\n```'); - return html; -}; - - - - \ No newline at end of file + diff --git a/renderer/src/components/main-panel/chat/message-meta.vue b/renderer/src/components/main-panel/chat/message-meta.vue deleted file mode 100644 index 46f00e5..0000000 --- a/renderer/src/components/main-panel/chat/message-meta.vue +++ /dev/null @@ -1,85 +0,0 @@ - - - - - \ No newline at end of file diff --git a/renderer/src/views/connect/connection-log.vue b/renderer/src/views/connect/connection-log.vue index 7262391..a49bbd0 100644 --- a/renderer/src/views/connect/connection-log.vue +++ b/renderer/src/views/connect/connection-log.vue @@ -2,11 +2,10 @@
{{ t('log') }} -
- {{ connectionResult.logString }} +
+
+ {{ log.message }} +
@@ -34,7 +33,7 @@ const { t } = useI18n(); .connection-option .output-content { border-radius: .5em; - padding: 15px; + padding: 12px 16px; min-height: 300px; height: fit-content; font-family: var(--code-font-family); @@ -42,9 +41,59 @@ const { t } = useI18n(); word-break: break-all; user-select: text; cursor: text; - font-size: 15px; - line-height: 1.5; - background-color: var(--sidebar); + font-size: 14px; + line-height: 1.6; + background-color: rgba(var(--sidebar), 0.3); height: 95%; } + +.output-content .info { + background-color: rgba(103, 194, 58, 0.5); + margin: 8px 0; + margin-bottom: 12px; + padding: 5px 9px; + border-radius: .5em; +} + +.output-content .error { + background-color: rgba(245, 108, 108, 0.5); + margin: 8px 0; + margin-bottom: 12px; + padding: 5px 9px; + border-radius: .5em; +} + +.output-content .warning { + background-color: rgba(230, 162, 60, 0.5); + margin: 8px 0; + margin-bottom: 12px; + padding: 5px 9px; + border-radius: .5em; +} + +.log-icon { + display: inline-block; + width: 8px; + height: 8px; + border-radius: 50%; + margin-right: 8px; + vertical-align: middle; +} + +.log-icon.info { + background-color: rgba(103, 194, 58, 0.3); +} + +.log-icon.error { + background-color: rgba(245, 108, 108, 0.3); +} + +.log-icon.warning { + background-color: rgba(230, 162, 60, 0.3); +} + +.log-message { + display: inline-block; + vertical-align: middle; +} \ No newline at end of file diff --git a/renderer/src/views/connect/connection.ts b/renderer/src/views/connect/connection.ts index fd5a45f..562dfad 100644 --- a/renderer/src/views/connect/connection.ts +++ b/renderer/src/views/connect/connection.ts @@ -3,7 +3,6 @@ import { reactive } from 'vue'; import { pinkLog } from '../setting/util'; import { ElMessage } from 'element-plus'; import { ILaunchSigature } from '@/hook/type'; -import { url } from 'inspector'; export const connectionMethods = reactive({ current: 'STDIO', @@ -80,17 +79,25 @@ export function doConnect() { bridge.addCommandListener('connect', async data => { const { code, msg } = data; connectionResult.success = (code === 200); - connectionResult.logString = msg; if (code === 200) { const res = await getServerVersion() as { name: string, version: string }; connectionResult.serverInfo.name = res.name || ''; connectionResult.serverInfo.version = res.version || ''; + connectionResult.logString.push({ + type: 'info', + message: msg + }); + } else { ElMessage({ type: 'error', message: msg }); + connectionResult.logString.push({ + type: 'error', + message: msg + }); } resolve(void 0); @@ -189,9 +196,13 @@ async function launchStdio() { bridge.addCommandListener('connect', async data => { const { code, msg } = data; connectionResult.success = (code === 200); - connectionResult.logString = msg; if (code === 200) { + connectionResult.logString.push({ + type: 'info', + message: msg + }); + const res = await getServerVersion() as { name: string, version: string }; connectionResult.serverInfo.name = res.name || ''; connectionResult.serverInfo.version = res.version || ''; @@ -217,6 +228,11 @@ async function launchStdio() { }); } else { + connectionResult.logString.push({ + type: 'error', + message: msg + }); + ElMessage({ type: 'error', message: msg @@ -257,9 +273,13 @@ async function launchSSE() { bridge.addCommandListener('connect', async data => { const { code, msg } = data; connectionResult.success = (code === 200); - connectionResult.logString = msg; if (code === 200) { + connectionResult.logString.push({ + type: 'info', + message: msg + }); + const res = await getServerVersion() as { name: string, version: string }; connectionResult.serverInfo.name = res.name || ''; connectionResult.serverInfo.version = res.version || ''; @@ -279,6 +299,11 @@ async function launchSSE() { }); } else { + connectionResult.logString.push({ + type: 'error', + message: msg + }); + ElMessage({ type: 'error', message: msg @@ -328,9 +353,16 @@ export function doReconnect() { console.log(); } -export const connectionResult = reactive({ +export const connectionResult = reactive<{ + success: boolean, + logString: { type: 'info' | 'error' | 'warning', message: string }[], + serverInfo: { + name: string, + version: string + } +}>({ success: false, - logString: '', + logString: [], serverInfo: { name: '', version: '' @@ -353,3 +385,7 @@ export function getServerVersion() { }); }); } + +export const envVarStatus = { + launched: false +}; \ No newline at end of file diff --git a/renderer/src/views/connect/env-var.vue b/renderer/src/views/connect/env-var.vue index 86f5231..7efc576 100644 --- a/renderer/src/views/connect/env-var.vue +++ b/renderer/src/views/connect/env-var.vue @@ -44,7 +44,7 @@