From ce25e1931cc6de21578c46c5619a9054bdd45eb5 Mon Sep 17 00:00:00 2001 From: DebugIsFalse <511418503@qq.com> Date: Thu, 16 May 2024 14:45:49 +0800 Subject: [PATCH] feature: add featrue --- composables/useFetchRequest.js | 14 +-- pages/index.vue | 19 +++- pages/search/[id].vue | 176 ++++++++++++++++++++++----------- server/api/mock/[...slug].js | 2 +- 4 files changed, 139 insertions(+), 72 deletions(-) diff --git a/composables/useFetchRequest.js b/composables/useFetchRequest.js index 5d87309..0531269 100644 --- a/composables/useFetchRequest.js +++ b/composables/useFetchRequest.js @@ -1,27 +1,17 @@ -const BASE_URL = 'http://localhost:3000'; +const BASE_URL = 'https://gpu-pod656e861afe3d944d6b3ce77e-7862.node.inscode.run'; const useFetchRequest = (baseUrl) => { baseUrl = baseUrl || BASE_URL; const config = { headers: {} }; - const loading = ref(false); const fetchRequest = (url, fetchConfig) => { url = `${BASE_URL}${url}`; fetchConfig = fetchConfig || {}; fetchConfig.method = (fetchConfig.method || 'get').toLocaleUpperCase(); - if (!fetchConfig['Content-Type']) { - fetchConfig['Content-Type'] = 'application/json'; - } fetchConfig = Object.assign(config, fetchConfig); - return $fetch(url, fetchConfig).then(async (response) => { - console.log(`response:`, response) - return response; - }).finally(() => { - loading.value = false - }) + return $fetch(url, fetchConfig); } return { - loading, fetchRequest } } diff --git a/pages/index.vue b/pages/index.vue index 2ae0f07..fb4290d 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -24,10 +24,25 @@ diff --git a/pages/search/[id].vue b/pages/search/[id].vue index 61dcd96..4affa35 100644 --- a/pages/search/[id].vue +++ b/pages/search/[id].vue @@ -133,9 +133,11 @@ \ No newline at end of file diff --git a/server/api/mock/[...slug].js b/server/api/mock/[...slug].js index 51e2c61..ca5447b 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: 'Hello World' } + 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) -- GitLab