nathadfield commented on code in PR #39248:
URL: https://github.com/apache/airflow/pull/39248#discussion_r1580850336
##########
airflow/providers/openai/hooks/openai.py:
##########
@@ -133,26 +143,26 @@ def get_assistants(self, **kwargs: Any) ->
list[Assistant]:
return assistants.data
def get_assistant_by_name(self, assistant_name: str) -> Assistant | None:
- """Get an OpenAI Assistant object for a given name.
+ """
+ Get an OpenAI Assistant object for a given name.
:param assistant_name: The name of the assistant to retrieve
"""
- response = self.get_assistants()
- for assistant in response:
- if assistant.name == assistant_name:
- return assistant
- return None
+ assistants = self.get_assistants()
+ return next((assistant for assistant in assistants if assistant.name
== assistant_name), None)
Review Comment:
Yes, I figured this was better in terms of performance but you make a good a
point. I've not actually checked if it's possible to create two assistants
with the same name. I'll find out.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]