infiniflow / ragflow

RAGFlow is an open-source RAG (Retrieval-Augmented Generation) engine based on deep document understanding.
https://ragflow.io
Apache License 2.0
16.34k stars 1.66k forks source link

[Question]: AzureOpenAI error when loading embedding model #1599

Open Said-Apollo opened 1 month ago

Said-Apollo commented 1 month ago

Describe your problem

Hi, I already have deployed some models and the ada and larg3 embedding models, however, when entering the API-key and endpoint, I'm receiving an error message that the encoding method was not implemented. As far as I know support was added by issue #1512 . Upon closer insection I saw in the embedding_model.py that there is no encode method for the azure openai class, or was that added somewhere else?

Here the azure class directly inherits from Base class AzureEmbed(Base): def __init__(self, key, model_name, **kwargs): self.client = AzureOpenAI(api_key=key, azure_endpoint=kwargs["base_url"], api_version="2024-02-01") self.model_name = model_name

And here the Base `class Base(ABC): def init(self, key, model_name): pass

def encode(self, texts: list, batch_size=32):
    raise NotImplementedError("Please implement encode method!")

def encode_queries(self, text: str):
    raise NotImplementedError("Please implement encode method!")`
mapa17 commented 1 month ago

Looks to me like its derived from the wrong base class. Could try to derive it from OpenAIEmbed. Unfortunately, i dont have an dev env to try it.

mapa17 commented 1 month ago

I can confirm that changing the base class to OpenAIEmbed works. I am able to use my azure deployed endpoinds with them. As an additional note the name of the endpoints must be:

and similar, so azure- followed by the model type.