Skip to content

Commit

Permalink
add graphrag to ui
Browse files Browse the repository at this point in the history
  • Loading branch information
parkererickson-tg committed Nov 22, 2024
1 parent d9672c4 commit c4479af
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion copilot-ui/src/components/Bot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ const Bot = ({ layout, getConversationId }: { layout?: string | undefined, getCo
<DropdownMenuLabel>Select a RAG Pattern</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuGroup>
{["HNSW", "HNSW_Overlap", "Sibling"].map((f, i) => (
{["HNSW", "HNSW_Overlap", "Sibling", "GraphRAG"].map((f, i) => (
<DropdownMenuItem key={i} onSelect={() => handleSelectRag(f)}>
{/* <User className="mr-2 h-4 w-4" /> */}
<span>{f}</span>
Expand Down
30 changes: 29 additions & 1 deletion copilot/app/agent/agent_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from langgraph.graph import END, StateGraph
from pyTigerGraph.pyTigerGraphException import TigerGraphException
from supportai.retrievers import (HNSWOverlapRetriever, HNSWRetriever,
HNSWSiblingRetriever)
HNSWSiblingRetriever, GraphRAG)
from tools import MapQuestionToSchemaException
from typing_extensions import TypedDict

Expand Down Expand Up @@ -272,6 +272,32 @@ def sibling_search(self, state):
state["lookup_source"] = "supportai"
return state

def graphrag_search(self, state):
"""
Run the agent graphrag search.
"""
self.emit_progress("Searching the knowledge graph")
retriever = GraphRAG(
self.embedding_model,
self.embedding_store,
self.llm_provider.model,
self.db_connection,
)
step = retriever.search(
state["question"],
community_level=3
)

state["context"] = {
"function_call": "GraphRAG",
"result": {"@@final_retrieval": step[0]},
"query_output_format": self.db_connection.getQueryMetadata(
"GraphRAG_Community_Retriever"
)["output"],
}
state["lookup_source"] = "supportai"
return state

def supportai_search(self, state):
"""
Run the agent supportai search.
Expand All @@ -283,6 +309,8 @@ def supportai_search(self, state):
return self.hnsw_search(state)
elif self.supportai_retriever == "sibling":
return self.sibling_search(state)
elif self.supportai_retriever == "graphrag":
return self.graphrag_search(state)
else:
raise ValueError(f"Invalid supportai retriever: {self.supportai_retriever}")

Expand Down
2 changes: 1 addition & 1 deletion eventual-consistency-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.11.8
FROM python:3.11.8-bullseye
WORKDIR /code

COPY common/requirements.txt requirements.txt
Expand Down

0 comments on commit c4479af

Please sign in to comment.