mirror of
https://github.com/khoj-ai/khoj.git
synced 2024-11-23 15:38:55 +01:00
Add Advanced Self Hosting Section, Improve Self Hosting, OpenAI Proxy Docs
- Add instructions for self-hosted users with info, warning boxes to avoid, fix common issues when setting up Khoj server - Create new Advanced Self Hosting section - Extract Advanced Self-Hosting Sections from the Advanced Page and move them to separate Pages under Advanced Self Hosting section - Improve OpenAI Proxy Docs - Put Ollama setup as a section under OpenAI API Proxy page instead of a separate page - Add Section to use Khoj with chat model from LM Studio - Update LiteLLM docs to use chat model from LM Studio
This commit is contained in:
parent
732332a3c5
commit
68e7c297e0
15 changed files with 247 additions and 152 deletions
8
documentation/docs/advanced/_category_.json
Normal file
8
documentation/docs/advanced/_category_.json
Normal file
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"label": "Advanced Self Hosting",
|
||||
"position": 6,
|
||||
"link": {
|
||||
"type": "generated-index",
|
||||
"description": "Advanced setup for Self Hosting Khoj server"
|
||||
}
|
||||
}
|
|
@ -1,11 +1,16 @@
|
|||
# Authentication when Self-Hosting
|
||||
# Authenticate
|
||||
|
||||
By default, most of the instructions for self-hosting Khoj assume a single user, and so the default configuration is to run in anonymous mode. However, if you want to enable authentication, you can do so either with [Google Auth](/miscellaneous/google_auth) or with magic links, as shown below. This can be helpful if you want to make sure your Khoj instance is only accessible to you and your team.
|
||||
:::info
|
||||
This is only helpful for self-hosted users or teams. If you're using [Khoj Cloud](https://app.khoj.dev), both Magic Links and Google OAuth work.
|
||||
:::
|
||||
|
||||
By default, most of the instructions for self-hosting Khoj assume a single user, and so the default configuration is to run in anonymous mode. However, if you want to enable authentication, you can do so either with with [Magic Links](#using-magic-links) or [Google OAuth](#using-google-oauth) as shown below. This can be helpful to make Khoj securely accessible to you and your team.
|
||||
|
||||
:::tip[Note]
|
||||
Remove the `--anonymous-mode` flag in your start up command to enable authentication.
|
||||
:::
|
||||
|
||||
## Using Magic Links
|
||||
The most secure way to do this is to integrate with [Resend](https://resend.com) by setting up an account and adding an environment variable for `RESEND_API_KEY`. You can get your API key [here](https://resend.com/api-keys). This will allow you to automatically send sign-in links to users who want to log in.
|
||||
|
||||
It's still possible to use the magic links feature without Resend, but you'll need to manually send the magic links to users who want to log in.
|
||||
|
@ -28,3 +33,20 @@ Go to the [admin panel](http://localhost:42110/server/admin/database/khojuser/).
|
|||
Once they click on the link, they'll automatically be logged in. They'll have to repeat this process for every new device they want to log in from, but they shouldn't have to repeat it on the same device.
|
||||
|
||||
A given magic link can only be used once. If the user tries to use it again, they'll be redirected to the login page to get a new magic link.
|
||||
|
||||
## Using Google OAuth
|
||||
|
||||
To set up your self-hosted Khoj with Google Auth, you need to create a project in the Google Cloud Console and enable the Google Auth API.
|
||||
|
||||
To implement this, you'll need to:
|
||||
1. You must use the `python` package or build from source, because you'll need to install additional packages for the google auth libraries (`prod`). The syntax to install the right packages is
|
||||
```
|
||||
pip install khoj-assistant[prod]
|
||||
```
|
||||
2. [Create authorization credentials](https://developers.google.com/identity/sign-in/web/sign-in) for your application.
|
||||
3. Open your [Google cloud console](https://console.developers.google.com/apis/credentials) and create a configuration like below for the relevant `OAuth 2.0 Client IDs` project:
|
||||
![Google auth login project settings](https://github.com/khoj-ai/khoj/assets/65192171/9bcbf6f4-197d-4d0c-973a-c10b1331c892)
|
||||
|
||||
4. Configure these environment variables: `GOOGLE_CLIENT_SECRET`, and `GOOGLE_CLIENT_ID`. You can find these values in the Google cloud console, in the same place where you configured the authorized origins and redirect URIs.
|
||||
|
||||
That's it! That should be all you have to do. Now, when you reload Khoj without `--anonymous-mode`, you should be able to use your Google account to sign in.
|
17
documentation/docs/advanced/support-multilingual-docs.md
Normal file
17
documentation/docs/advanced/support-multilingual-docs.md
Normal file
|
@ -0,0 +1,17 @@
|
|||
# Support Multilingual Docs
|
||||
Khoj uses an embedding model to understand documents. Multilingual embedding models improve the search quality for documents not in English. This affects both search and chat with docs experiences across Khoj.
|
||||
|
||||
To improve search and chat quality for non-english documents you can use a [multilingual model](https://www.sbert.net/docs/pretrained_models.html#multi-lingual-models).<br />
|
||||
For example, the [paraphrase-multilingual-MiniLM-L12-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2) supports [50+ languages](https://www.sbert.net/docs/pretrained_models.html#:~:text=we%20used%20the%20following%2050%2B%20languages), has decent search quality and speed for a consumer machine.
|
||||
To use it:
|
||||
1. Open [the search config](http://localhost:42110/server/admin/database/searchmodelconfig/) on your server's admin settings page. Either create a new search model, if none exists, or update the existing one. For example,
|
||||
- Set the `bi_encoder` field to `sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2`
|
||||
- Set the `cross_encoder` field to `mixedbread-ai/mxbai-rerank-xsmall-v1`
|
||||
2. Regenerate your content index from all the relevant clients. This step is very important, as you'll need to re-encode all your content with the new model.
|
||||
|
||||
:::info[Note]
|
||||
Modern search/embedding model like [mixedbread-ai/mxbai-embed-large-v1](https://huggingface.co/mixedbread-ai/mxbai-embed-large-v1) expect a prefix to the query (or docs) string to improve encoding. Update the `bi_encoder_query_encode_config` field of your [embedding model](http://localhost:42110/server/admin/database/searchmodelconfig/) with `{prompt: <prefix-prompt>}` to improve the search quality of these models.
|
||||
|
||||
E.g. `{prompt: "Represent this query for searching documents"}`. You can pass any valid JSON object that the SentenceTransformer `encode` function accepts
|
||||
|
||||
:::
|
119
documentation/docs/advanced/use-openai-proxy.md
Normal file
119
documentation/docs/advanced/use-openai-proxy.md
Normal file
|
@ -0,0 +1,119 @@
|
|||
---
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
# Use OpenAI Proxy
|
||||
:::info
|
||||
This is only helpful for self-hosted users. If you're using [Khoj Cloud](https://app.khoj.dev), you're limited to our first-party models.
|
||||
:::
|
||||
|
||||
:::info
|
||||
Khoj natively supports local LLMs [available on HuggingFace in GGUF format](https://huggingface.co/models?library=gguf). Using an OpenAI API proxy with Khoj maybe useful for ease of setup, trying new models or using commercial LLMs via API.
|
||||
:::
|
||||
|
||||
Khoj can use any OpenAI API compatible server including [Ollama](#ollama), [LMStudio](#lm-studio) and [LiteLLM](#litellm).
|
||||
Configuring this allows you to use non-standard, open or commercial, local or hosted LLM models for Khoj
|
||||
|
||||
Combine them with Khoj can turn your favorite LLM into an AI agent. Allowing you to chat with your docs, find answers from the internet, build custom agents and run automations.
|
||||
|
||||
## Ollama
|
||||
Ollama allows you to run [many popular open-source LLMs](https://ollama.com/library) locally from your terminal.
|
||||
For folks comfortable with the terminal, Ollama's terminal based flows can ease setup and management of chat models.
|
||||
|
||||
Ollama exposes a local [OpenAI API compatible server](https://github.com/ollama/ollama/blob/main/docs/openai.md#models). This makes it possible to use chat models from Ollama to create your personal AI agents with Khoj.
|
||||
|
||||
### Setup
|
||||
|
||||
1. Setup Ollama: https://ollama.com/
|
||||
2. Start your preferred model with Ollama. For example,
|
||||
```bash
|
||||
ollama run llama3
|
||||
```
|
||||
3. Create a new [OpenAI Processor Conversation Config](http://localhost:42110/server/admin/database/openaiprocessorconversationconfig/add) on your Khoj admin panel
|
||||
- Name: `ollama`
|
||||
- Api Key: `any string`
|
||||
- Api Base Url: `http://localhost:11434/v1/` (default for Ollama)
|
||||
4. Create a new [Chat Model Option](http://localhost:42110/server/admin/database/chatmodeloptions/add) on your Khoj admin panel.
|
||||
- Name: `llama3` (replace with the name of your local model)
|
||||
- Model Type: `Openai`
|
||||
- Openai Config: `<the ollama config you created in step 3>`
|
||||
- Max prompt size: `1000` (replace with the max prompt size of your model)
|
||||
5. Create a new [Server Chat Setting](http://localhost:42110/server/admin/database/serverchatsettings/add/) on your Khoj admin panel
|
||||
- Default model: `<name of chat model option you created in step 4>`
|
||||
- Summarizer model: `<name of chat model option you created in step 4>`
|
||||
6. Go to [your config](http://localhost:42110/config) and select the model you just created in the chat model dropdown.
|
||||
|
||||
That's it! You should now be able to chat with your Ollama model from Khoj. If you want to add additional models running on Ollama, repeat step 6 for each model.
|
||||
|
||||
|
||||
## LM Studio
|
||||
[LM Studio](https://lmstudio.ai/) is a desktop app to chat with open-source LLMs on your local machine. LM Studio provides a neat interface for folks comfortable with a GUI.
|
||||
|
||||
LM Studio can also expose an [OpenAI API compatible server](https://lmstudio.ai/docs/local-server). This makes it possible to turn chat models from LM Studio into your personal AI agents with Khoj.
|
||||
|
||||
### Setup
|
||||
1. Install [LM Studio](https://lmstudio.ai/) and download your preferred Chat Model
|
||||
2. Go to the Server Tab on LM Studio, Select your preferred Chat Model and Click the green Start Server button
|
||||
3. Create a new [OpenAI Processor Conversation Config](http://localhost:42110/server/admin/database/openaiprocessorconversationconfig/add) on your Khoj admin panel
|
||||
- Name: `proxy-name`
|
||||
- Api Key: `any string`
|
||||
- Api Base Url: `http://localhost:1234/v1/` (default for LMStudio)
|
||||
4. Create a new [Chat Model Option](http://localhost:42110/server/admin/database/chatmodeloptions/add) on your Khoj admin panel.
|
||||
- Name: `llama3` (replace with the name of your local model)
|
||||
- Model Type: `Openai`
|
||||
- Openai Config: `<the proxy config you created in step 3>`
|
||||
- Max prompt size: `2000` (replace with the max prompt size of your model)
|
||||
- Tokenizer: *Do not set for OpenAI, mistral, llama3 based models*
|
||||
5. Create a new [Server Chat Setting](http://localhost:42110/server/admin/database/serverchatsettings/add/) on your Khoj admin panel
|
||||
- Default model: `<name of chat model option you created in step 4>`
|
||||
- Summarizer model: `<name of chat model option you created in step 4>`
|
||||
6. Go to [your config](http://localhost:42110/config) and select the model you just created in the chat model dropdown.
|
||||
|
||||
## LiteLLM
|
||||
[LiteLLM](https://docs.litellm.ai/docs/proxy/quick_start) exposes an OpenAI compatible API that proxies requests to other LLM API services. This provides a standardized API to interact with both open-source and commercial LLMs.
|
||||
|
||||
Using LiteLLM with Khoj makes it possible to turn any LLM behind an API into your personal AI agent.
|
||||
|
||||
### Setup
|
||||
1. Install LiteLLM
|
||||
```bash
|
||||
pip install litellm[proxy]
|
||||
```
|
||||
2. Start LiteLLM and use Mistral tiny via Mistral API
|
||||
```
|
||||
export MISTRAL_API_KEY=<MISTRAL_API_KEY>
|
||||
litellm --model mistral/mistral-tiny --drop_params
|
||||
```
|
||||
3. Create a new [OpenAI Processor Conversation Config](http://localhost:42110/server/admin/database/openaiprocessorconversationconfig/add) on your Khoj admin panel
|
||||
- Name: `proxy-name`
|
||||
- Api Key: `any string`
|
||||
- Api Base Url: **URL of your Openai Proxy API**
|
||||
4. Create a new [Chat Model Option](http://localhost:42110/server/admin/database/chatmodeloptions/add) on your Khoj admin panel.
|
||||
- Name: `llama3` (replace with the name of your local model)
|
||||
- Model Type: `Openai`
|
||||
- Openai Config: `<the proxy config you created in step 3>`
|
||||
- Max prompt size: `2000` (replace with the max prompt size of your model)
|
||||
- Tokenizer: *Do not set for OpenAI, mistral, llama3 based models*
|
||||
5. Create a new [Server Chat Setting](http://localhost:42110/server/admin/database/serverchatsettings/add/) on your Khoj admin panel
|
||||
- Default model: `<name of chat model option you created in step 4>`
|
||||
- Summarizer model: `<name of chat model option you created in step 4>`
|
||||
6. Go to [your config](http://localhost:42110/config) and select the model you just created in the chat model dropdown.
|
||||
|
||||
|
||||
## General
|
||||
|
||||
1. Start your preferred OpenAI API compatible app
|
||||
3. Create a new [OpenAI Processor Conversation Config](http://localhost:42110/server/admin/database/openaiprocessorconversationconfig/add) on your Khoj admin panel
|
||||
- Name: `proxy-name`
|
||||
- Api Key: `any string`
|
||||
- Api Base Url: **URL of your Openai Proxy API**
|
||||
4. Create a new [Chat Model Option](http://localhost:42110/server/admin/database/chatmodeloptions/add) on your Khoj admin panel.
|
||||
- Name: `llama3` (replace with the name of your local model)
|
||||
- Model Type: `Openai`
|
||||
- Openai Config: `<the proxy config you created in step 3>`
|
||||
- Max prompt size: `2000` (replace with the max prompt size of your model)
|
||||
- Tokenizer: *Do not set for OpenAI, mistral, llama3 based models*
|
||||
5. Create a new [Server Chat Setting](http://localhost:42110/server/admin/database/serverchatsettings/add/) on your Khoj admin panel
|
||||
- Default model: `<name of chat model option you created in step 4>`
|
||||
- Summarizer model: `<name of chat model option you created in step 4>`
|
||||
6. Go to [your config](http://localhost:42110/config) and select the model you just created in the chat model dropdown.
|
|
@ -7,8 +7,8 @@ sidebar_position: 1
|
|||
> Query your Second Brain from your machine
|
||||
|
||||
Use the Desktop app to chat and search with Khoj.
|
||||
You can also sync any relevant files with Khoj using the app.
|
||||
Khoj will use these files to provide contextual responses when you search or chat.
|
||||
You can also share your files, folders with Khoj using the app.
|
||||
Khoj will keep these files in sync to provide contextual responses when you search or chat.
|
||||
|
||||
## Features
|
||||
- **Chat**
|
||||
|
@ -25,6 +25,7 @@ Khoj will use these files to provide contextual responses when you search or cha
|
|||
2. Generate an API key on the [Khoj Web App](https://app.khoj.dev/config#clients)
|
||||
3. Set your Khoj API Key on the *Settings* page of the Khoj Desktop app
|
||||
4. [Optional] Add any files, folders you'd like Khoj to be aware of on the *Settings* page and Click *Save*
|
||||
These files and folders will be automatically kept in sync for you
|
||||
|
||||
## Interface
|
||||
| Chat | Search |
|
||||
|
|
|
@ -29,6 +29,7 @@ Khoj is available as a [Desktop app](/clients/desktop), [Emacs package](/clients
|
|||
![](/img/khoj_clients.svg ':size=400px')
|
||||
|
||||
### Supported Data Sources
|
||||
Khoj can understand your org-mode, markdown, PDF, plaintext files, [Github projects](/data-sources/github_integration) and [Notion pages](/data-sources/notion_integration).
|
||||
Khoj can understand your word, PDF, org-mode, markdown, plaintext files, [Github projects](/data-sources/github_integration) and [Notion pages](/data-sources/notion_integration).
|
||||
|
||||
|
||||
![](/img/khoj_datasources.svg ':size=200px')
|
|
@ -5,5 +5,5 @@
|
|||
Khoj will use your local time zone to determine the scheduling localization. You can go back and configure the prompt any time you want from the automations page. You can also delete the automation if you no longer need it.
|
||||
|
||||
:::danger[Note]
|
||||
Automations will not deliver emails to self-hosted users out of the box. You'll have to have Resend and [Authentication](/miscellaneous/authentication) setup to send emails.
|
||||
Automations will not deliver emails to self-hosted users out of the box. You'll have to have Resend and [Authentication](/advanced/authentication) setup to send emails.
|
||||
:::
|
||||
|
|
|
@ -8,7 +8,8 @@ Click on the little mic icon to send your voice message to Khoj. It will send ba
|
|||
|
||||
## Voice Response
|
||||
|
||||
When you get a response from Khoj, you can click on the speaker icon to hear the response. This feature is available only on the web view right now.
|
||||
If you send a voice message, Khoj will automatically respond back with a voice message.
|
||||
You can also click on the speaker icon next to any message to hear it out loud. The voice response feature is available only on the web view right now.
|
||||
|
||||
![Speaker Icon](/img/speaker_icon.png)
|
||||
|
|
@ -14,7 +14,7 @@ Here's what to consider if you're using Khoj, whether self-hosted or on our clou
|
|||
1. We collect completely anonymized usage telemetry and send it to [PostHog](https://posthog.com/). This includes data like unique chat requests, unique search requests, unique requests to index data. Usage data is collected to help us understand how people are using Khoj, and to help us prioritize features.
|
||||
- We do not log your IP address, nor upload any of your personal data to PostHog.
|
||||
- You can see our telemetry aggregation code [here](https://github.com/khoj-ai/khoj/blob/master/src/khoj/routers/helpers.py#L71) and see our telemetry server [here](https://github.com/khoj-ai/khoj/blob/master/src/telemetry/telemetry.py).
|
||||
- If you're self-hosting, you can opt out of telemetry by following [these instructions](./miscellaneous/telemetry).
|
||||
- If you're self-hosting, you can opt out of telemetry by following [these instructions](/miscellaneous/telemetry).
|
||||
|
||||
|
||||
Self-hosting isn't for everyone, so we've still taken steps to make Khoj privacy-friendly, even if you choose to use our [cloud offering](https://app.khoj.dev/login). Here's what to consider when using Khoj Cloud:
|
|
@ -16,20 +16,13 @@ import TabItem from '@theme/TabItem';
|
|||
|
||||
## Setup
|
||||
These are the general setup instructions for self-hosted Khoj.
|
||||
|
||||
- Make sure [python](https://realpython.com/installing-python/) and [pip](https://pip.pypa.io/en/stable/installation/) are installed on your machine
|
||||
- Check the [Khoj Emacs docs](/clients/emacs#setup) to setup Khoj with Emacs<br />
|
||||
It's simpler as it can skip the server *install*, *run* and *configure* step below.
|
||||
- Check the [Khoj Obsidian docs](/clients/obsidian#setup) to setup Khoj with Obsidian<br />
|
||||
Its simpler as it can skip the *configure* step below.
|
||||
|
||||
For Installation, you can either use Docker or install the Khoj server locally.
|
||||
You can install the Khoj server using either Docker or Pip.
|
||||
|
||||
:::info[Offline Model + GPU]
|
||||
If you want to use the offline chat model and you have a GPU, you should use Installation Option 2 - local setup via the Python package directly. Our Docker image doesn't currently support running the offline chat model on GPU, making inference times really slow.
|
||||
:::
|
||||
|
||||
### Installation Option 1 (Docker)
|
||||
### 1A. Install Method 1: Docker
|
||||
|
||||
#### Prerequisites
|
||||
1. Install Docker Engine. See [official instructions](https://docs.docker.com/engine/install/).
|
||||
|
@ -37,21 +30,23 @@ If you want to use the offline chat model and you have a GPU, you should use Ins
|
|||
|
||||
#### Setup
|
||||
|
||||
Use the sample docker-compose [in Github](https://github.com/khoj-ai/khoj/blob/master/docker-compose.yml) to run Khoj in Docker. Start by configuring all the environment variables to your choosing. Your admin account will automatically be created based on the admin credentials in that file, so pay attention to those. To start the container, run the following command in the same directory as the docker-compose.yml file. This will automatically setup the database and run the Khoj server.
|
||||
1. Get the sample docker-compose file [from Github](https://github.com/khoj-ai/khoj/blob/master/docker-compose.yml).
|
||||
2. Configure the environment variables in the docker-compose.yml to your choosing.<br />
|
||||
Note: *Your admin account will automatically be created based on the admin credentials in that file, so pay attention to those.*
|
||||
3. Now start the container by running the following command in the same directory as your docker-compose.yml file. This will automatically setup the database and run the Khoj server.
|
||||
```shell
|
||||
docker-compose up
|
||||
```
|
||||
|
||||
```shell
|
||||
docker-compose up
|
||||
```
|
||||
Khoj should now be running at http://localhost:42110! You can see the web UI in your browser.
|
||||
|
||||
Khoj should now be running at http://localhost:42110. You can see the web UI in your browser.
|
||||
|
||||
### Installation Option 2 (Local)
|
||||
### 1B. Install Method 2: Pip
|
||||
|
||||
#### Prerequisites
|
||||
|
||||
##### Install Postgres (with PgVector)
|
||||
|
||||
Khoj uses the `pgvector` package to store embeddings of your index in a Postgres database. In order to use this, you need to have Postgres installed.
|
||||
Khoj uses Postgres DB for all server configuration and to scale to multi-user setups. It uses the pgvector package in Postgres to manage your document embeddings. Both Postgres and pgvector need to be installed for Khoj to work.
|
||||
|
||||
```mdx-code-block
|
||||
<Tabs groupId="operating-systems">
|
||||
|
@ -97,14 +92,13 @@ sudo -u postgres createdb khoj --password
|
|||
</Tabs>
|
||||
```
|
||||
|
||||
#### Install Khoj server
|
||||
|
||||
#### Install package
|
||||
|
||||
##### Local Server Setup
|
||||
##### Install Khoj Server
|
||||
- *Make sure [python](https://realpython.com/installing-python/) and [pip](https://pip.pypa.io/en/stable/installation/) are installed on your machine*
|
||||
- Check [llama-cpp-python setup](https://python.langchain.com/docs/integrations/llms/llamacpp#installation) if you hit any llama-cpp issues with the installation
|
||||
|
||||
Run the following command in your terminal to install the Khoj backend.
|
||||
Run the following command in your terminal to install the Khoj server.
|
||||
|
||||
```mdx-code-block
|
||||
<Tabs groupId="operating-systems">
|
||||
|
@ -146,7 +140,7 @@ python -m pip install khoj-assistant
|
|||
</Tabs>
|
||||
```
|
||||
|
||||
##### Local Server Start
|
||||
##### Start Khoj Server
|
||||
|
||||
Before getting started, configure the following environment variables in your terminal for the first run
|
||||
|
||||
|
@ -186,26 +180,37 @@ On the first run, you will be prompted to input credentials for your admin accou
|
|||
|
||||
Khoj should now be running at http://localhost:42110. You can see the web UI in your browser.
|
||||
|
||||
Note: To start Khoj automatically in the background use [Task scheduler](https://www.windowscentral.com/how-create-automated-task-using-task-scheduler-windows-10) on Windows or [Cron](https://en.wikipedia.org/wiki/Cron) on Mac, Linux (e.g with `@reboot khoj`)
|
||||
Note: To start Khoj automatically in the background use [Task scheduler](https://www.windowscentral.com/how-create-automated-task-using-task-scheduler-windows-10) on Windows or [Cron](https://en.wikipedia.org/wiki/Cron) on Mac, Linux (e.g. with `@reboot khoj`)
|
||||
|
||||
|
||||
### Setup Notes
|
||||
|
||||
You can use Khoj with a custom domain as well. To do so, you need to set the `KHOJ_DOMAIN` environment variable to your domain (e.g., `export KHOJ_DOMAIN=my-khoj-domain.com` or add it to your `docker-compose.yml`). By default, the Khoj server you set up will not be accessible outside of `localhost` or `127.0.0.1`.
|
||||
|
||||
:::warning[Without HTTPS certificate]
|
||||
To expose Khoj on a custom domain over the public internet, use of an SSL certificate is strongly recommended. You can use [Let's Encrypt](https://letsencrypt.org/) to get a free SSL certificate for your domain.
|
||||
|
||||
To disable HTTPS, set the `KHOJ_NO_HTTPS` environment variable to `True`. This can be useful if Khoj is only accessible behind a secure, private network.
|
||||
:::
|
||||
|
||||
### 2. Configure
|
||||
1. Go to http://localhost:42110/server/admin and login with your admin credentials.
|
||||
#### Login to the Khoj Admin Panel
|
||||
Go to http://localhost:42110/server/admin and login with the admin credentials you setup during installation.
|
||||
|
||||
:::info[CSRF Error]
|
||||
Ensure you are using **localhost, not 127.0.0.1**, to access the admin panel to avoid the CSRF error.
|
||||
:::
|
||||
|
||||
:::info[DISALLOWED HOST Error]
|
||||
You may hit this if you try access Khoj exposed on a custom domain (e.g. 192.168.12.3 or example.com) or over HTTP.
|
||||
Set the environment variables KHOJ_DOMAIN=your-domain and KHOJ_NO_HTTPS=false if required to avoid this error.
|
||||
:::
|
||||
|
||||
:::tip[Note]
|
||||
Using Safari on Mac? You might not be able to login to the admin panel. Try using Chrome or Firefox instead.
|
||||
:::
|
||||
|
||||
#### Configure Chat Model
|
||||
##### Configure OpenAI or a custom OpenAI-compatible proxy server
|
||||
Setup which chat model you'd want to use. Khoj supports local and online chat models.
|
||||
|
||||
:::tip[Multiple Chat Models]
|
||||
Add a `ServerChatSettings` with `Default` and `Summarizer` fields set to your preferred chat model via [the admin panel](http://localhost:42110/server/admin/database/serverchatsettings/add/). Otherwise Khoj defaults to use the first chat model in your [ChatModelOptions](http://localhost:42110/server/admin/database/chatmodeloptions/) for all non chat response generation tasks.
|
||||
:::
|
||||
|
||||
##### Configure OpenAI Chat
|
||||
|
||||
:::info[Ollama Integration]
|
||||
Using Ollama? See the [Ollama Integration](/miscellaneous/ollama) section for more custom setup instructions.
|
||||
Using Ollama? See the [Ollama Integration](/advanced/use-openai-proxy#ollama) section for more custom setup instructions.
|
||||
:::
|
||||
|
||||
1. Go to the [OpenAI settings](http://localhost:42110/server/admin/database/openaiprocessorconversationconfig/) in the server admin settings to add an OpenAI processor conversation config. This is where you set your API key and server API base URL. The API base URL is optional - it's only relevant if you're using another OpenAI-compatible proxy server.
|
||||
|
@ -214,49 +219,41 @@ Using Ollama? See the [Ollama Integration](/miscellaneous/ollama) section for mo
|
|||
- The `tokenizer` and `max-prompt-size` fields are optional. Set them only if you're sure of the tokenizer or token limit for the model you're using. Contact us if you're unsure what to do here.
|
||||
|
||||
##### Configure Offline Chat
|
||||
Any chat model on Huggingface in GGUF format can be used for local chat. Here's how you can set it up:
|
||||
|
||||
1. No need to setup a conversation processor config!
|
||||
2. Go over to configure your [chat model options](http://localhost:42110/server/admin/database/chatmodeloptions/). Set the `chat-model` field to a supported chat model[^1] of your choice. For example, we recommend `NousResearch/Hermes-2-Pro-Mistral-7B-GGUF`, but [any gguf model on huggingface](https://huggingface.co/models?library=gguf) should work.
|
||||
- Make sure to set the `model-type` to `Offline`. Do not set `openai config`.
|
||||
- The `tokenizer` and `max-prompt-size` fields are optional. Set them only when using a non-standard model (i.e not mistral, gpt or llama2 model) when you know the token limit.
|
||||
- The `tokenizer` and `max-prompt-size` fields are optional. You can set these for non-standard models (i.e not Mistral or Llama based models) or when you know the token limit of the model to improve context stuffing.
|
||||
|
||||
#### Share your data
|
||||
1. Select files and folders to index [using the desktop client](/get-started/setup#2-download-the-desktop-client). When you click 'Save', the files will be sent to your server for indexing.
|
||||
You can sync your files and folders with Khoj using the [Desktop](/get-started/setup#2-download-the-desktop-client), Obsidian, or Emacs clients or just drag and drop specific files on the Web client Here's how you can do it:
|
||||
1. Select files and folders to index [using the desktop client]. When you click 'Save', the files will be sent to your server for indexing.
|
||||
- Select Notion workspaces and Github repositories to index using the web interface.
|
||||
|
||||
[^1]: Khoj, by default, can use [OpenAI GPT3.5+ chat models](https://platform.openai.com/docs/models/overview) or [GGUF chat models](https://huggingface.co/models?library=gguf). See [this section](/miscellaneous/advanced#use-openai-compatible-llm-api-server-self-hosting) on how to locally use OpenAI-format compatible proxy servers.
|
||||
|
||||
:::tip[Note]
|
||||
Using Safari on Mac? You might not be able to login to the admin panel. Try using Chrome or Firefox instead.
|
||||
:::
|
||||
### 3. Use Khoj 🚀
|
||||
|
||||
### 3. Download the desktop client (Optional)
|
||||
Now open http://localhost:42110 to start interacting with Khoj!
|
||||
|
||||
You can use our desktop executables to select file paths and folders to index. You can simply select the folders or files, and they'll be automatically uploaded to the server. Once you specify a file or file path, you don't need to update the configuration again; it will grab any data diffs dynamically over time.
|
||||
|
||||
**To download the latest desktop client, go to https://download.khoj.dev** and the correct executable for your OS will automatically start downloading. You can also go to https://khoj.dev/downloads to explicitly download your image of choice. Once downloaded, you can configure your folders for indexing using the settings tab. To set your chat configuration, you'll have to use the web interface for the Khoj server you setup in the previous step.
|
||||
|
||||
To use the desktop client, you need to go to your Khoj server's settings page (http://localhost:42110/config) and copy the API key. Then, paste it into the desktop client's settings page. Once you've done that, you can select files and folders to index. Set the desktop client settings to use `http://127.0.0.1:42110` as the host URL.
|
||||
|
||||
|
||||
### 4. Install Client Plugins (Optional)
|
||||
### 4. Install Khoj Clients (Optional)
|
||||
Khoj exposes a web interface to search, chat and configure by default.<br />
|
||||
The optional steps below allow using Khoj from within an existing application like Obsidian or Emacs.
|
||||
You can install a Khoj client to sync your documents or to easily access Khoj from within Obsidian, Emacs or your OS.
|
||||
|
||||
- **Khoj Desktop**:<br />
|
||||
[Install](/clients/desktop#setup) the Khoj Desktop app.
|
||||
|
||||
- **Khoj Obsidian**:<br />
|
||||
[Install](/clients/obsidian#setup) the Khoj Obsidian plugin
|
||||
[Install](/clients/obsidian#setup) the Khoj Obsidian plugin.
|
||||
|
||||
- **Khoj Emacs**:<br />
|
||||
[Install](/clients/emacs#setup) khoj.el
|
||||
|
||||
#### Setup host URL
|
||||
To configure your host URL on your clients when self-hosting, use `http://127.0.0.1:42110`. This is the default port for the Khoj server. Note that `localhost` will not work.
|
||||
|
||||
### 5. Use Khoj 🚀
|
||||
|
||||
You can head to http://localhost:42110 to use the web interface. You can also use the desktop client to search and chat.
|
||||
Set the host URL on your clients settings page to your Khoj server URL. By default, use `http://127.0.0.1:42110` or `http://localhost:42110`. Note that `localhost` may not work in all cases.
|
||||
|
||||
## Upgrade
|
||||
### Upgrade Khoj Server
|
||||
|
||||
```mdx-code-block
|
||||
<Tabs groupId="environment">
|
||||
|
@ -284,7 +281,6 @@ You can head to http://localhost:42110 to use the web interface. You can also us
|
|||
```
|
||||
|
||||
## Uninstall
|
||||
### Uninstall Khoj Server
|
||||
|
||||
```mdx-code-block
|
||||
<Tabs groupId="environment">
|
||||
|
@ -343,3 +339,14 @@ You can head to http://localhost:42110 to use the web interface. You can also us
|
|||
#### Khoj in Docker errors out with \"Killed\" in error message
|
||||
- **Fix**: Increase RAM available to Docker Containers in Docker Settings
|
||||
- **Refer**: [StackOverflow Solution](https://stackoverflow.com/a/50770267), [Configure Resources on Docker for Mac](https://docs.docker.com/desktop/mac/#resources)
|
||||
|
||||
## Advanced
|
||||
### Self Host on Custom Domain
|
||||
|
||||
You can self-host Khoj behind a custom domain as well. To do so, you need to set the `KHOJ_DOMAIN` environment variable to your domain (e.g., `export KHOJ_DOMAIN=my-khoj-domain.com` or add it to your `docker-compose.yml`). By default, the Khoj server you set up will not be accessible outside of `localhost` or `127.0.0.1`.
|
||||
|
||||
:::warning[Without HTTPS certificate]
|
||||
To expose Khoj on a custom domain over the public internet, use of an SSL certificate is strongly recommended. You can use [Let's Encrypt](https://letsencrypt.org/) to get a free SSL certificate for your domain.
|
||||
|
||||
To disable HTTPS, set the `KHOJ_NO_HTTPS` environment variable to `True`. This can be useful if Khoj is only accessible behind a secure, private network.
|
||||
:::
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"label": "Miscellaneous",
|
||||
"position": 6,
|
||||
"position": 7,
|
||||
"link": {
|
||||
"type": "generated-index",
|
||||
"description": "Additional resources for learning about Khoj"
|
||||
|
|
|
@ -4,14 +4,6 @@ sidebar_position: 3
|
|||
|
||||
# Advanced Usage
|
||||
|
||||
## Search across Different Languages (Self-Hosting)
|
||||
To search for notes in multiple, different languages, you can use a [multi-lingual model](https://www.sbert.net/docs/pretrained_models.html#multi-lingual-models).<br />
|
||||
For example, the [paraphrase-multilingual-MiniLM-L12-v2](https://huggingface.co/sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2) supports [50+ languages](https://www.sbert.net/docs/pretrained_models.html#:~:text=we%20used%20the%20following%2050%2B%20languages), has good search quality and speed. To use it:
|
||||
1. Manually update the search config in server's admin settings page. Go to [the search config](http://localhost:42110/server/admin/database/searchmodelconfig/). Either create a new one, if none exists, or update the existing one. Set the bi_encoder to `sentence-transformers/multi-qa-MiniLM-L6-cos-v1` and the cross_encoder to `mixedbread-ai/mxbai-rerank-xsmall-v1`.
|
||||
2. Regenerate your content index from all the relevant clients. This step is very important, as you'll need to re-encode all your content with the new model.
|
||||
|
||||
Note: If you use a search model that expects a prefix (e.g [mixedbread-ai/mxbai-embed-large-v1](https://huggingface.co/mixedbread-ai/mxbai-embed-large-v1)) to the query (or docs) string before encoding. Update the `bi_encoder_query_encode_config` field with `{prompt: <prefix-prompt>}`. Eg. `{prompt: "Represent this query for searching documents"}`. You can pass a valid JSON object that the SentenceTransformer `encode` function accepts
|
||||
|
||||
## Query Filters
|
||||
|
||||
Use structured query syntax to filter entries from your knowledge based used by search results or chat responses.
|
||||
|
@ -32,25 +24,3 @@ Use structured query syntax to filter entries from your knowledge based used by
|
|||
- containing dates from the year *1984*
|
||||
- excluding words *"big"* and *"brother"*
|
||||
- that best match the natural language query *"what is the meaning of life?"*
|
||||
|
||||
## Use OpenAI compatible LLM API Server (Self Hosting)
|
||||
Use this if you want to use non-standard, open or commercial, local or hosted LLM models for Khoj chat
|
||||
1. Setup your desired chat LLM by installing an OpenAI compatible LLM API Server like [LiteLLM](https://docs.litellm.ai/docs/proxy/quick_start), [llama-cpp-python](https://github.com/abetlen/llama-cpp-python?tab=readme-ov-file#openai-compatible-web-server)
|
||||
2. Set environment variable `OPENAI_API_BASE="<url-of-your-llm-server>"` before starting Khoj
|
||||
3. Add ChatModelOptions with `model-type` `OpenAI`, and `chat-model` to anything (e.g `gpt-3.5-turbo`) during [Config](/get-started/setup#3-configure)
|
||||
- *(Optional)* Set the `tokenizer` and `max-prompt-size` relevant to the actual chat model you're using
|
||||
|
||||
#### Sample Setup using LiteLLM and Mistral API
|
||||
|
||||
```shell
|
||||
# Install LiteLLM
|
||||
pip install litellm[proxy]
|
||||
|
||||
# Start LiteLLM and use Mistral tiny via Mistral API
|
||||
export MISTRAL_API_KEY=<MISTRAL_API_KEY>
|
||||
litellm --model mistral/mistral-tiny --drop_params
|
||||
|
||||
# Set OpenAI API Base to LiteLLM server URL and start Khoj
|
||||
export OPENAI_API_BASE='http://localhost:8000'
|
||||
khoj --anonymous-mode
|
||||
```
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
# Setting up Google Auth
|
||||
|
||||
To set up your self-hosted Khoj with Google Auth, you need to create a project in the Google Cloud Console and enable the Google Auth API.
|
||||
|
||||
|
||||
To implement this, you'll need to:
|
||||
1. You must use the `python` package or build from source, because you'll need to install additional packages for the google auth libraries (`prod`). The syntax to install the right packages is
|
||||
```
|
||||
pip install khoj-assistant[prod]
|
||||
```
|
||||
2. [Create authorization credentials](https://developers.google.com/identity/sign-in/web/sign-in) for your application.
|
||||
3. Go to your [Google cloud console](https://console.developers.google.com/apis/credentials) and create a configuration like below for the relevant `OAuth 2.0 Client IDs` project:
|
||||
![Google auth login project settings](https://github.com/khoj-ai/khoj/assets/65192171/9bcbf6f4-197d-4d0c-973a-c10b1331c892)
|
||||
|
||||
4. Configure these environment variables: `GOOGLE_CLIENT_SECRET`, and `GOOGLE_CLIENT_ID`. You can find these values in the Google cloud console, in the same place where you configured the authorized origins and redirect URIs.
|
||||
|
||||
That's it! That should be all you have to do. Now, when you reload Khoj without `--anonymous-mode`, you should be able to use your Google account to sign in.
|
|
@ -1,33 +0,0 @@
|
|||
# Ollama / Khoj
|
||||
|
||||
You can run your own open source models locally with Ollama and use them with Khoj.
|
||||
|
||||
:::info[Ollama Integration]
|
||||
This is only going to be helpful for self-hosted users. If you're using [Khoj Cloud](https://app.khoj.dev), you're limited to our first-party models.
|
||||
:::
|
||||
|
||||
Khoj supports any OpenAI-API compatible server, which includes [Ollama](http://ollama.ai/). Ollama allows you to start a local server with [several popular open-source LLMs](https://ollama.com/library) directly on your own computer. Combined with Khoj, you can chat with these LLMs and use them to search your notes and documents.
|
||||
|
||||
While Khoj also supports local-hosted LLMs downloaded from Hugging Face, the Ollama integration is particularly useful for its ease of setup and multi-model support, especially if you're already using Ollama.
|
||||
|
||||
## Setup
|
||||
|
||||
1. Setup Ollama: https://ollama.com/
|
||||
2. Start your preferred model with Ollama. For example,
|
||||
```bash
|
||||
ollama run llama3
|
||||
```
|
||||
3. Go to Khoj settings at [OpenAI Processor Conversation Config](http://localhost:42110/server/admin/database/openaiprocessorconversationconfig/)
|
||||
4. Create a new config.
|
||||
- Name: `ollama`
|
||||
- Api Key: `any string`
|
||||
- Api Base Url: `http://localhost:11434/v1/` (default for Ollama)
|
||||
5. Go to [Chat Model Options](http://localhost:42110/server/admin/database/chatmodeloptions/)
|
||||
6. Create a new config.
|
||||
- Name: `llama3` (replace with the name of your local model)
|
||||
- Model Type: `Openai`
|
||||
- Openai Config: `<the ollama config you created in step 4>`
|
||||
- Max prompt size: `1000` (replace with the max prompt size of your model)
|
||||
7. Go to [your config](http://localhost:42110/config) and select the model you just created in the chat model dropdown.
|
||||
|
||||
That's it! You should now be able to chat with your Ollama model from Khoj. If you want to add additional models running on Ollama, repeat step 6 for each model.
|
|
@ -75,7 +75,6 @@ const config = {
|
|||
({
|
||||
image: 'img/khoj-logo-sideways-500.png',
|
||||
metadata: [
|
||||
{name: 'keywords', content: 'khoj, khoj ai, chatgpt, open ai, open source, productivity'},
|
||||
{name: 'og:title', content: 'Khoj Documentation'},
|
||||
{name: 'og:type', content: 'website'},
|
||||
{name: 'og:site_name', content: 'Khoj Documentation'},
|
||||
|
@ -129,18 +128,18 @@ const config = {
|
|||
},
|
||||
{
|
||||
label: 'Features',
|
||||
to: '/features/all_features',
|
||||
to: '/features/all-features',
|
||||
},
|
||||
{
|
||||
label: 'Client Apps',
|
||||
to: '/category/clients',
|
||||
},
|
||||
{
|
||||
label: 'Self-Hosting',
|
||||
label: 'Self-Host',
|
||||
to: '/get-started/setup',
|
||||
},
|
||||
{
|
||||
label: 'Contributing',
|
||||
label: 'Contribute',
|
||||
to: '/contributing/development',
|
||||
},
|
||||
],
|
||||
|
|
Loading…
Reference in a new issue