refactor(base.py): remove unnecessary comment
feat(base.py): add support for int type in node value feat(base.py): add support for chunk_size and chunk_overlap in TextSplitterCreator signature
This commit is contained in:
parent
b56d905042
commit
6d2f948bdb
2 changed files with 22 additions and 2 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
# - Defer prompts building to the last moment or when they have all the tools
|
# - Defer prompts building to the last moment or when they have all the tools
|
||||||
# - Build each inner agent first, then build the outer agent
|
# - Build each inner agent first, then build the outer agent
|
||||||
|
|
||||||
|
import contextlib
|
||||||
import types
|
import types
|
||||||
import warnings
|
import warnings
|
||||||
from copy import deepcopy
|
from copy import deepcopy
|
||||||
|
|
@ -94,8 +95,6 @@ class Node:
|
||||||
|
|
||||||
params[key] = file_path
|
params[key] = file_path
|
||||||
|
|
||||||
# We should check if the type is in something not
|
|
||||||
# the opposite
|
|
||||||
elif value.get("type") not in DIRECT_TYPES:
|
elif value.get("type") not in DIRECT_TYPES:
|
||||||
# Get the edge that connects to this node
|
# Get the edge that connects to this node
|
||||||
edges = [
|
edges = [
|
||||||
|
|
@ -129,6 +128,9 @@ class Node:
|
||||||
new_value = value.get("value")
|
new_value = value.get("value")
|
||||||
if new_value is None:
|
if new_value is None:
|
||||||
warnings.warn(f"Value for {key} in {self.node_type} is None. ")
|
warnings.warn(f"Value for {key} in {self.node_type} is None. ")
|
||||||
|
if value.get("type") == "int":
|
||||||
|
with contextlib.suppress(TypeError, ValueError):
|
||||||
|
new_value = int(new_value) # type: ignore
|
||||||
params[key] = new_value
|
params[key] = new_value
|
||||||
|
|
||||||
# Add _type to params
|
# Add _type to params
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,24 @@ class TextSplitterCreator(LangChainTypeCreator):
|
||||||
"display_name": "Separator",
|
"display_name": "Separator",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
signature["template"]["chunk_size"] = {
|
||||||
|
"type": "int",
|
||||||
|
"required": True,
|
||||||
|
"show": True,
|
||||||
|
"value": 4000,
|
||||||
|
"name": "chunk_size",
|
||||||
|
"display_name": "Chunk Size",
|
||||||
|
}
|
||||||
|
|
||||||
|
signature["template"]["chunk_overlap"] = {
|
||||||
|
"type": "int",
|
||||||
|
"required": True,
|
||||||
|
"show": True,
|
||||||
|
"value": 200,
|
||||||
|
"name": "chunk_overlap",
|
||||||
|
"display_name": "Chunk Overlap",
|
||||||
|
}
|
||||||
|
|
||||||
return signature
|
return signature
|
||||||
except ValueError as exc:
|
except ValueError as exc:
|
||||||
raise ValueError(f"Text Splitter {name} not found") from exc
|
raise ValueError(f"Text Splitter {name} not found") from exc
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue