Commit Graph

4817 Commits

Author SHA1 Message Date
Debanjum
623c8b65f1 Set failed response message when a research iteration fails.
Previously summarizedResult would be unset when a tool call failed.

This caused research to fail due to ChatMessageModel failures when
constructing tool chat histories and would have caused similar errors
in other constructed chat histories.

Putting a failed iteration message in the summary prevents that while
letting the research agent continue its research.
2025-06-20 14:13:50 -07:00
Debanjum
b85c646611 Make organic web search result text snippet field optional
All web search providers, like Jina/Searxng?, do not return a text
snippet. Making snippet optional allows processing search results by
these web search providers, without hitting validation errors.
2025-06-20 13:47:08 -07:00
Debanjum
22d71cab44 Log ChatMessageModel validation errors during conversation save 2025-06-19 16:48:11 -07:00
Debanjum
494e7b3856 Update gemini 2.5 to stable model pricing from preview pricing 2025-06-19 16:48:11 -07:00
Debanjum
029bd3be56 Handle breaking change in write file to e2b code sandbox
For some reason the function signature, kwargs are broken. Removing
usage of keyword args resolves the file upload to sandbox error.
2025-06-19 16:48:11 -07:00
Debanjum
b18b7b2e33 Handle unset response thoughts. Useful when retry on failed request
Previously resulted in unbound local variable response_thoughts error
2025-06-19 16:48:06 -07:00
Debanjum
906ff46e6c Handle research iterations where document search returns no results 2025-06-19 16:47:08 -07:00
Debanjum
aa7b23c125 Handle rendering document references with no compiled text on web app 2025-06-17 15:47:58 -07:00
Debanjum
4ca247f0bc Always append random suffix to shared conversations urls 2025-06-17 15:47:58 -07:00
Debanjum
68b7057a76 Share https url unless explicitly disabled or on localhost 2025-06-17 15:47:58 -07:00
Debanjum
bdda03b0bf Git ignore obsidian config directories 2025-06-16 12:01:19 -07:00
Debanjum
e635b8e3b9 Handle gemini chat response completion chunk when streaming 2025-06-13 18:36:53 -07:00
Debanjum
963ebc8875 Pass query params to doc search function before user, chat history
Makes document search arg ordering more consistent with other tools
like online search, run code etc.
2025-06-13 13:29:30 -07:00
Debanjum
9673f8beba Release Khoj version 1.42.5 2025-06-11 13:36:46 -07:00
Debanjum
e87be4edf4 Pin python version used by github workflow to publish to pypi
Avoids having to update python path to write web app static build
files to everytime patch version of python is updated
2025-06-11 13:30:15 -07:00
Debanjum
eaae1cf74e Fix rendering thoughts of Gemini reasoning models
Previously there was duplication of thought in message to user and in
the train of thought. This should be resolved now
2025-06-11 13:09:38 -07:00
Debanjum
4946ea1668 Fix to save organic results to conversation context in DB
This bug was introduced in 05d4e19cb, version 1.42.2, during migration
to save deeply typed ChatMessageModel. As the ChatMessageModel did
not use the right field name for organic results (since the start).

Previously it did not matter as it was storing to DB irrespective but
now the mapping of dictionary to ChatMessageModel drops that field
before save to conversation in DB.

This was resulting in organic context being lost on page reload and
only being shown on first response.
2025-06-11 12:52:42 -07:00
Debanjum
30ced1d86c Log non schema adhering chat message before save to DB 2025-06-11 12:52:42 -07:00
Debanjum
71763684a9 Explicitly drop stream_options if not streaming openai chat response
Not sure why but it some cases when interacting with o3 (which needs
non-streaming) the stream_options seems to be set.

Cannot reproduce but hopefully dropping the stream_options explicitly
should resolve this issue.

Related 985a98214
2025-06-11 12:52:42 -07:00
Debanjum
65644f78b0 Set lower max output tokens for non reasoning Gemini models
While reasoning models support longer output tokens. Non reasoning
models do not. Use a lower max output tokens for them
2025-06-11 11:12:24 -07:00
Debanjum
71221533c8 Release Khoj version 1.42.4 2025-06-10 23:49:30 -07:00
Debanjum
985a982148 Update openai package to stream response by non-reasoning models
Older package (like 1.84.0) seem to always pass reasoning_effort
argument to openai api, which now seems to be throwing unexpected
request argument error when used with non-reasoning models (like
4o-mini).
2025-06-10 23:49:04 -07:00
Debanjum
9b767438e2 Update model pricing, default models, context and version metadata 2025-06-10 23:49:04 -07:00
Debanjum
753972997f Enable non-streaming response via openai api to support o3 models 2025-06-10 23:49:04 -07:00
Debanjum
5110a06085 Fix GET agents API to return agent specific chat model
There had been a regression that made all agents display the default
chat model instead of the actual chat model associated with the agent.

