Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add graphrag to ui #278

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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