🐛 fix(PromptRunner.py): change beta variable type from string to boolean to match expected type

🐛 fix(Metaphor.py): change beta variable type from string to boolean to match expected type
🐛 fix(GetRequest.py): change beta variable type from string to boolean to match expected type
🐛 fix(JSONDocumentBuilder.py): change beta variable type from string to boolean to match expected type
🐛 fix(PostRequest.py): change beta variable type from string to boolean to match expected type
🐛 fix(UpdateRequest.py): change beta variable type from string to boolean to match expected type
🐛 fix(Chroma.py): change beta variable type from string to boolean to match expected type
🐛 fix(Vectara.py): change beta variable type from string to boolean to match expected type
🐛 fix(component.py): change ERROR_CODE_NULL variable type from dict to string to match expected type
🐛 fix(custom_component.py): change code_class_base_inheritance variable type from dict to string to match expected type
🐛 fix(custom_component.py): change function_entrypoint_name variable type from dict to string to match expected type
🐛 fix(initialize/vector_store.py): change chromadb variable name to chromadb_instance for clarity
🐛 fix(database/manager.py): change expected_columns to use model_fields instead of __fields__ to match new SQLModel version
🐛 fix(database/models/base.py): remove unused model_config variable
🐛 fix(database/models/flow/flow.py): change validator decorator to field_validator to match new pydantic version
🐛 fix(settings.py): change root_validator decorator to model_validator to match new pydantic version
This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-11-03 11:50:03 -03:00
commit 87db2f4d0b
15 changed files with 24 additions and 29 deletions

View file

