Merge branch 'main' into vertex_ai
This commit is contained in:
commit
5a69b479ff
6 changed files with 44 additions and 29 deletions
|
|
@ -123,7 +123,7 @@ llms:
|
|||
documentation: "https://python.langchain.com/docs/modules/model_io/models/llms/integrations/google_vertex_ai_palm"
|
||||
memories:
|
||||
ConversationBufferMemory:
|
||||
documentation: "https://python.langchain.com/docs/modules/memory/how_to/summary"
|
||||
documentation: "https://python.langchain.com/docs/modules/memory/how_to/buffer"
|
||||
ConversationSummaryMemory:
|
||||
documentation: "https://python.langchain.com/docs/modules/memory/how_to/summary"
|
||||
ConversationKGMemory:
|
||||
|
|
|
|||
|
|
@ -188,18 +188,22 @@ def instantiate_documentloader(class_object: Type[BaseLoader], params: Dict):
|
|||
extension.strip() in x for extension in extensions
|
||||
)
|
||||
metadata = params.pop("metadata", None)
|
||||
if metadata and isinstance(metadata, str):
|
||||
try:
|
||||
metadata = json.loads(metadata)
|
||||
except json.JSONDecodeError as exc:
|
||||
raise ValueError(
|
||||
"The metadata you provided is not a valid JSON string."
|
||||
) from exc
|
||||
docs = class_object(**params).load()
|
||||
# Now if metadata is an empty dict, we will not add it to the documents
|
||||
if metadata:
|
||||
if isinstance(metadata, str):
|
||||
try:
|
||||
metadata = json.loads(metadata)
|
||||
except json.JSONDecodeError as exc:
|
||||
raise ValueError(
|
||||
"The metadata you provided is not a valid JSON string."
|
||||
) from exc
|
||||
|
||||
for doc in docs:
|
||||
doc.metadata = metadata
|
||||
# If the document already has metadata, we will not overwrite it
|
||||
if not doc.metadata:
|
||||
doc.metadata = metadata
|
||||
else:
|
||||
doc.metadata.update(metadata)
|
||||
|
||||
return docs
|
||||
|
||||
|
|
@ -216,13 +220,19 @@ def instantiate_textsplitter(
|
|||
"Try changing the chunk_size of the Text Splitter."
|
||||
) from exc
|
||||
|
||||
if "separator_type" in params and params["separator_type"] == "Text":
|
||||
if (
|
||||
"separator_type" in params and params["separator_type"] == "Text"
|
||||
) or "separator_type" not in params:
|
||||
params.pop("separator_type", None)
|
||||
text_splitter = class_object(**params)
|
||||
else:
|
||||
params["language"] = params.pop("separator_type", None)
|
||||
params.pop("separators", None)
|
||||
text_splitter = class_object.from_language(**params)
|
||||
from langchain.text_splitter import Language
|
||||
|
||||
language = params.pop("separator_type", None)
|
||||
params["language"] = Language(language)
|
||||
params.pop("separators", None)
|
||||
|
||||
text_splitter = class_object.from_language(**params)
|
||||
return text_splitter.split_documents(documents)
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,8 @@ class TextSplittersFrontendNode(FrontendNode):
|
|||
# Add a field for type of separator
|
||||
# which will have Text or any value from the
|
||||
# Language enum
|
||||
options = [x.value for x in Language] + ["Text"]
|
||||
options.sort()
|
||||
self.template.add_field(
|
||||
TemplateField(
|
||||
field_type="str",
|
||||
|
|
@ -29,7 +31,7 @@ class TextSplittersFrontendNode(FrontendNode):
|
|||
name="separator_type",
|
||||
advanced=False,
|
||||
is_list=True,
|
||||
options=[x.value for x in Language],
|
||||
options=options,
|
||||
value="Text",
|
||||
display_name="Separator Type",
|
||||
)
|
||||
|
|
|
|||
|
|
@ -81,6 +81,8 @@ const NodeToolbarComponent = (props) => {
|
|||
? " text-muted-foreground"
|
||||
: " text-foreground")
|
||||
)}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
href={props.data.node.documentation}
|
||||
// deactivate link if no documentation is provided
|
||||
onClick={(event) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue