From e465daf848b4cbaf84cd561c43e8c7f4907fe0f6 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 24 Feb 2023 14:34:02 +0000 Subject: [PATCH 1/7] small fixes --- frontend/src/About.tsx | 41 ++++++++++++++++++---- frontend/src/Hero.tsx | 6 ++-- frontend/src/conversation/Conversation.tsx | 9 +++++ 3 files changed, 47 insertions(+), 9 deletions(-) diff --git a/frontend/src/About.tsx b/frontend/src/About.tsx index ca8ddd8..43002a0 100644 --- a/frontend/src/About.tsx +++ b/frontend/src/About.tsx @@ -4,12 +4,21 @@ 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 🦖

-

+

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.

@@ -42,11 +51,31 @@ export default function About() {

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/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 cc38c2a..ab9d9eb 100644 --- a/frontend/src/conversation/Conversation.tsx +++ b/frontend/src/conversation/Conversation.tsx @@ -49,6 +49,15 @@ export default function Conversation() { ref={inputRef} contentEditable className={`border-000000 overflow-x-hidden; max-h-24 min-h-[2.6rem] w-full overflow-y-auto rounded-xl border bg-white p-2 pr-9 opacity-100 focus:border-2 focus:outline-none`} + onKeyDown={(e) => { + if (e.key === 'Enter' && !e.shiftKey) { + e.preventDefault(); + if (inputRef.current?.textContent && status !== 'loading') { + handleQuestion(inputRef.current.textContent); + inputRef.current.textContent = ''; + } + } + }} >
{status === 'loading' ? ( Date: Fri, 24 Feb 2023 14:48:02 +0000 Subject: [PATCH 2/7] spacing --- frontend/src/About.tsx | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/src/About.tsx b/frontend/src/About.tsx index 43002a0..0f2b5db 100644 --- a/frontend/src/About.tsx +++ b/frontend/src/About.tsx @@ -5,9 +5,9 @@ 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

-

+

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 @@ -64,7 +64,7 @@ export default function About() { .

-

+

If you want to launch it on your own server - follow Date: Fri, 24 Feb 2023 17:04:37 +0000 Subject: [PATCH 3/7] dockefiles --- docker-compose.yaml | 12 ++++++++++++ frontend/Dockerfile | 10 ++++++++++ 2 files changed, 22 insertions(+) create mode 100644 docker-compose.yaml create mode 100644 frontend/Dockerfile 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"] From 4bc1a87fcf24f47f77257d2d2f5671636dee93b0 Mon Sep 17 00:00:00 2001 From: ajaythapliyal Date: Sat, 25 Feb 2023 08:43:00 +0530 Subject: [PATCH 4/7] preserves whitespaces and newlines in message --- frontend/src/conversation/Conversation.tsx | 2 +- frontend/src/conversation/ConversationBubble.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/conversation/Conversation.tsx b/frontend/src/conversation/Conversation.tsx index ab9d9eb..f07749b 100644 --- a/frontend/src/conversation/Conversation.tsx +++ b/frontend/src/conversation/Conversation.tsx @@ -48,7 +48,7 @@ export default function Conversation() {

{ if (e.key === 'Enter' && !e.shiftKey) { e.preventDefault(); diff --git a/frontend/src/conversation/ConversationBubble.tsx b/frontend/src/conversation/ConversationBubble.tsx index 1283c79..661a3fc 100644 --- a/frontend/src/conversation/ConversationBubble.tsx +++ b/frontend/src/conversation/ConversationBubble.tsx @@ -33,7 +33,7 @@ const ConversationBubble = forwardRef< {type === 'ERROR' && ( alert )} - {message} +

{message}

); From f90abd8753ef93df566a7dafd491bd68dc1a97ec Mon Sep 17 00:00:00 2001 From: ajaythapliyal Date: Sat, 25 Feb 2023 09:52:15 +0530 Subject: [PATCH 5/7] fixes the middleware setup --- frontend/src/store.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/frontend/src/store.ts b/frontend/src/store.ts index 23097d7..e5da25c 100644 --- a/frontend/src/store.ts +++ b/frontend/src/store.ts @@ -20,12 +20,12 @@ 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 From 63af495693a550698c1f542b193d8cc16e4c00b2 Mon Sep 17 00:00:00 2001 From: ajaythapliyal Date: Sat, 25 Feb 2023 11:11:15 +0530 Subject: [PATCH 6/7] incorporates 13 from Nicks list --- frontend/src/conversation/Conversation.tsx | 2 +- frontend/src/conversation/ConversationBubble.tsx | 12 ++++++++---- frontend/src/store.ts | 2 ++ frontend/tailwind.config.cjs | 1 + 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/frontend/src/conversation/Conversation.tsx b/frontend/src/conversation/Conversation.tsx index f07749b..99bd2db 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 (
Date: Sat, 25 Feb 2023 11:51:17 +0530 Subject: [PATCH 7/7] on mobile view the app used to launch with nav bar open, this fixes it. About page had same large horizontal margin which made about page very narrow. This fixes it. --- frontend/src/About.tsx | 2 +- frontend/src/App.tsx | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/frontend/src/About.tsx b/frontend/src/About.tsx index 0f2b5db..814943d 100644 --- a/frontend/src/About.tsx +++ b/frontend/src/About.tsx @@ -4,7 +4,7 @@ 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 🦖

diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index b0c6cb2..2cbe582 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 (