feat: integrate nano-graphrag (#433)

* add nano graph-rag

* ignore entities for relevant context reference

* refactor and add local model as default nano-graphrag

* feat: add kotaemon llm & embedding integration with nanographrag

* fix: add env var for nano GraphRAG

---------

Co-authored-by: Tadashi <tadashi@cinnamon.is>
This commit is contained in:
cin-klein
2024-10-30 15:32:30 +07:00
committed by GitHub
parent 19b386b51e
commit 66e565649e
7 changed files with 470 additions and 18 deletions

View File

@@ -284,11 +284,43 @@ SETTINGS_REASONING = {
},
}
USE_NANO_GRAPHRAG = config("USE_NANO_GRAPHRAG", default=False, cast=bool)
GRAPHRAG_INDEX_TYPE = (
"ktem.index.file.graph.GraphRAGIndex"
if not USE_NANO_GRAPHRAG
else "ktem.index.file.graph.NanoGraphRAGIndex"
)
KH_INDEX_TYPES = [
"ktem.index.file.FileIndex",
"ktem.index.file.graph.GraphRAGIndex",
GRAPHRAG_INDEX_TYPE,
]
GRAPHRAG_INDEX = (
{
"name": "GraphRAG",
"config": {
"supported_file_types": (
".png, .jpeg, .jpg, .tiff, .tif, .pdf, .xls, .xlsx, .doc, .docx, "
".pptx, .csv, .html, .mhtml, .txt, .md, .zip"
),
"private": False,
},
"index_type": "ktem.index.file.graph.GraphRAGIndex",
}
if not USE_NANO_GRAPHRAG
else {
"name": "NanoGraphRAG",
"config": {
"supported_file_types": (
".png, .jpeg, .jpg, .tiff, .tif, .pdf, .xls, .xlsx, .doc, .docx, "
".pptx, .csv, .html, .mhtml, .txt, .md, .zip"
),
"private": False,
},
"index_type": "ktem.index.file.graph.NanoGraphRAGIndex",
}
)
KH_INDICES = [
{
"name": "File",
@@ -301,15 +333,5 @@ KH_INDICES = [
},
"index_type": "ktem.index.file.FileIndex",
},
{
"name": "GraphRAG",
"config": {
"supported_file_types": (
".png, .jpeg, .jpg, .tiff, .tif, .pdf, .xls, .xlsx, .doc, .docx, "
".pptx, .csv, .html, .mhtml, .txt, .md, .zip"
),
"private": False,
},
"index_type": "ktem.index.file.graph.GraphRAGIndex",
},
GRAPHRAG_INDEX,
]