mirror of
https://github.com/infiniflow/ragflow.git
synced 2025-12-08 20:42:30 +08:00
Integrates LLM Azure OpenAI (#1318)
### What problem does this PR solve? feat: Integrates LLM Azure OpenAI #716 ### Type of change - [x] New Feature (non-breaking change which adds functionality) ### Other It's just the back-end code, the front-end needs to provide the Azure OpenAI model addition form. #### Required parameters - base_url - api_key --------- Co-authored-by: yonghui li <yonghui.li@bondex.com.cn>
This commit is contained in:
@ -18,6 +18,7 @@ from typing import Optional
|
||||
import threading
|
||||
import requests
|
||||
from huggingface_hub import snapshot_download
|
||||
from openai.lib.azure import AzureOpenAI
|
||||
from zhipuai import ZhipuAI
|
||||
import os
|
||||
from abc import ABC
|
||||
@ -110,6 +111,11 @@ class OpenAIEmbed(Base):
|
||||
return np.array(res.data[0].embedding), res.usage.total_tokens
|
||||
|
||||
|
||||
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
|
||||
|
||||
class BaiChuanEmbed(OpenAIEmbed):
|
||||
def __init__(self, key,
|
||||
model_name='Baichuan-Text-Embedding',
|
||||
|
||||
Reference in New Issue
Block a user