style: run ruff

This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-06-24 09:03:58 -03:00
commit 6f836c35b1
4 changed files with 18 additions and 19 deletions

View file

@ -1,6 +1,6 @@
from typing import Any from typing import Any
from langflow.custom import Component from langflow.custom import Component
from langflow.inputs.inputs import DictInput, SecretStrInput, StrInput, MessageTextInput from langflow.inputs.inputs import DictInput, SecretStrInput, MessageTextInput
from langflow.template.field.base import Output from langflow.template.field.base import Output
@ -14,30 +14,30 @@ class AstraVectorize(Component):
MessageTextInput( MessageTextInput(
name="provider", name="provider",
display_name="Provider name", display_name="Provider name",
info='The embedding provider to use.', info="The embedding provider to use.",
), ),
MessageTextInput( MessageTextInput(
name="model_name", name="model_name",
display_name="Model name", display_name="Model name",
info='The embedding model to use.', info="The embedding model to use.",
), ),
DictInput( DictInput(
name="authentication", name="authentication",
display_name="Authentication", display_name="Authentication",
info='Authentication parameters. Use the Astra Portal to add the embedding provider integration to your Astra organization.', info="Authentication parameters. Use the Astra Portal to add the embedding provider integration to your Astra organization.",
is_list=True is_list=True,
), ),
SecretStrInput( SecretStrInput(
name="provider_api_key", name="provider_api_key",
display_name="Provider API Key", display_name="Provider API Key",
info='An alternative to the Astra Authentication that let you use directly the API key of the provider.' info="An alternative to the Astra Authentication that let you use directly the API key of the provider.",
), ),
DictInput( DictInput(
name="model_parameters", name="model_parameters",
display_name="Model parameters", display_name="Model parameters",
info='Additional model parameters.', info="Additional model parameters.",
advanced=True, advanced=True,
is_list=True is_list=True,
), ),
] ]
outputs = [ outputs = [
@ -51,7 +51,7 @@ class AstraVectorize(Component):
"provider": self.provider, "provider": self.provider,
"modelName": self.model_name, "modelName": self.model_name,
"authentication": self.authentication, "authentication": self.authentication,
"parameters": self.model_parameters "parameters": self.model_parameters,
}, },
"collection_embedding_api_key": self.provider_api_key "collection_embedding_api_key": self.provider_api_key,
} }

View file

@ -1,5 +1,5 @@
import uuid import uuid
from typing import Optional, Any, from typing import Any, Optional
from langflow.custom import CustomComponent from langflow.custom import CustomComponent
from langflow.schema.dotdict import dotdict from langflow.schema.dotdict import dotdict
@ -10,10 +10,7 @@ class UUIDGeneratorComponent(CustomComponent):
description = "Generates a unique ID." description = "Generates a unique ID."
def update_build_config( # type: ignore def update_build_config( # type: ignore
self, self, build_config: dotdict, field_value: Any, field_name: Optional[str] = None
build_config: dotdict,
field_value: Any,
field_name: Optional[str] = None,
): ):
if field_name == "unique_id": if field_name == "unique_id":
build_config[field_name]["value"] = str(uuid.uuid4()) build_config[field_name]["value"] = str(uuid.uuid4())

View file

@ -1,4 +1,4 @@
µfrom .ConditionalRouter import ConditionalRouterComponent from .ConditionalRouter import ConditionalRouterComponent
from .FlowTool import FlowToolComponent from .FlowTool import FlowToolComponent
from .Listen import ListenComponent from .Listen import ListenComponent
from .Notify import NotifyComponent from .Notify import NotifyComponent

View file

@ -159,10 +159,12 @@ class AstraVectorStoreComponent(LCVectorStoreComponent):
embedding_dict = {"embedding": self.embedding} embedding_dict = {"embedding": self.embedding}
else: else:
from astrapy.info import CollectionVectorServiceOptions from astrapy.info import CollectionVectorServiceOptions
dict_options = self.embedding.get("collection_vector_service_options", {}) dict_options = self.embedding.get("collection_vector_service_options", {})
dict_options["authentication"] = {k: v for k, v in dict_options.get("authentication", {}).items() if k and v} dict_options["authentication"] = {
dict_options["parameters"] = {k: v for k, v in dict_options.get("parameters", {}).items() if k: v for k, v in dict_options.get("authentication", {}).items() if k and v
k and v} }
dict_options["parameters"] = {k: v for k, v in dict_options.get("parameters", {}).items() if k and v}
embedding_dict = { embedding_dict = {
"collection_vector_service_options": CollectionVectorServiceOptions.from_dict(dict_options), "collection_vector_service_options": CollectionVectorServiceOptions.from_dict(dict_options),
"collection_embedding_api_key": self.embedding.get("collection_embedding_api_key"), "collection_embedding_api_key": self.embedding.get("collection_embedding_api_key"),