about summary refs log tree commit diff
path: root/gnqa/paper2_eval/src/run_questions.py
diff options
context:
space:
mode:
authorShelbySolomonDarnell2024-09-24 23:40:11 +0300
committerShelbySolomonDarnell2024-09-24 23:40:11 +0300
commitcb28feac47dc1f6147260f1bc057970c54b314f3 (patch)
tree6c45082bc4d723468609f774170339c718576873 /gnqa/paper2_eval/src/run_questions.py
parentea942f68346abcd6e51d1cc96b0c90361c3cdfa2 (diff)
downloadgn-ai-cb28feac47dc1f6147260f1bc057970c54b314f3.tar.gz
Human questions in json format, code for formatting r2r response
Diffstat (limited to 'gnqa/paper2_eval/src/run_questions.py')
-rw-r--r--gnqa/paper2_eval/src/run_questions.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/gnqa/paper2_eval/src/run_questions.py b/gnqa/paper2_eval/src/run_questions.py
new file mode 100644
index 00000000..5e0b28b2
--- /dev/null
+++ b/gnqa/paper2_eval/src/run_questions.py
@@ -0,0 +1,45 @@
+import json
+import sys
+import os
+
+from r2r import R2R, Document, GenerationConfig, R2RClient
+
+
+def writeDatasetFile(responses, outp_file):
+  print(outp_file)
+  output = json.dumps(responses, indent=2)
+  if os.path.exists(outp_file):
+    with open(outp_file, "a") as the_data:
+      the_data.write('' + output)
+  else:
+    with open(outp_file, "a") as the_data:
+      the_data.write(output)
+
+client = R2RClient("http://localhost:8000")
+
+health_resp = client.health()
+
+print("The R2R client's health status is {0}".format(health_resp))
+
+questions = [
+    "List as many studies as you can that include rapamycin.",
+    "Why is it so difficult to map gene loci that control aging in humans?"
+]
+rag_response = {}
+
+ndx = 1
+for question in questions:
+    rag_response[str(ndx)] = client.rag(question)
+    ndx = ndx + 1
+
+#print(json.dumps(rag_response, indent=2))
+
+
+try:
+    read_file = str(sys.argv[1])
+    out_file  = str(sys.argv[2])
+except:
+    exit('Example use "python run_questions.py ../data/questions/human/de/aging.json ../data/responses/human/de/aging_resp.json"')
+
+
+writeDatasetFile(rag_response, out_file)
\ No newline at end of file