-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathqna_tool.h
More file actions
executable file
·63 lines (50 loc) · 2.36 KB
/
qna_tool.h
File metadata and controls
executable file
·63 lines (50 loc) · 2.36 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#pragma once
#include <iostream>
#include <fstream>
#include "Node.h"
#include "dict.h"
#include "search.h"
using namespace std;
struct my_para;
class QNA_tool {
private:
// You are free to change the implementation of this function
void query_llm(string filename1, string filename2, string one_more_file, Node* root, int k, string API_KEY_GPT, string API_KEY_PALM, string question, string filename3, string email, string pswd);
// filename is the python file which will call ChatGPT API
// root is the head of the linked list of paragraphs
// k is the number of paragraphs (or the number of nodes in linked list)
// API_KEY is the API key for ChatGPT
// question is the question asked by the user
// You can add attributes/helper functions here
public:
Dict corpus = Dict(9973);
// Dict gen_corpus = Dict(9973);
vector<my_para*> para;
int book;
int page_temp;
int para_temp;
int para_count;
int pref[128];
/* Please do not touch the attributes and
functions within the guard lines placed below */
/* ------------------------------------------- */
QNA_tool(); // Constructor
~QNA_tool(); // Destructor
void insert_sentence(int book_code, int page, int paragraph, int sentence_no, string sentence);
// This function is similar to the functions in dict and search
// The corpus will be provided to you via this function
// It will be called for each sentence in the corpus
Node* get_top_k_para(string question, int k);
// This function takes in a question, preprocess it
// And returns a list of paragraphs which contain the question
// In each Node, you must set: book_code, page, paragraph (other parameters won't be checked)
std::string get_paragraph(int book_code, int page, int paragraph);
// Given the book_code, page number, and the paragraph number, returns the string paragraph.
// Searches through the corpus.
void query(string question, string filename1, string filename2, string one_more_file, string filename3);
// This function takes in a question and a filename.
// It should write the final answer to the specified filename.
/* -----------------------------------------*/
/* Please do not touch the code above this line */
// You can add attributes/helper functions here
};