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 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
@ -14,30 +14,30 @@ class AstraVectorize(Component):
MessageTextInput(
name="provider",
display_name="Provider name",
info='The embedding provider to use.',
info="The embedding provider to use.",
),
MessageTextInput(
name="model_name",
display_name="Model name",
info='The embedding model to use.',
info="The embedding model to use.",
),
DictInput(
name="authentication",
display_name="Authentication",
info='Authentication parameters. Use the Astra Portal to add the embedding provider integration to your Astra organization.',
is_list=True
info="Authentication parameters. Use the Astra Portal to add the embedding provider integration to your Astra organization.",
is_list=True,
),
SecretStrInput(
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(
name="model_parameters",
display_name="Model parameters",
info='Additional model parameters.',
info="Additional model parameters.",
advanced=True,
is_list=True
is_list=True,
),
]
outputs = [
@ -51,7 +51,7 @@ class AstraVectorize(Component):
"provider": self.provider,
"modelName": self.model_name,
"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
from typing import Optional, Any,
from typing import Any, Optional
from langflow.custom import CustomComponent
from langflow.schema.dotdict import dotdict
@ -10,10 +10,7 @@ class UUIDGeneratorComponent(CustomComponent):
description = "Generates a unique ID."
def update_build_config( # type: ignore
self,
build_config: dotdict,
field_value: Any,
field_name: Optional[str] = None,
self, build_config: dotdict, field_value: Any, field_name: Optional[str] = None
):
if field_name == "unique_id":
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 .Listen import ListenComponent
from .Notify import NotifyComponent

View file

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