Commit graph

2270 commits

Author SHA1 Message Date
sabaimran
b1c86fee3b Release Khoj version 1.6.0 2024-02-20 14:12:24 -08:00
sabaimran
45c5a2598d Temp - change gunicorn config to use a single worker 2024-02-20 13:56:51 -08:00
sabaimran
44f8f20ea7
Miscellaneous bugs and fixes for chat sessions (#646)
* Display given_name field only if it is not None

* Add default slugs in the migration script

* Ensure that updated_at is saved appropriately, make sure most recent chat is returned for default history

* Remove the bin button from the chat interface, given deletion is handled in the drop-down menus

* Refresh the side panel when a new chat is created

* Improveme tool retrieval prompt, don't let /online fail, and improve parsing of extract questions

* Fix ending chat response by offline chat on hitting a stop phrase

Previously the whole phrase wouldn't be in the same response chunk, so
chat response wouldn't stop on hitting a stop phrase

Now use a queue to keep track of last 3 chunks, and to stop responding
when hit a stop phrase

* Make chat on Obsidian backward compatible post chat session API updates

- Make chat on Obsidian get chat history from
  `responseJson.response.chat' when available (i.e when using new api)
- Else fallback to loading chat history from
  responseJson.response (i.e when using old api)

* Fix detecting success of indexing update in khoj.el

When khoj.el attempts to index on a Khoj server served behind an https
endpoint, the success reponse status contains plist with certs. This
doesn't mean the update failed.

Look for :errors key in status instead to determine if indexing API
call failed. This fixes detecting indexing API call success on the
Khoj Emacs client, even for Khoj servers running behind SSL/HTTPS

* Fix the mechanism for populating notes references in the conversation primer for both offline and online chat

* Return conversation.default when empty list for dynamic prompt selection, send all cmds in telemetry

* Fix making chat on Obsidian backward compatible post chat session API updates

New API always has conversation_id set, not `chat' which can be unset
when chat session is empty.

So use conversation_id to decide whether to get chat logs from
`responseJson.response.chat' or `responseJson.response' instead

---------

Co-authored-by: Debanjum Singh Solanky <debanjum@gmail.com>
2024-02-20 13:55:35 -08:00
sabaimran
138f5223bd
Fix process for generating embeddings for Notion entries (#648)
* Fix process for generating embeddings for Notion entries
* If no title field found, just log a warning and set the title to
2024-02-20 13:46:56 -08:00
Debanjum
43013c4fd4
Make Production Dependencies for Khoj Cloud Optional to Install (#647)
- Remove unused git dependency from Docker images
- Move python packages used for test into dev dependency group
- Only enable API token, Whatsapp cards on Web UI when Stripe, Twilio setup
- Move production dependencies to prod python packages group
- Fix docs links in Khoj welcome chat message
2024-02-16 17:42:23 +05:30
Debanjum Singh Solanky
4696577636 Upgrade python dependencies 2024-02-16 17:41:09 +05:30
Debanjum Singh Solanky
4007c871ae Remove unused git dependency from Docker images 2024-02-16 17:41:09 +05:30
Debanjum Singh Solanky
e21a8530f3 Move used python packages for test into dev dependency group
The test dependency group was being used independently
2024-02-16 17:41:09 +05:30
Debanjum Singh Solanky
4722da9642 Only enable API token, Whatsapp cards on Web UI when Stripe, Twilio setup 2024-02-16 17:41:09 +05:30
Debanjum Singh Solanky
cf4a524988 Move production dependencies to prod python packages group
This will reduce khoj dependencies to install for self-hosting users

- Move auth production dependencies to prod python packages group
  - Only enable authentication API router if not in anonymous mode
  - Improve error with requirements to enable authentication when not in
    anonymous mode
2024-02-16 17:41:08 +05:30
Debanjum Singh Solanky
d7dbb715ef Fix docs links in khoj introductory chat message 2024-02-13 22:38:03 +05:30
sabaimran
32ec54172e
Add additional personalization in Chat via Location, Username (#644)
* Add location metadata to chat history
* Add support for custom configuration of the user name
* Add region, country, city in the desktop app's URL for context in chat
* Update prompts to specify user location, rather than just location.
* Add location data to Obsidian chat query
* Use first word for first name, last word for last name when setting profile name
2024-02-13 17:05:13 +05:30
sabaimran
a3eb17b7d4
Have Khoj dynamically select conversation command(s) in chat (#641)
* Have Khoj dynamically select which conversation command(s) are to be used in the chat flow
- Intercept the commands if in default mode, and have Khoj dynamically guess which tools would be the most relevant for answering the user's query
* Remove conditional for default to enter online search mode
* Add multiple-tool examples in the prompt, make prompt for tools more specific to info collection
2024-02-11 17:11:32 +05:30
sabaimran
69344a6aa6
Add support for multiple chat sessions in the desktop application (#639)
* Add chat sessions to the desktop application
* Increase width of the main chat body to 90vw
* Update the version of electron
* Render the default message if chat history fails to load
* Merge conversation migrations and fix slug setting
* Update the welcome message, use the hostURL, and update background color for chat actions
* Only update the window's web contents if the page is config
2024-02-11 16:05:28 +05:30
sabaimran
1412ed6a00
Support multiple chat sessions within the web UI (#638)
* Enable support for multiple chat sessions within the web client

- Allow users to create multiple chat sessions and manage them
- Give chat session slugs based on the most recent message
- Update web UI to have a collapsible menu with active chats
- Move chat routes into a separate file

* Make the collapsible side panel more graceful, improve some styling elements of the new layout

* Support modification of the conversation title

- Add a new field to the conversation object
- Update UI to add a threedotmenu to each conversation

* Get the default conversation if a matching one is not found by id
2024-02-11 15:48:28 +05:30
sabaimran
208ccc83ec Fix version of gpt4all to 2.1.0 as it's not backwards compatible 2024-02-10 09:32:04 +05:30
Debanjum Singh Solanky
70f74cde68 Fix timestamps to separate each logline. Info log response start time 2024-02-07 20:45:16 +05:30
Debanjum Singh Solanky
667b975400 Free space on Github workflow VM to build Khoj docker images 2024-02-06 23:37:51 +05:30
Debanjum Singh Solanky
8e5db72140 Release Khoj version 1.5.1 2024-02-06 23:09:33 +05:30
Debanjum
fc1b8f6fb6
Fix Khoj Obsidian plugin on Obsidian Mobile (#635)
- Removed node-fetch dependency to work on mobile. 
- Fix CORS issue for Khoj (streaming) chat on Obsidian mobile
- Verified Khoj plugin, search, chat work on Obsidian mobile.

## Details
### Major
- Allow calls to Khoj server from Obsidian mobile app to fix CORS issue
- Chat stream using default `fetch' not `node-fetch' in obsidian plugin

### Minor
- Load chat history after other elements in chat modal on Obsidian are rendered
- Scroll to bottom of chat modal on Obsidian across mobile & desktop
2024-02-06 22:03:51 +05:30
Debanjum
c6fa98ce3e
Make Offline Chat Date Aware (#636)
- Provide more context and instructions to offline chat on Khoj
- Upgrade offilne chat quality tests to support more use-cases

### Details
- Improve offline chat system prompt to think step by step
- Make offline chat model current date aware. Improve system prompts
- Fix actor, director tests using freeze time by ignoring transformers package
2024-02-06 21:32:34 +05:30
Debanjum Singh Solanky
fd238ff792 Load chat history after other elements in chat modal on Obsidian rendered
This reduces laggy feeling due to latency of loading chat history from
server
2024-02-06 21:25:43 +05:30
Debanjum Singh Solanky
e06a0c6ae0 Scroll to bottom of chat modal on Obsidian across mobile & desktop
Put logic into single reused function
2024-02-06 21:25:43 +05:30
Debanjum Singh Solanky
07dc04f40e Allow calls to Khoj server from Obsidian mobile app to fix CORS issue
- Obsidian mobile uses capacitor js. Requests from it have origin as
  http://localhost on Android and capacitor://localhost on iOS
- Allow those Obsidian mobile origins in CORS middleware of server
2024-02-06 21:25:43 +05:30
Debanjum Singh Solanky
dd4cf66be1 Improve offline chat system prompt to think step by step 2024-02-06 20:23:19 +05:30
Debanjum Singh Solanky
035165b534 Make offline chat model current date aware. Improve system prompts
- Can now expect date awareness chat quality test to pass
- Prevent offline chat model from printing verbatim user Notes and
  special tokens
- Make it ask follow-up questions if it needs more context
2024-02-06 20:23:19 +05:30
Debanjum Singh Solanky
447904f0ab Chat stream using default fetch' not node-fetch' in obsidian plugin
Plugins using NodeJS libraries like `node-fetch' don't work on
Obsidian mobile
2024-02-06 03:03:42 +05:30
Debanjum Singh Solanky
0d949140f4 Fix actor, director tests using freeze time by ignoring transformers package
transformers package was causing freeze time to fail during setup
2024-02-06 03:00:48 +05:30
Debanjum Singh Solanky
c40f642afa Move Use OpenAI Compatible LLM Server section to existing advanced page
Add footnote on supported chat models to the self-hosting section
2024-02-04 16:16:55 +05:30
Debanjum Singh Solanky
523af5b3aa Fix docs. Chat model options need to be set if using OpenAI proxy server 2024-02-04 06:42:05 +05:30
Debanjum Singh Solanky
ba79334863 Only log number of day old user requests, not the complete dictionary 2024-02-02 10:33:31 +05:30
Debanjum Singh Solanky
474afa5efe Document using OpenAI-compatible LLM API server for Khoj chat
This allows using open or commerical, local or hosted LLM models that
are not supported in Khoj by default.

It also allows users to use other local LLM API servers that support
their GPU

Closes #407
2024-02-02 10:31:27 +05:30
Debanjum Singh Solanky
1c6f1d94f5 Fix styling of Whatsapp card & notify banner in config page of web app
- Put Whatsapp card back in Client section.
  - Fixes side spacing on cards
  - Improve Whatsapp card row gaps

- Hide notification banner on web app load. Previously it showed up as
  a yellow dot on smaller displays
2024-02-01 22:59:57 +05:30
Debanjum Singh Solanky
e05474e7e0 Say when max-prompt, tokenizer fields needs setup in self-host docs 2024-01-31 08:42:22 +05:30
sabaimran
4daac334bc
Fix subscription state detection for users based on phone numbers, emails (#633)
* Fix subscription state detection for users based on phone numbers, emails
* Fix unit tests for api_user4
* Use a single method for determining subscription from user
* Pass user object, rather than user.email for getting subscription state
2024-01-31 07:48:55 +05:30
sabaimran
fc4b57d9f6 Revert styling for white-space pre-line in the chat views as it looks bad 2024-01-29 18:29:54 +05:30
sabaimran
da854703aa Release Khoj version 1.5.0 2024-01-29 18:05:10 +05:30
Debanjum
d1bfb245df
Improve Khoj Chat and Settings UI (#630)
* Fix license in pyproject.toml. Remove unused utils.state import

* Use single debug mode check function. Disable telemetry in debug mode

- Use single logic to check if khoj is running in debug mode.
  Previously there were 3 different variants of the check

- Do not log telemetry if KHOJ_DEBUG is set to true. Previously didn't
log telemetry even if KHOJ_DEBUG set to false

* Respect line breaks in user, khoj chat messages to improve formatting

* Disable Whatsapp config section on web client if Twilio not configured

Simplify Whatsapp configuration status checking js by standardizing
external input to lower case

* Disable Phone API when Twilio not setup and rate limit calls to it

- Move phone api to separate router and only enable it if Twilio enabled
- Add rate-limiting to OTP and verification calls

* Add slugs for phone rate limiting

---------

Co-authored-by: sabaimran <narmiabas@gmail.com>
2024-01-29 18:03:43 +05:30
sabaimran
9ad44f0e77
Include info about privacy in the docs (#631)
* Add a page about privacy and organize some of the documentation
* Add notice about telemetry
* Improve copy for privacy section, link to telemetry section
2024-01-29 17:47:23 +05:30
sabaimran
4fb8d5c6d4
Store rate limiter-related metadata in the database for more resilience (#629)
* Store rate limiter-related metadata in the database for more resilience
- This helps maintain state even between server restarts
- Allows you to scale up workers on your service without having to implement sticky routing
* Make the usage exceeded message less abrasive
* Fix rate limiter for specific conversation commands and improve the copy
2024-01-29 15:27:06 +05:30
sabaimran
71cbe5160d
Add retries in case the embeddings API fails (#628)
* Add retries in case the embeddings API fails
* Improve error handling in the inference endpoint API request handler
- retry only if HTTP exception
- use logger to output information about errors
2024-01-29 15:26:34 +05:30
sabaimran
b782683e60
Scrape results from Serper results using Olostep (#627)
* Initailize changes to incporate web scraping logic after getting SERP results
- Do some minor refactors to pass a symptom prompt to the openai model when making a query
- integrate Olostep in order to perform the webscraping
* Fix truncation error with new line, fix typing in olostep code
* Use the authorization header for the token
* Add a small hint/indicator for how to use Khojs other modalities in the welcome prompt
* Add more detailed error message if Olostep query fails
* Add unit tests which invoke Olostep in chat director
* Add test for olostep tool
2024-01-29 14:16:50 +05:30
sabaimran
360b59cdb2 Add handling for None field values in logs and make telemetry upload more frequent 2024-01-26 00:00:55 +05:30
sabaimran
737fb6417b Revert none checking in telemetry logs 2024-01-25 23:48:09 +05:30
sabaimran
211c5623e8 Improve error handling for telemetry uploads
- Use response.raise_for_status when telemetry upload files
- Do not send null packets to the destination server
2024-01-25 20:40:42 +05:30
Debanjum Singh Solanky
098a8e4fb1 Fix evaluating connected to server status in Obsidian plugin
Only show welcome status message when khojApiKey not set and khojUrl
set to khoj cloud
2024-01-25 18:04:29 +05:30
Debanjum Singh Solanky
518f3c0c99 Update docs to say khoj chat shown on obsidian ribbon now 2024-01-25 18:03:22 +05:30
Debanjum Singh Solanky
1c52ddf792 Bump up server side content indexing interval to ~1 day
Reduce server side indexing load and API request failures
2024-01-25 13:33:34 +05:30
sabaimran
0fba1e27c5 Add hint to input text for using slash commands 2024-01-25 11:56:56 +05:30
sabaimran
da6cd5ddc4
Improve subqueries for online search and prompt generation for image (#626)
* Improve subqueries for online search and prompt generation for image
- Include conversation history so that subqueries or intermediate prompts are generated with the appropriate context
2024-01-24 17:42:59 +05:30