aboutsummaryrefslogtreecommitdiff
path: root/gnqa/paper2_eval/src/run_questions.py
blob: 88053290077aeae6ccca2a79d11be34c12740fac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import json
import sys
import os

from r2r import R2R, Document, GenerationConfig, R2RClient
from document_operations import DocOps, QuestionList

'''
*******************************************************************************
Variables
*******************************************************************************
'''
rag_response = {}
client       = R2RClient("http://localhost:8000")
health_resp  = client.health()

'''
*******************************************************************************
Commands
*******************************************************************************
'''

print("The R2R client's health status is {0}".format(health_resp))

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"')

qLst = QuestionList(read_file, 1) # second parameter is for verbose output
ndx = 1
for question in qLst.get("domainexpert","aging"):
    print('Getting response for the following question --> {0}'.format(question))
    rag_response[str(ndx)] = client.rag(question)
    ndx += 1

DocOps.writeDatasetFile(rag_response, out_file)