From 3a102b2f731d87b5493273a0ca289dd843f0bd29 Mon Sep 17 00:00:00 2001 From: DebugIsFalse <511418503@qq.com> Date: Fri, 17 May 2024 11:08:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=88=A0=E9=99=A4=E5=88=86=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/i/Create.vue | 14 +++++++------- components/md/renderer.vue | 8 ++++---- composables/useFetchRequest.js | 16 ++++++++-------- layouts/default.vue | 2 +- pages/md.vue | 16 ++++++++-------- server/api/fetchMarkdown.js | 2 +- server/api/mock/[...slug].js | 2 +- utils/fetchEventSource.js | 2 +- 8 files changed, 31 insertions(+), 31 deletions(-) diff --git a/components/i/Create.vue b/components/i/Create.vue index 2449fb5..a49d45c 100644 --- a/components/i/Create.vue +++ b/components/i/Create.vue @@ -38,21 +38,21 @@ const repos = ref([ { url: 'https://github.com/allwefantasy/byzer-llm.git', label: 'byzer-llm', branch: 'master' }, { url: 'https://github.com/keycloak/keycloak.git', label: 'keycloak', branch: 'master' } ]) -const loading = ref(false); +const loading = ref(false) const handleSearch = async () => { - if (loading.value) return; - loading.value = true; + if (loading.value) return + loading.value = true const result = await fetchRequest('/v1/chat/completion/create', { method: 'post', headers: { 'Content-Type': 'application/x-www-form-urlencoded' } - }); + }) if (result && result.data) { - const currentRepo = repos.value.find(item => item.label === selectedRepo.value); - navigateTo(`/search/${result.data.c_id}?query=${query.value}&repo=${selectedRepo.value}`); + const currentRepo = repos.value.find(item => item.label === selectedRepo.value) + navigateTo(`/search/${result.data.c_id}?query=${query.value}&repo=${selectedRepo.value}`) nextTick(() => { - loading.value = false; + loading.value = false }) } } diff --git a/components/md/renderer.vue b/components/md/renderer.vue index b07a272..f1bbd5e 100644 --- a/components/md/renderer.vue +++ b/components/md/renderer.vue @@ -19,17 +19,17 @@ const initMarkdownIt = new MarkdownIt({ try { return `
` +
                hljs.highlight(str, { language: lang, ignoreIllegals: true }).value +
-               '
'; + '' } catch (__) {} } - return '
' + initMarkdownIt.utils.escapeHtml(str) + '
'; + return '
' + initMarkdownIt.utils.escapeHtml(str) + '
' } }) const handleRenderMd = () => { - mdHtml.value = initMarkdownIt.render(props.content || ''); + mdHtml.value = initMarkdownIt.render(props.content || '') } watch( () => props.content, () => { - handleRenderMd(); + handleRenderMd() }, { immediate: true }) \ No newline at end of file diff --git a/composables/useFetchRequest.js b/composables/useFetchRequest.js index 46d1fd9..91c9e6d 100644 --- a/composables/useFetchRequest.js +++ b/composables/useFetchRequest.js @@ -1,18 +1,18 @@ const BASE_URL = 'https://gpu-pod656e861afe3d944d6b3ce77e-7862.node.inscode.run' const useFetchRequest = (baseUrl) => { - baseUrl = baseUrl || BASE_URL; + baseUrl = baseUrl || BASE_URL const config = { headers: {} - }; + } const fetchRequest = (url, fetchConfig) => { - url = `${BASE_URL}${url}`; - fetchConfig = fetchConfig || {}; - fetchConfig.method = (fetchConfig.method || 'get').toLocaleUpperCase(); - fetchConfig = Object.assign(config, fetchConfig); - return $fetch(url, fetchConfig); + url = `${BASE_URL}${url}` + fetchConfig = fetchConfig || {} + fetchConfig.method = (fetchConfig.method || 'get').toLocaleUpperCase() + fetchConfig = Object.assign(config, fetchConfig) + return $fetch(url, fetchConfig) } return { fetchRequest } } -export default useFetchRequest; \ No newline at end of file +export default useFetchRequest \ No newline at end of file diff --git a/layouts/default.vue b/layouts/default.vue index d407df5..4043e5e 100644 --- a/layouts/default.vue +++ b/layouts/default.vue @@ -33,6 +33,6 @@ diff --git a/pages/md.vue b/pages/md.vue index f653d74..33f94b8 100644 --- a/pages/md.vue +++ b/pages/md.vue @@ -7,8 +7,8 @@ \ No newline at end of file diff --git a/server/api/fetchMarkdown.js b/server/api/fetchMarkdown.js index 74bd431..7e09b81 100644 --- a/server/api/fetchMarkdown.js +++ b/server/api/fetchMarkdown.js @@ -1,6 +1,6 @@ export default defineEventHandler(async (event) => { // const config = useRuntimeConfig(event) - const cookie = event.headers.get('cookie'); + const cookie = event.headers.get('cookie') // console.log(`config:`, event.headers.get('cookie')) const repo = await $fetch('https://ieditor-ai.inscode.cc/ai/md', { method: 'POST', diff --git a/server/api/mock/[...slug].js b/server/api/mock/[...slug].js index ca5447b..25ed0f7 100644 --- a/server/api/mock/[...slug].js +++ b/server/api/mock/[...slug].js @@ -3,7 +3,7 @@ import { createRouter, defineEventHandler, useBase } from 'h3' const router = createRouter() router.get('/test', defineEventHandler(() => { - return 'data:{"message":"success","data":{"id":"c_20240516095719_bfaJkBJyg4KTwL8g","object":"chat.completion","created":1715824958,"model":"chat_qwen110b","choices":[{"index":0,"message":{"role":"assistant","content":"Hello! I\'m here to help you with any questions or tasks related to the Byzer-LLM project or its usage. Whether you need assistance with deployment, querying models, understanding the integration process, or exploring its features, feel free to ask. For instance, if you\'re looking to set up a model like `sparkdesk_chat`, run a simple inference, validate the model, or even understand how to use Python scripts for interacting with Byzer-LLM, just let me know your specific inquiry!"},"finish_reason":"stop"}],"usage":{"prompt_tokens":6653,"completion_tokens":104,"total_tokens":6757},"meta":{"type":"answer"}}}'; + return 'data:{"message":"success","data":{"id":"c_20240516095719_bfaJkBJyg4KTwL8g","object":"chat.completion","created":1715824958,"model":"chat_qwen110b","choices":[{"index":0,"message":{"role":"assistant","content":"Hello! I\'m here to help you with any questions or tasks related to the Byzer-LLM project or its usage. Whether you need assistance with deployment, querying models, understanding the integration process, or exploring its features, feel free to ask. For instance, if you\'re looking to set up a model like `sparkdesk_chat`, run a simple inference, validate the model, or even understand how to use Python scripts for interacting with Byzer-LLM, just let me know your specific inquiry!"},"finish_reason":"stop"}],"usage":{"prompt_tokens":6653,"completion_tokens":104,"total_tokens":6757},"meta":{"type":"answer"}}}' })) export default useBase('/api/mock', router.handler) diff --git a/utils/fetchEventSource.js b/utils/fetchEventSource.js index 254be64..3020f4d 100644 --- a/utils/fetchEventSource.js +++ b/utils/fetchEventSource.js @@ -11,5 +11,5 @@ export default (url, { onmessage, onerror, controller, params }) => { onmessage, onerror, signal: controller && controller.signal - }); + }) } \ No newline at end of file -- GitLab