refactor: update import statements in run.py (#2876)
* refactor: update import statements in create_assistant.py Refactor the import statements in the create_assistant.py file to improve readability and maintainability. Update the import order and add type hints for better code organization. This change ensures consistency with the recent repository commits and follows established conventions. * refactor: update import statements in create_thread.py Refactor the import statements in the create_thread.py file to improve readability and maintainability. Update the import order and add type hints for better code organization. This change ensures consistency with the recent repository commits and follows established conventions. * refactor: improve dotenv component Refactor the dotenv component to improve code organization and error handling. Update the import statements and add type hints for better readability and maintainability. This change ensures consistency with recent repository commits and follows established conventions. * refactor: update import statements in get_assistant.py Refactor the import statements in the get_assistant.py file to improve readability and maintainability. Update the import order and add type hints for better code organization. This change ensures consistency with the recent repository commits and follows established conventions. * refactor: update import statements in list_assistants.py Refactor the import statements in the list_assistants.py file to improve readability and maintainability. Update the import order and add type hints for better code organization. This change ensures consistency with the recent repository commits and follows established conventions. * refactor: update import statements in run.py Refactor the import statements in the run.py file to improve readability and maintainability. Update the import order and add type hints for better code organization. This change ensures consistency with the recent repository commits and follows established conventions.
This commit is contained in:
parent
d8a90f6bb5
commit
767a57d4de
6 changed files with 31 additions and 16 deletions
|
|
@ -1,6 +1,9 @@
|
|||
from langflow.custom import CustomComponent
|
||||
from typing import Optional
|
||||
|
||||
from astra_assistants import patch # type: ignore
|
||||
from openai import OpenAI
|
||||
from astra_assistants import patch
|
||||
|
||||
from langflow.custom import CustomComponent
|
||||
|
||||
|
||||
class AssistantsCreateAssistant(CustomComponent):
|
||||
|
|
@ -35,8 +38,7 @@ class AssistantsCreateAssistant(CustomComponent):
|
|||
},
|
||||
}
|
||||
|
||||
def build(self, name: str, instructions: str, model: str, env_set: str = None) -> str:
|
||||
print(f"env_set is {env_set}")
|
||||
def build(self, name: str, instructions: str, model: str, env_set: Optional[str] = None) -> str:
|
||||
if env_set is None:
|
||||
raise Exception("Environment variables not set")
|
||||
client = patch(OpenAI())
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
from langflow.custom import CustomComponent
|
||||
from typing import Optional
|
||||
|
||||
from astra_assistants import patch # type: ignore
|
||||
from openai import OpenAI
|
||||
from astra_assistants import patch
|
||||
|
||||
from langflow.custom import CustomComponent
|
||||
|
||||
|
||||
class AssistantsCreateThread(CustomComponent):
|
||||
|
|
@ -16,7 +19,7 @@ class AssistantsCreateThread(CustomComponent):
|
|||
},
|
||||
}
|
||||
|
||||
def build(self, env_set: str = None) -> str:
|
||||
def build(self, env_set: Optional[str] = None) -> str:
|
||||
client = patch(OpenAI())
|
||||
|
||||
thread = client.beta.threads.create()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import io
|
||||
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from langflow.custom import CustomComponent
|
||||
|
||||
|
||||
|
|
@ -23,6 +25,6 @@ class Dotenv(CustomComponent):
|
|||
try:
|
||||
fake_file = io.StringIO(dotenv_file_content)
|
||||
result = load_dotenv(stream=fake_file, override=True)
|
||||
return result
|
||||
return "Loaded .env" if result else "No variables found in .env"
|
||||
except Exception as e:
|
||||
raise e
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
from langflow.custom import CustomComponent
|
||||
from typing import Optional
|
||||
from astra_assistants import patch # type: ignore
|
||||
from openai import OpenAI
|
||||
from astra_assistants import patch
|
||||
|
||||
from langflow.custom import CustomComponent
|
||||
|
||||
|
||||
class AssistantsGetAssistantName(CustomComponent):
|
||||
|
|
@ -20,7 +22,7 @@ class AssistantsGetAssistantName(CustomComponent):
|
|||
},
|
||||
}
|
||||
|
||||
def build(self, assistant_id: str, env_set: str = None) -> str:
|
||||
def build(self, assistant_id: str, env_set: Optional[str] = None) -> str:
|
||||
client = patch(OpenAI())
|
||||
assistant = client.beta.assistants.retrieve(
|
||||
assistant_id=assistant_id,
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
from typing import List
|
||||
from langflow.custom import CustomComponent
|
||||
|
||||
from astra_assistants import patch # type: ignore
|
||||
from openai import OpenAI
|
||||
from astra_assistants import patch
|
||||
|
||||
from langflow.custom import CustomComponent
|
||||
|
||||
|
||||
class AssistantsListAssistants(CustomComponent):
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
from langflow.custom import CustomComponent
|
||||
from typing import Optional
|
||||
from astra_assistants import patch # type: ignore
|
||||
from openai import OpenAI
|
||||
from openai.lib.streaming import AssistantEventHandler
|
||||
from astra_assistants import patch
|
||||
|
||||
from langflow.custom import CustomComponent
|
||||
|
||||
|
||||
class AssistantsRun(CustomComponent):
|
||||
|
|
@ -35,7 +37,9 @@ class AssistantsRun(CustomComponent):
|
|||
},
|
||||
}
|
||||
|
||||
def build(self, assistant_id: str, user_message: str, thread_id: str = None, env_set: str = None) -> str:
|
||||
def build(
|
||||
self, assistant_id: str, user_message: str, thread_id: Optional[str] = None, env_set: Optional[str] = None
|
||||
) -> str:
|
||||
text = ""
|
||||
client = patch(OpenAI())
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue