Skip to content

Commit

Permalink
fixed;
Browse files Browse the repository at this point in the history
  • Loading branch information
KingSkyLi committed Aug 30, 2024
1 parent 34353e8 commit 9c9d661
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions examples/rag/graph_rag_summary_example.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
import asyncio
import os

from dbgpt.configs.model_config import ROOT_PATH
from dbgpt.configs.model_config import ROOT_PATH, MODEL_PATH
from dbgpt.model.proxy.llms.chatgpt import OpenAILLMClient
from dbgpt.rag import ChunkParameters
from dbgpt.rag.assembler import EmbeddingAssembler
from dbgpt.rag.knowledge import KnowledgeFactory
from dbgpt.rag.embedding import DefaultEmbeddingFactory
from dbgpt.rag.retriever import RetrieverStrategy
from dbgpt.storage.knowledge_graph.community_summary import (
CommunitySummaryKnowledgeGraph,
CommunitySummaryKnowledgeGraphConfig,
)
from dbgpt.storage.knowledge_graph.knowledge_graph import BuiltinKnowledgeGraphConfig



"""GraphRAG example.
pre-requirements:
* Set LLM config (url/sk) in `.env`.
Expand All @@ -25,6 +28,7 @@
TUGRAPH_USERNAME=admin
TUGRAPH_PASSWORD=73@TuGraph
GRAPH_COMMUNITY_SUMMARY_ENABLED=True
TUGRAPH_PLUGIN_NAMES=leiden
```
Examples:
..code-block:: shell
Expand All @@ -36,9 +40,14 @@ def _create_kg_connector():
"""Create knowledge graph connector."""
return CommunitySummaryKnowledgeGraph(
config=CommunitySummaryKnowledgeGraphConfig(
name="graph_rag_test",
embedding_fn=None,
llm_client=OpenAILLMClient(),
name="graph_rag_summary_test",
embedding_fn=DefaultEmbeddingFactory(
default_model_name=os.path.join(MODEL_PATH, "text2vec-large-chinese"),
).create(),
llm_client=OpenAILLMClient(
api_base=os.getenv('PROXY_SERVER_URL'),
api_key=os.getenv('PROXY_API_KEY'),
),
model_name="gpt-3.5-turbo",
),
)
Expand All @@ -63,7 +72,7 @@ async def main():
"What actions has Megatron taken ?", score_threshold=0.3
)
print(f"embedding rag example results:{chunks}")
graph_store.delete_vector_name("graph_rag_test")
graph_store.delete_vector_name("graph_rag_summary_test")


if __name__ == "__main__":
Expand Down

0 comments on commit 9c9d661

Please sign in to comment.