-
Notifications
You must be signed in to change notification settings - Fork 736
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
fix: api_keys_required #1277
fix: api_keys_required #1277
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.
Thanks @Wendong-Fan .
If a class depends on multiple tokens at the same time, it seems that only one api_key
can be verified.
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.
Hey @Wendong-Fan , left some comments below
A situation that currently does not meet expectations: class ExampleClass:
def __init__(self, messages: List[str], key_1: str = None, api_key_2: str = None):
self._key1 = key_1 or os.environ.get("API_KEY_1")
self._key2 = api_key_2 or os.environ.get("API_KEY_2")
self.messages = messages
@api_keys_required(
[
("key_1", 'API_KEY_1'),
("api_key_2", 'API_KEY_2'),
]
)
def run(self):
print("API keys validated!")
if __name__ == "__main__":
# Example with API_KEY_1 provided in arguments
obj = ExampleClass(messages=["xx"], key_1="API", api_key_2="dfadf")
obj.run()
"""
Traceback (most recent call last):
File "path\to\camel\camel\utils\test.py", line 53, in <module>
obj.run()
File "path\to\camel\camel\utils\commons.py", line 307, in wrapper
raise ValueError(
ValueError: Missing required API keys: API_KEY_1, API_KEY_2
""" |
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.
Looks good to me
Description
Describe your changes in detail.
Motivation and Context
close #1273
Types of changes
What types of changes does your code introduce? Put an
x
in all the boxes that apply:Implemented Tasks
Checklist
Go over all the following points, and put an
x
in all the boxes that apply.If you are unsure about any of these, don't hesitate to ask. We are here to help!