+ By using this service, users are required to agree to the following terms:
+ The service is a research preview intended for non-commercial use only. It
+ only provides limited safety measures and may generate offensive content.
+ It must not be used for any illegal, harmful, violent, racist, or sexual
+ purposes. The service may collect user dialogue data for future research.
+ Please click the "Flag" button if you get any inappropriate answer! We
+ will collect those to keep improving our moderator. For an optimal
+ experience, please use desktop computers for this demo, as mobile devices
+ may compromise its quality.
+
+ {/if}
+
diff --git a/VisualQnA/docker/ui/svelte/src/lib/network/chat/Network.ts b/VisualQnA/docker/ui/svelte/src/lib/network/chat/Network.ts
new file mode 100644
index 000000000..2381054c6
--- /dev/null
+++ b/VisualQnA/docker/ui/svelte/src/lib/network/chat/Network.ts
@@ -0,0 +1,34 @@
+// Copyright (c) 2024 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import { env } from "$env/dynamic/public";
+import { SSE } from "sse.js";
+
+const BACKEND_BASE_URL = env.BACKEND_BASE_URL;
+
+export async function fetchTextStream(query: string, knowledge_base_id: string, isCheckedStore: boolean) {
+ let payload = {};
+ let url = "";
+
+ payload = {
+ messages: query,
+ stream: "True",
+ };
+ url = `${BACKEND_BASE_URL}`;
+
+ return new SSE(url, {
+ headers: { "Content-Type": "application/json" },
+ payload: JSON.stringify(payload),
+ });
+}
diff --git a/VisualQnA/docker/ui/svelte/src/lib/network/upload/Network.ts b/VisualQnA/docker/ui/svelte/src/lib/network/upload/Network.ts
new file mode 100644
index 000000000..284494f85
--- /dev/null
+++ b/VisualQnA/docker/ui/svelte/src/lib/network/upload/Network.ts
@@ -0,0 +1,57 @@
+// Copyright (c) 2024 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import { env } from "$env/dynamic/public";
+
+const BACKEND_BASE_URL = env.BACKEND_BASE_URL;
+
+export async function fetchKnowledgeBaseId(file: Blob, fileName: string) {
+ const url = `${BACKEND_BASE_URL}/create`;
+ const formData = new FormData();
+ formData.append("file", file, fileName);
+ const init: RequestInit = {
+ method: "POST",
+ body: formData,
+ };
+
+ try {
+ const response = await fetch(url, init);
+ if (!response.ok) throw response.status;
+ return await response.json();
+ } catch (error) {
+ console.error("network error: ", error);
+ return undefined;
+ }
+}
+
+export async function fetchKnowledgeBaseIdByPaste(pasteUrlList: any, urlType: string | undefined) {
+ const url = `${BACKEND_BASE_URL}/upload_link`;
+ const data = {
+ link_list: pasteUrlList,
+ };
+ const init: RequestInit = {
+ method: "POST",
+ headers: { "Content-Type": "application/json" },
+ body: JSON.stringify(data),
+ };
+
+ try {
+ const response = await fetch(url, init);
+ if (!response.ok) throw response.status;
+ return await response.json();
+ } catch (error) {
+ console.error("network error: ", error);
+ return undefined;
+ }
+}
diff --git a/VisualQnA/docker/ui/svelte/src/lib/shared/Utils.ts b/VisualQnA/docker/ui/svelte/src/lib/shared/Utils.ts
new file mode 100644
index 000000000..fb182cef6
--- /dev/null
+++ b/VisualQnA/docker/ui/svelte/src/lib/shared/Utils.ts
@@ -0,0 +1,54 @@
+// Copyright (c) 2024 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+export function scrollToBottom(scrollToDiv: HTMLElement) {
+ if (scrollToDiv) {
+ setTimeout(
+ () =>
+ scrollToDiv.scroll({
+ behavior: "auto",
+ top: scrollToDiv.scrollHeight,
+ }),
+ 100,
+ );
+ }
+}
+
+export function scrollToTop(scrollToDiv: HTMLElement) {
+ if (scrollToDiv) {
+ setTimeout(
+ () =>
+ scrollToDiv.scroll({
+ behavior: "auto",
+ top: 0,
+ }),
+ 100,
+ );
+ }
+}
+
+export function getCurrentTimeStamp() {
+ return Math.floor(new Date().getTime());
+}
+
+export function fromTimeStampToTime(timeStamp: number) {
+ return new Date(timeStamp * 1000).toTimeString().slice(0, 8);
+}
+
+export function formatTime(seconds) {
+ const hours = String(Math.floor(seconds / 3600)).padStart(2, "0");
+ const minutes = String(Math.floor((seconds % 3600) / 60)).padStart(2, "0");
+ const remainingSeconds = String(seconds % 60).padStart(2, "0");
+ return `${hours}:${minutes}:${remainingSeconds}`;
+}
diff --git a/VisualQnA/docker/ui/svelte/src/lib/shared/components/header/header.svelte b/VisualQnA/docker/ui/svelte/src/lib/shared/components/header/header.svelte
new file mode 100644
index 000000000..c851dec98
--- /dev/null
+++ b/VisualQnA/docker/ui/svelte/src/lib/shared/components/header/header.svelte
@@ -0,0 +1,33 @@
+
+
+
+
+
+
diff --git a/VisualQnA/docker/ui/svelte/src/lib/shared/components/loading/Loading.svelte b/VisualQnA/docker/ui/svelte/src/lib/shared/components/loading/Loading.svelte
new file mode 100644
index 000000000..51e89cfe7
--- /dev/null
+++ b/VisualQnA/docker/ui/svelte/src/lib/shared/components/loading/Loading.svelte
@@ -0,0 +1,48 @@
+
+
+
+
+
+
diff --git a/VisualQnA/docker/ui/svelte/src/lib/shared/constant/Interface.ts b/VisualQnA/docker/ui/svelte/src/lib/shared/constant/Interface.ts
new file mode 100644
index 000000000..221f17a26
--- /dev/null
+++ b/VisualQnA/docker/ui/svelte/src/lib/shared/constant/Interface.ts
@@ -0,0 +1,47 @@
+// Copyright (c) 2024 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+export enum MessageRole {
+ Assistant,
+ User,
+}
+
+export enum MessageType {
+ Text,
+ SingleAudio,
+ AudioList,
+ SingleImage,
+ ImageList,
+ singleVideo,
+}
+
+type Map = T extends MessageType.Text | MessageType.SingleAudio
+ ? string
+ : T extends MessageType.AudioList
+ ? string[]
+ : T extends MessageType.SingleImage
+ ? { imgSrc: string; imgId: string }
+ : { imgSrc: string; imgId: string }[];
+
+export interface Message {
+ role: MessageRole;
+ type: MessageType;
+ content: Map;
+ time: number;
+}
+
+export enum LOCAL_STORAGE_KEY {
+ STORAGE_CHAT_KEY = "chatMessages",
+ STORAGE_TIME_KEY = "initTime",
+}
diff --git a/VisualQnA/docker/ui/svelte/src/lib/shared/stores/common/Store.ts b/VisualQnA/docker/ui/svelte/src/lib/shared/stores/common/Store.ts
new file mode 100644
index 000000000..19a120497
--- /dev/null
+++ b/VisualQnA/docker/ui/svelte/src/lib/shared/stores/common/Store.ts
@@ -0,0 +1,41 @@
+// Copyright (c) 2024 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import { writable } from "svelte/store";
+
+export let open = writable(true);
+
+export let knowledgeAccess = writable(true);
+
+export let showTemplate = writable(false);
+
+export let showSidePage = writable(false);
+
+export let droppedObj = writable({});
+
+export let isLoading = writable(false);
+
+export let newUploadNum = writable(0);
+
+export let ifStoreMsg = writable(true);
+
+export let isCheckedStore = writable(false);
+
+export const resetControl = writable(false);
+
+export const knowledge1 = writable<{
+ id: string;
+}>();
+
+export const knowledgeName = writable("");
diff --git a/VisualQnA/docker/ui/svelte/src/routes/+layout.svelte b/VisualQnA/docker/ui/svelte/src/routes/+layout.svelte
new file mode 100644
index 000000000..8141177d4
--- /dev/null
+++ b/VisualQnA/docker/ui/svelte/src/routes/+layout.svelte
@@ -0,0 +1,48 @@
+
+
+
+
+
+
+
+
+
diff --git a/VisualQnA/docker/ui/svelte/src/routes/+page.ts b/VisualQnA/docker/ui/svelte/src/routes/+page.ts
new file mode 100644
index 000000000..f4de8d676
--- /dev/null
+++ b/VisualQnA/docker/ui/svelte/src/routes/+page.ts
@@ -0,0 +1,26 @@
+// Copyright (c) 2024 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import { browser } from "$app/environment";
+import { LOCAL_STORAGE_KEY } from "$lib/shared/constant/Interface";
+
+export const load = async () => {
+ if (browser) {
+ const chat = localStorage.getItem(LOCAL_STORAGE_KEY.STORAGE_CHAT_KEY);
+
+ return {
+ chatMsg: JSON.parse(chat || "[]"),
+ };
+ }
+};
diff --git a/VisualQnA/docker/ui/svelte/static/favicon.png b/VisualQnA/docker/ui/svelte/static/favicon.png
new file mode 100644
index 000000000..75b997f81
Binary files /dev/null and b/VisualQnA/docker/ui/svelte/static/favicon.png differ
diff --git a/VisualQnA/docker/ui/svelte/svelte.config.js b/VisualQnA/docker/ui/svelte/svelte.config.js
new file mode 100644
index 000000000..0f2977ecc
--- /dev/null
+++ b/VisualQnA/docker/ui/svelte/svelte.config.js
@@ -0,0 +1,38 @@
+// Copyright (c) 2024 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import adapter from "@sveltejs/adapter-auto";
+import preprocess from "svelte-preprocess";
+import postcssPresetEnv from "postcss-preset-env";
+
+/** @type {import('@sveltejs/kit').Config} */
+const config = {
+ // Consult https://github.com/sveltejs/svelte-preprocess
+ // for more information about preprocessors
+ preprocess: preprocess({
+ sourceMap: true,
+ postcss: {
+ plugins: [postcssPresetEnv({ features: { "nesting-rules": true } })],
+ },
+ }),
+
+ kit: {
+ adapter: adapter(),
+ env: {
+ publicPrefix: "",
+ },
+ },
+};
+
+export default config;
diff --git a/VisualQnA/docker/ui/svelte/tailwind.config.cjs b/VisualQnA/docker/ui/svelte/tailwind.config.cjs
new file mode 100644
index 000000000..6cc3a8b95
--- /dev/null
+++ b/VisualQnA/docker/ui/svelte/tailwind.config.cjs
@@ -0,0 +1,43 @@
+// Copyright (c) 2024 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+const config = {
+ content: ["./src/**/*.{html,js,svelte,ts}", "./node_modules/flowbite-svelte/**/*.{html,js,svelte,ts}"],
+
+ plugins: [require("flowbite/plugin")],
+
+ darkMode: "class",
+
+ theme: {
+ extend: {
+ colors: {
+ // flowbite-svelte
+ primary: {
+ 50: "#FFF5F2",
+ 100: "#FFF1EE",
+ 200: "#FFE4DE",
+ 300: "#FFD5CC",
+ 400: "#FFBCAD",
+ 500: "#FE795D",
+ 600: "#EF562F",
+ 700: "#EB4F27",
+ 800: "#CC4522",
+ 900: "#A5371B",
+ },
+ },
+ },
+ },
+};
+
+module.exports = config;
diff --git a/VisualQnA/docker/ui/svelte/tsconfig.json b/VisualQnA/docker/ui/svelte/tsconfig.json
new file mode 100644
index 000000000..0f47472f7
--- /dev/null
+++ b/VisualQnA/docker/ui/svelte/tsconfig.json
@@ -0,0 +1,13 @@
+{
+ "extends": "./.svelte-kit/tsconfig.json",
+ "compilerOptions": {
+ "allowJs": true,
+ "checkJs": true,
+ "esModuleInterop": true,
+ "forceConsistentCasingInFileNames": true,
+ "resolveJsonModule": true,
+ "skipLibCheck": true,
+ "sourceMap": true,
+ "strict": true
+ }
+}
diff --git a/VisualQnA/docker/ui/svelte/vite.config.ts b/VisualQnA/docker/ui/svelte/vite.config.ts
new file mode 100644
index 000000000..1166165dc
--- /dev/null
+++ b/VisualQnA/docker/ui/svelte/vite.config.ts
@@ -0,0 +1,23 @@
+// Copyright (c) 2024 Intel Corporation
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+import { sveltekit } from "@sveltejs/kit/vite";
+import type { UserConfig } from "vite";
+
+const config: UserConfig = {
+ plugins: [sveltekit()],
+ server: {},
+};
+
+export default config;