-
Notifications
You must be signed in to change notification settings - Fork 57
OpenAI and Huggingface Providers #16
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left some suggestions but looks great all around!
@@ -0,0 +1,9 @@ | |||
|
|||
from redisvl.providers.openai import OpenAIProvider |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we consider organizing it one layer deeper, under embeddings
? that way its clear whether its for Embedding creation or something else (future proofing)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a long import but I see what you mean. A couple options
from redisvl.api.embedding.openai
from redisvl.embedding.openai import OpenAIEmbedding
from redisvl.model.embedding.openai import ...
others?
@@ -0,0 +1,29 @@ | |||
from typing import Dict, List, Optional | |||
|
|||
from sentence_transformers import SentenceTransformer |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we could consider importing this scoped within the class -- and then we can prevent folks from having to install SentenceTransformers (torch, etc) if they don't plan to need it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the default for LLMCache... should we not assume that? I do like the scoped gaurd approach.
@@ -0,0 +1,48 @@ | |||
from typing import Dict, List, Optional | |||
|
|||
import openai |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same point as above?
openai.api_key = api_config.get("api_key", None) | ||
self._model_client = openai.Embedding | ||
|
||
def embed_many( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we look to make this immune to rate limit issues? One pattern I have seen is to use tenacity
and their exponential backoff decorator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tylerhutcherson can you point me to or write a code sample for this?
addressing changes in Next PR |
Providers for creating embeddings with OpenAI and Hugginface.
Includes