diff --git a/client/web/discovery/package.json b/client/web/discovery/package.json
index d349f16629..90dd015391 100644
--- a/client/web/discovery/package.json
+++ b/client/web/discovery/package.json
@@ -36,6 +36,7 @@
"vue": "2.7.16",
"vue-native-websocket": "^2.0.15",
"vue-router": "^3.4.9",
+ "vue-simple-markdown": "^1.1.5",
"vue-split-panel": "^1.0.4",
"vuex": "^3.6.2"
},
diff --git a/client/web/discovery/src/components/Rag.vue b/client/web/discovery/src/components/Rag.vue
new file mode 100644
index 0000000000..4cc67531fb
--- /dev/null
+++ b/client/web/discovery/src/components/Rag.vue
@@ -0,0 +1,230 @@
+
+
+
+
+
+ {{ $t("title") }}
+
+
+ {{ $t("description") }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ $t("welcome-title") }}
+
+
+ {{ $t("welcome-message") }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Loading...
+
+
+ Loading...
+
+
+ Loading...
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/client/web/discovery/src/components/faIcons.js b/client/web/discovery/src/components/faIcons.js
index d7abbd79b1..7453c51817 100644
--- a/client/web/discovery/src/components/faIcons.js
+++ b/client/web/discovery/src/components/faIcons.js
@@ -16,6 +16,8 @@ import {
faEllipsisV,
faCheck,
faLocationCrosshairs,
+ faPaperPlane,
+ faRobot,
} from '@fortawesome/free-solid-svg-icons'
import {
faQuestionCircle,
@@ -49,4 +51,6 @@ library.add(
faLocationCrosshairs,
faEnvelope,
faEnvelopeOpen,
+ faPaperPlane,
+ faRobot,
)
diff --git a/client/web/discovery/src/components/rag/ChatInput.vue b/client/web/discovery/src/components/rag/ChatInput.vue
new file mode 100644
index 0000000000..e9c219bf30
--- /dev/null
+++ b/client/web/discovery/src/components/rag/ChatInput.vue
@@ -0,0 +1,83 @@
+
+
+
+
+
diff --git a/client/web/discovery/src/components/rag/ChatMessage.vue b/client/web/discovery/src/components/rag/ChatMessage.vue
new file mode 100644
index 0000000000..7c519ea169
--- /dev/null
+++ b/client/web/discovery/src/components/rag/ChatMessage.vue
@@ -0,0 +1,94 @@
+
+
+
+
+
+
+ {{ formatTime(message.timestamp) }}
+
+
+
+
+
+
+
+
diff --git a/client/web/discovery/src/plugins/index.js b/client/web/discovery/src/plugins/index.js
index 56c4630f8b..cd671785da 100644
--- a/client/web/discovery/src/plugins/index.js
+++ b/client/web/discovery/src/plugins/index.js
@@ -3,6 +3,8 @@ import Vuex from 'vuex'
import Router from 'vue-router'
import { BootstrapVue, BootstrapVueIcons } from 'bootstrap-vue'
import VueNativeSock from 'vue-native-websocket'
+import VueSimpleMarkdown from 'vue-simple-markdown'
+import 'vue-simple-markdown/dist/vue-simple-markdown.css'
import { plugins, websocket } from '@cortezaproject/corteza-vue'
import DiscoveryAPI from './searcher.js'
@@ -25,3 +27,4 @@ Vue.use(plugins.CortezaAPI('compose'))
Vue.use(plugins.Settings, { api: Vue.prototype.$SystemAPI })
Vue.use(DiscoveryAPI())
Vue.use(VueNativeSock, websocket.endpoint(), websocket.config)
+Vue.use(VueSimpleMarkdown)
diff --git a/client/web/discovery/src/plugins/searcher.js b/client/web/discovery/src/plugins/searcher.js
index a49e5b0c05..b61a5bf21d 100644
--- a/client/web/discovery/src/plugins/searcher.js
+++ b/client/web/discovery/src/plugins/searcher.js
@@ -89,6 +89,19 @@ class Searcher {
})
}
+ ragApi () {
+ const headers = { ...this.headers }
+ const accessToken = this.accessTokenFn ? this.accessTokenFn() : undefined
+ if (accessToken) {
+ headers.Authorization = 'Bearer ' + accessToken
+ }
+ return axios.create({
+ withCredentials: true,
+ baseURL: this.baseURL,
+ headers,
+ })
+ }
+
// List namespaces
async query (a, extra = {}) {
const {
@@ -127,4 +140,33 @@ class Searcher {
return `/?q=${query}`
}
+
+ // RAG Query
+ async rag (question, extra = {}) {
+ const params = new URLSearchParams()
+ params.append('question', question)
+
+ const cfg = {
+ ...extra,
+ method: 'get',
+ url: '/rag',
+ params,
+ }
+
+ return this.ragApi()
+ .request(cfg)
+ .then((response) => {
+ if (response.data) {
+ return {
+ response: response.data.response,
+ sources: response.data.sources || [],
+ }
+ }
+ return response.data
+ })
+ .catch((error) => {
+ console.error('RAG API error:', error)
+ throw error
+ })
+ }
}
diff --git a/client/web/discovery/src/views/Layout.vue b/client/web/discovery/src/views/Layout.vue
index 091515aa8f..bdc86bc554 100644
--- a/client/web/discovery/src/views/Layout.vue
+++ b/client/web/discovery/src/views/Layout.vue
@@ -20,7 +20,7 @@
}"
>
- {{ $t('discovery') }}
+ {{ $t("discovery") }}
@@ -47,7 +47,7 @@
@@ -62,16 +62,41 @@
:timeout="$Settings.get('auth.autoLogout.timeout')"
:labels="{
extend: $t('general:extendSession.labels.extend'),
- warning: (countdownTime) => $t('general:extendSession.labels.warning', { countdownTime }),
+ warning: (countdownTime) =>
+ $t('general:extendSession.labels.warning', { countdownTime }),
}"
/>
-
+
+
+
+
+
+