Refactor DocumentLoaderVertex to use record instead of doc and update display message format
This commit is contained in:
parent
d403ca7a6c
commit
16c8d5be0c
1 changed files with 8 additions and 7 deletions
|
|
@ -1,6 +1,7 @@
|
||||||
import ast
|
import ast
|
||||||
import json
|
import json
|
||||||
from typing import AsyncIterator, Callable, Dict, Iterator, List, Optional, Union
|
from typing import (AsyncIterator, Callable, Dict, Iterator, List, Optional,
|
||||||
|
Union)
|
||||||
|
|
||||||
import yaml
|
import yaml
|
||||||
from langchain_core.messages import AIMessage
|
from langchain_core.messages import AIMessage
|
||||||
|
|
@ -124,13 +125,13 @@ class DocumentLoaderVertex(Vertex):
|
||||||
|
|
||||||
if not isinstance(self._built_object, UnbuiltObject):
|
if not isinstance(self._built_object, UnbuiltObject):
|
||||||
avg_length = sum(
|
avg_length = sum(
|
||||||
len(doc.page_content)
|
len(record.text)
|
||||||
for doc in self._built_object
|
for record in self._built_object
|
||||||
if hasattr(doc, "page_content")
|
if hasattr(record, "text")
|
||||||
) / len(self._built_object)
|
) / len(self._built_object)
|
||||||
return f"""{self.display_name}({len(self._built_object)} documents)
|
return f"""{self.display_name}({len(self._built_object)} records)
|
||||||
\nAvg. Document Length (characters): {int(avg_length)}
|
\nAvg. Record Length (characters): {int(avg_length)}
|
||||||
Documents: {self._built_object[:3]}..."""
|
Records: {self._built_object[:3]}..."""
|
||||||
return f"{self.vertex_type}()"
|
return f"{self.vertex_type}()"
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue