Fix disallowed_special parameter and refactor CharacterTextSplitterComponent (#1410)

This pull request fixes the disallowed_special parameter in the OpenAIEmbeddingsComponent and refactors the CharacterTextSplitterComponent to use typing and update the return value. It also updates the ChromaComponent configuration and bumps the version to 0.6.7a1 in pyproject.toml.
This commit is contained in:
Gabriel Luiz Freitas Almeida 2024-02-07 18:59:58 -03:00 committed by GitHub
commit e260ee1470
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 6 deletions

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "langflow"
version = "0.6.6"
version = "0.6.7a1"
description = "A Python package with a built-in web application"
authors = ["Logspace <contact@logspace.ai>"]
maintainers = [

View file

@ -95,12 +95,15 @@ class OpenAIEmbeddingsComponent(CustomComponent):
tikToken_enable: bool = True,
tiktoken_model_name: Optional[str] = None,
) -> Union[OpenAIEmbeddings, Callable]:
# This is to avoid errors with Vector Stores (e.g Chroma)
if disallowed_special == ["all"]:
disallowed_special = "all"
return OpenAIEmbeddings(
tiktoken_enabled=tikToken_enable,
default_headers=default_headers,
default_query=default_query,
allowed_special=set(allowed_special),
disallowed_special=set(disallowed_special),
disallowed_special="all",
chunk_size=chunk_size,
client=client,
deployment=deployment,

View file

@ -1,7 +1,8 @@
from langflow import CustomComponent
from typing import List
from langchain.text_splitter import CharacterTextSplitter
from langchain_core.documents.base import Document
from typing import List
from langflow import CustomComponent
class CharacterTextSplitterComponent(CustomComponent):
@ -23,8 +24,10 @@ class CharacterTextSplitterComponent(CustomComponent):
chunk_size: int = 1000,
separator: str = "\n",
) -> List[Document]:
return CharacterTextSplitter(
docs = CharacterTextSplitter(
chunk_overlap=chunk_overlap,
chunk_size=chunk_size,
separator=separator,
).split_documents(documents)
self.status = docs
return docs

View file

@ -29,7 +29,7 @@ class ChromaComponent(CustomComponent):
"collection_name": {"display_name": "Collection Name", "value": "langflow"},
"persist": {"display_name": "Persist"},
"persist_directory": {"display_name": "Persist Directory"},
"code": {"show": False, "display_name": "Code"},
"code": {"advanced": True, "display_name": "Code"},
"documents": {"display_name": "Documents", "is_list": True},
"embedding": {"display_name": "Embedding"},
"chroma_server_cors_allow_origins": {