mgokg commited on
Commit
d89a2ae
·
verified ·
1 Parent(s): f2a245f

Upload 5 files

Browse files
docs/API/SEARCH.md ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Perplexica Search API Documentation
2
+
3
+ ## Overview
4
+
5
+ Perplexica’s Search API makes it easy to use our AI-powered search engine. You can run different types of searches, pick the models you want to use, and get the most recent info. Follow the following headings to learn more about Perplexica's search API.
6
+
7
+ ## Endpoint
8
+
9
+ ### **POST** `http://localhost:3001/api/search`
10
+
11
+ **Note**: Replace `3001` with any other port if you've changed the default PORT
12
+
13
+ ### Request
14
+
15
+ The API accepts a JSON object in the request body, where you define the focus mode, chat models, embedding models, and your query.
16
+
17
+ #### Request Body Structure
18
+
19
+ ```json
20
+ {
21
+ "chatModel": {
22
+ "provider": "openai",
23
+ "model": "gpt-4o-mini"
24
+ },
25
+ "embeddingModel": {
26
+ "provider": "openai",
27
+ "model": "text-embedding-3-large"
28
+ },
29
+ "optimizationMode": "speed",
30
+ "focusMode": "webSearch",
31
+ "query": "What is Perplexica",
32
+ "history": [
33
+ ["human", "Hi, how are you?"],
34
+ ["assistant", "I am doing well, how can I help you today?"]
35
+ ]
36
+ }
37
+ ```
38
+
39
+ ### Request Parameters
40
+
41
+ - **`chatModel`** (object, optional): Defines the chat model to be used for the query. For model details you can send a GET request at `http://localhost:3001/api/models`. Make sure to use the key value (For example "gpt-4o-mini" instead of the display name "GPT 4 omni mini").
42
+
43
+ - `provider`: Specifies the provider for the chat model (e.g., `openai`, `ollama`).
44
+ - `model`: The specific model from the chosen provider (e.g., `gpt-4o-mini`).
45
+ - Optional fields for custom OpenAI configuration:
46
+ - `customOpenAIBaseURL`: If you’re using a custom OpenAI instance, provide the base URL.
47
+ - `customOpenAIKey`: The API key for a custom OpenAI instance.
48
+
49
+ - **`embeddingModel`** (object, optional): Defines the embedding model for similarity-based searching. For model details you can send a GET request at `http://localhost:3001/api/models`. Make sure to use the key value (For example "text-embedding-3-large" instead of the display name "Text Embedding 3 Large").
50
+
51
+ - `provider`: The provider for the embedding model (e.g., `openai`).
52
+ - `model`: The specific embedding model (e.g., `text-embedding-3-large`).
53
+
54
+ - **`focusMode`** (string, required): Specifies which focus mode to use. Available modes:
55
+
56
+ - `webSearch`, `academicSearch`, `writingAssistant`, `wolframAlphaSearch`, `youtubeSearch`, `redditSearch`.
57
+
58
+ - **`optimizationMode`** (string, optional): Specifies the optimization mode to control the balance between performance and quality. Available modes:
59
+
60
+ - `speed`: Prioritize speed and return the fastest answer.
61
+ - `balanced`: Provide a balanced answer with good speed and reasonable quality.
62
+
63
+ - **`query`** (string, required): The search query or question.
64
+
65
+ - **`history`** (array, optional): An array of message pairs representing the conversation history. Each pair consists of a role (either 'human' or 'assistant') and the message content. This allows the system to use the context of the conversation to refine results. Example:
66
+
67
+ ```json
68
+ [
69
+ ["human", "What is Perplexica?"],
70
+ ["assistant", "Perplexica is an AI-powered search engine..."]
71
+ ]
72
+ ```
73
+
74
+ ### Response
75
+
76
+ The response from the API includes both the final message and the sources used to generate that message.
77
+
78
+ #### Example Response
79
+
80
+ ```json
81
+ {
82
+ "message": "Perplexica is an innovative, open-source AI-powered search engine designed to enhance the way users search for information online. Here are some key features and characteristics of Perplexica:\n\n- **AI-Powered Technology**: It utilizes advanced machine learning algorithms to not only retrieve information but also to understand the context and intent behind user queries, providing more relevant results [1][5].\n\n- **Open-Source**: Being open-source, Perplexica offers flexibility and transparency, allowing users to explore its functionalities without the constraints of proprietary software [3][10].",
83
+ "sources": [
84
+ {
85
+ "pageContent": "Perplexica is an innovative, open-source AI-powered search engine designed to enhance the way users search for information online.",
86
+ "metadata": {
87
+ "title": "What is Perplexica, and how does it function as an AI-powered search ...",
88
+ "url": "https://askai.glarity.app/search/What-is-Perplexica--and-how-does-it-function-as-an-AI-powered-search-engine"
89
+ }
90
+ },
91
+ {
92
+ "pageContent": "Perplexica is an open-source AI-powered search tool that dives deep into the internet to find precise answers.",
93
+ "metadata": {
94
+ "title": "Sahar Mor's Post",
95
+ "url": "https://www.linkedin.com/posts/sahar-mor_a-new-open-source-project-called-perplexica-activity-7204489745668694016-ncja"
96
+ }
97
+ }
98
+ ....
99
+ ]
100
+ }
101
+ ```
102
+
103
+ ### Fields in the Response
104
+
105
+ - **`message`** (string): The search result, generated based on the query and focus mode.
106
+ - **`sources`** (array): A list of sources that were used to generate the search result. Each source includes:
107
+ - `pageContent`: A snippet of the relevant content from the source.
108
+ - `metadata`: Metadata about the source, including:
109
+ - `title`: The title of the webpage.
110
+ - `url`: The URL of the webpage.
111
+
112
+ ### Error Handling
113
+
114
+ If an error occurs during the search process, the API will return an appropriate error message with an HTTP status code.
115
+
116
+ - **400**: If the request is malformed or missing required fields (e.g., no focus mode or query).
117
+ - **500**: If an internal server error occurs during the search.
docs/architecture/README.md ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Perplexica's Architecture
2
+
3
+ Perplexica's architecture consists of the following key components:
4
+
5
+ 1. **User Interface**: A web-based interface that allows users to interact with Perplexica for searching images, videos, and much more.
6
+ 2. **Agent/Chains**: These components predict Perplexica's next actions, understand user queries, and decide whether a web search is necessary.
7
+ 3. **SearXNG**: A metadata search engine used by Perplexica to search the web for sources.
8
+ 4. **LLMs (Large Language Models)**: Utilized by agents and chains for tasks like understanding content, writing responses, and citing sources. Examples include Claude, GPTs, etc.
9
+ 5. **Embedding Models**: To improve the accuracy of search results, embedding models re-rank the results using similarity search algorithms such as cosine similarity and dot product distance.
10
+
11
+ For a more detailed explanation of how these components work together, see [WORKING.md](https://github.com/ItzCrazyKns/Perplexica/tree/master/docs/architecture/WORKING.md).
docs/architecture/WORKING.md ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## How does Perplexica work?
2
+
3
+ Curious about how Perplexica works? Don't worry, we'll cover it here. Before we begin, make sure you've read about the architecture of Perplexica to ensure you understand what it's made up of. Haven't read it? You can read it [here](https://github.com/ItzCrazyKns/Perplexica/tree/master/docs/architecture/README.md).
4
+
5
+ We'll understand how Perplexica works by taking an example of a scenario where a user asks: "How does an A.C. work?". We'll break down the process into steps to make it easier to understand. The steps are as follows:
6
+
7
+ 1. The message is sent via WS to the backend server where it invokes the chain. The chain will depend on your focus mode. For this example, let's assume we use the "webSearch" focus mode.
8
+ 2. The chain is now invoked; first, the message is passed to another chain where it first predicts (using the chat history and the question) whether there is a need for sources and searching the web. If there is, it will generate a query (in accordance with the chat history) for searching the web that we'll take up later. If not, the chain will end there, and then the answer generator chain, also known as the response generator, will be started.
9
+ 3. The query returned by the first chain is passed to SearXNG to search the web for information.
10
+ 4. After the information is retrieved, it is based on keyword-based search. We then convert the information into embeddings and the query as well, then we perform a similarity search to find the most relevant sources to answer the query.
11
+ 5. After all this is done, the sources are passed to the response generator. This chain takes all the chat history, the query, and the sources. It generates a response that is streamed to the UI.
12
+
13
+ ### How are the answers cited?
14
+
15
+ The LLMs are prompted to do so. We've prompted them so well that they cite the answers themselves, and using some UI magic, we display it to the user.
16
+
17
+ ### Image and Video Search
18
+
19
+ Image and video searches are conducted in a similar manner. A query is always generated first, then we search the web for images and videos that match the query. These results are then returned to the user.
docs/installation/NETWORKING.md ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Expose Perplexica to a network
2
+
3
+ This guide will show you how to make Perplexica available over a network. Follow these steps to allow computers on the same network to interact with Perplexica. Choose the instructions that match the operating system you are using.
4
+
5
+ ## Windows
6
+
7
+ 1. Open PowerShell as Administrator
8
+
9
+ 2. Navigate to the directory containing the `docker-compose.yaml` file
10
+
11
+ 3. Stop and remove the existing Perplexica containers and images:
12
+
13
+ ```
14
+ docker compose down --rmi all
15
+ ```
16
+
17
+ 4. Open the `docker-compose.yaml` file in a text editor like Notepad++
18
+
19
+ 5. Replace `127.0.0.1` with the IP address of the server Perplexica is running on in these two lines:
20
+
21
+ ```
22
+ args:
23
+ - NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api
24
+ - NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001
25
+ ```
26
+
27
+ 6. Save and close the `docker-compose.yaml` file
28
+
29
+ 7. Rebuild and restart the Perplexica container:
30
+
31
+ ```
32
+ docker compose up -d --build
33
+ ```
34
+
35
+ ## macOS
36
+
37
+ 1. Open the Terminal application
38
+
39
+ 2. Navigate to the directory with the `docker-compose.yaml` file:
40
+
41
+ ```
42
+ cd /path/to/docker-compose.yaml
43
+ ```
44
+
45
+ 3. Stop and remove existing containers and images:
46
+
47
+ ```
48
+ docker compose down --rmi all
49
+ ```
50
+
51
+ 4. Open `docker-compose.yaml` in a text editor like Sublime Text:
52
+
53
+ ```
54
+ nano docker-compose.yaml
55
+ ```
56
+
57
+ 5. Replace `127.0.0.1` with the server IP in these lines:
58
+
59
+ ```
60
+ args:
61
+ - NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api
62
+ - NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001
63
+ ```
64
+
65
+ 6. Save and exit the editor
66
+
67
+ 7. Rebuild and restart Perplexica:
68
+
69
+ ```
70
+ docker compose up -d --build
71
+ ```
72
+
73
+ ## Linux
74
+
75
+ 1. Open the terminal
76
+
77
+ 2. Navigate to the `docker-compose.yaml` directory:
78
+
79
+ ```
80
+ cd /path/to/docker-compose.yaml
81
+ ```
82
+
83
+ 3. Stop and remove containers and images:
84
+
85
+ ```
86
+ docker compose down --rmi all
87
+ ```
88
+
89
+ 4. Edit `docker-compose.yaml`:
90
+
91
+ ```
92
+ nano docker-compose.yaml
93
+ ```
94
+
95
+ 5. Replace `127.0.0.1` with the server IP:
96
+
97
+ ```
98
+ args:
99
+ - NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api
100
+ - NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001
101
+ ```
102
+
103
+ 6. Save and exit the editor
104
+
105
+ 7. Rebuild and restart Perplexica:
106
+
107
+ ```
108
+ docker compose up -d --build
109
+ ```
docs/installation/UPDATING.md ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Update Perplexica to the latest version
2
+
3
+ To update Perplexica to the latest version, follow these steps:
4
+
5
+ ## For Docker users
6
+
7
+ 1. Clone the latest version of Perplexica from GitHub:
8
+
9
+ ```bash
10
+ git clone https://github.com/ItzCrazyKns/Perplexica.git
11
+ ```
12
+
13
+ 2. Navigate to the Project Directory.
14
+
15
+ 3. Pull latest images from registry.
16
+
17
+ ```bash
18
+ docker compose pull
19
+ ```
20
+
21
+ 4. Update and Recreate containers.
22
+
23
+ ```bash
24
+ docker compose up -d
25
+ ```
26
+
27
+ 5. Once the command completes running go to http://localhost:3000 and verify the latest changes.
28
+
29
+ ## For non Docker users
30
+
31
+ 1. Clone the latest version of Perplexica from GitHub:
32
+
33
+ ```bash
34
+ git clone https://github.com/ItzCrazyKns/Perplexica.git
35
+ ```
36
+
37
+ 2. Navigate to the Project Directory
38
+ 3. Execute `npm i` in both the `ui` folder and the root directory.
39
+ 4. Once packages are updated, execute `npm run build` in both the `ui` folder and the root directory.
40
+ 5. Finally, start both the frontend and the backend by running `npm run start` in both the `ui` folder and the root directory.