{children} diff --git a/chatbot-ui/components/PageBanner.tsx b/chatbot-ui/components/PageBanner.tsx index 15159b0..cd7e2d8 100644 --- a/chatbot-ui/components/PageBanner.tsx +++ b/chatbot-ui/components/PageBanner.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React from 'react'; const PageBanner = () => { return ( @@ -8,10 +8,10 @@ const PageBanner = () => { Beta - This is a new service – your{" "} + This is a new service – your{' '} feedback - {" "} + {' '} will help us to improve it.

diff --git a/chatbot-ui/components/PageFooter.tsx b/chatbot-ui/components/PageFooter.tsx index efed8c5..e16cf82 100644 --- a/chatbot-ui/components/PageFooter.tsx +++ b/chatbot-ui/components/PageFooter.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React from 'react'; interface Props {} diff --git a/chatbot-ui/components/PageHeader.tsx b/chatbot-ui/components/PageHeader.tsx index 3d0f488..0cc705b 100644 --- a/chatbot-ui/components/PageHeader.tsx +++ b/chatbot-ui/components/PageHeader.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React from 'react'; interface Props {} diff --git a/chatbot-ui/components/PageTitle.tsx b/chatbot-ui/components/PageTitle.tsx index 1ee84a4..6342741 100644 --- a/chatbot-ui/components/PageTitle.tsx +++ b/chatbot-ui/components/PageTitle.tsx @@ -1,4 +1,4 @@ -import React from "react"; +import React from 'react'; interface Props { caption?: string; diff --git a/chatbot-ui/next.config.js b/chatbot-ui/next.config.js index 92fe471..0cf5b85 100644 --- a/chatbot-ui/next.config.js +++ b/chatbot-ui/next.config.js @@ -7,7 +7,7 @@ const nextConfig = { webpack(config) { // Grab the existing rule that handles SVG imports const fileLoaderRule = config.module.rules.find((rule) => - rule.test?.test?.(".svg") + rule.test?.test?.('.svg'), ); config.module.rules.push( @@ -22,8 +22,8 @@ const nextConfig = { test: /\.svg$/i, issuer: /\.[jt]sx?$/, resourceQuery: { not: /url/ }, // exclude if *.svg?url - use: ["@svgr/webpack"], - } + use: ['@svgr/webpack'], + }, ); // Modify the file loader rule to ignore *.svg, since we have it handled now. diff --git a/chatbot-ui/pages/_app.tsx b/chatbot-ui/pages/_app.tsx index 09e9304..29688d3 100644 --- a/chatbot-ui/pages/_app.tsx +++ b/chatbot-ui/pages/_app.tsx @@ -1,5 +1,5 @@ -import type { AppProps } from "next/app"; -import "../styles/_all.scss"; +import type { AppProps } from 'next/app'; +import '../styles/_all.scss'; function App({ Component, pageProps }: AppProps) { return ; diff --git a/chatbot-ui/pages/_document.tsx b/chatbot-ui/pages/_document.tsx index 0205e85..7dd48ef 100644 --- a/chatbot-ui/pages/_document.tsx +++ b/chatbot-ui/pages/_document.tsx @@ -1,4 +1,4 @@ -import { Html, Head, Main, NextScript } from "next/document"; +import { Html, Head, Main, NextScript } from 'next/document'; export default function Document() { return ( diff --git a/chatbot-ui/pages/index.tsx b/chatbot-ui/pages/index.tsx index 2c41ce6..6a931e5 100644 --- a/chatbot-ui/pages/index.tsx +++ b/chatbot-ui/pages/index.tsx @@ -1,22 +1,22 @@ -import { useRef, useState, useEffect } from "react"; -import Page from "@/components/Page"; -import styles from "@/styles/Home.module.css"; -import ReactMarkdown from "react-markdown"; -import LoadingDots from "@/components/LoadingDots"; -import classNames from "classnames"; -import React from "react"; -import RobotIcon from "../public/assets/images/icons/robot.svg"; -import UserIcon from "../public/assets/images/icons/user.svg"; +import { useRef, useState, useEffect } from 'react'; +import Page from '@/components/Page'; +import styles from '@/styles/Home.module.css'; +import ReactMarkdown from 'react-markdown'; +import LoadingDots from '@/components/LoadingDots'; +import classNames from 'classnames'; +import React from 'react'; +import RobotIcon from '../public/assets/images/icons/robot.svg'; +import UserIcon from '../public/assets/images/icons/user.svg'; type Message = { - type: "apiMessage" | "userMessage"; + type: 'apiMessage' | 'userMessage'; message: string; isStreaming?: boolean; links?: string[]; }; function Home() { - const [query, setQuery] = useState(""); + const [query, setQuery] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [messageState, setMessageState] = useState<{ @@ -27,15 +27,15 @@ function Home() { messages: [ { message: - "Hi, what would you like to know about the latest publications on EES?", - type: "apiMessage", + 'Hi, what would you like to know about the latest publications on EES?', + type: 'apiMessage', }, ], history: [], }); const api_url = - process.env.NEXT_PUBLIC_CHAT_URL_API ?? "http://localhost:8010/api/chat"; + process.env.NEXT_PUBLIC_CHAT_URL_API ?? 'http://localhost:8010/api/chat'; const { messages } = messageState; @@ -51,7 +51,7 @@ function Home() { e.preventDefault(); if (!query) { - setError("Enter a question"); + setError('Enter a question'); return; } @@ -64,20 +64,20 @@ function Home() { messages: [ ...state.messages, { - type: "userMessage", + type: 'userMessage', message: question, }, ], })); setLoading(true); - setQuery(""); + setQuery(''); try { const response = await fetch(api_url, { - method: "POST", + method: 'POST', headers: { - "Content-Type": "application/json", + 'Content-Type': 'application/json', }, body: JSON.stringify({ question, @@ -91,8 +91,8 @@ function Home() { messages: [ ...state.messages, { - type: "apiMessage", - message: "", + type: 'apiMessage', + message: '', }, ], })); @@ -105,7 +105,7 @@ function Home() { const decoder = new TextDecoder(); let done = false; - let pending = ""; + let pending = ''; while (!done) { const { value, done: doneReading } = await reader.read(); done = doneReading; @@ -132,15 +132,15 @@ function Home() { //messageListRef.current?.scrollTo(0, messageListRef.current.scrollHeight); } catch (error) { setLoading(false); - setError("An error occurred while fetching the data. Please try again."); + setError('An error occurred while fetching the data. Please try again.'); } } //prevent empty submissions const handleEnter = (e: any) => { - if (e.key === "Enter" && query) { + if (e.key === 'Enter' && query) { handleSubmit(e); - } else if (e.key == "Enter") { + } else if (e.key == 'Enter') { e.preventDefault(); } }; @@ -170,14 +170,14 @@ function Home() { )} -
+
{messages.map((message, index) => { let icon; let className; - if (message.type === "apiMessage") { + if (message.type === 'apiMessage') { icon = ; className = styles.apimessage; } else { @@ -191,7 +191,7 @@ function Home() { return (
{icon}
diff --git a/chatbot-ui/styles/_all.scss b/chatbot-ui/styles/_all.scss index ee44b8a..e0de5e7 100644 --- a/chatbot-ui/styles/_all.scss +++ b/chatbot-ui/styles/_all.scss @@ -1 +1 @@ -@import '~govuk-frontend/govuk/all'; \ No newline at end of file +@import '~govuk-frontend/govuk/all'; diff --git a/chatbot-ui/tsconfig.json b/chatbot-ui/tsconfig.json index c4ebc4f..225e527 100644 --- a/chatbot-ui/tsconfig.json +++ b/chatbot-ui/tsconfig.json @@ -1,14 +1,8 @@ { "compilerOptions": { - "typeRoots": [ - "./types" - ], + "typeRoots": ["./types"], "target": "es2020", - "lib": [ - "dom", - "dom.iterable", - "esnext" - ], + "lib": ["dom", "dom.iterable", "esnext"], "allowJs": true, "skipLibCheck": true, "strict": true, @@ -28,18 +22,10 @@ } ], "paths": { - "@/*": [ - "./*" - ] + "@/*": ["./*"] }, "sourceMap": true }, - "include": [ - "next-env.d.ts", - "**/*.ts", - "**/*.tsx" - ], - "exclude": [ - "node_modules" - ] + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"], + "exclude": ["node_modules"] } diff --git a/docker-compose.yaml b/docker-compose.yaml index 5c40833..0955e7e 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,4 +1,4 @@ -version: "3.8" +version: '3.8' services: qdrant: diff --git a/package.json b/package.json index 1018cde..b93bc94 100644 --- a/package.json +++ b/package.json @@ -14,4 +14,4 @@ "eslint-plugin-prettier": "5.0.0", "prettier": "3.0.0" } -} \ No newline at end of file +}