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

Unlock Local AI Processing in Obsidian (feature request) #302

Open
dicksensei69 opened this issue Aug 3, 2023 · 23 comments
Open

Unlock Local AI Processing in Obsidian (feature request) #302

dicksensei69 opened this issue Aug 3, 2023 · 23 comments

Comments

@dicksensei69
Copy link

dicksensei69 commented Aug 3, 2023

I'm writing to request a feature that would allow users to easily switch between different AI APIs within obsidian-smart-connections. Specifically, I'm interested in being able to toggle between the OpenAI API and emerging alternatives like Oobabooga's textgen and Llamacpp.

These new services offer exciting capabilities like local embeddings and on-device processing that could enhance the Obsidian experience, especially for users who want to avoid sending personal data to third parties. I've found where the API endpoint is configured in the code, and with some tweaking I may be able to switch between them manually. However, having an official option to select different APIs would provide a much smoother experience.

For those wondering, the API endpoint is currently specified in multiple locations the first being on line 1043 of main.js.
url: https://api.openai.com/v1/embeddings,

line 2666
const url = "https://api.openai.com/v1/chat/completions";

line 2719
url: https://api.openai.com/v1/chat/completions,

To manually change the API, these endpoints could be modified to point to local services like Oobabooga or Anthropic. However, this involves directly editing the source code which is cumbersome.

Ideally, there could be a function that defaults to OpenAI, but allows the API URL to be easily configured as a setting. Users could then switch to local IPs or services with just a simple configuration change. Furthermore, if this setting was exposed through the GUI, it would enable seamless API swapping without any code editing required.

The open source ecosystem is rapidly evolving, and empowering users to take advantage of these new innovations aligns with Obsidian's ethos of flexibility and customization. Users would love to rely on my own local hardware for AI processing rather than being locked into a single provider.

Thank you for your consideration. Obsidian has been invaluable for my workflow, and I'm excited by its potential to integrate some of these cutting-edge AI capabilities in a privacy-preserving way. Enabling easy API switching would be a major step forward. Please let me know if I can provide any other details!

@dicksensei69 dicksensei69 changed the title Dropdown or space in settings to change the openai url (feature request) Unlock Local AI Processing in Obsidian (feature request) Aug 3, 2023
@dragos240
Copy link

I may make a PR for this. I've gotten it to work on my local instance of text-generation-webui. All that needs to be done to change the URL is to open main.js and replace the OpenAI API base URL with your own. For it to work with text-generation-webui, you'll need to enable the openai extension, which mimics the endpoints of the OpenAI API. One thing I am not entirely sure about is how the embeddings play with it. I'm testing it out now.

@dragos240
Copy link

Nevermind, someone beat me to it

@nomadphase
Copy link

In case this is not prioritised here, it may be useful to look at the Khoj/Obsidian plugin, which is opensource and enabling Llama2

@brianpetro
Copy link
Owner

@nomadphase thanks for sharing that project.

I checked it out and it does require a separate desktop application to be installed to use the Obsidian plugin. This is the route I expect will be necessary to utilize local models with Obsidian.

While there hasn't been much publicly to see lately in terms of plugin updates, I have been doing a lot in private that will have big implications for this plugin. For example, allowing the Smart Chat to add to and edit notes is just one long weekend away.

And during my weekday work, I've been chugging away at something that, when it makes its way into Obsidian, will be unlike anything else I've seen publicly as far as AI tools are concerned. To clarify why I bring this up now, I've been focussing on using GPT-3.5 for that project because I want the result to be compatible with local models. Basically, my hypothesis is that, if I can make it work with GPT-3.5, then the same functionality should work with local models very soon.

It's still been tough to find a local model for the embeddings that beats OpenAI's ada embeddings. If anyone comes across anything, please let me know.

And lastly, thanks everyone (@dragos240 @dicksensei69 ) for your interest in Smart Connections and I'm looking forward to making more updates soon!

Now back to it,
Brian 🌴

@ReliablyAwkward
Copy link

I yearn to be updated on this topic, as I am now playing with Docker for windows to obtain LocalAi, such descriptions as the owner hinted upon above would be a genuine game changer.

@wenlzhang
Copy link

Here are some local LLM related tools that might be of interest:

@huachuman
Copy link

What about using g4f?

https://github.com/xtekky/gpt4free
https://github.com/xiangsx/gpt4free-ts

@brianpetro
Copy link
Owner

@wenlzhang @huachuman thanks for the resources!

I'm still reviewing options and requirements, but I think we're pretty close to having a local embedding model.

