-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzero_rag_demo.py
79 lines (65 loc) · 2.38 KB
/
zero_rag_demo.py
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#!/usr/bin/env python
import os
import argparse
import sys
import json
from os.path import exists, dirname, basename, join, expanduser
from glob import glob
import pandas as pd
import numpy as np
HELP_PARAGRAPHS = {
'main':'an example cli tool',
'level1': {
'main':'main level',
'first-thing':'docs for first thing',
'second-thing':'docs for second thing',
},
'level2': {
'main':'level 2',
'third-thing':'docs for third thing',
'fourth-thing':'docs for fourth thing',
},
}
def check_path(fp):
# Check if the path is absolute or relative
if os.path.isabs(args.input_file):
file_path = args.input_file
else:
file_path = os.path.join(os.getcwd(), args.input_file)
# Verify if the file exists
if not os.path.exists(file_path):
print(f"Error: File '{file_path}' not found.")
return file_path
def main():
parser = argparse.ArgumentParser(description=HELP_PARAGRAPHS['main'])
subparsers = parser.add_subparsers(dest='command', help='')
h = HELP_PARAGRAPHS['level1']
parser_corpus = subparsers.add_parser('level1', help=h['main'])
parser_corpus.add_argument('--first-thing', '-f', required=False,
default='', action='store',
help=h['first-thing'])
parser_corpus.add_argument('--second-thing', '-s', required=False,
default=False, action='store_true',
help=h['second-thing'])
h = HELP_PARAGRAPHS['level2']
parser_summ = subparsers.add_parser('level2', help=h['main'])
parser_summ.add_argument('--third-thing', '-t', required=False,
default=False, action='store_true',
help=h['third-thing'])
parser_summ.add_argument('--fourth-thing', '-f', required=False,
default=False, action='store_true',
help=h['fourth-thing'])
args = parser.parse_args()
if args.command == 'level1':
if args.first_thing:
print('here is first thing')
elif args.second_thing:
from zero_rag import main as sc
sc.func()
elif args.command == 'level2':
if args.third_thing:
print('3rd')
elif args.fourth_thing:
print('4th')
if __name__ == '__main__':
main()