fix: move client instantiation in AssistantsGetAssistantName and AssistantsListAssistants to inner function (#3043)

The OpenAI client instantiation was removed from the `AssistantsGetAssistantName` and `AssistantsListAssistants` components. This commit fixes the issue by adding back the OpenAI client instantiation in the `process_inputs` method of both components.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-07-29 17:28:58 -03:00 committed by GitHub
commit c63876fcff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 6 deletions

View file

@ -8,7 +8,6 @@ from langflow.template import Output
class AssistantsGetAssistantName(Component):
client = patch(OpenAI())
display_name = "Get Assistant name"
description = "Assistant by id"
@ -30,6 +29,7 @@ class AssistantsGetAssistantName(Component):
]
def process_inputs(self) -> Message:
patch(OpenAI())
assistant = self.client.beta.assistants.retrieve(
assistant_id=self.assistant_id,
)

View file

@ -1,12 +1,12 @@
from astra_assistants import patch # type: ignore
from langflow.template.field.base import Output
from langflow.custom import Component
from openai import OpenAI
from langflow.custom import Component
from langflow.schema.message import Message
from langflow.template.field.base import Output
class AssistantsListAssistants(Component):
client = patch(OpenAI())
display_name = "List Assistants"
description = "Returns a list of assistant id's"
@ -15,6 +15,7 @@ class AssistantsListAssistants(Component):
]
def process_inputs(self) -> Message:
patch(OpenAI())
assistants = self.client.beta.assistants.list()
id_list = [assistant.id for assistant in assistants]
message = Message(

View file

@ -11,8 +11,6 @@ from langflow.template import Output
class AssistantsRun(Component):
client = patch(OpenAI())
display_name = "Run Assistant"
description = "Executes an Assistant Run against a thread"
@ -59,6 +57,7 @@ class AssistantsRun(Component):
outputs = [Output(display_name="Assistant Response", name="assistant_response", method="process_inputs")]
def process_inputs(self) -> Message:
patch(OpenAI())
try:
text = ""