From b61f4100221a2d96e23de9c90b703c7aa28722a9 Mon Sep 17 00:00:00 2001 From: nemo Date: Mon, 17 Jun 2024 15:36:02 +0100 Subject: [PATCH 1/5] put chat behind proxy --- src/components/ChatWidget.vue | 67 +++++++++++++++++++++++++++++++++-- src/main.ts | 2 ++ 2 files changed, 67 insertions(+), 2 deletions(-) diff --git a/src/components/ChatWidget.vue b/src/components/ChatWidget.vue index e079d25..eca32ed 100644 --- a/src/components/ChatWidget.vue +++ b/src/components/ChatWidget.vue @@ -33,6 +33,7 @@ import axios from 'axios'; import { inject } from 'vue'; import { obpApiHostKey } from '@/obp/keys'; + import { Check, Close } from '@element-plus/icons-vue' import 'prismjs/components/prism-markup'; import 'prismjs/components/prism-javascript'; @@ -41,7 +42,6 @@ import 'prismjs/components/prism-http'; import 'prismjs/components/prism-python'; import 'prismjs/components/prism-go'; - import 'prismjs/themes/prism-okaidia.css'; @@ -82,11 +82,13 @@ console.log('OBP API HOST: ', this.obpApiHost) try { - const response = await axios.post('http://localhost:5000/chat', { + const response = await axios.post('/opey/chat', { session_id: this.sessionId, message: newMessage.content, obp_api_host: this.obpApiHost }); + + console.log(response) if (response.status != 200) { @@ -202,6 +204,35 @@
+
+ + + + + + + + + + + + +
+ +
+
@@ -241,6 +272,29 @@ position: relative; } +.feedback button { + background-color: #fff; + color: #989898; + border: none; + font-size: 20px; +} + +.feedback .approve:hover { + color: #72bc39; +} + +.feedback .bad-response:hover { + color: #bc3939; +} + +.feedback .regenerate:hover { + color: #eb9c09; +} + +.feedback .copy:hover { + color: #0991eb; +} + .quit-button { position: absolute; top: -12px; @@ -334,6 +388,15 @@ background-color: #fff; } +.feedback { + display:none; + align-items: end; +} + +.chat-message.assistant:hover .feedback { + display:block; +} + .chat-message.error { background-color: #eec2c2; color: #b10101; diff --git a/src/main.ts b/src/main.ts index 5a889a3..d9a64bf 100644 --- a/src/main.ts +++ b/src/main.ts @@ -30,6 +30,8 @@ import { createPinia } from 'pinia' import ElementPlus from 'element-plus' import * as ElementPlusIconsVue from '@element-plus/icons-vue' +import { Check, Close } from '@element-plus/icons-vue' + import App from './App.vue' import appRouter from './router' import { createI18n } from 'vue-i18n' From ddb4d49105391e814e4e95c012df6e1375fed03c Mon Sep 17 00:00:00 2001 From: nemo Date: Mon, 17 Jun 2024 15:53:28 +0100 Subject: [PATCH 2/5] add chat url in env --- .env.example | 1 + vite.config.ts | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/.env.example b/.env.example index e121c54..121a98a 100644 --- a/.env.example +++ b/.env.example @@ -14,6 +14,7 @@ VITE_OBP_REDIS_URL = redis://127.0.0.1:6379 # Enable the chatbot interface "Opey" VITE_CHATBOT_ENABLED=false +VITE_CHATBOT_ENDPOINT_URL=http://localhost:5000 # Product styling setting #VITE_OBP_LINKS_COLOR="#52b165" diff --git a/vite.config.ts b/vite.config.ts index d8ff8b9..dce92e1 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -43,6 +43,11 @@ export default defineConfig({ changeOrigin: true, rewrite: (path) => path.replace(/^\/api/, ''), }, + '^/opey': { + target: import.meta.env.VITE_CHATBOT_ENDPOINT_URL, + changeOrigin: true, + rewrite: (path) => path.replace(/^\/opey/, ''), + }, }, }, }) From 605dc81c53fd17cd0922d61dc71228c035e167ae Mon Sep 17 00:00:00 2001 From: nemo Date: Tue, 18 Jun 2024 16:53:58 +0100 Subject: [PATCH 3/5] hard-code chat endpoint --- vite.config.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index dce92e1..b549e28 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,6 @@ import { fileURLToPath, URL } from 'node:url' -import { defineConfig } from 'vite' +import { loadEnv, defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import vueJsx from '@vitejs/plugin-vue-jsx' @@ -12,6 +12,9 @@ import pluginRewriteAll from 'vite-plugin-rewrite-all'; // https://vitejs.dev/config/ export default defineConfig({ + + const env = loadEnv(mode, process.cwd(), ''); + plugins: [ vue(), vueJsx(), AutoImport({ @@ -44,7 +47,7 @@ export default defineConfig({ rewrite: (path) => path.replace(/^\/api/, ''), }, '^/opey': { - target: import.meta.env.VITE_CHATBOT_ENDPOINT_URL, + target: 'http://test-chat.openbankproject.com', changeOrigin: true, rewrite: (path) => path.replace(/^\/opey/, ''), }, From 52916d31a8195421789f118985f1df0f04b3124e Mon Sep 17 00:00:00 2001 From: nemo Date: Tue, 18 Jun 2024 17:00:28 +0100 Subject: [PATCH 4/5] bugfix vite config --- vite.config.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index b549e28..b9a9c2d 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -12,9 +12,7 @@ import pluginRewriteAll from 'vite-plugin-rewrite-all'; // https://vitejs.dev/config/ export default defineConfig({ - - const env = loadEnv(mode, process.cwd(), ''); - + plugins: [ vue(), vueJsx(), AutoImport({ From b0fe2b6d7e8e9e469bbf34c2ba708c21a84e82cc Mon Sep 17 00:00:00 2001 From: nemo Date: Thu, 20 Jun 2024 13:50:10 +0100 Subject: [PATCH 5/5] change chat routing to https --- vite.config.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index b9a9c2d..5e86600 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -12,7 +12,7 @@ import pluginRewriteAll from 'vite-plugin-rewrite-all'; // https://vitejs.dev/config/ export default defineConfig({ - + plugins: [ vue(), vueJsx(), AutoImport({ @@ -45,7 +45,7 @@ export default defineConfig({ rewrite: (path) => path.replace(/^\/api/, ''), }, '^/opey': { - target: 'http://test-chat.openbankproject.com', + target: 'https://test-chat.openbankproject.com', changeOrigin: true, rewrite: (path) => path.replace(/^\/opey/, ''), },