A React-based web application that provides healthcare-related assistance powered by the OpenAI ChatGPT API. Users can ask health-related questions, and the app responds with helpful and formatted advice in a tabular format.
- AI-Powered Assistance: Uses OpenAI's GPT-3.5/4 to provide accurate healthcare advice.
- User-Friendly Interface: Simple and intuitive text input and response display.
- Formatted Responses: Presents AI-generated advice in a tabular format for better readability.
- Secure Configuration: API key management using environment variables.
- Error Handling: Displays clear messages for invalid inputs or API errors.
- Frontend: React.js
- Backend API: OpenAI ChatGPT API
- Styling: CSS
- Environment Management:
.env
for sensitive data
git clone https://github.com/thekartikeyamishra/healthcare-ai-agent.git
cd healthcare-ai-agent
Ensure you have Node.js installed. Then, run:
npm install
- Create a
.env
file in the project root:touch .env
- Add your OpenAI API key to the
.env
file:REACT_APP_OPENAI_API_KEY=your_openai_api_key_here
npm start
The app will be available at http://localhost:3000
.
- Enter a Query: Type a healthcare-related question in the input box (e.g., "What are the symptoms of a cold?").
- Get Response: Click on the "Get Response" button.
- View Results: The AI-generated response will be displayed in a formatted table below the input box.
healthcare-ai-agent/
│
├── public/
│ ├── index.html # Main HTML file
│ ├── favicon.ico # Favicon
│
├── src/
│ ├── components/
│ │ └── HealthcareAgent.js # Main AI Agent Component
│ │
│ ├── App.js # Main App Component
│ ├── index.js # Entry Point for React App
│ └── styles.css # Custom Styles
│
├── .env # Environment Variables (Not committed to Git)
├── .gitignore # Git Ignore File
├── package.json # Project Dependencies
└── README.md # Project Documentation
Key | Description |
---|---|
REACT_APP_OPENAI_API_KEY |
Your OpenAI API key for the ChatGPT API |
- Install Netlify CLI:
npm install -g netlify-cli
- Build the project:
npm run build
- Deploy the build folder:
netlify deploy
- Add
REACT_APP_OPENAI_API_KEY
in the environment variable settings on Netlify.
- Install Vercel CLI:
npm install -g vercel
- Deploy the project:
vercel
- Add
REACT_APP_OPENAI_API_KEY
in the environment variable settings on Vercel.
What are the symptoms of a cold?
Field | Details |
---|---|
Symptom 1 | Sneezing |
Symptom 2 | Runny nose |
Symptom 3 | Sore throat |
Symptom 4 | Mild headache |
Advice | Rest, stay hydrated, and take over-the-counter medication if needed. |
-
Error: "API key is missing. Check your .env file."
- Ensure the
.env
file is created and contains the correct API key. - Restart the development server after adding the
.env
file.
- Ensure the
-
Error: "Failed to fetch AI response."
- Verify your OpenAI API key is valid and has sufficient credits.
- Check your network connection.
-
Blank or Unexpected Responses
- Ensure the question is clear and concise.
- Try rephrasing the query for better results.
Contributions are welcome! If you would like to contribute:
- Fork the repository.
- Create a feature branch:
git checkout -b feature-name
- Commit your changes:
git commit -m "Add feature-name"
- Push to your branch:
git push origin feature-name
- Create a pull request.
- OpenAI for the ChatGPT API.
- React.js community for providing excellent documentation and tools.
Let me know if you need further assistance!