From 53835cb16203279de8e213d72e0b6f6681297351 Mon Sep 17 00:00:00 2001
From: gjl <2802427218@qq.com>
Date: Thu, 10 Oct 2024 12:15:59 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=B9=E8=AF=9Dbug?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../src/renderer/src/views/agentconfig.vue | 15 +---
.../renderer/src/views/conversationSummary.ts | 4 +-
.../renderer/src/views/customComponents.ts | 87 ++++++++++---------
Frontend/src/renderer/src/views/home.vue | 28 ++++--
.../src/views/knowledgebase/kbconfig.vue | 2 +-
.../src/views/knowledgebase/newkbdialog.vue | 22 ++++-
6 files changed, 88 insertions(+), 70 deletions(-)
diff --git a/Frontend/src/renderer/src/views/agentconfig.vue b/Frontend/src/renderer/src/views/agentconfig.vue
index 21ada61..1884da7 100644
--- a/Frontend/src/renderer/src/views/agentconfig.vue
+++ b/Frontend/src/renderer/src/views/agentconfig.vue
@@ -191,7 +191,6 @@ import {
ElFormItem,
ElInput,
ElButton,
- ElUpload,
ElContainer,
ElHeader,
ElSlider,
@@ -199,7 +198,7 @@ import {
ElOption,
ElMessage
} from 'element-plus'
-import { ArrowDown, UploadFilled } from '@element-plus/icons-vue'
+import { ArrowDown } from '@element-plus/icons-vue'
import uploadIcon from '../assets/material-symbols--upload-sharp.png'
import { Icon } from '@iconify/vue'
import { useRoute, useRouter } from 'vue-router'
@@ -221,17 +220,6 @@ const agentForm = reactive({
max_tokens: 4096
})
-const fakeRAGOptions = ref([
- {
- value: 'knowledge_base',
- label: '知识库1'
- },
- {
- value: 'knowledge_base1',
- label: '知识库2'
- }
-])
-const selectedRAGOption = ref('')
const onUploadIcon = () => {
const input = document.createElement('input')
@@ -383,7 +371,6 @@ onMounted(() => {
import { useConversation } from './conversationApi'
import { Tool } from './toolConfig'
-import IconifyIconOffline from '../components/ReIcon/src/iconifyIconOffline'
const { handleDebugConversation, debugConversationConfig } = useConversation()
diff --git a/Frontend/src/renderer/src/views/conversationSummary.ts b/Frontend/src/renderer/src/views/conversationSummary.ts
index c383ca0..9e82033 100644
--- a/Frontend/src/renderer/src/views/conversationSummary.ts
+++ b/Frontend/src/renderer/src/views/conversationSummary.ts
@@ -21,8 +21,8 @@ export const conversationSummary = async (chatConversation: string) => {
agent_enable: false,
tool_config: [],
chat_model_config: {
- api_key: "",
- base_url: "",
+ api_key: "sk-cERDW9Fr2ujq8D2qYck9cpc9MtPytN26466bunfYXZVZWV7Y",
+ base_url: "https://api.chatanywhere.tech/v1/",
is_openai: true,
llm_model: {
"gpt-4o": {
diff --git a/Frontend/src/renderer/src/views/customComponents.ts b/Frontend/src/renderer/src/views/customComponents.ts
index 0f31062..6b341f9 100644
--- a/Frontend/src/renderer/src/views/customComponents.ts
+++ b/Frontend/src/renderer/src/views/customComponents.ts
@@ -1,10 +1,10 @@
export class JsonCollapse extends HTMLElement {
- private header: HTMLDivElement | null = null;
- private content: HTMLDivElement | null = null;
+ private header: HTMLDivElement | null = null
+ private content: HTMLDivElement | null = null
constructor() {
- super();
- this.attachShadow({ mode: "open" });
+ super()
+ this.attachShadow({ mode: 'open' })
this.shadowRoot!.innerHTML = `
-
+
- `;
+ `
- this.header = this.shadowRoot!.querySelector("#header");
- this.content = this.shadowRoot!.querySelector("#content");
+ this.header = this.shadowRoot!.querySelector('#header')
+ this.content = this.shadowRoot!.querySelector('#content')
- this.header?.addEventListener("click", this.toggleContent.bind(this));
+ this.header?.addEventListener('click', this.toggleContent.bind(this))
}
connectedCallback() {
- this.renderJson();
+ this.renderJson()
}
static get observedAttributes() {
- return ["data-json"];
+ return ['data-json']
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
attributeChangedCallback(name: string, _oldValue: string, _newValue: string) {
- if (name === "data-json") {
- this.renderJson();
+ if (name === 'data-json') {
+ this.renderJson()
}
}
private toggleContent() {
if (this.content) {
- this.content.style.display = this.content.style.display === "block" ? "none" : "block";
+ this.content.style.display = this.content.style.display === 'block' ? 'none' : 'block'
}
}
private renderJson() {
- const json = this.getAttribute("data-json");
+ const json = this.getAttribute('data-json')
if (this.content) {
try {
- const obj = JSON.parse(json || "{}");
- const formattedJson = JSON.stringify(obj, null, 2);
- this.content.textContent = formattedJson;
+ const obj = JSON.parse(json || '{}')
+ const formattedJson = JSON.stringify(obj, null, 2)
+ this.content.textContent = formattedJson
} catch (e) {
- this.content.textContent = "Invalid JSON";
+ this.content.textContent = 'Invalid JSON'
}
}
}
}
-
export class MessageCollapse extends HTMLElement {
- private header: HTMLDivElement | null = null;
- private content: HTMLDivElement | null = null;
- private isCollapsed = true;
+ private header: HTMLDivElement | null = null
+ private content: HTMLDivElement | null = null
+ private isCollapsed = true
constructor() {
- super();
- this.attachShadow({ mode: "open" });
+ super()
+ this.attachShadow({ mode: 'open' })
this.shadowRoot!.innerHTML = `
- `;
+ `
- this.header = this.shadowRoot!.querySelector("#header");
- this.content = this.shadowRoot!.querySelector("#content");
+ this.header = this.shadowRoot!.querySelector('#header')
+ this.content = this.shadowRoot!.querySelector('#content')
- this.header?.addEventListener("click", this.toggleContent.bind(this));
+ this.header?.addEventListener('click', this.toggleContent.bind(this))
}
connectedCallback() {
- this.renderMessage();
+ this.renderMessage()
}
static get observedAttributes() {
- return ["data-message"];
+ return ['data-message']
}
attributeChangedCallback(name: string, _oldValue: string, _newValue: string) {
- if (name === "data-message") {
- this.renderMessage();
+ console.log(_oldValue, _newValue)
+ if (name === 'data-message') {
+ this.renderMessage()
}
}
private toggleContent() {
if (this.content) {
- this.isCollapsed = !this.isCollapsed;
- this.content.style.display = this.isCollapsed ? "none" : "block";
- this.header!.textContent = this.isCollapsed ? this.getCollapsedMessage() : this.getFullMessage();
+ this.isCollapsed = !this.isCollapsed
+ this.content.style.display = this.isCollapsed ? 'none' : 'block'
+ this.header!.textContent = this.isCollapsed
+ ? this.getCollapsedMessage()
+ : this.getFullMessage()
}
}
private renderMessage() {
- const message = this.getAttribute("data-message") || "";
+ const message = this.getAttribute('data-message') || ''
if (this.header && this.content) {
- this.header.textContent = this.getCollapsedMessage();
- this.content.textContent = message;
+ this.header.textContent = this.getCollapsedMessage()
+ this.content.textContent = message
}
}
private getCollapsedMessage() {
- const message = this.getAttribute("data-message") || "";
- return message.length > 50 ? message.substring(0, 50) + "..." : message;
+ const message = this.getAttribute('data-message') || ''
+ return message.length > 50 ? message.substring(0, 50) + '...' : message
}
private getFullMessage() {
- return this.getAttribute("data-message") || "";
+ return this.getAttribute('data-message') || ''
}
}
-
diff --git a/Frontend/src/renderer/src/views/home.vue b/Frontend/src/renderer/src/views/home.vue
index ccecd27..68fb413 100644
--- a/Frontend/src/renderer/src/views/home.vue
+++ b/Frontend/src/renderer/src/views/home.vue
@@ -36,7 +36,7 @@