@ -8,7 +8,7 @@ from langchain.schema import Document
class PromptRunner(CustomComponent): class PromptRunner(CustomComponent):
display_name: str = "Prompt Runner" display_name: str = "Prompt Runner"
description: str = "Run a Chain with the given PromptTemplate" description: str = "Run a Chain with the given PromptTemplate"
beta: str = True beta: bool = True
field_config = { field_config = {
"llm": {"display_name": "LLM"}, "llm": {"display_name": "LLM"},
"prompt": { "prompt": {

View file

@ -13,7 +13,7 @@ class MetaphorToolkit(CustomComponent):
documentation = ( documentation = (
"https://python.langchain.com/docs/integrations/tools/metaphor_search" "https://python.langchain.com/docs/integrations/tools/metaphor_search"
) )
beta: str = True beta: bool = True
# api key should be password = True # api key should be password = True
field_config = { field_config = {
"metaphor_api_key": {"display_name": "Metaphor API Key", "password": True}, "metaphor_api_key": {"display_name": "Metaphor API Key", "password": True},

View file

@ -10,7 +10,7 @@ class GetRequest(CustomComponent):
description: str = "Make a GET request to the given URL." description: str = "Make a GET request to the given URL."
output_types: list[str] = ["Document"] output_types: list[str] = ["Document"]
documentation: str = "https://docs.langflow.org/components/utilities#get-request" documentation: str = "https://docs.langflow.org/components/utilities#get-request"
beta: str = True beta: bool = True
field_config = { field_config = {
"url": { "url": {
"display_name": "URL", "display_name": "URL",

View file

@ -20,7 +20,7 @@ class JSONDocumentBuilder(CustomComponent):
display_name: str = "JSON Document Builder" display_name: str = "JSON Document Builder"
description: str = "Build a Document containing a JSON object using a key and another Document page content." description: str = "Build a Document containing a JSON object using a key and another Document page content."
output_types: list[str] = ["Document"] output_types: list[str] = ["Document"]
beta: str = True beta: bool = True
documentation: str = ( documentation: str = (
"https://docs.langflow.org/components/utilities#json-document-builder" "https://docs.langflow.org/components/utilities#json-document-builder"
) )

View file

@ -10,7 +10,7 @@ class PostRequest(CustomComponent):
description: str = "Make a POST request to the given URL." description: str = "Make a POST request to the given URL."
output_types: list[str] = ["Document"] output_types: list[str] = ["Document"]
documentation: str = "https://docs.langflow.org/components/utilities#post-request" documentation: str = "https://docs.langflow.org/components/utilities#post-request"
beta: str = True beta: bool = True
field_config = { field_config = {
"url": {"display_name": "URL", "info": "The URL to make the request to."}, "url": {"display_name": "URL", "info": "The URL to make the request to."},
"headers": { "headers": {

View file

@ -10,7 +10,7 @@ class UpdateRequest(CustomComponent):
description: str = "Make a PATCH request to the given URL." description: str = "Make a PATCH request to the given URL."
output_types: list[str] = ["Document"] output_types: list[str] = ["Document"]
documentation: str = "https://docs.langflow.org/components/utilities#update-request" documentation: str = "https://docs.langflow.org/components/utilities#update-request"
beta: str = True beta: bool = True
field_config = { field_config = {
"url": {"display_name": "URL", "info": "The URL to make the request to."}, "url": {"display_name": "URL", "info": "The URL to make the request to."},
"headers": { "headers": {

View file

@ -17,7 +17,7 @@ class ChromaComponent(CustomComponent):
display_name: str = "Chroma" display_name: str = "Chroma"
description: str = "Implementation of Vector Store using Chroma" description: str = "Implementation of Vector Store using Chroma"
documentation = "https://python.langchain.com/docs/integrations/vectorstores/chroma" documentation = "https://python.langchain.com/docs/integrations/vectorstores/chroma"
beta: str = True beta: bool = True
def build_config(self): def build_config(self):
""" """

View file

@ -13,7 +13,7 @@ class VectaraComponent(CustomComponent):
documentation = ( documentation = (
"https://python.langchain.com/docs/integrations/vectorstores/vectara" "https://python.langchain.com/docs/integrations/vectorstores/vectara"
) )
beta: str = True beta: bool = True
# api key should be password = True # api key should be password = True
field_config = { field_config = {
"vectara_customer_id": {"display_name": "Vectara Customer ID"}, "vectara_customer_id": {"display_name": "Vectara Customer ID"},

View file

@ -1,5 +1,5 @@
import ast import ast
from typing import Any, ClassVar, Dict, Optional from typing import Any, ClassVar, Optional
from pydantic import BaseModel from pydantic import BaseModel
from fastapi import HTTPException from fastapi import HTTPException
@ -16,9 +16,9 @@ class ComponentFunctionEntrypointNameNullError(HTTPException):
class Component(BaseModel): class Component(BaseModel):
ERROR_CODE_NULL: ClassVar[Dict] = "Python code must be provided." ERROR_CODE_NULL: ClassVar[str] = "Python code must be provided."
ERROR_FUNCTION_ENTRYPOINT_NAME_NULL: ClassVar[ ERROR_FUNCTION_ENTRYPOINT_NAME_NULL: ClassVar[
Dict str
] = "The name of the entrypoint function must be provided." ] = "The name of the entrypoint function must be provided."
code: Optional[str] = None code: Optional[str] = None

View file

@ -1,4 +1,4 @@
from typing import Any, Callable, ClassVar, List, Optional, Union, Dict from typing import Any, Callable, ClassVar, List, Optional, Union
from uuid import UUID from uuid import UUID
from fastapi import HTTPException from fastapi import HTTPException
from langflow.field_typing.constants import CUSTOM_COMPONENT_SUPPORTED_TYPES from langflow.field_typing.constants import CUSTOM_COMPONENT_SUPPORTED_TYPES
@ -19,8 +19,8 @@ class CustomComponent(Component, extra="allow"):
description = "Custom Component" description = "Custom Component"
code: Optional[str] = None code: Optional[str] = None
field_config: dict = {} field_config: dict = {}
code_class_base_inheritance: ClassVar[Dict] = "CustomComponent" code_class_base_inheritance: ClassVar[str] = "CustomComponent"
function_entrypoint_name: ClassVar[Dict] = "build" function_entrypoint_name: ClassVar[str] = "build"
function: Optional[Callable] = None function: Optional[Callable] = None
return_type_valid_list: List[str] = list(CUSTOM_COMPONENT_SUPPORTED_TYPES.keys()) return_type_valid_list: List[str] = list(CUSTOM_COMPONENT_SUPPORTED_TYPES.keys())
repr_value: Optional[Any] = "" repr_value: Optional[Any] = ""

View file

@ -196,7 +196,7 @@ def initialize_chroma(class_object: Type[Chroma], params: dict):
params.pop("documents", None) params.pop("documents", None)
params.pop("texts", None) params.pop("texts", None)
params["embedding_function"] = params.pop("embedding") params["embedding_function"] = params.pop("embedding")
chromadb = class_object(**params) chromadb_instance = class_object(**params)
else: else:
if "texts" in params: if "texts" in params:
params["documents"] = params.pop("texts") params["documents"] = params.pop("texts")
@ -211,10 +211,10 @@ def initialize_chroma(class_object: Type[Chroma], params: dict):
if value is None: if value is None:
doc.metadata[key] = "" doc.metadata[key] = ""
chromadb = class_object.from_documents(**params) chromadb_instance = class_object.from_documents(**params)
if persist: if persist:
chromadb.persist() chromadb_instance.persist()
return chromadb return chromadb_instance
def initialize_qdrant(class_object: Type[Qdrant], params: dict): def initialize_qdrant(class_object: Type[Qdrant], params: dict):

View file

@ -94,7 +94,7 @@ class DatabaseService(Service):
legacy_tables = ["flowstyle"] legacy_tables = ["flowstyle"]
for table, model in model_mapping.items(): for table, model in model_mapping.items():
expected_columns = list(model.__fields__.keys()) expected_columns = list(model.model_fields.keys())
try: try:
available_columns = [ available_columns = [

View file

@ -1,6 +1,5 @@
from sqlmodel import SQLModel from sqlmodel import SQLModel
import orjson import orjson
from pydantic import ConfigDict
def orjson_dumps(v, *, default=None, sort_keys=False, indent_2=True): def orjson_dumps(v, *, default=None, sort_keys=False, indent_2=True):
@ -22,8 +21,4 @@ def orjson_dumps(v, *, default=None, sort_keys=False, indent_2=True):
class SQLModelSerializable(SQLModel): class SQLModelSerializable(SQLModel):
# TODO[pydantic]: The following keys were removed: `json_loads`, `json_dumps`. # TODO[pydantic]: The following keys were removed: `json_loads`, `json_dumps`.
# Check https://docs.pydantic.dev/dev-v2/migration/#changes-to-config for more information. # Check https://docs.pydantic.dev/dev-v2/migration/#changes-to-config for more information.
model_config = ConfigDict( pass
from_attributes=True,
# json_loads=orjson.loads,
# json_dumps=orjson_dumps
)

View file

@ -1,7 +1,7 @@
# Path: src/backend/langflow/database/models/flow.py # Path: src/backend/langflow/database/models/flow.py
from langflow.services.database.models.base import SQLModelSerializable from langflow.services.database.models.base import SQLModelSerializable
from pydantic import validator from pydantic import field_validator
from sqlmodel import Field, JSON, Column, Relationship from sqlmodel import Field, JSON, Column, Relationship
from uuid import UUID, uuid4 from uuid import UUID, uuid4
@ -16,7 +16,7 @@ class FlowBase(SQLModelSerializable):
description: Optional[str] = Field(index=True, nullable=True, default=None) description: Optional[str] = Field(index=True, nullable=True, default=None)
data: Optional[Dict] = Field(default=None, nullable=True) data: Optional[Dict] = Field(default=None, nullable=True)
@validator("data") @field_validator("data")
def validate_json(v): def validate_json(v):
if not v: if not v:
return v return v

View file

@ -5,7 +5,7 @@ from typing import Optional, List
from pathlib import Path from pathlib import Path
import yaml import yaml
from pydantic import root_validator, validator from pydantic import validator, model_validator
from pydantic_settings import BaseSettings from pydantic_settings import BaseSettings
from langflow.utils.logger import logger from langflow.utils.logger import logger
@ -88,7 +88,7 @@ class Settings(BaseSettings):
extra = "ignore" extra = "ignore"
env_prefix = "LANGFLOW_" env_prefix = "LANGFLOW_"
@root_validator(allow_reuse=True) @model_validator(mode="after")
def validate_lists(cls, values): def validate_lists(cls, values):
for key, value in values.items(): for key, value in values.items():
if key != "dev" and not value: if key != "dev" and not value: