AI Personal Learning
and practical guidance

Lepton Search: open source conversational AI search engine|Lepton Search

Lepton Search General Introduction

 

Lepton Search is a conversational AI search engine, launched by Jia Yangqing and built on the Lepton AI platform.Lepton Search actively searches the web for data and organizes it into organized and logical answers based on the user's natural language questions, with accompanying sources of information.Lepton Search not only answers common intellectual questions, such as "Is an electron a lepton? such as "Is an electron a lepton?" or "When was the first man on the moon?" Lepton Search can also answer complex questions such as "Why do apples fall off?" or "How do I write a chatbot in Python?" Lepton Search's code is open source, so developers can deploy and modify it themselves, or use the Lepton AI platform to quickly build their own conversational AI applications.


 

-1

Lepton Search Home

 

-2

Lepton Search Search Results Page

 

 

Lepton Search Feature List

 

  • Supports natural language input and output
  • Supports multiple types of questions, including knowledge-based, cause-based, and method-based
  • Supports multiple data sources, including Wikipedia, Twitter, Google, Bing, etc.
  • Supports multiple languages, including English, Chinese, Japanese, etc.
  • Support a variety of display methods, including text, images, tables, charts, etc.
  • Supports multiple interaction methods, including web, command line, API, etc.

 

 

Lepton Search Help

 

  • In the web version, type in the question you want to search for and press enter or click on the search button to see Lepton Search's answers!
  • Check out the documentation in the official GitHub repository.
  • You can build your own search engine according to the official demo.
  • Developers are free to use open source code under the Apache License.

 

 

Lepton Search Code Comment

 

# Importing necessary libraries and modules
import concurrent.futures # for concurrent execution of tasks
import glob # for file path pattern matching
import json # for processing JSON data
import os # Used to manipulate the file system
import re # for regular expression matching
import threading # for threading operations
import requests # Used to initiate network requests
import traceback # Used to trace exception information
from typing import Annotated, List, Generator, Optional # for type annotations

# Importing FastAPI related classes and exceptions
from fastapi import HTTPException
from fastapi.responses import HTMLResponse, StreamingResponse, RedirectResponse
import httpx # for HTTP requests
from loguru import logger # for logging

# Importing Lepton AI-related libraries and modules
import leptonai
from leptonai import Client
from leptonai.kv import KV # for key-value storage
from leptonai.photon import Photon, StaticFiles # for Photon application development
from leptonai.photon.types import to_bool # for boolean conversion
from leptonai.api.workspace import WorkspaceInfoLocalRecord # for workspace information
from leptonai.util import tool # contains some utilities

Constant values for the # RAG model
BING_SEARCH_V7_ENDPOINT = "https://api.bing.microsoft.com/v7.0/search" # Bing Search API Endpoints
BING_MKT = "en-US" # Bing Search Marketplace
GOOGLE_SEARCH_ENDPOINT = "https://customsearch.googleapis.com/customsearch/v1" # Google Custom Search API Endpoints
SERPER_SEARCH_ENDPOINT = "https://google.serper.dev/search" # Serper Search API Endpoints
SEARCHAPI_SEARCH_ENDPOINT = "https://www.searchapi.io/api/v1/search" # SearchApi Search API Endpoints

# Number of results found
REFERENCE_COUNT = 8

# Search Timeout Time
DEFAULT_SEARCH_ENGINE_TIMEOUT = 5

# Default Query
_default_query = "Who said 'live long and prosper'?"

Query text template for the # RAG model
_rag_query_text = """

You are a large language AI assistant built by Lepton AI. When you receive a user question, please provide a clean, concise and accurate answer. You will be given a series of contexts related to the question, each preceded by a citation number such as [[citation:x]], where x is a number. Please use these contexts and, where applicable, quote the context number at the end of each sentence.

Your answer must be correct, accurate, and written by an expert in a neutral and professional tone. Please limit yourself to 1024 tokens. Do not provide information that is not relevant to the question and do not repeat yourself. If the given context does not provide enough information, say "Information about... Information about... is missing".

Please cite the context in citation number format, e.g. [citation:x]. If a sentence is from more than one context, list all applicable citations, e.g. [citation:3][citation:5]. With the exception of codes, specific names, and citations, your answer must be in the same language as the question.

Here is a series of contexts:

{context}

Remember, don't blindly repeat the context verbatim. It's the user's problem here:

"""

# List of deactivated words
stop_words = [
"",
"[End]",
"[end]",
"\nReferences:\n".
"\nSources:\n".
"End.",
]

# Generate alert text for relevant questions
_more_questions_prompt = """

You are a useful assistant to help users ask relevant questions based on the original question and its associated context. Please identify topics that are worth following up on and ask them in questions of no more than 20 words. Make sure that specific information, such as events, names, places, etc., are included in the follow-up questions so that they can be asked independently. For example, if the original question asked about the Manhattan Project, in the follow-up question, instead of just saying "the project," use the full name, "The Manhattan Project. Your related questions must be in the same language as the original question.

Here is the context of the question:

{context}

Remember to ask three such further questions based on the original question and the relevant context. Do not repeat the original question. Each related question should be no more than 20 words. Here is the original question:

"""

# The following search functions are defined to interact with different search engines
def search_with_bing(query: str, subscription_key: str).
# Use Bing search engine to search and return contextual information
pass

def search_with_google(query: str, subscription_key: str, cx: str).
# Conduct searches using the Google search engine and return contextual information
pass

def search_with_serper(query: str, subscription_key: str).
# Search and return contextual information using the Serper search engine
pass

def search_with_searchapi(query: str, subscription_key: str).
# Searching with SearchApi.io and returning contextual information
pass

# RAG class, inherited from Photon, for building RAG engines
class RAG(Photon).
# Class Initialization and Method Definitions
pass

# If this script is run directly, the RAG application is started
if __name__ == "__main__".
rag = RAG()
rag.launch()

 

 

open source address

Chief AI Sharing CircleThis content has been hidden by the author, please enter the verification code to view the content
Captcha:
Please pay attention to this site WeChat public number, reply "CAPTCHA, a type of challenge-response test (computing)", get the verification code. Search in WeChat for "Chief AI Sharing Circle"or"Looks-AI"or WeChat scanning the right side of the QR code can be concerned about this site WeChat public number.

AI Easy Learning

The layman's guide to getting started with AI

Help you learn how to utilize AI tools at a low cost and from a zero base.AI, like office software, is an essential skill for everyone. Mastering AI will give you an edge in your job search and half the effort in your future work and studies.

View Details>
May not be reproduced without permission:Chief AI Sharing Circle " Lepton Search: open source conversational AI search engine|Lepton Search

Chief AI Sharing Circle

Chief AI Sharing Circle specializes in AI learning, providing comprehensive AI learning content, AI tools and hands-on guidance. Our goal is to help users master AI technology and explore the unlimited potential of AI together through high-quality content and practical experience sharing. Whether you are an AI beginner or a senior expert, this is the ideal place for you to gain knowledge, improve your skills and realize innovation.

Contact Us
en_USEnglish