kevinhug commited on
Commit
034500c
·
1 Parent(s): 3c1b8db

knowledge graph

Browse files
Files changed (2) hide show
  1. app.py +2 -10
  2. knowledge.py +3 -2
app.py CHANGED
@@ -4,16 +4,8 @@ from tool import rival_product
4
  from graphrag import reasoning
5
  from knowledge import graph
6
 
7
- '''
8
- NotImplementedError: cannot instantiate ‘WindowsPath’ on your system
9
- '''
10
- import pathlib
11
- import platform
12
- plt = platform.system()
13
- if plt == 'Windows':
14
- pathlib.PosixPath = pathlib.WindowsPath
15
- else:
16
- pathlib.WindowsPath = pathlib.PosixPath
17
 
18
  with gr.Blocks() as demo:
19
  with gr.Tab("RAG"):
 
4
  from graphrag import reasoning
5
  from knowledge import graph
6
 
7
+
8
+
 
 
 
 
 
 
 
 
9
 
10
  with gr.Blocks() as demo:
11
  with gr.Tab("RAG"):
knowledge.py CHANGED
@@ -31,6 +31,7 @@ class KnowledgeGraph(BaseModel):
31
 
32
  from groq import Groq
33
  import os
 
34
  # Initialize with API key
35
  client = Groq(api_key=os.getenv("GROQ_API_KEY"))
36
 
@@ -72,9 +73,9 @@ def visualize_knowledge_graph(kg: KnowledgeGraph):
72
  dot.edge(str(edge.source), str(edge.target), label=edge.label, color=edge.color)
73
 
74
  # Render the graph
75
- dot.render("knowledge_graph", format="png")
76
 
77
  def graph(query):
78
  graph = generate_graph(query)
79
  visualize_knowledge_graph(graph)
80
- return "knowledge_graph.png"
 
31
 
32
  from groq import Groq
33
  import os
34
+ os.environ["PATH"] += os.pathsep + '/usr/bin/'
35
  # Initialize with API key
36
  client = Groq(api_key=os.getenv("GROQ_API_KEY"))
37
 
 
73
  dot.edge(str(edge.source), str(edge.target), label=edge.label, color=edge.color)
74
 
75
  # Render the graph
76
+ dot.render("/tmp/knowledge_graph", format="png")
77
 
78
  def graph(query):
79
  graph = generate_graph(query)
80
  visualize_knowledge_graph(graph)
81
+ return "/tmp/knowledge_graph.png"