liuhua liuhua commited on
Commit
c62f284
·
1 Parent(s): 84b999e

Fix a bug in VolcEngine (#3658)

Browse files

### What problem does this PR solve?

Fix a bug in VolcEngine #3553

### Type of change

- [x] Bug Fix (non-breaking change which fixes an issue)

Co-authored-by: liuhua <[email protected]>

rag/llm/__init__.py CHANGED
@@ -48,6 +48,7 @@ EmbeddingModel = {
48
  "BaiduYiyan": BaiduYiyanEmbed,
49
  "Voyage AI": VoyageEmbed,
50
  "HuggingFace": HuggingFaceEmbed,
 
51
  }
52
 
53
  CvModel = {
 
48
  "BaiduYiyan": BaiduYiyanEmbed,
49
  "Voyage AI": VoyageEmbed,
50
  "HuggingFace": HuggingFaceEmbed,
51
+ "VolcEngine":VolcEngineEmbed,
52
  }
53
 
54
  CvModel = {
rag/llm/embedding_model.py CHANGED
@@ -718,3 +718,10 @@ class HuggingFaceEmbed(Base):
718
  else:
719
  raise Exception(f"Error: {response.status_code} - {response.text}")
720
 
 
 
 
 
 
 
 
 
718
  else:
719
  raise Exception(f"Error: {response.status_code} - {response.text}")
720
 
721
+ class VolcEngineEmbed(OpenAIEmbed):
722
+ def __init__(self, key, model_name, base_url="https://ark.cn-beijing.volces.com/api/v3"):
723
+ if not base_url:
724
+ base_url = "https://ark.cn-beijing.volces.com/api/v3"
725
+ ark_api_key = json.loads(key).get('ark_api_key', '')
726
+ model_name = json.loads(key).get('ep_id', '') + json.loads(key).get('endpoint_id', '')
727
+ super().__init__(ark_api_key,model_name,base_url)