Skip to content
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: move client instantiation in AssistantsGetAssistantName and AssistantsListAssistants to inner function #3043

Merged
merged 1 commit into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@


class AssistantsGetAssistantName(Component):
client = patch(OpenAI())
display_name = "Get Assistant name"
description = "Assistant by id"

Expand All @@ -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,
)
Expand Down
Original file line number Diff line number Diff line change
@@ -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"

Expand All @@ -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(
Expand Down
3 changes: 1 addition & 2 deletions src/backend/base/langflow/components/astra_assistants/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@


class AssistantsRun(Component):
client = patch(OpenAI())

display_name = "Run Assistant"
description = "Executes an Assistant Run against a thread"

Expand Down Expand Up @@ -59,6 +57,7 @@ def update_build_config(
outputs = [Output(display_name="Assistant Response", name="assistant_response", method="process_inputs")]

def process_inputs(self) -> Message:
patch(OpenAI())
try:
text = ""

Expand Down
Loading