A small AI research assistant, inspired by Perplexity.
Instead of asking just one AI for an answer, Mini-Perplexity asks three of them to work together: two AI models answer your question at the same time, and a third AI acts as a "judge" that reads both answers and writes one final, clear reply.
Imagine you ask the same question to two knowledgeable friends.
- Friend A gives you their answer.
- Friend B gives you theirs.
Both answers are useful, but they might overlap, disagree slightly, or explain things differently. So you bring in a third friend who is good at summarizing. This friend reads both answers, removes repetition, settles any disagreements, keeps what's most accurate, and hands you one clean, easy-to-understand answer.
That third friend is the "judge." That is exactly how Mini-Perplexity works.
Different AI models have different strengths. One might be more detailed, another might be clearer or more up to date. By combining answers from multiple models and letting a judge pick the best parts, you usually get a better, more reliable answer than you would from any single model alone.
Here is the journey your question takes, step by step:
Your question
│
▼
┌─────────────────┐
│ index.js │ Starting point
│ (asks the Q) │
└────────┬────────┘
│
▼
┌─────────────────┐
│ helper.js │ Sends the question to two AIs at once
└───┬─────────┬───┘
│ │
┌────────────▼─┐ ┌──▼────────────┐
│ Groq │ │ Google │ The two AIs answer
│ (Llama 3.3) │ │ Gemini │ in parallel
└────────────┬─┘ └──┬────────────┘
│ │
└────┬────┘
│ both answers
▼
┌─────────────────┐
│ judge.js │ A third AI (GPT-4) combines
│ (GPT-4 judge) │ them into one clear answer
└────────┬────────┘
│
▼
Final answer
-
You ask a question. The question is set inside
index.js(for example, "What is an Array in JavaScript?"). -
The question is sent to two AI models at the same time.
helper.jssends your question to:- Groq (running the Llama 3.3 model)
- Google Gemini (the Gemini 2.5 Flash model)
Both run in parallel, so you don't wait twice as long. You get both answers at roughly the same time.
-
A judge combines the answers.
judge.jssends both answers to OpenAI's GPT-4, with instructions to:- merge them into one answer,
- resolve any conflicts,
- remove repeated information,
- prefer facts that are correct,
- and keep the language simple enough for a beginner.
-
You get one final answer. The combined, simplified answer is printed to the screen.
| File | What it does |
|---|---|
index.js |
The starting point. Holds the question and kicks everything off. |
helper.js |
Sends the question to Groq and Gemini at the same time, then passes both answers to the judge. |
judge.js |
The "judge." Uses GPT-4 to merge the two answers into one clear reply. |
groqModels.json |
A reference list of models available on Groq. |
.env |
Stores your secret API keys (never shared or uploaded). |
package.json |
Lists the project's dependencies and settings. |
- Node.js — the environment that runs the project.
- OpenAI (GPT-4) — acts as the judge.
- Groq (Llama 3.3) — one of the two answering models.
- Google Gemini — the other answering model.
- dotenv — safely loads the secret API keys.
- axios — a helper library for making web requests.
- Node.js installed on your computer.
- API keys for three services:
An API key is like a password that lets the project talk to each AI service.
Open a terminal inside the project folder and run:
cd 01-mini-perplexity
npm installThis downloads everything the project needs to run.
Create a file named .env inside the 01-mini-perplexity folder and add your keys:
OPENAI_API_KEY="your-openai-key-here"
GROQ_API_KEY="your-groq-key-here"
GEMINI_API_KEY="your-gemini-key-here"Keep this file private. It contains secrets and is already ignored by Git, so it won't be uploaded to GitHub.
node index.jsYou'll see each AI's individual answer printed out, followed by the final combined answer from the judge.
Open index.js and change the text inside init(...) to whatever you'd like to ask:
init('What is a function in JavaScript?')The .env file holds secret keys. Treat them like passwords:
- Never share them or post them publicly.
- If a key is ever exposed, regenerate (rotate) it from the provider's website.
Mini-Perplexity shows a simple but powerful idea: ask several AI models, then let one more AI combine the best of their answers. The result is usually clearer and more trustworthy than relying on a single AI.