vercel / modelfusion

The TypeScript library for building AI applications.
https://modelfusion.dev
MIT License
1.06k stars 76 forks source link

Embedding with AzureOpenAI #194

Closed nanotronic closed 7 months ago

nanotronic commented 7 months ago

I am trying to get the pdf-chat-terminal example working with Azure. I have created two api configurations for this. One for embedding and the other for chatting. It looks like this:

const embeddApi = new AzureOpenAIApiConfiguration({
  // apiKey: automatically uses process.env.AZURE_OPENAI_API_KEY,
  resourceName: "my-resource-name",
  deploymentId: "my-embedd-id",
  apiVersion: "my-api-version",
})

Unfortunately I get the following error Too many inputs. The max number of inputs is 16....

Is there a possibility to set this parameter?

Thanks in advance

lgrammel commented 7 months ago

@nanotronic right now it's not configurable.

Here is the value (for OpenAI): https://github.com/lgrammel/modelfusion/blob/main/src/model-provider/openai/OpenAITextEmbeddingModel.ts#L94

You could change it such that it's part of OpenAITextEmbeddingModelSettings and defaults to 2048.

Then you could set it when you create the OpenAITextEmbeddingModel with your Azure config.

Would you mind sending a PR?

nanotronic commented 7 months ago

Yes, I will.

lgrammel commented 7 months ago

PR included in v0.89.0. Thanks!