Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: patch embedding issue in tests #1096

Merged
merged 3 commits into from
Mar 5, 2024
Merged
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
23 changes: 21 additions & 2 deletions memgpt/embeddings.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,25 @@ def embedding_model(config: EmbeddingConfig, user_id: Optional[uuid.UUID] = None
credentials = MemGPTCredentials.load()

if endpoint_type == "openai":
assert credentials.openai_key is not None
from llama_index.embeddings.openai import OpenAIEmbedding

additional_kwargs = {"user_id": user_id} if user_id else {}
model = OpenAIEmbedding(api_base=config.embedding_endpoint, api_key=credentials.openai_key, additional_kwargs=additional_kwargs)
model = OpenAIEmbedding(
api_base=config.embedding_endpoint,
api_key=credentials.openai_key,
additional_kwargs=additional_kwargs,
)
return model

elif endpoint_type == "azure":
assert all(
[
credentials.azure_key is not None,
credentials.azure_embedding_endpoint is not None,
credentials.azure_version is not None,
]
)
from llama_index.embeddings.azure_openai import AzureOpenAIEmbedding

# https://learn.microsoft.com/en-us/azure/ai-services/openai/reference#embeddings
Expand All @@ -176,7 +189,13 @@ def embedding_model(config: EmbeddingConfig, user_id: Optional[uuid.UUID] = None
azure_endpoint=credentials.azure_endpoint,
api_version=credentials.azure_version,
)

elif endpoint_type == "hugging-face":
return EmbeddingEndpoint(model=config.embedding_model, base_url=config.embedding_endpoint, user=user_id)
return EmbeddingEndpoint(
model=config.embedding_model,
base_url=config.embedding_endpoint,
user=user_id,
)

else:
return default_embedding_model()
Loading
Loading