-
Notifications
You must be signed in to change notification settings - Fork 399
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
Add optional api_key
parameter
#362
Conversation
…iable when no key is supplied
api_key
parameter
def __init__( | ||
self, | ||
model_name: str, | ||
api_key: Optional[str] = os.getenv("OPENAI_API_KEY"), |
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.
Optional
is equivalent to X | None
in Python. Since a default value is provided this should not be typed as Optional
.
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.
Alright, the mypy precommit hook was complaining and that solved it. Will get it fixed correctly.
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.
Ah right, it's because os.getenv can return None. Sorry bit new to python.
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.
Makes sense
outlines/models/openai.py
Outdated
) -> Union[List[str], str]: | ||
"""Generate a sequence that must be one of many options. | ||
` | ||
.. warning:: |
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.
Why has this moved?
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.
I think formatter commit hook did this
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.
Hmm doesn't mess with the formatting now.
Thank you for contributing! I have a couple of comments that will need to be addressed before merging. |
Thank you for contributing! |
This PR allows users to supply an optional Openai API key, this is useful for services that allow users to supply their own API keys (like web services).