DeabLabs / cannoli

Cannoli allows you to build and run no-code LLM scripts using the Obsidian Canvas editor.
MIT License
258 stars 18 forks source link

[Feature Request] Add Azure OpenAI option and display relevant fields in config #38

Closed johannesamee closed 1 month ago

johannesamee commented 1 month ago

I would love to see an option for Azure OpenAI in the AI Provider dropdown that when selected displays the extra configuration fields needed to connect to Azure OpenAI resources:

cephalization commented 1 month ago

I haven't used azure openai in some time, but can you manufacture a base URL that contains this configuration in it? I believe that's how Gemini works.

If not, I can plumb these fields through for you within the next few days

johannesamee commented 1 month ago

I was experimenting with it a bit and it seemed like it put the /chat/completions part after the ?api-version=xxxx-xx-xx at the end making the URL invalid.

lundqdec commented 1 month ago

Hi, been looking for the Azure Open AI option aswell.

Here's the LangChain.js class: https://github.com/langchain-ai/langchainjs/blob/3ad93f6f11fdacd125d2143208da19a2a3915fa4/libs/langchain-openai/src/azure/llms.ts#L12

You need api version, deployment name (which differs from the model name since this will be set freely in Azure Open AI Studio)

The full end url looks something like this: baseurl.com/openai/deployments/[your deployment name]/chat/completions?api-version=2024-05-15

Awesome tool by the way!!

cephalization commented 1 month ago

Gotcha, looks like some naive string concatenation on my end. I blame copilot 😅

I will either add a dedicated azure openai LLM target, or expose the options in the base openai config

cephalization commented 1 month ago

@johannesamee Planning on merging and releasing #39 within the next few hours

cephalization commented 1 month ago

This is now released, please let me know how it works you for you!

johannesamee commented 1 month ago

@cephalization Awesome that you implemented this as fast as you did! 🙌 After some testing I got it to work perfectly, initially I set the baseUrl to https://MY-INSTANCE-NAME.openai.azure.com/ because that's how Azure displays it in their portals/playgrounds.

When I set it to https://MY-INSTANCE-NAME.openai.azure.com/openai/deployments it worked like a charm!

johannesamee commented 1 month ago

https://github.com/DeabLabs/cannoli/blob/09f850ae2f6fae6e6866e65026d0c4a8c1f489f0/main.ts#L1289

.setPlaceholder("https://YOUR-INSTANCE-NAME.openai.azure.com/openai/deployments") 
.setPlaceholder("https://[instanceName].openai.azure.com/openai/deployments") 

Or something similar might be something to add!

cephalization commented 1 month ago

@johannesamee

It should actually work just fine if you leave out baseURL entirely! Let me know how that goes for you. I will make it more apparent that baseURL is optional, and only required if you have a special url for your deployment

lundqdec commented 1 month ago

A-maze-ing! I can confirm this config works: image

johannesamee commented 1 month ago

@cephalization Ah gotcha, that makes sense!

johannesamee commented 1 month ago

Been testing around and everything works perfectly, thanks again for getting this added so fast!