-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtui.py
37 lines (30 loc) · 943 Bytes
/
tui.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
import os
import argparse
from dotenv import load_dotenv
from rich.console import Console
from main import Agent
load_dotenv()
def main():
parser = argparse.ArgumentParser(
description="Understand your files."
)
parser.add_argument(
"--file", type=str, required=True, help="A file to understand."
)
parser.add_argument(
"--query", type=str, required=False, default=None, help="A question about the file."
)
parser.add_argument(
"--summarise", action="store_true", help="Summarise the file."
)
console = Console()
with console.status("Getting file context..."):
args = parser.parse_args()
agent = Agent(os.getenv("COHERE_API_KEY"))
if args.summarise:
response = agent.summarise(args.file)
else:
response = agent.rag(args.file, args.query)
console.print(response)
if __name__ == "__main__":
main()