brianpetro / jsbrains

A collection of low-to-no dependency modules for building smart apps with JavaScript
https://jsbrains.org
MIT License
27 stars 7 forks source link

Obsidian Smart-connections: configure which parameters to pass to the module #1

Open bobbruno opened 4 months ago

bobbruno commented 4 months ago

Hi, I'm a user of the Obsidian Smart Connection plugin, and I'm playing with using other models (specifically, models hosted on Databricks). I noticed they mostly work with the API custom configuration, but I had to edit the file below to remove the presence_penalty and frequence_penalty parameters when working with DBRX-instruct - it doesn't recognize these parameters.

Would it be possible to add a configuration for which parameters to send to the model and with which values? Not sure if I should have opened this issue on the Obsidian Smart Connections repo, but I couldn't find the function reference in the source there.

https://github.com/brianpetro/jsbrains/blob/6351576cf8b3b3b138393f7a5894e5fe4c4b597f/smart-chat-model/smart_chat_model.js#L53

brianpetro commented 4 months ago

Hey @bobbruno

Congrats on being issue #1 in the JS Brains repo 💪

The way I would approach this would be to create a databricks adapter, similar to the anthropic and google adapters https://github.com/brianpetro/jsbrains/tree/main/smart-chat-model/adapters

If the base smart_chat_model.js already mostly works, then the new adapter likely only needs to add the prepare_request_body() method to the adapter.

This gets called right before requesting the API and transforms the request body. https://github.com/brianpetro/jsbrains/blob/main/smart-chat-model/smart_chat_model.js#L104C103-L104C123

Besides that, if you wanted to add Databricks as a platform (I'm not familiar with them, so I don't know if that makes sense), you could also create a fetch function for retrieving the models like in https://github.com/brianpetro/jsbrains/blob/main/smart-chat-model/models/open_router.js and then add the platform to the JSON file https://github.com/brianpetro/jsbrains/blob/main/smart-chat-model/platforms.json

If added as a platform, it will automatically be added to Smart Connections in the next update. Without adding as a platform, Smart Connections will require an additional update that allows selecting a specific adapter for use with the custom server configuration.

🌴