Skip to content

Commit

Permalink
Add graphrag (#1793)
Browse files Browse the repository at this point in the history
### What problem does this PR solve?

#1594

### Type of change

- [x] New Feature (non-breaking change which adds functionality)
  • Loading branch information
KevinHuSh authored Aug 2, 2024
1 parent 80032b1 commit 152072f
Show file tree
Hide file tree
Showing 74 changed files with 2,522 additions and 105 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions graph/canvas.py → agent/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@

import pandas as pd

from graph.component import component_class
from graph.component.base import ComponentBase
from graph.settings import flow_logger, DEBUG
from agent.component import component_class
from agent.component.base import ComponentBase
from agent.settings import flow_logger, DEBUG


class Canvas(ABC):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion graph/component/answer.py → agent/component/answer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import pandas as pd

from graph.component.base import ComponentBase, ComponentParamBase
from agent.component.base import ComponentBase, ComponentParamBase


class AnswerParam(ComponentParamBase):
Expand Down
6 changes: 2 additions & 4 deletions graph/component/arxiv.py → agent/component/arxiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import random
from abc import ABC
from functools import partial
import arxiv
import pandas as pd
from graph.settings import DEBUG
from graph.component.base import ComponentBase, ComponentParamBase
from agent.settings import DEBUG
from agent.component.base import ComponentBase, ComponentParamBase


class ArXivParam(ComponentParamBase):
Expand Down
4 changes: 2 additions & 2 deletions graph/component/baidu.py → agent/component/baidu.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
import pandas as pd
import requests
import re
from graph.settings import DEBUG
from graph.component.base import ComponentBase, ComponentParamBase
from agent.settings import DEBUG
from agent.component.base import ComponentBase, ComponentParamBase


class BaiduParam(ComponentParamBase):
Expand Down
4 changes: 2 additions & 2 deletions graph/component/base.py → agent/component/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@

import pandas as pd

from graph import settings
from graph.settings import flow_logger, DEBUG
from agent import settings
from agent.settings import flow_logger, DEBUG

_FEEDED_DEPRECATED_PARAMS = "_feeded_deprecated_params"
_DEPRECATED_PARAMS = "_deprecated_params"
Expand Down
5 changes: 2 additions & 3 deletions graph/component/begin.py → agent/component/begin.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import json
from functools import partial

import pandas as pd
from graph.component.base import ComponentBase, ComponentParamBase
from agent.component.base import ComponentBase, ComponentParamBase


class BeginParam(ComponentParamBase):

Expand Down
4 changes: 2 additions & 2 deletions graph/component/bing.py → agent/component/bing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from abc import ABC
import requests
import pandas as pd
from graph.settings import DEBUG
from graph.component.base import ComponentBase, ComponentParamBase
from agent.settings import DEBUG
from agent.component.base import ComponentBase, ComponentParamBase


class BingParam(ComponentParamBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@
# limitations under the License.
#
from abc import ABC

import pandas as pd

from api.db import LLMType
from api.db.services.llm_service import LLMBundle
from graph.component import GenerateParam, Generate
from graph.settings import DEBUG
from agent.component import GenerateParam, Generate
from agent.settings import DEBUG


class CategorizeParam(GenerateParam):
Expand Down
2 changes: 1 addition & 1 deletion graph/component/cite.py → agent/component/cite.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from api.db.services.knowledgebase_service import KnowledgebaseService
from api.db.services.llm_service import LLMBundle
from api.settings import retrievaler
from graph.component.base import ComponentBase, ComponentParamBase
from agent.component.base import ComponentBase, ComponentParamBase


class CiteParam(ComponentParamBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import random
from abc import ABC
from functools import partial
from duckduckgo_search import DDGS
import pandas as pd
from graph.settings import DEBUG
from graph.component.base import ComponentBase, ComponentParamBase
from agent.settings import DEBUG
from agent.component.base import ComponentBase, ComponentParamBase


class DuckDuckGoParam(ComponentParamBase):
Expand Down
4 changes: 1 addition & 3 deletions graph/component/generate.py → agent/component/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@
#
import re
from functools import partial

import pandas as pd

from api.db import LLMType
from api.db.services.llm_service import LLMBundle
from api.settings import retrievaler
from graph.component.base import ComponentBase, ComponentParamBase
from agent.component.base import ComponentBase, ComponentParamBase


class GenerateParam(ComponentParamBase):
Expand Down
4 changes: 2 additions & 2 deletions graph/component/google.py → agent/component/google.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
from abc import ABC
from serpapi import GoogleSearch
import pandas as pd
from graph.settings import DEBUG
from graph.component.base import ComponentBase, ComponentParamBase
from agent.settings import DEBUG
from agent.component.base import ComponentBase, ComponentParamBase


class GoogleParam(ComponentParamBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#
from abc import ABC
import pandas as pd
from graph.settings import DEBUG
from graph.component.base import ComponentBase, ComponentParamBase
from agent.settings import DEBUG
from agent.component.base import ComponentBase, ComponentParamBase
from scholarly import scholarly


Expand Down
4 changes: 2 additions & 2 deletions graph/component/keyword.py → agent/component/keyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from abc import ABC
from api.db import LLMType
from api.db.services.llm_service import LLMBundle
from graph.component import GenerateParam, Generate
from graph.settings import DEBUG
from agent.component import GenerateParam, Generate
from agent.settings import DEBUG


class KeywordExtractParam(GenerateParam):
Expand Down
5 changes: 1 addition & 4 deletions graph/component/message.py → agent/component/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@
import random
from abc import ABC
from functools import partial

import pandas as pd

from graph.component.base import ComponentBase, ComponentParamBase
from agent.component.base import ComponentBase, ComponentParamBase


class MessageParam(ComponentParamBase):
Expand Down
6 changes: 2 additions & 4 deletions graph/component/pubmed.py → agent/component/pubmed.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
import random
from abc import ABC
from functools import partial
from Bio import Entrez
import pandas as pd
import xml.etree.ElementTree as ET
from graph.settings import DEBUG
from graph.component.base import ComponentBase, ComponentParamBase
from agent.settings import DEBUG
from agent.component.base import ComponentBase, ComponentParamBase


class PubMedParam(ComponentParamBase):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from abc import ABC
from api.db import LLMType
from api.db.services.llm_service import LLMBundle
from graph.component import GenerateParam, Generate
from agent.component import GenerateParam, Generate
from rag.utils import num_tokens_from_string, encoder


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from api.db.services.knowledgebase_service import KnowledgebaseService
from api.db.services.llm_service import LLMBundle
from api.settings import retrievaler
from graph.component.base import ComponentBase, ComponentParamBase
from agent.component.base import ComponentBase, ComponentParamBase


class RetrievalParam(ComponentParamBase):
Expand Down
2 changes: 1 addition & 1 deletion graph/component/rewrite.py → agent/component/rewrite.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from abc import ABC
from api.db import LLMType
from api.db.services.llm_service import LLMBundle
from graph.component import GenerateParam, Generate
from agent.component import GenerateParam, Generate


class RewriteQuestionParam(GenerateParam):
Expand Down
7 changes: 1 addition & 6 deletions graph/component/switch.py → agent/component/switch.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,7 @@
from abc import ABC

import pandas as pd

from api.db import LLMType
from api.db.services.knowledgebase_service import KnowledgebaseService
from api.db.services.llm_service import LLMBundle
from api.settings import retrievaler
from graph.component.base import ComponentBase, ComponentParamBase
from agent.component.base import ComponentBase, ComponentParamBase


class SwitchParam(ComponentParamBase):
Expand Down
4 changes: 2 additions & 2 deletions graph/component/wikipedia.py → agent/component/wikipedia.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
from functools import partial
import wikipedia
import pandas as pd
from graph.settings import DEBUG
from graph.component.base import ComponentBase, ComponentParamBase
from agent.settings import DEBUG
from agent.component.base import ComponentBase, ComponentParamBase


class WikipediaParam(ComponentParamBase):
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
5 changes: 2 additions & 3 deletions graph/test/client.py → agent/test/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@
import argparse
import os
from functools import partial
import readline
from graph.canvas import Canvas
from graph.settings import DEBUG
from agent.canvas import Canvas
from agent.settings import DEBUG

if __name__ == '__main__':
parser = argparse.ArgumentParser()
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 1 addition & 3 deletions api/apps/api_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from flask import request, Response
from flask_login import login_required, current_user

from api.db import FileType, ParserType, FileSource, LLMType
from api.db import FileType, ParserType, FileSource
from api.db.db_models import APIToken, API4Conversation, Task, File
from api.db.services import duplicate_name
from api.db.services.api_service import APITokenService, API4ConversationService
Expand All @@ -29,7 +29,6 @@
from api.db.services.file2document_service import File2DocumentService
from api.db.services.file_service import FileService
from api.db.services.knowledgebase_service import KnowledgebaseService
from api.db.services.llm_service import TenantLLMService
from api.db.services.task_service import queue_tasks, TaskService
from api.db.services.user_service import UserTenantService
from api.settings import RetCode, retrievaler
Expand All @@ -38,7 +37,6 @@
from itsdangerous import URLSafeTimedSerializer

from api.utils.file_utils import filename_type, thumbnail
from rag.nlp import keyword_extraction
from rag.utils.minio_conn import MINIO


Expand Down
5 changes: 1 addition & 4 deletions api/apps/canvas_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@
#
import json
from functools import partial

from flask import request, Response
from flask_login import login_required, current_user

from api.db.db_models import UserCanvas
from api.db.services.canvas_service import CanvasTemplateService, UserCanvasService
from api.utils import get_uuid
from api.utils.api_utils import get_json_result, server_error_response, validate_request
from graph.canvas import Canvas
from agent.canvas import Canvas


@manager.route('/templates', methods=['GET'])
Expand Down
Loading

0 comments on commit 152072f

Please sign in to comment.