Giter Site home page Giter Site logo

jjcruise / morphic Goto Github PK

View Code? Open in Web Editor NEW

This project forked from miurla/morphic

0.0 0.0 0.0 4.29 MB

An AI-powered search engine with a generative UI

Home Page: https://morphic.sh

License: Apache License 2.0

JavaScript 0.54% TypeScript 98.64% CSS 0.71% Dockerfile 0.11%

morphic's Introduction

Morphic

An AI-powered search engine with a generative UI.

capture

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.

๐Ÿ—‚๏ธ Overview

๐Ÿ›  Features

  • 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
    • Google Generative AI Provider
    • Anthropic Provider โ€ป
    • Ollama Provider (Unstable)
  • Specify the model to generate answers
  • Local Redis support
  • SearXNG Search API support with customizable depth (basic or advanced)
  • Configurable search depth (basic or advanced)
  • SearXNG Search API support with customizable depth

๐Ÿงฑ Stack

๐Ÿš€ Quickstart

1. Fork and Clone repo

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

2. Install dependencies

cd morphic
bun install

3. Setting up Upstash Redis

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.

4. Fill out secrets

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.

# SearXNG Configuration
SEARXNG_API_URL=http://localhost:8080  # Replace with your local SearXNG API URL or docker http://searxng:8080
SEARCH_API=tavily  #  use searxng, tavily or exa
SEARXNG_SECRET="" # generate a secret key e.g. openssl rand -base64 32
SEARXNG_PORT=8080 # default port
SEARXNG_BIND_ADDRESS=0.0.0.0 # default address
SEARXNG_IMAGE_PROXY=true # enable image proxy
SEARXNG_LIMITER=false # can be enabled to limit the number of requests per IP address
SEARXNG_DEFAULT_DEPTH=basic # Set to 'basic' or 'advanced', only affects SearXNG searches
SEARXNG_MAX_RESULTS=50 # Maximum number of results to return from SearXNG

5. Run app locally

Using Bun

To run the application locally using Bun, execute the following command:

bun dev

You can now visit http://localhost:3000 in your web browser.

Using Docker

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.

๐ŸŒ Deploy

Host your own live version of Morphic with Vercel or Cloudflare Pages.

Vercel

Deploy with Vercel

๐Ÿ”Ž Search Engine

Setting up the Search Engine in Your Browser

If you want to use Morphic as a search engine in your browser, follow these steps:

  1. Open your browser settings.
  2. Navigate to the search engine settings section.
  3. Select "Manage search engines and site search".
  4. Under "Site search", click on "Add".
  5. Fill in the fields as follows:
    • Search engine: Morphic
    • Shortcut: morphic
    • URL with %s in place of query: https://morphic.sh/search?q=%s
  6. Click "Add" to save the new search engine.
  7. 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.

Using SearXNG as an Alternative Search Backend

Morphic now supports SearXNG as an alternative search backend with advanced search capabilities. To use SearXNG:

  1. Ensure you have Docker and Docker Compose installed on your system.

  2. In your .env.local file, set the following variables:

    • NEXT_PUBLIC_BASE_URL=http://localhost:3000 # Base URL for local development
    • 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
    • SEARXNG_DEFAULT_DEPTH=basic # Set to 'basic' or 'advanced'
    • SEARXNG_MAX_RESULTS=50 # Maximum number of results to return from SearXNG
    • SEARXNG_ENGINES=google,bing,duckduckgo,wikipedia # can be overriden in searxng config
    • SEARXNG_TIME_RANGE=None # Time range for search results
    • SEARXNG_SAFESEARCH=0 # Safe search setting
    • SEARXNG_CRAWL_MULTIPLIER=4 # Multiplier for the number of results to crawl in advanced search
  3. 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.
  4. Run docker-compose up to start the Morphic stack with SearXNG included.

  5. SearXNG will be available at http://localhost:8080 and Morphic will use it as the search backend.

Advanced Search Configuration

  • NEXT_PUBLIC_BASE_URL: Set this to your local development URL (http://localhost:3000) or your production URL when deploying.
  • SEARXNG_DEFAULT_DEPTH: Set to 'basic' or 'advanced' to control the default search depth.
  • SEARXNG_MAX_RESULTS: Maximum number of results to return from SearXNG.
  • SEARXNG_CRAWL_MULTIPLIER: In advanced search mode, this multiplier determines how many results to crawl. For example, if SEARXNG_MAX_RESULTS=10 and SEARXNG_CRAWL_MULTIPLIER=4, up to 40 results will be crawled before filtering and ranking.
  • SEARXNG_ENGINES: Comma-separated list of search engines to use.
  • SEARXNG_TIME_RANGE: Time range for search results (e.g., 'day', 'week', 'month', 'year', 'all').
  • SEARXNG_SAFESEARCH: Safe search setting (0 for off, 1 for moderate, 2 for strict).

The advanced search feature includes content crawling, relevance scoring, and filtering to provide more accurate and comprehensive results.

Customizing SearXNG

  • 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.

Troubleshooting

  • If you encounter issues with specific search engines (e.g., Wikidata), you can disable them in searxng-settings.yml:
engines:
  - name: wikidata
    disabled: true

โœ… Verified models

List of models applicable to all:

  • 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 โ€ป

List of verified models that can be specified to writers:

  • Groq
    • LLaMA3.1 8b
    • LLaMA3.1 70B
    • LLaMA3 8b
    • LLaMA3 70b

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.