This is a Node.js backend application for generating MCQs (Multiple Choice Questions), summarizing text, evaluating answers, and more using Gemini AI. The backend is built using Express.js and leverages GoogleGenerativeAI for AI-driven content generation and evaluation.
Live: https://gen-mcq.onrender.com/
- Get Output from User Prompt: Generate content based on a user-provided prompt.
- Generate MCQs: Create multiple-choice questions for given text, difficulty level, and optional image.
- Summarize Text: Provide a summary of given text with optional image association.
- Evaluate Answer: Evaluate a given answer, provide marks based on the expected answer length, and offer detailed feedback and corrections.
- Node.js
- NPM (Node Package Manager)
- GoogleGenerativeAI API Key
- Python (for testing purposes)
- Requests library for Python (install using
pip install requests
)
-
Clone the repository:
git clone https://github.com/UltronTheAI/GEN-MCQ.git cd GEN-MCQ
-
Install dependencies:
npm install express dotenv @google/generative-ai fs
-
Create a
.env
file in the project root to store your API key:GEMINI_API_KEY=your_gemini_api_key_here
-
Start the server:
node app.js
-
Use the following endpoints to interact with the backend:
- Endpoint:
/get-output
- Method: GET
- Parameters:
prompt
(required): The user prompt to generate content.
- Response:
{ "output": "string" }
- Endpoint:
/generate-mcq
- Method: GET
- Parameters:
text
(required): The text for which MCQs need to be generated.number_of_questions
(required): The number of questions to be generated.level
(required, 1 to 10): The difficulty level of the questions.image
(optional): An image associated with the text, if applicable.
- Response:
[ { "question": "string", "options": ["list of strings"], "answer": "integer", "explanation": "string" } ]
- Endpoint:
/summarize
- Method: GET
- Parameters:
text
(required): The text to be summarized.image
(optional): An image associated with the text, if applicable.
- Response:
{ "summary": "string" }
- Endpoint:
/evaluate-answer
- Method: GET
- Parameters:
question
(required): The question text.answer
(required): The user's answer.max_marks
(required): The maximum marks for the question.
- Response:
{ "marks_scored": "integer", "explanation": "string", "correct_answer": "string" }
Use the provided Python script (test_backend.py
) to test the endpoints.
- Ensure Python and pip are installed.
- Install the requests library:
pip install requests
- Run the script to test different endpoints:
-
Get Output from User Prompt:
python test_backend.py get-output "Explain how AI works"
-
Generate MCQs:
python test_backend.py generate-mcq "Python Basics" 5 3 --image "path_to_image.jpg"
-
Summarize Text:
python test_backend.py summarize "Photosynthesis is the process used by plants to convert light energy into chemical energy." --image "path_to_image.jpg"
-
Evaluate Answer:
python test_backend.py evaluate-answer "What is the capital of France?" "Paris" 1
Feel free to fork the repository and submit pull requests. For major changes, please open an issue to discuss what you would like to change.
This project is licensed under the MIT License.