fixes and refactory

This commit is contained in:
Nicolò Boschi 2024-06-24 09:35:26 +02:00 committed by Gabriel Luiz Freitas Almeida
commit 8f31291d97
6 changed files with 29 additions and 50 deletions

View file

@ -11,6 +11,18 @@ Used to load embedding models from [Amazon Bedrock](https://aws.amazon.com/bedro
| `endpoint_url` | `str` | URL to set a specific service endpoint other than the default AWS endpoint. | |
| `region_name` | `str` | AWS region to use, e.g., `us-west-2`. Falls back to `AWS_DEFAULT_REGION` environment variable or region specified in ~/.aws/config if not provided. | |
## Astra vectorize
Used to generate server-side embeddings using [DataStax Astra](https://docs.datastax.com/en/astra-db-serverless/databases/embedding-generation.html).
| **Parameter** | **Type** | **Description** | **Default** |
|--------------------|----------|-----------------------------------------------------------------------------------------------------------------------|-------------|
| `provider` | `str` | The embedding provider to use. | |
| `model_name` | `str` | The embedding model to use. | |
| `authentication` | `dict` | Authentication parameters. Use the Astra Portal to add the embedding provider integration to your Astra organization. | |
| `provider_api_key` | `str` | An alternative to the Astra Authentication that let you use directly the API key of the provider. | |
| `model_parameters` | `dict` | Additional model parameters. | |
## Cohere Embeddings
Used to load embedding models from [Cohere](https://cohere.com/).

View file

@ -9,7 +9,7 @@ The `Astra DB` initializes a vector store using Astra DB from Data. It creates A
**Parameters:**
- **Input:** Documents or Data for input.
- **Embedding:** Embedding model Astra DB uses.
- **Embedding or Astra vectorize:** External or server-side model Astra DB uses.
- **Collection Name:** Name of the Astra DB collection.
- **Token:** Authentication token for Astra DB.
- **API Endpoint:** API endpoint for Astra DB.
@ -40,7 +40,7 @@ The `Astra DB` initializes a vector store using Astra DB from Data. It creates A
- **Search Type:** Type of search, such as Similarity or MMR.
- **Input Value:** Value to search for.
- **Embedding:** Embedding model Astra DB uses.
- **Embedding or Astra vectorize:** External or server-side model Astra DB uses.
- **Collection Name:** Name of the Astra DB collection.
- **Token:** Authentication token for Astra DB.
- **API Endpoint:** API endpoint for Astra DB.

View file

@ -1,41 +1,7 @@
from typing import Optional, Dict, Any
from langflow.custom import CustomComponent
from typing import Any
from langflow.custom import Component
from base.langflow.inputs import TextInput
from base.langflow.template.field.base import Output
#
#
# class AstraVectorize(Component):
# display_name = "Astra Vectorize"
# description = "Configuration options for Astra Vectorize server-side embeddings."
# documentation = "..."
# icon = "AstraDB" # TODO: New icon?
#
# inputs = [
# TextInput(
# name="provider",
# display_name="Provider",
# )
# ]
# outputs = [
# Output(display_name="Vectorize_configuration", name="embeddings", method="build"),
# ]
#
# def build(
# self,
# ) -> Dict[str, Any]:
# return {
# "provider": self.provider
# }
from langflow.custom import Component
from langflow.inputs.inputs import DataInput, IntInput, TextInput, DictInput, SecretStrInput
from langflow.schema import Data
from langflow.inputs.inputs import DictInput, SecretStrInput, StrInput
from langflow.template.field.base import Output
from langflow.utils.util import build_loader_repr_from_data, unescape_string
class AstraVectorize(Component):
@ -45,15 +11,15 @@ class AstraVectorize(Component):
icon = "AstraDB"
inputs = [
TextInput(
StrInput(
name="provider",
display_name="Provider name",
info='The provider to use.',
info='The embedding provider to use.',
),
TextInput(
StrInput(
name="model_name",
display_name="Model name",
info='The model to use.',
info='The embedding model to use.',
),
DictInput(
name="authentication",
@ -63,20 +29,20 @@ class AstraVectorize(Component):
),
SecretStrInput(
name="provider_api_key",
display_name="Provider API Key to authenticate to the external service",
display_name="Provider API Key",
info='An alternative to the Astra Authentication that let you use directly the API key of the provider.',
advanced=True
),
DictInput(
name="parameters",
display_name="Additional model parameters",
display_name="Model parameters",
info='Additional model parameters.',
advanced=True,
is_list=True
),
]
outputs = [
Output(display_name="Configuration", name="config", method="build", types=["dict"]),
Output(display_name="Vectorize", name="config", method="build", types=["dict"]),
]
def build(self) -> dict[str, Any]:

View file

@ -106,7 +106,7 @@ class AstraVectorStoreComponent(LCVectorStoreComponent):
),
HandleInput(
name="embedding",
display_name="Embedding",
display_name="Embedding or Astra Vectorize",
input_types=["Embeddings", "dict"],
),
StrInput(

View file

@ -787,6 +787,7 @@
},
"node_modules/@clack/prompts/node_modules/is-unicode-supported": {
"version": "1.3.0",
"extraneous": true,
"inBundle": true,
"license": "MIT",
"engines": {

View file

@ -632,7 +632,7 @@ export default function ParameterComponent({
editNode={false}
value={
!data.node!.template[name]?.value ||
data.node!.template[name]?.value?.toString() === "{}"
!Object.keys(data.node!.template[name]?.value || {}).length
? {}
: data.node!.template[name]?.value
}
@ -648,9 +648,9 @@ export default function ParameterComponent({
disabled={disabled}
editNode={false}
value={
data.node!.template[name]?.value?.length === 0 ||
!data.node!.template[name]?.value
? [{ "": "" }]
!data.node!.template[name]?.value ||
!Object.keys(data.node!.template[name]?.value || {}).length
? [{"":""}]
: convertObjToArray(data.node!.template[name]?.value, type!)
}
duplicateKey={errorDuplicateKey}