Merge branch 'main' into fe-fixed

pull/125/head
Alex 1 year ago committed by GitHub
commit 1c10c95114
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -0,0 +1,12 @@
version: "3.9"
services:
frontend:
build: ./frontend
ports:
- "5173:5173"
backend:
build: ./application
ports:
- "5001:5000"

@ -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"]

@ -4,49 +4,78 @@
export default function About() { export default function About() {
return ( return (
//Parent div for all content shown through App.tsx routing needs to have this styling. Might change when state management is updated. //Parent div for all content shown through App.tsx routing needs to have this styling. Might change when state management is updated.
<div className="mx-6 grid min-h-screen"> <div className="mx-5 grid min-h-screen md:mx-36">
<article className=" mx-auto my-auto flex w-full max-w-6xl flex-col place-items-center gap-6 rounded-lg bg-gray-100 p-6 text-jet lg:p-10 xl:p-16"> <article className=" place-items-left mx-auto my-auto flex w-full max-w-6xl flex-col gap-6 rounded-lg bg-gray-100 p-6 text-jet lg:p-10 xl:p-16">
<p className="text-3xl font-semibold">About DocsGPT 🦖</p> <p className="text-3xl">About DocsGPT 🦖</p>
<p className="mt-4 text-xl font-bold"> <p className="mt-4">
Find the information in your documentation through AI-powered Find the information in your documentation through AI-powered
open-source chatbot. Powered by GPT-3, Faiss and LangChain. <a
className="text-blue-500"
href="https://github.com/arc53/DocsGPT"
target="_blank"
rel="noreferrer"
>
{' '}
open-source{' '}
</a>
chatbot. Powered by GPT-3, Faiss and LangChain.
</p> </p>
<div> <div>
<p className="text-lg"> <p>
If you want to add your own documentation, please follow the If you want to add your own documentation, please follow the
instruction below: instruction below:
</p> </p>
<p className="mt-4 text-lg"> <p className="mt-4 ml-2">
1. Navigate to{' '} 1. Navigate to{' '}
<span className="bg-gray-200 italic"> /application</span> folder <span className="bg-gray-200 italic"> /application</span> folder
</p> </p>
<p className="mt-4 text-lg"> <p className="mt-4 ml-2">
2. Install dependencies from{' '} 2. Install dependencies from{' '}
<span className="bg-gray-200 italic"> <span className="bg-gray-200 italic">
pip install -r requirements.txt pip install -r requirements.txt
</span> </span>
</p> </p>
<p className="mt-4 text-lg"> <p className="mt-4 ml-2">
3. Prepare a <span className="bg-gray-200 italic">.env</span> file. 3. Prepare a <span className="bg-gray-200 italic">.env</span> file.
Copy <span className="bg-gray-200 italic">.env_sample</span> and Copy <span className="bg-gray-200 italic">.env_sample</span> and
create <span className="bg-gray-200 italic">.env</span> with your create <span className="bg-gray-200 italic">.env</span> with your
OpenAI API token OpenAI API token
</p> </p>
<p className="mt-4 text-lg"> <p className="mt-4 ml-2">
4. Run the app with{' '} 4. Run the app with{' '}
<span className="bg-gray-200 italic">python app.py</span> <span className="bg-gray-200 italic">python app.py</span>
</p> </p>
</div> </div>
<p className="text-lg"> <p>
Currently It uses python pandas documentation, so it will respond to Currently It uses python pandas documentation, so it will respond to
information relevant to pandas. If you want to train it on different information relevant to pandas. If you want to train it on different
documentation - please follow this guide. documentation - please follow
<a
className="text-blue-500"
href="https://github.com/arc53/DocsGPT/wiki/How-to-train-on-other-documentation"
target="_blank"
rel="noreferrer"
>
{' '}
this guide
</a>
.
</p> </p>
<p className="mt-4 text-lg"> <p className="mt-4 text-left">
If you want to launch it on your own server - follow this guide. If you want to launch it on your own server - follow
<a
className="text-blue-500"
href="https://github.com/arc53/DocsGPT/wiki/Hosting-the-app"
target="_blank"
rel="noreferrer"
>
{' '}
this guide
</a>
.
</p> </p>
</article> </article>
</div> </div>

@ -6,7 +6,10 @@ import { useState } from 'react';
import { ActiveState } from './models/misc'; import { ActiveState } from './models/misc';
export default function App() { export default function App() {
const [navState, setNavState] = useState<ActiveState>('ACTIVE'); //TODO : below media query is disjoint from tailwind. Please wire it together.
const [navState, setNavState] = useState<ActiveState>(
window.matchMedia('((min-width: 768px)').matches ? 'ACTIVE' : 'INACTIVE',
);
return ( return (
<div className="min-h-full min-w-full"> <div className="min-h-full min-w-full">

@ -4,15 +4,15 @@ export default function Hero({ className = '' }: { className?: string }) {
<p className="mb-10 text-center text-4xl font-semibold"> <p className="mb-10 text-center text-4xl font-semibold">
DocsGPT <span className="text-3xl">🦖</span> DocsGPT <span className="text-3xl">🦖</span>
</p> </p>
<p className="mb-3 text-center"> <p className="mb-3 text-center text-gray-2000">
Welcome to DocsGPT, your technical documentation assistant! Welcome to DocsGPT, your technical documentation assistant!
</p> </p>
<p className="mb-3 text-center"> <p className="mb-3 text-center text-gray-2000">
Enter a query related to the information in the documentation you Enter a query related to the information in the documentation you
selected to receive and we will provide you with the most relevant selected to receive and we will provide you with the most relevant
answers. answers.
</p> </p>
<p className="text-center"> <p className="text-center text-gray-2000">
Start by entering your query in the input field below and we will do the Start by entering your query in the input field below and we will do the
rest! rest!
</p> </p>

@ -30,7 +30,7 @@ export default function Conversation() {
return ( return (
<div className="flex justify-center p-6"> <div className="flex justify-center p-6">
<div className="mt-20 w-10/12 transition-all md:w-1/2"> <div className="flex mt-20 w-10/12 flex-col transition-all md:w-1/2">
{messages.map((message, index) => { {messages.map((message, index) => {
return ( return (
<ConversationBubble <ConversationBubble
@ -48,7 +48,16 @@ export default function Conversation() {
<div <div
ref={inputRef} ref={inputRef}
contentEditable 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`} className={`border-000000 overflow-x-hidden; max-h-24 min-h-[2.6rem] w-full overflow-y-auto whitespace-pre-wrap 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 = '';
}
}
}}
></div> ></div>
{status === 'loading' ? ( {status === 'loading' ? (
<img <img

@ -16,15 +16,17 @@ const ConversationBubble = forwardRef<
ref={ref} ref={ref}
className={`flex rounded-3xl ${ className={`flex rounded-3xl ${
type === 'ANSWER' type === 'ANSWER'
? 'bg-gray-1000' ? 'self-start bg-gray-1000'
: type === 'ERROR' : type === 'ERROR'
? 'bg-red-1000' ? 'self-start bg-red-1000'
: '' : 'flex-row-reverse self-end bg-blue-1000 text-white'
} py-7 px-5 ${className}`} } py-7 px-5 ${className}`}
> >
<Avatar avatar={type === 'QUESTION' ? '👤' : '🦖'}></Avatar> <Avatar avatar={type === 'QUESTION' ? '👤' : '🦖'}></Avatar>
<div <div
className={`ml-5 flex items-center ${ className={`${
type === 'QUESTION' ? 'mr-5' : 'ml-5'
} flex items-center ${
type === 'ERROR' type === 'ERROR'
? 'rounded-lg border border-red-2000 p-2 text-red-3000' ? 'rounded-lg border border-red-2000 p-2 text-red-3000'
: '' : ''
@ -33,10 +35,12 @@ const ConversationBubble = forwardRef<
{type === 'ERROR' && ( {type === 'ERROR' && (
<img src={Alert} alt="alert" className="mr-2 inline" /> <img src={Alert} alt="alert" className="mr-2 inline" />
)} )}
<span>{message}</span> <p className="whitespace-pre-wrap break-all">{message}</p>
</div> </div>
</div> </div>
); );
}); });
export default ConversationBubble; export default ConversationBubble;
// TODO : split question and answer into two diff JSX

@ -20,12 +20,14 @@ const store = configureStore({
preference: prefSlice.reducer, preference: prefSlice.reducer,
conversation: conversationSlice.reducer, conversation: conversationSlice.reducer,
}, },
middleware: (getDefaultMiddleware) => [ middleware: (getDefaultMiddleware) =>
...getDefaultMiddleware(), getDefaultMiddleware().concat(prefListenerMiddleware.middleware),
prefListenerMiddleware.middleware,
],
}); });
export type RootState = ReturnType<typeof store.getState>; export type RootState = ReturnType<typeof store.getState>;
export type AppDispatch = typeof store.dispatch; export type AppDispatch = typeof store.dispatch;
export default store; 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

@ -17,6 +17,7 @@ module.exports = {
'red-1000': 'rgb(254, 202, 202)', 'red-1000': 'rgb(254, 202, 202)',
'red-2000': '#F44336', 'red-2000': '#F44336',
'red-3000': '#621B16', 'red-3000': '#621B16',
'blue-1000': '#7D54D1'
}, },
}, },
}, },

Loading…
Cancel
Save