GithubHelp home page GithubHelp logo

eugeneyan / obsidian-copilot Goto Github PK

View Code? Open in Web Editor NEW
428.0 7.0 30.0 518 KB

๐Ÿค– A prototype assistant for writing and thinking

Home Page: https://eugeneyan.com/writing/obsidian-copilot/

License: Apache License 2.0

Dockerfile 1.27% Makefile 6.93% Shell 0.28% JavaScript 3.43% TypeScript 32.76% CSS 0.35% Python 54.98%
assistant generative-ai llm obsidian-plugin retrieval-augmented-generation large-language-models

obsidian-copilot's Introduction

Obsidian-copilot

How would a copilot for writing and thinking look like?

Here's a possible implementation: You write a section header and the copilot retrieves relevant notes & docs to draft that section for you. This pattern of retrieval-augmented generation can also be extended to other use cases. Here's an example where the copilot helps you reflect on your week based on your daily journal entries.

copilot-v2.mp4

Currently, copilot helps you:

  • Draft sections based on your notes
  • Reflect on your week based on your daily journal entries

More technical details on how it works here: Obsidian-Copilot: A Prototype Assistant for Writing & Thinking

Quick start

Clone and update the path to your obsidian-vault and huggingface hub cache

git clone https://github.com/eugeneyan/obsidian-copilot.git

Update your ~/.bashrc or ~/.zshrc with the OBSIDIAN_PATH and TRANSFORMER_CACHE paths and then source it. Note: the trailing slash is important.


export OBSIDIAN_PATH=/path/to/obsidian-vault/
export TRANSFORMER_CACHE=/path/to/.cache/huggingface/hub

If you don't already have a huggingface hub cache, you can create the directory with mkdir -p $TRANSFORMER_CACHE

Build the OpenSearch and semantic indices

# Build the docker image
make build

# Start the opensearch container and wait for it to start.
# You should see something like this: [c6587bf83572] Node 'c6587bf83572' initialized
make opensearch

# In ANOTHER terminal, build your artifacts (this can take a while)
make build-artifacts

Running the retrieval app

# First, stop the opensearch container (CTRL + C). Then, start the retrieval app.
# You should see this: Uvicorn running on http://0.0.0.0:8000
make run

Install the copilot-plugin, enable it in community plugin settings, and update the API key in copilot

make install-plugin

How does it work?

At a high level, when you type a section header, it'll:

  • Retrieve relevant documents/snippets from the your obsidian vault via:
  • The retrieved context is then used to generate paragraphs for the section
  • It is also displayed in a new tab for info

Contributing

To install the pre-commit hooks, run pip install pre-commit && pre-commit install in the root of the repository.

TODOs

  • Add support for using anthrophic claude (100k context)
  • Assess sending in entire documents instead of chunks

obsidian-copilot's People

Contributors

aayushmnit avatar crypdick avatar dependabot[bot] avatar eugeneyan avatar lzumot avatar pentchaff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

obsidian-copilot's Issues

`make opensearch` fails with permissions issues

Running make opensearch fails with a java.nio.file.AccessDeniedException. Full trace here.

Things I've tried:

  • added command: chown -R 1000:root /usr/share/opensearch/data to the opensearch service in docker-compose.yml.
  • manually created a few of the folders in the cloned repo, e.g. ./obsidian-copilot/data/nodes. This was a game of wack-a-mole as more files/folders were missing.

ValueError: need at least one array to concatenate

During make build-artifacts I got this error:

Downloading pytorch_model.bin: 100%|โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆ| 134M/134M [00:04<00:00, 31.6MB/s]
2023-06-14 16:59:43,807 - src.logger - INFO - Embedding index length: 0
Traceback (most recent call last):
  File "/usr/local/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/obsidian-copilot/src/prep/build_semantic_index.py", line 146, in <module>
    doc_embeddings_array = build_embedding_array(vault, tokenizer, model)
  File "/obsidian-copilot/src/prep/build_semantic_index.py", line 113, in build_embedding_array
    doc_embeddings_array = np.concatenate(embedding_list, axis=0)
  File "<__array_function__ internals>", line 200, in concatenate
ValueError: need at least one array to concatenate
make: *** [build-artifacts] Error 1

support for podman

Hi i had a few issues when tryign to run with podman
##########################
I had to make changes to makefile change makefile: replace all docker with podman (alias docker=podman nto enough asyou ahve to modify docker-network and docker-compose as well as remove buildkit and add --format docker
e.g.:
podman-network:
podman network create ${NETWORK} || true
...
opensearch: podman-network
podman run ....
...
podman build --format docker -t ${IMAGE_TAG} -f Dockerfile .
...
podman run ....
...
podman-compose up # need to do pip install podman-compose if you don't have it
...

##########################
need to mkdir data in the repo directory as it was failing make opensearch
##########################
need to explicitly set env again or place in bashrc in new terminal when doing make build-artifacts or replace the makefile params with your own
##########################
instructions could be clearer that make opensearch should be stopped for make run to work

Add linter and formatter pre-commit hook

Hi @eugeneyan, thanks for the awesome work here. I've only been using this plugin for a few days and it's already been super awesome.

As I work on my own fork, I'm injecting subconsciously injecting my personal coding conventions which clash with yours (preference for " over ', linebreaks, trailing commas, etc. I think it would be great if there were some pre-commit hooks to keep consistent conventions.

Another Obsidian Copilot

I expect you know this already; there is an Obsidian plugin available from the community library called 'Obsidian Copilot'. I'm not going to get into debate which one was earliest or most popular or whatever. I am hugely grateful for all developers who create plugins. Just pointing out at the very least the clash of names. I'm quite sure there's room for all sorts of AI functionality. Thanks for what you are doing.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.