This change resolves that issue by prioritizing agent specific chat
model from DB (over user or server chat model).
2025-06-10 15:29:46 -07:00
Debanjum
0cd709caf4 Release Khoj version 1.42.3 2025-06-10 10:20:44 -07:00
Debanjum
313f648bd7 Compile ai message content into single string when using DeepInfra
DeepInfra only accepts assistant message.content of string type
2025-06-10 01:58:43 -07:00
Debanjum
9e73309d01 Add no think tag for qwen models msgs over api when no deepthought 2025-06-10 01:58:43 -07:00
Debanjum
64886cd0dd Fix storing code results on server and rendering them on web app
- Fix code context data type for validation on server. This would
  prevent the chat message from being written to history
- Handle null code results on web app
2025-06-09 23:46:12 -07:00
Debanjum
b1a6e53d77 Fix populating chat message history to continue interrupted research
We now pass deeply typed chat messages throughout the application to
construct tool specific chat history views since 05d4e19cb.

This ChatMessageModel didn't allow intent.query to be unset. But
interrupted research iteration history can have unset query. This
changes allows makes intent.query optional.

It also uses message by user entry to populate user message in tool
chat history views. Using query from khoj intent was an earlier
shortcut used to not have to deal with message by user. But that
doesn't scale to current scenario where turns are not always required
to have a single user, assistant message pair.

Specifically a chat history can now contain multiple user messages
followed by a single khoj message. The new change constructs a chat
history that handles this scenario naturally and makes the code more
readable.

Also now only previous research iterations that completed are
populated. Else they do not serve much purpose.
2025-06-09 23:46:12 -07:00
Debanjum
bd928b9f3c Handle unset agent slug, name. E.g when chat with user created agents 2025-06-09 18:11:25 -07:00
Debanjum
5dd8a9cb24 Only add cache control to last Claude text block if exists, non-empty
Otherwise Claude API throws error
2025-06-08 19:41:21 -07:00
Debanjum
d638a49cd9 Release Khoj version 1.42.2 2025-06-07 13:32:12 -07:00
Debanjum
2423db0186 Remove broken link to deprecated summarize slash command in docs 2025-06-07 13:31:21 -07:00
Debanjum
b6ceaeeffc Execute doc search in parallel using asyncio instead of threadpool 2025-06-07 13:06:49 -07:00
Debanjum
dc1c3561fe Make search type comparison in document search more robust 2025-06-07 12:52:10 -07:00
Debanjum
b9c6252a4a Increase scroll amount on horizontal scroll in computer environment 2025-06-07 11:17:52 -07:00
Debanjum
3fc175d27b Restrict Khoj to work with python <3.13
Python 3.13 not supported by all dependencies yet
2025-06-07 00:44:04 -07:00
Debanjum
1bbf719b04 Apply migrations to db for test runs to install pgvector 2025-06-06 15:47:28 -07:00
Debanjum
77caf183ee Patch update django, next.js dependencies 2025-06-06 15:39:39 -07:00
Debanjum
c4cc70bcc9 Delete file summarization slash commands docs page
File summarization slash commands have been deprecated. Folks can
upload files and ask their questions directly
2025-06-06 15:30:21 -07:00
Debanjum
257c238a88 Improve DB clean up after test runs 2025-06-06 15:09:39 -07:00
Debanjum
6ac1530816 More robustly default to searching all content type 2025-06-06 15:09:39 -07:00
Debanjum
b21706aa45 Drop help, summarize and automation /slash commands from chat api
Clean non useful slash commands to make chat API more maintanable.
- App version, chat model via /help is visible in other parts of the
  UX. Asking help questions with site:docs.khoj.dev filter isn't used
  or known to folks
- /summarize is esoterically tuned. Should be rewritten if add back.
  It wasn't being used by /research already
- Automations can be configured via UX. It wasn't being shown in UX
  already
2025-06-06 15:09:39 -07:00
Debanjum
7f6db526c3 Enforce json for non reasoning anthropic models even in deepthought 2025-06-06 13:28:18 -07:00
Debanjum
d2c7e5516f Fix online chat actor tests, improve offline chat actor tests
The chat actor (and director) tests haven't been looked into in a long
while. They'd gone stale in how they were calling thee functions. And
what was required to run them. Now the online chat actor tests work
again.
2025-06-06 13:28:18 -07:00
Debanjum
2f4160e24b Use single extract questions method across all LLMs for doc search
Using model specific extract questions was an artifact from older
times, with less guidable models.

New changes collate and reuse logic
- Rely on send_message_to_model_wrapper for model specific formatting.
- Use same prompt, context for all LLMs as can handle prompt variation.
- Use response schema enforcer to ensure response consistency across models.

Extract questions (because of its age) was the only tool directly within
each provider code. Put it into helpers to have all the (mini) tools
in one place.
2025-06-06 13:28:18 -07:00
Debanjum
c2cd92a454 [Breaking] Move automation api into new router with consistent routes
- Rename GET /api/automations to GET /api/automation
- Rename POST /api/trigger/automation to POST /api/automation/trigger
- Update calls to the automations API from the web app.
2025-06-06 13:28:18 -07:00
Debanjum
7dfa710cb4 Log invalid automation ids for investigation and clean-up 2025-06-06 13:28:18 -07:00
Debanjum
7d59688729 Move document search tool into helpers module with other tools
Document search (because of its age) was the only tool directly within
an api router. Put it into helpers to have all the (mini) tools in one
place.
2025-06-06 13:28:18 -07:00