Perplexed
Open-source Perplexity app.
Install / Use
/learn @philfung/PerplexedREADME
<img height="25" src="https://github.com/philfung/perplexed/blob/main/frontend/public/images/logo-color.svg"/> Perplexed
An open-source app inspired by the amazing web search product, Perplexity.
<img width="600" alt="Screenshot 2025-03-19 at 1 26 54 PM" src="https://github.com/user-attachments/assets/f190473c-467c-4169-87c9-a285dc0f234f" /> <img width="600" alt="Screenshot 2025-03-19 at 1 26 35 PM" src="https://github.com/user-attachments/assets/07b0ad71-9c53-4d7f-a1e7-b2bded2f1806" />Implementation
Given a user query, the app conducts a web search, downloads the top N resulting web pages, then analyzes those pages with an LLM.
<img height="400" alt="Screenshot 2024-11-16 at 10 06 03 AM" src="https://github.com/user-attachments/assets/e88ff3ee-2efc-4a36-8427-fcf90141a083">The LLM can be any smaller, consumer-grade with at least 5k context window (assuming each web page ~1k tokens).
Development
To take advantage of the configured build steps, our recommended tools are:
Workflow and Local Deployment
- run
justin the terminal to see available recipes. We support recipes to launch the app in dev, staging and production modes.- dev: run app as two processes on localhost
- both processes can be exited with
Ctrl-Cin the terminal
- both processes can be exited with
- staging: run app inside a docker container as a single http service, fronted by
nginx- the single http service
docker runs in the foreground,Ctrl-Cto stop container
- the single http service
- production: a variant of staging with diff env vars
- the single http service will respond to platform-specific terminate/kill signals
- generally the platforms will rotate in a new container instance when you deploy a new version and directing traffic there when the container is ready/healthy.
- dev: run app as two processes on localhost
- required: pre-fill
.env.*files prior to starting app instances- e.g. if testing in staging, fill out
frontend/.env.stagingthenjust build-image-staging && just runto take your app into the container and launch the server onhttp://localhost:30000
- e.g. if testing in staging, fill out
Deployment Instructions - Manual, without our justfile recipes
Refer to the justfile for step by step recipes. The following describes the requirements if you choose to re-implement in a different environment.
A. Python Server
-
cd backend cp .env.example .env -
In
backend/.env, fill inGOOGLE_SEARCH_API_KEYandGOOGLE_SEARCH_ENGINE_IDcredentials from Google Custom Search API. -
Fill in
GROQ_API_KEYcredentials from Groq. -
Setup virtual environment, packages, and deploy the server
uv venv . .venv/bin/activate uv pip install -r requirements.txt python app.pyThis is fine for dev testing.
-
Wherever you run this backend, you need to define env var
DOMAINS_ALLOWto match the frontend domain the browser sees.For production, check
docker/for example containerized/cloud process management scripts.You may choose to do add-on engineering with
supervisord,nginxor a variety of modifications.Furthermore, in production environments you should set the secrets according the platform best practices, you should expect a secrets get/set API or CLI, e.g. in our Fly.io example you would use
fly secrets set|unsetprior to deploying your app.
B. React Frontend
The React app can be compiled into a static site you can serve with nginx, npx serve or your choice of framework.
-
cd frontend -
Update
REACT_APP_API_URLinconstants.jsto point to your server -
Install Bun TL;DR:
curl -fsSL https://bun.com/install | bash, or usenpx bunif you already havenpxbun install bun run build:dev bun run build:staging bun run build:prodThere are justfile recipes for all of the above.
-
In dev testing, to start the server:
just frontend-dev PORT=30000 bun start ./build-[dev|staging|prod] -
In staging the docker app on your host, to start the server:
Fill in values in
frontend/.env.staging. Refer to the justfile recipes for implementation details.just run
Contributors
git add -uyour modified files and runpre-committo performrufflint/format checks
TODOS
- [ ] Clarify the pre-existing Cloudfront deployment strategy for the frontend
- [ ] Create
./deployment/cloudflareexample for Cloudflare Containers
