GirishaBuilds01 commited on
Commit
d947206
·
verified ·
1 Parent(s): 3c2b266

Update hyperrag.py

Browse files
Files changed (1) hide show
  1. hyperrag.py +6 -19
hyperrag.py CHANGED
@@ -3,30 +3,19 @@ from vector_store import search
3
 
4
  GRAPH = nx.Graph()
5
 
6
-
7
- def add_node(text):
8
-
9
- GRAPH.add_node(text)
10
-
11
-
12
- def link_nodes(a, b):
13
-
14
- GRAPH.add_edge(a, b)
15
-
16
-
17
  def build_graph(docs):
18
 
19
  for i in range(len(docs)-1):
20
 
21
- add_node(docs[i])
22
- add_node(docs[i+1])
23
 
24
- link_nodes(docs[i], docs[i+1])
25
 
26
 
27
  def hyperrag(query):
28
 
29
- hits = search(query, 3)
30
 
31
  context = []
32
 
@@ -38,10 +27,8 @@ def hyperrag(query):
38
 
39
  if text in GRAPH:
40
 
41
- neighbors = GRAPH.neighbors(text)
42
-
43
- for n in neighbors:
44
 
45
  context.append(n)
46
 
47
- return context[:6]
 
3
 
4
  GRAPH = nx.Graph()
5
 
 
 
 
 
 
 
 
 
 
 
 
6
  def build_graph(docs):
7
 
8
  for i in range(len(docs)-1):
9
 
10
+ GRAPH.add_node(docs[i])
11
+ GRAPH.add_node(docs[i+1])
12
 
13
+ GRAPH.add_edge(docs[i], docs[i+1])
14
 
15
 
16
  def hyperrag(query):
17
 
18
+ hits = search(query)
19
 
20
  context = []
21
 
 
27
 
28
  if text in GRAPH:
29
 
30
+ for n in GRAPH.neighbors(text):
 
 
31
 
32
  context.append(n)
33
 
34
+ return context[:5]