Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion backend/config/init_config.yaml.copy
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ LLM_MODELS:
EMBEDDING_MODELS:
# OpenAI Embedding model
- name: "text-embedding-ada-002" # Model name
deployment_type: "cloud" # Deployment type: cloud or local
deployment_type: "cloud" # Deployment type: cloud or cloud-aliyun or local
category: "embedding" # Model category
api_base: "https://api.openai.com/v1" # API base URL
api_key: "your-openai-api-key" # Replace with your actual API key
Expand Down
8 changes: 8 additions & 0 deletions backend/llm_model/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from typing import List, Union, Optional, Dict
from langchain_openai import OpenAIEmbeddings
from langchain_community.embeddings.huggingface import HuggingFaceEmbeddings
from langchain_community.embeddings import DashScopeEmbeddings
from tenacity import retry, stop_after_attempt, wait_random_exponential

from models import LLMModel
Expand Down Expand Up @@ -93,6 +94,13 @@ def load_embedding(self, model_config: dict):
openai_api_key=model_config['api_key'],
openai_api_base=model_config['api_base']
)
elif model_config["deployment_type"] == "cloud-aliyun":
# Cloud model (Aliyun)
# Ref: https://help.aliyun.com/zh/model-studio/use-bailian-in-langchain
embedding = DashScopeEmbeddings(
model=model_config["name"],
dashscope_api_key=model_config["api_key"],
)
else:
import torch
# Determine device
Expand Down