AbdulMoid commited on
Commit
d0bbbfb
·
verified ·
1 Parent(s): 6c94fb7

Update graph_rag.py

Browse files
Files changed (1) hide show
  1. graph_rag.py +10 -1
graph_rag.py CHANGED
@@ -27,20 +27,29 @@ def unzip_folder(zip_path, extract_path):
27
  return output_dir
28
 
29
  def run_graphrag_query(query, ragtest_dir):
 
 
 
 
 
 
30
  command = [
31
  "python", "-m", "graphrag.query",
32
  "--root", ragtest_dir,
33
- "--method", "local",
34
  query
35
  ]
36
 
 
37
  result = subprocess.run(command, capture_output=True, text=True)
38
 
 
39
  if result.returncode == 0:
40
  return result.stdout
41
  else:
42
  return result.stderr
43
 
 
44
  def qa_tool_graph_rag(user_question):
45
  original_dir = os.getcwd() # Store the original directory
46
  try:
 
27
  return output_dir
28
 
29
  def run_graphrag_query(query, ragtest_dir):
30
+ # Check and log the contents of the ragtest_dir
31
+ logger.info(f"Contents of {ragtest_dir}:")
32
+ for file in os.listdir(ragtest_dir):
33
+ logger.info(os.path.join(ragtest_dir, file))
34
+
35
+ # Define the command
36
  command = [
37
  "python", "-m", "graphrag.query",
38
  "--root", ragtest_dir,
39
+ "--method", "local", # or "global"
40
  query
41
  ]
42
 
43
+ # Run the command
44
  result = subprocess.run(command, capture_output=True, text=True)
45
 
46
+ # Return the output or error message
47
  if result.returncode == 0:
48
  return result.stdout
49
  else:
50
  return result.stderr
51
 
52
+
53
  def qa_tool_graph_rag(user_question):
54
  original_dir = os.getcwd() # Store the original directory
55
  try: