-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into ollamaclient
- Loading branch information
Showing
119 changed files
with
11,273 additions
and
2,219 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from dataclasses import dataclass | ||
from enum import Enum, auto | ||
from typing import Optional | ||
|
||
|
||
class DocumentType(Enum): | ||
""" | ||
Enum for supporting document type. | ||
""" | ||
|
||
TEXT = auto() | ||
HTML = auto() | ||
PDF = auto() | ||
|
||
|
||
@dataclass | ||
class Document: | ||
""" | ||
A wrapper of graph store query results. | ||
""" | ||
|
||
doctype: DocumentType | ||
data: Optional[object] = None | ||
path_or_url: Optional[str] = "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
from dataclasses import dataclass, field | ||
from typing import List, Optional, Protocol | ||
|
||
from .document import Document | ||
|
||
|
||
@dataclass | ||
class GraphStoreQueryResult: | ||
""" | ||
A wrapper of graph store query results. | ||
answer: human readable answer to question/query. | ||
results: intermediate results to question/query, e.g. node entities. | ||
""" | ||
|
||
answer: Optional[str] = None | ||
results: list = field(default_factory=list) | ||
|
||
|
||
class GraphQueryEngine(Protocol): | ||
"""An abstract base class that represents a graph query engine on top of a underlying graph database. | ||
This interface defines the basic methods for graph rag. | ||
""" | ||
|
||
def init_db(self, input_doc: List[Document] | None = None): | ||
""" | ||
This method initializes graph database with the input documents or records. | ||
Usually, it takes the following steps, | ||
1. connecting to a graph database. | ||
2. extract graph nodes, edges based on input data, graph schema and etc. | ||
3. build indexes etc. | ||
Args: | ||
input_doc: a list of input documents that are used to build the graph in database. | ||
Returns: GraphStore | ||
""" | ||
pass | ||
|
||
def add_records(self, new_records: List) -> bool: | ||
""" | ||
Add new records to the underlying database and add to the graph if required. | ||
""" | ||
pass | ||
|
||
def query(self, question: str, n_results: int = 1, **kwargs) -> GraphStoreQueryResult: | ||
""" | ||
This method transform a string format question into database query and return the result. | ||
""" | ||
pass |
Oops, something went wrong.