Open xuhaoruins opened 5 months ago
I assume you set the Azure env variables, see https://ts.llamaindex.ai/modules/llms/available_llms/azure#environment-variables?
Then I would try calling the embedding model directly first:
const texts = ["hello", "world"];
const embeddings = await azureOpenaiEmbedding.getTextEmbeddingsBatch(texts);
console.log(`\nWe have ${embeddings.length} embeddings`);
@xuhaoruins when creating an instance of OpenAIEmbedding
class, you need to make sure you are using EMBEDDING_MODEL
as a deployment target:
const azure = {
azureADTokenProvider,
deployment: process.env.AZURE_OPENAI_DEPLOYMENT ?? "gpt-35-turbo",
};
// configure LLM model
Settings.llm = new OpenAI({
azure,
}) as any;
azure.deployment = process.env.EMBEDDING_MODEL as string; // <-----
Settings.embedModel = new OpenAIEmbedding({
azure,
model: process.env.EMBEDDING_MODEL,
dimensions: process.env.EMBEDDING_DIM
? parseInt(process.env.EMBEDDING_DIM)
: undefined,
});
@xuhaoruins does this mean that azure.deployment
and model
need to have the same value? If it's not possible to use e.g. my-embedding
as deployment name then we would need to change that.
I cannot use Azure OpenAI embedding model as:
const azureOpenaiLLM = new OpenAI({ model: "gpt-4", temperature: 0 }); const azureOpenaiEmbedding = new OpenAIEmbedding({ model: "text-embedding-ada-002", }); const serviceContext = serviceContextFromDefaults({ llm: azureOpenaiLLM, embedModel : azureOpenaiEmbedding });
looks like the value not pass into: Stack trace: Error: 400 The embeddings operation does not work with the specified model, gpt-35-turbo. Please choose different model and try again.
May I know how to use Azure OpenAI embedding model?