khoj-ai / khoj

Your AI second brain. Get answers to your questions, whether they be online or in your own notes. Use online AI models (e.g gpt4) or private, local LLMs (e.g llama3). Self-host locally or use our cloud instance. Access from Obsidian, Emacs, Desktop app, Web or Whatsapp.
https://khoj.dev
GNU Affero General Public License v3.0
12.63k stars 640 forks source link

Obsidian Khoj Chat does not respond #606

Closed flowingblaze closed 8 months ago

flowingblaze commented 8 months ago

I tried to use Khoj again, and I ended up being able to put my khoj api key into obsidian and It said that it's connected to the khoj backend after I disabed and renabled the plugin. I then attempted to chat with it and I got a message similar to this that dissapears as soon as the window is closed.

image

flowingblaze commented 8 months ago

It only responds with that emoji, thats the core issue

debanjum commented 8 months ago

That's unfortunate! It'd be great if you can share more details on how you setup Khoj in Obsidian.

The emoji is a placeholder, which you see while waiting to get a response from the Khoj server. It should ideally be replaced by the actual response by Khoj. It disappears as it's a temporary placeholder for the response. The actual chat query and response shouldn't disappear on reopening the Khoj Chat modal.

flowingblaze commented 8 months ago

I got the api key from app.khoj.dev, I have windows 10 and I did the steps in the docs.

flowingblaze commented 8 months ago

I looked at my Files section on khoj and I saw "No documents synced with Khoj" even after a whole night trying to force sync with khoj-I think this is the issue

edbock commented 8 months ago

The link you provided does not currently give any information about how to set up the Khoj backend. I did find information here which OP may not yet be aware of.

debanjum commented 8 months ago

Hey @edbock, the instructions you saw in that Obsidian forum post I made is for self-hosting the Khoj server but those self-hosting instructions are now stale/incomplete. These docs have the latest instructions for self-hosting. OP is trying to use the Khoj Obsidian plugin with the Khoj cloud service. For that the self-hosting steps are not required

debanjum commented 8 months ago

@flowingblaze, What do you see when you open Developer Tools in your Obsidian and then try Khoj chat? Any Khoj related errors in the console logs there may provide more clues.

To open Developer Tools: Go to the "View" menubar and Click "Toggle Developer Tools" in your Obsidian (or try Ctrl-Shift-I or Win-Shift-I keyboard shortcuts to open it)

I looked at my Files section on khoj and I saw "No documents synced with Khoj" even after a whole night trying to force sync with khoj-I think this is the issue

Yeah, I think the main issue is that you aren't able to connect to Khoj cloud from your Obsidian plugin for some reason. This is why files are not getting syncing either. Files don't necessarily need to be synced to chat with Khoj as it can work as a generic chatbot as well without context about your files, if required.

edbock commented 8 months ago

Thank you for the clarification. The reason I encountered the error is because I was trying to work around an error in Obsidian.

In settings I have https://app.khoj.dev as the "Khoj backend," and I used the API key I created at https://app.khoj.dev/config.

However, the top of the window says, "Disconnected from Khoj backend. Ensure Khoj backend is running and Khoj URL is correctly set"

edbock commented 8 months ago

I found this page and assumed I needed to follow those directions in order to get the backend working.

BTW Here are my relevant Developer Tools Console logs:

Khoj: Updating Khoj content index... app.khoj.dev/api/v1/index/update?force=true&client=obsidian:1 Failed to load resource: the server responded with a status of 400 () plugin:khoj:4436 Khoj: Updating Khoj content index... plugin:khoj:4455 Uncaught (in promise) TypeError: Failed to fetch at updateContentIndex (plugin:khoj:4455:26) at async eval (plugin:khoj:6274:41)

debanjum commented 8 months ago

Thank you for the clarification. The reason I encountered the error is because I was trying to work around an error in Obsidian.

However, the top of the window says, "Disconnected from Khoj backend. Ensure Khoj backend is running and Khoj URL is correctly set"

I see. This error is a bit lagging/confusing. If you still see the error on restarting obsidian then it means it's an actual issue connection to the Khoj backend. I'm working on a fix for the confusion on my end as well

debanjum commented 8 months ago

BTW Here are my relevant Developer Tools Console logs:

Khoj: Updating Khoj content index... app.khoj.dev/api/v1/index/update?force=true&client=obsidian:1 Failed to load resource: the server responded with a status of 400 () plugin:khoj:4436 Khoj: Updating Khoj content index... plugin:khoj:4455 Uncaught (in promise) TypeError: Failed to fetch at updateContentIndex (plugin:khoj:4455:26) at async eval (plugin:khoj:6274:41)

Thanks for sharing the error logs. Let me try reproduce the issue on my end. (I haven't been able to trigger this error for myself yet)

edbock commented 8 months ago

Restarting Obsidian: Hmm, why are some of the easiest things so hard to remember?

Now the error in the settings dialog is gone, replaced by the message "Connected to Khoj backend." That's a good sign.

Unfortunately I'm still getting the 400 errors. Here's my most recent logs:

Khoj: Updating Khoj content index... app.khoj.dev/api/v1/index/update?force=true&client=obsidian:1 Failed to load resource: the server responded with a status of 400 () plugin:khoj:4436 Khoj: Updating Khoj content index... plugin:khoj:4455 POST https://app.khoj.dev/api/v1/index/update?force=true&client=obsidian 400 updateContentIndex @ plugin:khoj:4455 await in updateContentIndex (async) eval @ plugin:khoj:4562 (anonymous) @ app.js:1

Thank you very much for the incredibly responsive support. This is a fantastic service, well worth doing some troubleshooting to get working.

debanjum commented 8 months ago

Restarting Obsidian: Hmm, why are some of the easiest things so hard to remember?

Now the error in the settings dialog is gone, replaced by the message "Connected to Khoj backend." That's a good sign.

Great to hear that plugin is showing connected to the Khoj server after restart!

Unfortunately I'm still getting the 400 errors. Here's my most recent logs:

Thank you very much for the incredibly responsive support. This is a fantastic service, well worth doing some troubleshooting to get working.

Thanks for the kind words!

edbock commented 8 months ago

Yes, I do have many 1000s of files. I would be happy to help with testing this in any way I can.

The inference endpoints option sounds exciting.

debanjum commented 8 months ago

Thanks a ton for helping investigate this issue. This issue was affecting folks using Khoj from Obsidian with the Dataview plugin installed. It's been fixed in #619. So you should be able to use Khoj chat from Obsidian (even with the dataview plugin enabled) by the next release of Khoj, which should be out today