mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-07-23 20:26:15 +00:00
style: code format (#1513)
This commit is contained in:
parent
f389a0c32d
commit
c8fb508fe4
@ -111,13 +111,23 @@ class Chunk(Document):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def chunk2langchain(cls, chunk):
|
def chunk2langchain(cls, chunk):
|
||||||
"""Transform Chunk to Langchain format."""
|
"""Transform Chunk to Langchain format."""
|
||||||
from langchain.schema import Document as LCDocument
|
try:
|
||||||
|
from langchain.schema import Document as LCDocument # mypy: ignore
|
||||||
|
except ImportError:
|
||||||
|
raise ValueError(
|
||||||
|
"Could not import python package: langchain "
|
||||||
|
"Please install langchain by command `pip install langchain"
|
||||||
|
)
|
||||||
return LCDocument(page_content=chunk.content, metadata=chunk.metadata)
|
return LCDocument(page_content=chunk.content, metadata=chunk.metadata)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def chunk2llamaindex(cls, chunk):
|
def chunk2llamaindex(cls, chunk):
|
||||||
"""Transform Chunk to llama-index format."""
|
"""Transform Chunk to llama-index format."""
|
||||||
from llama_index.schema import TextNode
|
try:
|
||||||
|
from llama_index.schema import TextNode
|
||||||
|
except ImportError:
|
||||||
|
raise ValueError(
|
||||||
|
"Could not import python package: llama_index "
|
||||||
|
"Please install llama_index by command `pip install llama_index"
|
||||||
|
)
|
||||||
return TextNode(text=chunk.content, metadata=chunk.metadata)
|
return TextNode(text=chunk.content, metadata=chunk.metadata)
|
||||||
|
@ -5,7 +5,9 @@ from typing import TYPE_CHECKING, List
|
|||||||
from dbgpt.core import Embeddings
|
from dbgpt.core import Embeddings
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from langchain.embeddings.base import Embeddings as LangChainEmbeddings
|
from langchain.embeddings.base import (
|
||||||
|
Embeddings as LangChainEmbeddings, # mypy: ignore
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
class WrappedEmbeddings(Embeddings):
|
class WrappedEmbeddings(Embeddings):
|
||||||
|
@ -37,7 +37,7 @@ class URLKnowledge(Knowledge):
|
|||||||
if self._loader:
|
if self._loader:
|
||||||
documents = self._loader.load()
|
documents = self._loader.load()
|
||||||
else:
|
else:
|
||||||
from langchain.document_loaders import WebBaseLoader
|
from langchain.document_loaders import WebBaseLoader # mypy: ignore
|
||||||
|
|
||||||
if self._path is not None:
|
if self._path is not None:
|
||||||
web_reader = WebBaseLoader(web_path=self._path)
|
web_reader = WebBaseLoader(web_path=self._path)
|
||||||
|
@ -56,8 +56,12 @@ class PGVectorStore(VectorStoreBase):
|
|||||||
|
|
||||||
def __init__(self, vector_store_config: PGVectorConfig) -> None:
|
def __init__(self, vector_store_config: PGVectorConfig) -> None:
|
||||||
"""Create a PGVectorStore instance."""
|
"""Create a PGVectorStore instance."""
|
||||||
from langchain.vectorstores import PGVector
|
try:
|
||||||
|
from langchain.vectorstores import PGVector # mypy: ignore
|
||||||
|
except ImportError:
|
||||||
|
raise ImportError(
|
||||||
|
"Please install the `langchain` package to use the PGVector."
|
||||||
|
)
|
||||||
self.connection_string = vector_store_config.connection_string
|
self.connection_string = vector_store_config.connection_string
|
||||||
self.embeddings = vector_store_config.embedding_fn
|
self.embeddings = vector_store_config.embedding_fn
|
||||||
self.collection_name = vector_store_config.name
|
self.collection_name = vector_store_config.name
|
||||||
|
1
setup.py
1
setup.py
@ -418,6 +418,7 @@ def core_requires():
|
|||||||
"typeguard",
|
"typeguard",
|
||||||
# Snowflake no additional dependencies.
|
# Snowflake no additional dependencies.
|
||||||
"snowflake-id",
|
"snowflake-id",
|
||||||
|
"typing_inspect",
|
||||||
]
|
]
|
||||||
# For DB-GPT python client SDK
|
# For DB-GPT python client SDK
|
||||||
setup_spec.extras["client"] = setup_spec.extras["core"] + [
|
setup_spec.extras["client"] = setup_spec.extras["core"] + [
|
||||||
|
Loading…
Reference in New Issue
Block a user