An AI-powered search engine with a generative UI.
Note
Please note that there are differences between this repository and the official website morphic.sh. The official website is a fork of this repository with additional features such as authentication, which are necessary for providing the service online. The core source code of Morphic resides in this repository, and it's designed to be easily built and deployed.
- π Features
- 𧱠Stack
- π Quickstart
- π Deploy
- π Search Engine
- β Verified models
- Search and answer using GenerativeUI
- Understand user's questions
- Search history functionality
- Share search results (Optional)
- Video search support (Optional)
- Get answers from specified URLs
- Use as a search engine β»
- Support for providers other than OpenAI
- Specify the model to generate answers
- Groq API support β»
- Local Redis support
- SearXNG Search API support
- App framework: Next.js
- Text streaming / Generative UI: Vercel AI SDK
- Generative Model: OpenAI
- Search API: Tavily AI / Serper / SearXNG
- Reader API: Jina AI
- Database (Serverless/Local): Upstash / Redis
- Component library: shadcn/ui
- Headless component primitives: Radix UI
- Styling: Tailwind CSS
Fork the repo to your Github account, then run the following command to clone the repo:
git clone [email protected]:[YOUR_GITHUB_ACCOUNT]/morphic.git
cd morphic
bun install
Follow the guide below to set up Upstash Redis. Create a database and obtain UPSTASH_REDIS_REST_URL
and UPSTASH_REDIS_REST_TOKEN
. Refer to the Upstash guide for instructions on how to proceed.
If you intend to use a local Redis, you can skip this step.
cp .env.local.example .env.local
Your .env.local file should look like this:
# OpenAI API key retrieved here: https://platform.openai.com/api-keys
OPENAI_API_KEY=
# Tavily API Key retrieved here: https://app.tavily.com/home
TAVILY_API_KEY=
# Upstash Redis URL and Token retrieved here: https://console.upstash.com/redis
UPSTASH_REDIS_REST_URL=
UPSTASH_REDIS_REST_TOKEN=
## Redis Configuration
This application supports both Upstash Redis and local Redis. To use local Redis:
1. Set `USE_LOCAL_REDIS=true` in your `.env.local` file.
2. Optionally, set `LOCAL_REDIS_URL` if your local Redis is not running on the default `localhost:6379` or `redis://redis:6379` if you're using docker compose.
To use Upstash Redis:
1. Set `USE_LOCAL_REDIS=false` or leave it unset in your `.env.local` file.
2. Set `UPSTASH_REDIS_REST_URL` and `UPSTASH_REDIS_REST_TOKEN` with your Upstash credentials.
To run the application locally using Bun, execute the following command:
bun dev
You can now visit http://localhost:3000 in your web browser.
To run the application using Docker, use the following command:
docker compose up -d
This will start the application in detached mode. You can access it at http://localhost:3000.
Host your own live version of Morphic with Vercel or Cloudflare Pages.
- Fork the repo to your GitHub.
- Create a Cloudflare Pages project.
- Select
Morphic
repo andNext.js
preset. - Set
OPENAI_API_KEY
andTAVILY_API_KEY
env vars. - Save and deploy.
- Cancel deployment, go to
Settings
->Functions
->Compatibility flags
, addnodejs_compat
to preview and production. - Redeploy.
The build error needs to be fixed: issue
If you want to use Morphic as a search engine in your browser, follow these steps:
- Open your browser settings.
- Navigate to the search engine settings section.
- Select "Manage search engines and site search".
- Under "Site search", click on "Add".
- Fill in the fields as follows:
- Search engine: Morphic
- Shortcut: morphic
- URL with %s in place of query:
https://morphic.sh/search?q=%s
- Click "Add" to save the new search engine.
- Find "Morphic" in the list of site search, click on the three dots next to it, and select "Make default".
This will allow you to use Morphic as your default search engine in the browser.
Morphic now supports SearXNG as an alternative search backend. To use SearXNG:
-
Ensure you have Docker and Docker Compose installed on your system.
-
In your
.env.local
file, set the following variables:- SEARXNG_API_URL=http://localhost:8080 # Replace with your local SearXNG API URL or docker http://searxng:8080
- SEARXNG_SECRET=your_secret_key_here
- SEARXNG_PORT=8080
- SEARXNG_IMAGE_PROXY=true
- SEARCH_API=searxng
- SEARXNG_LIMITER=false # can be enabled to limit the number of requests per IP
-
Two configuration files are provided in the root directory:
searxng-settings.yml
: This file contains the main configuration for SearXNG, including engine settings and server options.searxng-limiter.toml
: This file configures the rate limiting and bot detection features of SearXNG.
- Run
docker-compose up
to start the Morphic stack with SearXNG included. - SearXNG will be available at
http://localhost:8080
and Morphic will use it as the search backend.
- You can modify
searxng-settings.yml
to enable/disable specific search engines, change UI settings, or adjust server options. - The
searxng-limiter.toml
file allows you to configure rate limiting and bot detection. This is useful if you're exposing SearXNG directly to the internet. - If you prefer not to use external configuration files, you can set these options using environment variables in the
docker-compose.yml
file or directly in the SearXNG container.
- To disable the limiter entirely, set
LIMITER=false
in the SearXNG service environment variables. - For production use, consider adjusting the
SEARXNG_SECRET_KEY
to a secure, randomly generated value. - The
SEARXNG_IMAGE_PROXY
option allows SearXNG to proxy image results, enhancing privacy. Set totrue
to enable this feature.
- If you encounter issues with specific search engines (e.g., Wikidata), you can disable them in
searxng-settings.yml
:
engines:
- name: wikidata
disabled: true
- OpenAI
- gpt-4o
- gpt-4o-mini
- gpt-4-turbo
- gpt-3.5-turbo
- Google
- Gemini 1.5 pro (Unstable)
- Anthropic
- Claude 3.5 Sonnet
- Ollama (Unstable)
- mistral/openhermes & Phi3/llama3 β»
- Groq
- LLaMA3.1 8b
- LLaMA3.1 70B
- LLaMA3 8b
- LLaMA3 70b