mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-16 22:51:24 +00:00
chore: Add pylint for DB-GPT rag lib (#1267)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
"""String Knowledge."""
|
||||
from typing import Any, List, Optional
|
||||
|
||||
from dbgpt.rag.chunk import Document
|
||||
@@ -5,22 +6,23 @@ from dbgpt.rag.knowledge.base import ChunkStrategy, Knowledge, KnowledgeType
|
||||
|
||||
|
||||
class StringKnowledge(Knowledge):
|
||||
"""String Knowledge"""
|
||||
"""String Knowledge."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
text: str = None,
|
||||
text: str = "",
|
||||
knowledge_type: KnowledgeType = KnowledgeType.TEXT,
|
||||
encoding: Optional[str] = "utf-8",
|
||||
loader: Optional[Any] = None,
|
||||
**kwargs: Any,
|
||||
) -> None:
|
||||
"""Initialize with Knowledge arguments.
|
||||
"""Create String knowledge parameters.
|
||||
|
||||
Args:
|
||||
text:(str) text
|
||||
knowledge_type:(KnowledgeType) knowledge type
|
||||
encoding:(encoding) csv encoding
|
||||
loader:(loader) loader
|
||||
text(str): text
|
||||
knowledge_type(KnowledgeType): knowledge type
|
||||
encoding(str): encoding
|
||||
loader(Any): loader
|
||||
"""
|
||||
self._text = text
|
||||
self._type = knowledge_type
|
||||
@@ -28,21 +30,25 @@ class StringKnowledge(Knowledge):
|
||||
self._encoding = encoding
|
||||
|
||||
def _load(self) -> List[Document]:
|
||||
"""load raw text from loader"""
|
||||
"""Load raw text from loader."""
|
||||
metadata = {"source": "raw text"}
|
||||
docs = [Document(content=self._text, metadata=metadata)]
|
||||
return docs
|
||||
|
||||
@classmethod
|
||||
def support_chunk_strategy(cls) -> List[ChunkStrategy]:
|
||||
"""Return support chunk strategy."""
|
||||
return [
|
||||
ChunkStrategy.CHUNK_BY_SIZE,
|
||||
ChunkStrategy.CHUNK_BY_SEPARATOR,
|
||||
]
|
||||
|
||||
@classmethod
|
||||
def default_chunk_strategy(cls) -> ChunkStrategy:
|
||||
"""Return default chunk strategy."""
|
||||
return ChunkStrategy.CHUNK_BY_SIZE
|
||||
|
||||
@classmethod
|
||||
def type(cls):
|
||||
"""Return knowledge type."""
|
||||
return KnowledgeType.TEXT
|
||||
|
Reference in New Issue
Block a user