upgrade llama-index to v0.10

This commit is contained in:
seehi 2024-02-23 11:06:53 +08:00 committed by betterwang
parent 04527cf0eb
commit e14aedcea7
29 changed files with 725 additions and 370 deletions

View file

@ -5,12 +5,15 @@
@Author : alexanderwu
@File : embedding.py
"""
from llama_index.embeddings import OpenAIEmbedding
from llama_index.embeddings.openai import OpenAIEmbedding
from metagpt.config2 import config
def get_embedding() -> OpenAIEmbedding:
llm = config.get_openai_llm()
if llm is None:
raise ValueError("To use OpenAIEmbedding, please ensure that config.llm.api_type is correctly set to 'openai'.")
embedding = OpenAIEmbedding(api_key=llm.api_key, api_base=llm.base_url)
return embedding