The chat models still require an amount of hardware resources that make me pause, but we can do a lot with embeddings alone. And if we were to still use OpenAI for the chat responses while relying on a local embedding model, then that would also significantly reduce the exposure of vaults to OpenAI, as only context used for a specific query would be sent to their servers.

🌴

@joelmnz
Copy link

joelmnz commented Nov 20, 2023

In addition to local LLM support, would you consider a LLM router such as https://withmartian.com/ that boasts faster speeds and reduced costs?

I haven't tried this service out yet but if it would be considered I would be happy to investigate further

@barshag
Copy link

barshag commented Jan 20, 2024

any updates on how to connect Ollama ?

@brianpetro
Copy link
Owner

brianpetro commented Jan 20, 2024

@barshag

V2.1 will enable configuring API endpoints for the chat model. While I can't say how featureful this option will be compared to what's possible with the OpenAI API, especially considering I intend to add significant capabilities via function calling in v2.1 and I'm not up-to-date on where local models are in that regard, the configuration should allow for integration with local models for individuals capable of setting up the model locally to be accessed via localhost.

I hope that helps!

🌴

@benabhi
Copy link

benabhi commented Feb 29, 2024

I desperately need this feature ^^ I tried editing the main.js openai url and changing them to my local llm with lvstudio but it didn't work.

@wwjCMP
Copy link

wwjCMP commented Mar 1, 2024

LM Studio provides proxy functionality compatible with the OpenAI API.

@brianpetro
Copy link
Owner

@wwjCMP yes, it does.

I've already connected it in my development version of Smart Connections.

Configurable endpoints/models is just one of the chat features that will be rolling out with v2.1. Still got a few things I'm working on, but it should be rolling out pretty soon as an early access option for supporters.

🌴

@UBy
Copy link

UBy commented Mar 2, 2024

Support for an OpenRouter connection would be huge, as it gives you access to a great amount of models using the same API: https://openrouter.ai/docs#models
Maybe this is a bit off topic, but related as this is just another configuration of a custom endpoint.

@brianpetro
Copy link
Owner

@UBy that looks interesting, thanks for the tip.

@Korayem
Copy link

Korayem commented Mar 5, 2024

Support for an OpenRouter connection would be huge, as it gives you access to a great amount of models using the same API: https://openrouter.ai/docs#models Maybe this is a bit off topic, but related as this is just another configuration of a custom endpoint.

was about to post a Feature Request but did a search first and found your comment @UBy

Glad @brianpetro likes it!

@leethobbit
Copy link

Thanks for the great plugin - I'd like to add to the requests for local LLM usage - if it's to be allowed that we can modify the base_url for the model, can we ensure it will work beyond just localhost? I think a lot of us are hosting our models on servers or gaming desktops atm, and I definitely can't run anything locally on my laptop.

Very excited for this! Sending data to a 3rd party like OpenAI is a showstopper for me and most people I know that are dabbling in the LLM space currently.

@brianpetro
Copy link
Owner

Hey @leethobbit , happy to hear you like Smart Connections 😊

Custom local chat modes are already partially available in the v2.1 early release. I say partially because none of the people helping me beta test v2.1 seemed to have tried to use it. I could get it working in my tests, but the local models I was testing with, the only ones I could run on an M2 8GB Mac, returned mostly gibberish.

The current implementation allows custom configuration over localhost, but I already decided to implement access to all configurations for the "custom" models. This would allow using any hostname if the endpoint accepted the OpenAI API format. That's probably what you're looking for to access your gaming machine from your laptop. But this hasn't been a priority since no one participating in the early release has indicated any interest, or even use of, the local chat models.

Maybe you can help work out the bugs once v2.1 becomes a general release, which should be relatively soon, as I have some other big updates I'm looking forward to implementing in v2.2.

Thanks for participating in the Smart Connections community!
🌴

@brianpetro
Copy link
Owner

Update: Thanks to the help of an individual who prefers to remain unnamed, I got the Smart Chat working with Ollama. So far, the new settings for the local chat model look like this in the v2.1 early release:
Screenshot 2024-04-01 at 6 10 49 PM
🌴

@Allwaysthismoment
Copy link

Allwaysthismoment commented Apr 1, 2024 via email

@wwjCMP
Copy link

wwjCMP commented Apr 22, 2024

Update: Thanks to the help of an individual who prefers to remain unnamed, I got the Smart Chat working with Ollama. So far, the new settings for the local chat model look like this in the v2.1 early release: Screenshot 2024-04-01 at 6 10 49 PM 🌴

Whether it supports using the embedding model run through Ollama.

@brianpetro
Copy link
Owner

@wwjCMP embedding through Ollama is not yet supported. If this is something you're interested in, please make a feature request here https://github.com/brianpetro/obsidian-smart-connections/issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests