diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..cd54917 --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,12 @@ +version: "3.9" + +services: + frontend: + build: ./frontend + ports: + - "5173:5173" + + backend: + build: ./application + ports: + - "5001:5000" diff --git a/frontend/Dockerfile b/frontend/Dockerfile new file mode 100644 index 0000000..241c186 --- /dev/null +++ b/frontend/Dockerfile @@ -0,0 +1,10 @@ +FROM node:18-alpine3.14 + +WORKDIR /app +COPY package*.json ./ +RUN npm install +COPY . . + +EXPOSE 5173 + +CMD [ "npm", "run", "dev", "--" , "--host"] diff --git a/frontend/src/About.tsx b/frontend/src/About.tsx index ca8ddd8..814943d 100644 --- a/frontend/src/About.tsx +++ b/frontend/src/About.tsx @@ -4,49 +4,78 @@ export default function About() { return ( //Parent div for all content shown through App.tsx routing needs to have this styling. Might change when state management is updated. -
-
-

About DocsGPT 🦖

-

+

+
+

About DocsGPT 🦖

+

Find the information in your documentation through AI-powered - open-source chatbot. Powered by GPT-3, Faiss and LangChain. + + {' '} + open-source{' '} + + chatbot. Powered by GPT-3, Faiss and LangChain.

-

+

If you want to add your own documentation, please follow the instruction below:

-

+

1. Navigate to{' '} /application folder

-

+

2. Install dependencies from{' '} pip install -r requirements.txt

-

+

3. Prepare a .env file. Copy .env_sample and create .env with your OpenAI API token

-

+

4. Run the app with{' '} python app.py

-

+

Currently It uses python pandas documentation, so it will respond to information relevant to pandas. If you want to train it on different - documentation - please follow this guide. + documentation - please follow + + {' '} + this guide + + .

-

- If you want to launch it on your own server - follow this guide. +

+ If you want to launch it on your own server - follow + + {' '} + this guide + + .

diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index f0a53a6..aaaf5b3 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -6,7 +6,10 @@ import { useState } from 'react'; import { ActiveState } from './models/misc'; export default function App() { - const [navState, setNavState] = useState('ACTIVE'); + //TODO : below media query is disjoint from tailwind. Please wire it together. + const [navState, setNavState] = useState( + window.matchMedia('((min-width: 768px)').matches ? 'ACTIVE' : 'INACTIVE', + ); return (
diff --git a/frontend/src/Hero.tsx b/frontend/src/Hero.tsx index 817ba8b..ed2db20 100644 --- a/frontend/src/Hero.tsx +++ b/frontend/src/Hero.tsx @@ -4,15 +4,15 @@ export default function Hero({ className = '' }: { className?: string }) {

DocsGPT 🦖

-

+

Welcome to DocsGPT, your technical documentation assistant!

-

+

Enter a query related to the information in the documentation you selected to receive and we will provide you with the most relevant answers.

-

+

Start by entering your query in the input field below and we will do the rest!

diff --git a/frontend/src/conversation/Conversation.tsx b/frontend/src/conversation/Conversation.tsx index 41e63f2..c984563 100644 --- a/frontend/src/conversation/Conversation.tsx +++ b/frontend/src/conversation/Conversation.tsx @@ -30,7 +30,7 @@ export default function Conversation() { return (
-
+
{messages.map((message, index) => { return ( { + if (e.key === 'Enter' && !e.shiftKey) { + e.preventDefault(); + if (inputRef.current?.textContent && status !== 'loading') { + handleQuestion(inputRef.current.textContent); + inputRef.current.textContent = ''; + } + } + }} >
{status === 'loading' ? (
)} - {message} +

{message}

); }); export default ConversationBubble; + +// TODO : split question and answer into two diff JSX diff --git a/frontend/src/store.ts b/frontend/src/store.ts index 23097d7..3c84dc5 100644 --- a/frontend/src/store.ts +++ b/frontend/src/store.ts @@ -20,12 +20,14 @@ const store = configureStore({ preference: prefSlice.reducer, conversation: conversationSlice.reducer, }, - middleware: (getDefaultMiddleware) => [ - ...getDefaultMiddleware(), - prefListenerMiddleware.middleware, - ], + middleware: (getDefaultMiddleware) => + getDefaultMiddleware().concat(prefListenerMiddleware.middleware), }); export type RootState = ReturnType; export type AppDispatch = typeof store.dispatch; export default store; + +// TODO : use https://redux-toolkit.js.org/tutorials/typescript#define-typed-hooks everywere instead of direct useDispatch + +// TODO : streamline async state management diff --git a/frontend/tailwind.config.cjs b/frontend/tailwind.config.cjs index 2eb37ff..edc43a8 100644 --- a/frontend/tailwind.config.cjs +++ b/frontend/tailwind.config.cjs @@ -17,6 +17,7 @@ module.exports = { 'red-1000': 'rgb(254, 202, 202)', 'red-2000': '#F44336', 'red-3000': '#621B16', + 'blue-1000': '#7D54D1' }, }, },