Skip to content

Commit

Permalink
Update embedding.py (#431)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaojin3616 authored Mar 25, 2024
2 parents a4fd107 + 8e33533 commit 5e4ea52
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/backend/bisheng/utils/embedding.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ def decide_embeddings(model: str) -> Embeddings:
"""embed method"""
model_list = settings.get_knowledge().get('embeddings')
params = model_list.get(model)
if model == 'text-embedding-ada-002' or params.get('component', '') == 'openai':
if is_openai_v1() and 'openai_proxy' in params:
component = params.pop('component', '')
if model == 'text-embedding-ada-002' or component == 'openai':
if is_openai_v1() and params.get('openai_proxy'):
client_params = langchain_bug_openv1(params)
client_params['http_client'] = httpx.Client(proxies=params['openai_proxy'])
params['client'] = openai.OpenAI(**client_params).embeddings
client_params['http_client'] = httpx.AsyncClient(proxies=params['openai_proxy'])
params['async_client'] = openai.AsyncOpenAI(**client_params).embeddings
return OpenAIEmbeddings(**params)
elif params.get('component', '') == 'custom':
elif component == 'custom':
return CustomHostEmbedding(**params)
else:
return HostEmbeddings(**model_list.get(model))

0 comments on commit 5e4ea52

Please sign in to comment.