fix(docker-usage): init

This commit is contained in:
realies
2025-03-03 04:56:44 +00:00
parent 89b5229ce9
commit b3b8a05bd2
11 changed files with 167 additions and 87 deletions

View File

@ -28,10 +28,11 @@
- [Installation](#installation) - [Installation](#installation)
- [Getting Started with Docker (Recommended)](#getting-started-with-docker-recommended) - [Getting Started with Docker (Recommended)](#getting-started-with-docker-recommended)
- [Non-Docker Installation](#non-docker-installation) - [Non-Docker Installation](#non-docker-installation)
- [Nginx Reverse Proxy](#nginx-reverse-proxy)
- [Ollama Connection Errors](#ollama-connection-errors) - [Ollama Connection Errors](#ollama-connection-errors)
- [Using as a Search Engine](#using-as-a-search-engine) - [Using as a Search Engine](#using-as-a-search-engine)
- [Using Perplexica's API](#using-perplexicas-api) - [Using Perplexica's API](#using-perplexicas-api)
- [Expose Perplexica to a network](#expose-perplexica-to-network) - [Expose Perplexica to a Network](#expose-perplexica-to-a-network)
- [One-Click Deployment](#one-click-deployment) - [One-Click Deployment](#one-click-deployment)
- [Upcoming Features](#upcoming-features) - [Upcoming Features](#upcoming-features)
- [Support Us](#support-us) - [Support Us](#support-us)
@ -118,6 +119,17 @@ There are mainly 2 ways of installing Perplexica - With Docker, Without Docker.
See the [installation documentation](https://github.com/ItzCrazyKns/Perplexica/tree/master/docs/installation) for more information like exposing it your network, etc. See the [installation documentation](https://github.com/ItzCrazyKns/Perplexica/tree/master/docs/installation) for more information like exposing it your network, etc.
### Nginx Reverse Proxy
Perplexica includes an Nginx reverse proxy that provides several key benefits:
- **Single Port Access**: Access both frontend and backend through a single port (8080)
- **Dynamic Configuration**: Works with any domain or IP without rebuilding
- **WebSocket Support**: Automatic WebSocket URL configuration based on the current domain
- **Security Headers**: Enhanced security with proper HTTP headers
When using Docker, the reverse proxy is automatically configured. Access Perplexica at `http://localhost:8080` or `http://your-ip:8080` after starting the containers.
### Ollama Connection Errors ### Ollama Connection Errors
If you're encountering an Ollama connection error, it is likely due to the backend being unable to connect to Ollama's API. To fix this issue you can: If you're encountering an Ollama connection error, it is likely due to the backend being unable to connect to Ollama's API. To fix this issue you can:
@ -143,7 +155,7 @@ If you wish to use Perplexica as an alternative to traditional search engines li
1. Open your browser's settings. 1. Open your browser's settings.
2. Navigate to the 'Search Engines' section. 2. Navigate to the 'Search Engines' section.
3. Add a new site search with the following URL: `http://localhost:3000/?q=%s`. Replace `localhost` with your IP address or domain name, and `3000` with the port number if Perplexica is not hosted locally. 3. Add a new site search with the following URL: `http://localhost:8080/?q=%s`. Replace `localhost` with your IP address or domain name if needed.
4. Click the add button. Now, you can use Perplexica directly from your browser's search bar. 4. Click the add button. Now, you can use Perplexica directly from your browser's search bar.
## Using Perplexica's API ## Using Perplexica's API
@ -152,9 +164,15 @@ Perplexica also provides an API for developers looking to integrate its powerful
For more details, check out the full documentation [here](https://github.com/ItzCrazyKns/Perplexica/tree/master/docs/API/SEARCH.md). For more details, check out the full documentation [here](https://github.com/ItzCrazyKns/Perplexica/tree/master/docs/API/SEARCH.md).
## Expose Perplexica to network ## Expose Perplexica to a Network
You can access Perplexica over your home network by following our networking guide [here](https://github.com/ItzCrazyKns/Perplexica/blob/master/docs/installation/NETWORKING.md). Perplexica can be easily accessed over your home network or exposed to the internet through the Nginx reverse proxy. With this setup:
1. **Local Network Access**: Access Perplexica from any device on your network using `http://server-ip:8080`
2. **Domain Configuration**: If you have a domain name, point it to your server and access Perplexica with `http://your-domain.com:8080`
3. **SSL Support**: Configure SSL certificates in Nginx for secure `https://` access
For more network configuration details, see our [networking guide](https://github.com/ItzCrazyKns/Perplexica/blob/master/docs/installation/NETWORKING.md).
## One-Click Deployment ## One-Click Deployment

View File

@ -35,8 +35,8 @@ services:
context: . context: .
dockerfile: app.dockerfile dockerfile: app.dockerfile
args: args:
- NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api - NEXT_PUBLIC_API_URL=/api
- NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001 - NEXT_PUBLIC_WS_URL=auto
image: itzcrazykns1337/perplexica-frontend:main image: itzcrazykns1337/perplexica-frontend:main
depends_on: depends_on:
- perplexica-backend - perplexica-backend
@ -46,6 +46,19 @@ services:
- perplexica-network - perplexica-network
restart: unless-stopped restart: unless-stopped
nginx:
image: nginx:alpine
ports:
- "8080:80"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf:ro
depends_on:
- perplexica-frontend
- perplexica-backend
networks:
- perplexica-network
restart: unless-stopped
networks: networks:
perplexica-network: perplexica-network:

View File

@ -1,109 +1,106 @@
# Expose Perplexica to a network # Exposing Perplexica to a Network
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. This guide explains how to make Perplexica available over a network using the built-in Nginx reverse proxy.
## Windows ## Accessing Perplexica Over a Network
1. Open PowerShell as Administrator ### Basic Access
2. Navigate to the directory containing the `docker-compose.yaml` file With the Nginx reverse proxy, Perplexica is automatically accessible from any device on your network:
3. Stop and remove the existing Perplexica containers and images:
1. Start Perplexica using Docker Compose:
```bash ```bash
docker compose down --rmi all docker compose up -d
``` ```
4. Open the `docker-compose.yaml` file in a text editor like Notepad++ 2. Find your server's IP address:
- **Windows**: `ipconfig` in Command Prompt
- **macOS**: `ifconfig | grep "inet "` in Terminal
- **Linux**: `ip addr show | grep "inet "` in Terminal
5. Replace `127.0.0.1` with the IP address of the server Perplexica is running on in these two lines: 3. Access Perplexica from any device on your network:
```
```bash http://YOUR_SERVER_IP:8080
args:
- NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api
- NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001
``` ```
6. Save and close the `docker-compose.yaml` file ### Domain Configuration
7. Rebuild and restart the Perplexica container: If you have a domain name, you can point it to your server:
```bash 1. Configure your domain's DNS settings to point to your server IP
docker compose up -d --build
2. Access Perplexica via:
```
http://your-domain.com:8080
``` ```
## macOS ## Advanced Configuration
1. Open the Terminal application ### Custom Port
2. Navigate to the directory with the `docker-compose.yaml` file: If you need to use a different port instead of the default 8080:
```bash 1. Modify the `docker-compose.yaml` file:
cd /path/to/docker-compose.yaml ```yaml
nginx:
ports:
- "YOUR_CUSTOM_PORT:80"
``` ```
3. Stop and remove existing containers and images: 2. Restart the containers:
```bash ```bash
docker compose down --rmi all docker compose down && docker compose up -d
``` ```
4. Open `docker-compose.yaml` in a text editor like Sublime Text: ### SSL/HTTPS Configuration
```bash For secure HTTPS access:
nano docker-compose.yaml
1. Modify the Nginx configuration to include SSL:
```nginx
# In nginx.conf
server {
listen 80;
listen 443 ssl;
ssl_certificate /path/to/certificate.crt;
ssl_certificate_key /path/to/private.key;
# Rest of configuration...
}
``` ```
5. Replace `127.0.0.1` with the server IP in these lines: 2. Update the Docker volume to include your certificates:
```yaml
```bash nginx:
args: volumes:
- NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api - ./nginx.conf:/etc/nginx/nginx.conf:ro
- NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001 - ./ssl:/path/to/ssl:ro
``` ```
6. Save and exit the editor 3. Restart the containers:
7. Rebuild and restart Perplexica:
```bash ```bash
docker compose up -d --build docker compose down && docker compose up -d
``` ```
## Linux 4. Or just use another reverse proxy on top of this one...
1. Open the terminal ## Troubleshooting
2. Navigate to the `docker-compose.yaml` directory: If you encounter issues accessing Perplexica over your network:
1. **Firewall Settings**: Ensure port 8080 (or your custom port) is allowed in your firewall
2. **Docker Network**: Check if Docker's network settings allow external connections:
```bash ```bash
cd /path/to/docker-compose.yaml docker network inspect perplexica_perplexica-network
``` ```
3. Stop and remove containers and images: 3. **Nginx Logs**: Check for any connection issues:
```bash ```bash
docker compose down --rmi all docker logs perplexica-nginx-1
``` ```
4. Edit `docker-compose.yaml`: 4. **Direct Access**: Verify if you can access the services directly:
- Frontend: http://YOUR_SERVER_IP:3000
```bash - Backend: http://YOUR_SERVER_IP:3001
nano docker-compose.yaml
```
5. Replace `127.0.0.1` with the server IP:
```bash
args:
- NEXT_PUBLIC_API_URL=http://127.0.0.1:3001/api
- NEXT_PUBLIC_WS_URL=ws://127.0.0.1:3001
```
6. Save and exit the editor
7. Rebuild and restart Perplexica:
```bash
docker compose up -d --build
```

50
nginx.conf Normal file
View File

@ -0,0 +1,50 @@
events {
worker_connections 1024;
}
http {
port_in_redirect on;
absolute_redirect off;
server {
listen 80;
server_name localhost:8080;
# API requests
location /api {
proxy_pass http://perplexica-backend:3001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# WebSocket requests
location /ws {
proxy_pass http://perplexica-backend:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Frontend requests
location / {
proxy_pass http://perplexica-frontend:3000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Security headers
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
add_header X-XSS-Protection "1; mode=block" always;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
server_tokens off;
}
}

View File

@ -13,20 +13,20 @@ import type { BaseChatModel } from '@langchain/core/language_models/chat_models'
const VideoSearchChainPrompt = ` const VideoSearchChainPrompt = `
You will be given a conversation below and a follow up question. You need to rephrase the follow-up question so it is a standalone question that can be used by the LLM to search Youtube for videos. You will be given a conversation below and a follow up question. You need to rephrase the follow-up question so it is a standalone question that can be used by the LLM to search Youtube for videos.
You need to make sure the rephrased question agrees with the conversation and is relevant to the conversation. You need to make sure the rephrased question agrees with the conversation and is relevant to the conversation.
Example: Example:
1. Follow up question: How does a car work? 1. Follow up question: How does a car work?
Rephrased: How does a car work? Rephrased: How does a car work?
2. Follow up question: What is the theory of relativity? 2. Follow up question: What is the theory of relativity?
Rephrased: What is theory of relativity Rephrased: What is theory of relativity
3. Follow up question: How does an AC work? 3. Follow up question: How does an AC work?
Rephrased: How does an AC work Rephrased: How does an AC work
Conversation: Conversation:
{chat_history} {chat_history}
Follow up question: {query} Follow up question: {query}
Rephrased question: Rephrased question:
`; `;

View File

@ -50,7 +50,7 @@ export const academicSearchResponsePrompt = `
- If the user provides vague input or if relevant information is missing, explain what additional details might help refine the search. - If the user provides vague input or if relevant information is missing, explain what additional details might help refine the search.
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query. - If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
- You are set on focus mode 'Academic', this means you will be searching for academic papers and articles on the web. - You are set on focus mode 'Academic', this means you will be searching for academic papers and articles on the web.
### Example Output ### Example Output
- Begin with a brief introduction summarizing the event or query topic. - Begin with a brief introduction summarizing the event or query topic.
- Follow with detailed sections under clear headings, covering all aspects of the query if possible. - Follow with detailed sections under clear headings, covering all aspects of the query if possible.

View File

@ -50,7 +50,7 @@ export const redditSearchResponsePrompt = `
- If the user provides vague input or if relevant information is missing, explain what additional details might help refine the search. - If the user provides vague input or if relevant information is missing, explain what additional details might help refine the search.
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query. - If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
- You are set on focus mode 'Reddit', this means you will be searching for information, opinions and discussions on the web using Reddit. - You are set on focus mode 'Reddit', this means you will be searching for information, opinions and discussions on the web using Reddit.
### Example Output ### Example Output
- Begin with a brief introduction summarizing the event or query topic. - Begin with a brief introduction summarizing the event or query topic.
- Follow with detailed sections under clear headings, covering all aspects of the query if possible. - Follow with detailed sections under clear headings, covering all aspects of the query if possible.

View File

@ -50,7 +50,7 @@ export const wolframAlphaSearchResponsePrompt = `
- If the user provides vague input or if relevant information is missing, explain what additional details might help refine the search. - If the user provides vague input or if relevant information is missing, explain what additional details might help refine the search.
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query. - If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
- You are set on focus mode 'Wolfram Alpha', this means you will be searching for information on the web using Wolfram Alpha. It is a computational knowledge engine that can answer factual queries and perform computations. - You are set on focus mode 'Wolfram Alpha', this means you will be searching for information on the web using Wolfram Alpha. It is a computational knowledge engine that can answer factual queries and perform computations.
### Example Output ### Example Output
- Begin with a brief introduction summarizing the event or query topic. - Begin with a brief introduction summarizing the event or query topic.
- Follow with detailed sections under clear headings, covering all aspects of the query if possible. - Follow with detailed sections under clear headings, covering all aspects of the query if possible.

View File

@ -50,7 +50,7 @@ export const youtubeSearchResponsePrompt = `
- If the user provides vague input or if relevant information is missing, explain what additional details might help refine the search. - If the user provides vague input or if relevant information is missing, explain what additional details might help refine the search.
- If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query. - If no relevant information is found, say: "Hmm, sorry I could not find any relevant information on this topic. Would you like me to search again or ask something else?" Be transparent about limitations and suggest alternatives or ways to reframe the query.
- You are set on focus mode 'Youtube', this means you will be searching for videos on the web using Youtube and providing information based on the video's transcrip - You are set on focus mode 'Youtube', this means you will be searching for videos on the web using Youtube and providing information based on the video's transcrip
### Example Output ### Example Output
- Begin with a brief introduction summarizing the event or query topic. - Begin with a brief introduction summarizing the event or query topic.
- Follow with detailed sections under clear headings, covering all aspects of the query if possible. - Follow with detailed sections under clear headings, covering all aspects of the query if possible.

View File

@ -132,7 +132,7 @@ class MetaSearchAgent implements MetaSearchAgentType {
You are a web search summarizer, tasked with summarizing a piece of text retrieved from a web search. Your job is to summarize the You are a web search summarizer, tasked with summarizing a piece of text retrieved from a web search. Your job is to summarize the
text into a detailed, 2-4 paragraph explanation that captures the main ideas and provides a comprehensive answer to the query. text into a detailed, 2-4 paragraph explanation that captures the main ideas and provides a comprehensive answer to the query.
If the query is \"summarize\", you should provide a detailed summary of the text. If the query is a specific question, you should answer it in the summary. If the query is \"summarize\", you should provide a detailed summary of the text. If the query is a specific question, you should answer it in the summary.
- **Journalistic tone**: The summary should sound professional and journalistic, not too casual or vague. - **Journalistic tone**: The summary should sound professional and journalistic, not too casual or vague.
- **Thorough and detailed**: Ensure that every key point from the text is captured and that the summary directly answers the query. - **Thorough and detailed**: Ensure that every key point from the text is captured and that the summary directly answers the query.
- **Not too lengthy, but detailed**: The summary should be informative but not excessively long. Focus on providing detailed information in a concise format. - **Not too lengthy, but detailed**: The summary should be informative but not excessively long. Focus on providing detailed information in a concise format.

View File

@ -368,7 +368,7 @@ const loadMessages = async (
const ChatWindow = ({ id }: { id?: string }) => { const ChatWindow = ({ id }: { id?: string }) => {
const searchParams = useSearchParams(); const searchParams = useSearchParams();
const initialMessage = searchParams.get('q'); const initialMessage = searchParams?.get('q');
const [chatId, setChatId] = useState<string | undefined>(id); const [chatId, setChatId] = useState<string | undefined>(id);
const [newChatCreated, setNewChatCreated] = useState(false); const [newChatCreated, setNewChatCreated] = useState(false);
@ -378,7 +378,9 @@ const ChatWindow = ({ id }: { id?: string }) => {
const [isWSReady, setIsWSReady] = useState(false); const [isWSReady, setIsWSReady] = useState(false);
const ws = useSocket( const ws = useSocket(
process.env.NEXT_PUBLIC_WS_URL!, process.env.NEXT_PUBLIC_WS_URL === 'auto'
? `${window.location.protocol === 'https:' ? 'wss:' : 'ws:'}//${window.location.host}/ws`
: process.env.NEXT_PUBLIC_WS_URL!,
setIsWSReady, setIsWSReady,
setHasError, setHasError,
); );