Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade Khoj Obsidian: Chat from Side Pane, Stream Intermediate Steps, Copy Message to Clipboard #736

Merged
merged 23 commits into from
Jun 1, 2024

Conversation

debanjum
Copy link
Member

@debanjum debanjum commented May 8, 2024

Details

  • Chat with Khoj from right pane on Obsidian
    • Modal was too ephemeral, couldn't have it open for reference, quick jump to Khoj chat
  • Stream intermediate steps taken by Khoj for generating response to the chat pane
    Gives more transparency into Khoj 'thinking' process, e.g internet, notes searches performed, documents read etc.
    The feedback allows us to tune our messages to elicit better responses by Khoj
  • Add ability to copy message to clipboard, paste chat messages directly into current file
  • Jump to Search, Find Similar functions from navigation bar on the Khoj Obsidian side pane
  • Improve spacing, use consistent colors in chat message references and buttons

Screenshots

Type View
Khoj in Obsidian Side Pane Khoj Chat in Obsidian Side Pane
Chat Sessions in Obsidian Side Pane Obsidian Conversation Sessions

Resolves #789, #754

- Allows having it open on the side as you traverse your Obsidian notes
- Allow faster time to response, having responses visible for context
- Enables ambient interactions
Previously scroll and chat input focus weren't applied as view hadn't
been rendered yet
Previously we were just getting user email from the /health API
Instead store the retrieved user info in the user settings
@debanjum debanjum added upgrade New feature or request plugin Improvements or additions to content or UI integrations labels May 8, 2024
@debanjum debanjum requested a review from sabaimran May 8, 2024 20:37
Copy link
Collaborator

@sabaimran sabaimran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These improvements are super exciting for the Obsidian interface ✨

I think we can also create a better default page if/when the user hasn't connected to the server properly.

Closes #754

src/interface/obsidian/src/chat_view.ts Outdated Show resolved Hide resolved
src/interface/obsidian/src/utils.ts Outdated Show resolved Hide resolved
src/interface/obsidian/src/chat_view.ts Show resolved Hide resolved
- Jump to chat, show similar actions from nav menu of Khoj side pane
  - Add chat, search icons from web, desktop app
  - Use lucide icon for find similar (for now)
  - Match proportions of find similar icon to khoj other icons via css, js

- Use KhojPaneView abstract class to allow reuse of common functionality like
  - Creating the nav bar header in side pane views
  - Loading geo-location data for chat context
  This should make creating new views easier
It'll replace any highlighted text with the chat message or if not
text is highlighted, it'll insert the chat message at the last cursor
position in the active file
Works better with dark modes. References have more spacing and adhere
to background color of the chat message itself
- Setup websocket using Khoj web app as reference.
- Moved the geolocating code to chat view out from the general pane
  view
- Use loading spinner from web instead of the thinking emoji
Simplify, reuse, standardize code to render messages with references
in the obsidian, web and desktop clients. Specifically:

- Reuse function to create reference section, dedupe code
- Create reusable function to generate image markdown
- Simplify logic to render message with references
- Pass file path of reference along with the compiled reference in
  list of references returned by chat API converts
- Update the structure of references from list of strings to list of
  dictionary (containing 'compiled' and 'file' keys)
- Pull out the compiled reference from the new references data struct
  wherever it was is being used
lentinidante

This comment was marked as resolved.

Allow opening Khoj chat references in Obsidian vault if the reference
is a heading or file in the current Obsidian vault
Copy link
Collaborator

@sabaimran sabaimran left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a few more suggestions, but the experience including sessions is so much better.

src/interface/obsidian/src/chat_view.ts Outdated Show resolved Hide resolved
src/interface/obsidian/src/chat_view.ts Outdated Show resolved Hide resolved
src/interface/obsidian/src/chat_view.ts Show resolved Hide resolved
src/interface/obsidian/src/chat_view.ts Outdated Show resolved Hide resolved
src/interface/obsidian/src/chat_view.ts Show resolved Hide resolved
src/interface/obsidian/src/chat_view.ts Show resolved Hide resolved
sabaimran and others added 6 commits May 30, 2024 11:39
Fix code formating of Khoj chat view in Obsidian
- Dedupe the code to add action buttons to chat messages
- Update the renderIncrementalMessage function to also add the action
  buttons to newly generated chat messages by Khoj
- Conflicts:
  - src/khoj/interface/web/chat.html
    Use our changes with feedback button changes from master
Copy link

gitguardian bot commented Jun 1, 2024

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
10005301 Triggered Generic Password 7a93599 src/khoj/app/settings.py View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@debanjum debanjum merged commit b499b3f into master Jun 1, 2024
7 checks passed
@debanjum debanjum deleted the upgrade-khoj-on-obsidian branch June 1, 2024 08:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
plugin Improvements or additions to content or UI integrations upgrade New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FIX] Fix Styling, Selectable Text and Exiting Chat View in Obsidian
3 participants