ThinkAI is an intelligent question-answering system powered by OpenAI's GPT-3.5 model. Users can ask questions, and the AI responds with accurate and relevant answers in real time. This web application leverages React.js for the frontend and FastAPI with the OpenAI API for the backend.
- Ask any question, and get instant, relevant answers powered by GPT-3.5
- Interactive user interface for seamless interaction
- Instantaneous responses for any query
- Simple and user-friendly design
- Responsive layout optimized for desktops, tablets, and mobile devices
- Real-time updates of user questions and AI responses
- FastAPI
- OpenAI GPT-3.5 API
- Python 3.8+
- CORS enabled for cross-origin requests
- React.js
- React Router for navigation
- Context API for state management
- App.js // Main React component
- App.css // Styles for the frontend
- main.py // FastAPI backend entry point
- Clone the repository
git clone https://github.com/yourusername/thinkai.git
cd thinkai
- Create a virtual environment
python -m venv venv
source venv/bin/activate # For Windows: venv\Scripts\activate
- Install dependencies
pip install -r requirements.txt
- Set up environment variables (.env)
OPENAI_API_KEY=your-openai-api-key-here
- Run the backend server
uvicorn main:app --reload
- Navigate to the frontend directory
cd frontend
- Install dependencies
npm install
- Set up environment variables (.env)
REACT_APP_API_URL=http://localhost:8000
- Start the frontend server
npm start
POST /ask - Send a question to the AI for an answer
// Example of sending a question from the frontend const response = await fetch(${process.env.REACT_APP_API_URL}/ask, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ question: 'What is React.js?' }) });
const data = await response.json(); console.log(data.answer); // Logs the AI-generated answer
- Create a new Web Service on Render or your preferred platform
- Set the environment variable for OpenAI API key
- Deploy the backend service with FastAPI and Uvicorn
- Deploy the frontend on platforms like Render, Netlify, or Vercel
- Connect the deployed frontend to the backend API
- Environment variables for API keys
- Cross-origin resource sharing (CORS) protection
- API errors: Verify your OpenAI API key and network connection
- CORS issues: Ensure your frontend URL is allowed in the backend CORS settings
- Desktop (1200px+)
- Tablet (768px - 1199px)
- Mobile (320px - 767px)
- Fork the repository
- Create a feature branch
- Commit your changes
- Push your branch
- Create a Pull Request
This project is licensed under the MIT License.
Made with ❤️ by Vislavath Pavani