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:
parent
e15e70d43c
commit
c63876fcff
3 changed files with 6 additions and 6 deletions
|
|
@ -8,7 +8,6 @@ from langflow.template import Output
|
||||||
|
|
||||||
|
|
||||||
class AssistantsGetAssistantName(Component):
|
class AssistantsGetAssistantName(Component):
|
||||||
client = patch(OpenAI())
|
|
||||||
display_name = "Get Assistant name"
|
display_name = "Get Assistant name"
|
||||||
description = "Assistant by id"
|
description = "Assistant by id"
|
||||||
|
|
||||||
|
|
@ -30,6 +29,7 @@ class AssistantsGetAssistantName(Component):
|
||||||
]
|
]
|
||||||
|
|
||||||
def process_inputs(self) -> Message:
|
def process_inputs(self) -> Message:
|
||||||
|
patch(OpenAI())
|
||||||
assistant = self.client.beta.assistants.retrieve(
|
assistant = self.client.beta.assistants.retrieve(
|
||||||
assistant_id=self.assistant_id,
|
assistant_id=self.assistant_id,
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
from astra_assistants import patch # type: ignore
|
from astra_assistants import patch # type: ignore
|
||||||
from langflow.template.field.base import Output
|
|
||||||
from langflow.custom import Component
|
|
||||||
from openai import OpenAI
|
from openai import OpenAI
|
||||||
|
|
||||||
|
from langflow.custom import Component
|
||||||
from langflow.schema.message import Message
|
from langflow.schema.message import Message
|
||||||
|
from langflow.template.field.base import Output
|
||||||
|
|
||||||
|
|
||||||
class AssistantsListAssistants(Component):
|
class AssistantsListAssistants(Component):
|
||||||
client = patch(OpenAI())
|
|
||||||
display_name = "List Assistants"
|
display_name = "List Assistants"
|
||||||
description = "Returns a list of assistant id's"
|
description = "Returns a list of assistant id's"
|
||||||
|
|
||||||
|
|
@ -15,6 +15,7 @@ class AssistantsListAssistants(Component):
|
||||||
]
|
]
|
||||||
|
|
||||||
def process_inputs(self) -> Message:
|
def process_inputs(self) -> Message:
|
||||||
|
patch(OpenAI())
|
||||||
assistants = self.client.beta.assistants.list()
|
assistants = self.client.beta.assistants.list()
|
||||||
id_list = [assistant.id for assistant in assistants]
|
id_list = [assistant.id for assistant in assistants]
|
||||||
message = Message(
|
message = Message(
|
||||||
|
|
|
||||||
|
|
@ -11,8 +11,6 @@ from langflow.template import Output
|
||||||
|
|
||||||
|
|
||||||
class AssistantsRun(Component):
|
class AssistantsRun(Component):
|
||||||
client = patch(OpenAI())
|
|
||||||
|
|
||||||
display_name = "Run Assistant"
|
display_name = "Run Assistant"
|
||||||
description = "Executes an Assistant Run against a thread"
|
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")]
|
outputs = [Output(display_name="Assistant Response", name="assistant_response", method="process_inputs")]
|
||||||
|
|
||||||
def process_inputs(self) -> Message:
|
def process_inputs(self) -> Message:
|
||||||
|
patch(OpenAI())
|
||||||
try:
|
try:
|
||||||
text = ""
|
text = ""
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue