Hotfix: 0.2.6 -> Docs and TextSplitter bug (#564)

This commit is contained in:
Gabriel Luiz Freitas Almeida 2023-06-28 18:32:51 -03:00 • committed by GitHub
commit 98fb7c84c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 11 deletions

6
poetry.lock generated
View file

@ -2523,14 +2523,14 @@ i18n = ["Babel (>=2.7)"]
[[package]] [[package]]
name = "joblib" name = "joblib"
version = "1.2.0" version = "1.3.0"
description = "Lightweight pipelining with Python functions" description = "Lightweight pipelining with Python functions"
category = "main" category = "main"
optional = false optional = false
python-versions = ">=3.7" python-versions = ">=3.7"
files = [ files = [
{file = "joblib-1.2.0-py3-none-any.whl", hash = "sha256:091138ed78f800342968c523bdde947e7a305b8594b910a0fea2ab83c3c6d385"}, {file = "joblib-1.3.0-py3-none-any.whl", hash = "sha256:172d56d4c43dd6bcd953bea213018c4084cf754963bbf54b8dae40faea716b98"},
{file = "joblib-1.2.0.tar.gz", hash = "sha256:e1cee4a79e4af22881164f218d4311f60074197fb707e082e803b61f6d137018"}, {file = "joblib-1.3.0.tar.gz", hash = "sha256:0b12a65dc76c530dbd790dd92881f75c40932b4254a7c8e608a868df408ca0a3"},
] ]
[[package]] [[package]]

View file

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

View file

@ -121,7 +121,7 @@ llms:
documentation: "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/huggingface_hub" documentation: "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/huggingface_hub"
memories: memories:
ConversationBufferMemory: ConversationBufferMemory:
documentation: "https://python.langchain.com/docs/modules/memory/how_to/summary" documentation: "https://python.langchain.com/docs/modules/memory/how_to/buffer"
ConversationSummaryMemory: ConversationSummaryMemory:
documentation: "https://python.langchain.com/docs/modules/memory/how_to/summary" documentation: "https://python.langchain.com/docs/modules/memory/how_to/summary"
ConversationKGMemory: ConversationKGMemory:

View file

@ -221,14 +221,17 @@ def instantiate_textsplitter(
) from exc ) from exc
if ( if (
"separator_type" in params "separator_type" in params and params["separator_type"] == "Text"
and params["separator_type"] == "Text" ) or "separator_type" not in params:
or "separator_type" not in params params.pop("separator_type", None)
):
text_splitter = class_object(**params) text_splitter = class_object(**params)
else: else:
params["language"] = params.pop("separator_type", None) from langchain.text_splitter import Language
language = params.pop("separator_type", None)
params["language"] = Language(language)
params.pop("separators", None) params.pop("separators", None)
text_splitter = class_object.from_language(**params) text_splitter = class_object.from_language(**params)
return text_splitter.split_documents(documents) return text_splitter.split_documents(documents)

View file

@ -21,6 +21,8 @@ class TextSplittersFrontendNode(FrontendNode):
# Add a field for type of separator # Add a field for type of separator
# which will have Text or any value from the # which will have Text or any value from the
# Language enum # Language enum
options = [x.value for x in Language] + ["Text"]
options.sort()
self.template.add_field( self.template.add_field(
TemplateField( TemplateField(
field_type="str", field_type="str",
@ -29,7 +31,7 @@ class TextSplittersFrontendNode(FrontendNode):
name="separator_type", name="separator_type",
advanced=False, advanced=False,
is_list=True, is_list=True,
options=[x.value for x in Language], options=options,
value="Text", value="Text",
display_name="Separator Type", display_name="Separator Type",
) )