UnisKB/apps/models_provider/impl/vllm_model_provider/model/embedding.py

24 lines
651 B
Python
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# coding=utf-8
"""
@project: MaxKB
@Author
@file embedding.py
@date2024/7/12 17:44
@desc:
"""
from typing import Dict
from langchain_community.embeddings import OpenAIEmbeddings
from models_provider.base_model_provider import MaxKBBaseModel
class VllmEmbeddingModel(MaxKBBaseModel, OpenAIEmbeddings):
@staticmethod
def new_instance(model_type, model_name, model_credential: Dict[str, object], **model_kwargs):
return VllmEmbeddingModel(
model=model_name,
openai_api_key=model_credential.get('api_key'),
openai_api_base=model_credential.get('api_base'),
)