Update Khoj server to run on non standard port, 42110 instead of 8000

Resolves #295
This commit is contained in:
Debanjum Singh Solanky 2023-07-10 20:16:25 -07:00
parent bfd516c1a4
commit f664a74e77
9 changed files with 23 additions and 23 deletions

View file

@ -44,4 +44,4 @@ jobs:
push: true push: true
tags: ghcr.io/${{ github.repository }}:${{ env.DOCKER_IMAGE_TAG }} tags: ghcr.io/${{ github.repository }}:${{ env.DOCKER_IMAGE_TAG }}
build-args: | build-args: |
PORT=8000 PORT=42110

View file

@ -169,9 +169,9 @@ The optional steps below allow using Khoj from within an existing application li
- **Khoj via Emacs** - **Khoj via Emacs**
- Run `M-x khoj <user-query>` - Run `M-x khoj <user-query>`
- **Khoj via Web** - **Khoj via Web**
- Open <http://localhost:8000/> directly - Open <http://localhost:42110/> directly
- **Khoj via API** - **Khoj via API**
- See the Khoj FastAPI [Swagger Docs](http://localhost:8000/docs), [ReDocs](http://localhost:8000/redocs) - See the Khoj FastAPI [Swagger Docs](http://localhost:42110/docs), [ReDocs](http://localhost:42110/redocs)
<details><summary>Query Filters</summary> <details><summary>Query Filters</summary>
@ -207,7 +207,7 @@ Use structured query syntax to filter the natural language search results
- [Setup your OpenAI API key in Khoj](#set-your-openai-api-key-in-khoj) - [Setup your OpenAI API key in Khoj](#set-your-openai-api-key-in-khoj)
#### Use #### Use
1. Open [/chat](http://localhost:8000/chat)[^2] 1. Open [/chat](http://localhost:42110/chat)[^2]
2. Type your queries and see response by Khoj from your notes 2. Type your queries and see response by Khoj from your notes
#### Demo #### Demo
@ -256,7 +256,7 @@ pip install --upgrade --pre khoj-assistant
- **Refer**: [Issue with Fix](https://github.com/khoj-ai/khoj/issues/82#issuecomment-1241890946) for more details - **Refer**: [Issue with Fix](https://github.com/khoj-ai/khoj/issues/82#issuecomment-1241890946) for more details
#### Search starts giving wonky results #### Search starts giving wonky results
- **Fix**: Open [/api/update?force=true](http://localhost:8000/api/update?force=true)[^2] in browser to regenerate index from scratch - **Fix**: Open [/api/update?force=true](http://localhost:42110/api/update?force=true)[^2] in browser to regenerate index from scratch
- **Note**: *This is a fix for when you percieve the search results have degraded. Not if you think they've always given wonky results* - **Note**: *This is a fix for when you percieve the search results have degraded. Not if you think they've always given wonky results*
#### Khoj in Docker errors out with \"Killed\" in error message #### Khoj in Docker errors out with \"Killed\" in error message
@ -270,7 +270,7 @@ pip install --upgrade --pre khoj-assistant
### Access Khoj on Mobile ### Access Khoj on Mobile
1. [Setup Khoj](#Setup) on your personal server. This can be any always-on machine, i.e an old computer, RaspberryPi(?) etc 1. [Setup Khoj](#Setup) on your personal server. This can be any always-on machine, i.e an old computer, RaspberryPi(?) etc
2. [Install](https://tailscale.com/kb/installation/) [Tailscale](tailscale.com/) on your personal server and phone 2. [Install](https://tailscale.com/kb/installation/) [Tailscale](tailscale.com/) on your personal server and phone
3. Open the Khoj web interface of the server from your phone browser.<br /> It should be `http://tailscale-ip-of-server:8000` or `http://name-of-server:8000` if you've setup [MagicDNS](https://tailscale.com/kb/1081/magicdns/) 3. Open the Khoj web interface of the server from your phone browser.<br /> It should be `http://tailscale-ip-of-server:42110` or `http://name-of-server:42110` if you've setup [MagicDNS](https://tailscale.com/kb/1081/magicdns/)
4. Click the [Add to Homescreen](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Add_to_home_screen) button 4. Click the [Add to Homescreen](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Add_to_home_screen) button
5. Enjoy exploring your notes, documents and images from your phone! 5. Enjoy exploring your notes, documents and images from your phone!
@ -311,7 +311,7 @@ pip install --upgrade --pre khoj-assistant
model_directory: "~/.khoj/search/asymmetric/" model_directory: "~/.khoj/search/asymmetric/"
``` ```
2. Regenerate your content index. For example, by opening [\<khoj-url\>/api/update?t=force](http://localhost:8000/api/update?t=force) 2. Regenerate your content index. For example, by opening [\<khoj-url\>/api/update?t=force](http://localhost:42110/api/update?t=force)
### Bootstrap Khoj Search for Offline Usage later ### Bootstrap Khoj Search for Offline Usage later
@ -330,7 +330,7 @@ pip install --upgrade --pre khoj-assistant
### Set your OpenAI API key in Khoj ### Set your OpenAI API key in Khoj
If you want, Khoj can be configured to use OpenAI for search and chat.<br /> If you want, Khoj can be configured to use OpenAI for search and chat.<br />
Add your OpenAI API to Khoj by using either of the two options below: Add your OpenAI API to Khoj by using either of the two options below:
- Open your [Khoj settings](http://localhost:8000/config/processor/conversation), add your OpenAI API key, and click *Save*. Then go to your [Khoj settings](http://localhost:8000/config) and click `Configure`. This will refresh Khoj with your OpenAI API key. - Open your [Khoj settings](http://localhost:42110/config/processor/conversation), add your OpenAI API key, and click *Save*. Then go to your [Khoj settings](http://localhost:42110/config) and click `Configure`. This will refresh Khoj with your OpenAI API key.
- Set `openai-api-key` field under `processor.conversation` section in your `khoj.yml`[^1] to your [OpenAI API key](https://beta.openai.com/account/api-keys) and restart khoj: - Set `openai-api-key` field under `processor.conversation` section in your `khoj.yml`[^1] to your [OpenAI API key](https://beta.openai.com/account/api-keys) and restart khoj:
```diff ```diff
processor: processor:
@ -344,11 +344,11 @@ Add your OpenAI API to Khoj by using either of the two options below:
**Warning**: *This will enable Khoj to send your query and note(s) to OpenAI for processing* **Warning**: *This will enable Khoj to send your query and note(s) to OpenAI for processing*
### GPT API ### GPT API
- The [chat](http://localhost:8000/api/chat), [answer](http://localhost:8000/api/beta/answer) and [search](http://localhost:8000/api/beta/search) API endpoints use [OpenAI API](https://openai.com/api/) - The [chat](http://localhost:42110/api/chat), [answer](http://localhost:42110/api/beta/answer) and [search](http://localhost:42110/api/beta/search) API endpoints use [OpenAI API](https://openai.com/api/)
- They are disabled by default - They are disabled by default
- To use them: - To use them:
1. [Setup your OpenAI API key in Khoj](#set-your-openai-api-key-in-khoj) 1. [Setup your OpenAI API key in Khoj](#set-your-openai-api-key-in-khoj)
2. Interact with them from the [Khoj Swagger docs](http://locahost:8000/docs)[^2] 2. Interact with them from the [Khoj Swagger docs](http://locahost:42110/docs)[^2]
### Index Github Repository for Search, Chat ### Index Github Repository for Search, Chat
The Khoj Github plugin can index issues, commit messages and markdown, org-mode and PDF files from any repositories you have access to. This allows you to chat or search with these repositories. Get answers, resolve issues or just explore a repo with the help of your AI personal assistant. The Khoj Github plugin can index issues, commit messages and markdown, org-mode and PDF files from any repositories you have access to. This allows you to chat or search with these repositories. Get answers, resolve issues or just explore a repo with the help of your AI personal assistant.
@ -422,7 +422,7 @@ pip install -e .[dev]
khoj -vv khoj -vv
``` ```
2. Configure Khoj 2. Configure Khoj
- **Via the Settings UI**: Add files, directories to index the [Khoj settings](http://localhost:8000/config) UI once Khoj has started up. Once you've saved all your settings, click `Configure`. - **Via the Settings UI**: Add files, directories to index the [Khoj settings](http://localhost:42110/config) UI once Khoj has started up. Once you've saved all your settings, click `Configure`.
- **Manually**: - **Manually**:
- Copy the `config/khoj_sample.yml` to `~/.khoj/khoj.yml` - Copy the `config/khoj_sample.yml` to `~/.khoj/khoj.yml`
- Set `input-files` or `input-filter` in each relevant `content-type` section of `~/.khoj/khoj.yml` - Set `input-files` or `input-filter` in each relevant `content-type` section of `~/.khoj/khoj.yml`
@ -502,4 +502,4 @@ docker-compose build --pull
[^1]: Default Khoj config file @ `~/.khoj/khoj.yml` [^1]: Default Khoj config file @ `~/.khoj/khoj.yml`
[^2]: Default Khoj url @ http://localhost:8000 [^2]: Default Khoj url @ http://localhost:42110

View file

@ -7,7 +7,7 @@ services:
# If changing the remote port (right hand side), # If changing the remote port (right hand side),
# change the port in the args in the build section, # change the port in the args in the build section,
# as well as the port in the command section to match # as well as the port in the command section to match
- "8000:8000" - "42110:42110"
working_dir: /app working_dir: /app
volumes: volumes:
- .:/app - .:/app
@ -25,4 +25,4 @@ services:
- ./tests/data/embeddings/:/data/embeddings/ - ./tests/data/embeddings/:/data/embeddings/
- ./tests/data/models/:/data/models/ - ./tests/data/models/:/data/models/
# Use 0.0.0.0 to explicitly set the host ip for the service on the container. https://pythonspeed.com/articles/docker-connection-refused/ # Use 0.0.0.0 to explicitly set the host ip for the service on the container. https://pythonspeed.com/articles/docker-connection-refused/
command: --host="0.0.0.0" --port=8000 -c=config/khoj_docker.yml -vv command: --host="0.0.0.0" --port=42110 -c=config/khoj_docker.yml -vv

View file

@ -62,7 +62,7 @@
;; Khoj Static Configuration ;; Khoj Static Configuration
;; ------------------------- ;; -------------------------
(defcustom khoj-server-url "http://localhost:8000" (defcustom khoj-server-url "http://localhost:42110"
"Location of Khoj API server." "Location of Khoj API server."
:group 'khoj :group 'khoj
:type 'string) :type 'string)

View file

@ -75,7 +75,7 @@ export class KhojSearchModal extends SuggestModal<SearchResult> {
this.rerank = true this.rerank = true
// Set input element to contents of active markdown file // Set input element to contents of active markdown file
// truncate to first 8,000 characters to avoid hitting query size limits // truncate to first 8,000 characters to avoid hitting query size limits
this.inputEl.value = await this.app.vault.read(file).then(file_str => file_str.slice(0, 8000)); this.inputEl.value = await this.app.vault.read(file).then(file_str => file_str.slice(0, 42110));
// Trigger search to get and render similar notes from khoj backend // Trigger search to get and render similar notes from khoj backend
this.inputEl.dispatchEvent(new Event('input')); this.inputEl.dispatchEvent(new Event('input'));
this.rerank = false this.rerank = false

View file

@ -11,7 +11,7 @@ export interface KhojSetting {
export const DEFAULT_SETTINGS: KhojSetting = { export const DEFAULT_SETTINGS: KhojSetting = {
resultsCount: 6, resultsCount: 6,
khojUrl: 'http://127.0.0.1:8000', khojUrl: 'http://127.0.0.1:42110',
connectedToBackend: false, connectedToBackend: false,
autoConfigure: true, autoConfigure: true,
openaiApiKey: '', openaiApiKey: '',

View file

@ -35,12 +35,12 @@ def configure_server(args, required=False):
if args.config is None: if args.config is None:
if required: if required:
logger.error( logger.error(
f"Exiting as Khoj is not configured.\nConfigure it via http://localhost:8000/config or by editing {state.config_file}." f"Exiting as Khoj is not configured.\nConfigure it via http://localhost:42110/config or by editing {state.config_file}."
) )
sys.exit(1) sys.exit(1)
else: else:
logger.warning( logger.warning(
f"Khoj is not configured.\nConfigure it via http://localhost:8000/config, plugins or by editing {state.config_file}." f"Khoj is not configured.\nConfigure it via http://localhost:42110/config, plugins or by editing {state.config_file}."
) )
return return
else: else:

View file

@ -23,7 +23,7 @@ def cli(args=None):
) )
parser.add_argument("--verbose", "-v", action="count", default=0, help="Show verbose conversion logs. Default: 0") parser.add_argument("--verbose", "-v", action="count", default=0, help="Show verbose conversion logs. Default: 0")
parser.add_argument("--host", type=str, default="127.0.0.1", help="Host address of the server. Default: 127.0.0.1") parser.add_argument("--host", type=str, default="127.0.0.1", help="Host address of the server. Default: 127.0.0.1")
parser.add_argument("--port", "-p", type=int, default=8000, help="Port of the server. Default: 8000") parser.add_argument("--port", "-p", type=int, default=42110, help="Port of the server. Default: 42110")
parser.add_argument( parser.add_argument(
"--socket", "--socket",
type=pathlib.Path, type=pathlib.Path,

View file

@ -27,9 +27,9 @@
- Run ~M-x khoj <user-query>~ or Call ~C-c C-s~ - Run ~M-x khoj <user-query>~ or Call ~C-c C-s~
- *Khoj via API* - *Khoj via API*
- Query: ~GET~ [[http://localhost:8000/api/search?q=%22what%20is%20the%20meaning%20of%20life%22][http://localhost:8000/api/search?q="What is the meaning of life"]] - Query: ~GET~ [[http://localhost:42110/api/search?q=%22what%20is%20the%20meaning%20of%20life%22][http://localhost:42110/api/search?q="What is the meaning of life"]]
- Update Index: ~GET~ [[http://localhost:8000/api/update][http://localhost:8000/api/update]] - Update Index: ~GET~ [[http://localhost:42110/api/update][http://localhost:42110/api/update]]
- [[http://localhost:8000/docs][Khoj API Docs]] - [[http://localhost:42110/docs][Khoj API Docs]]
- *Call Khoj via Python Script Directly* - *Call Khoj via Python Script Directly*
#+begin_src shell #+begin_src shell