-
Notifications
You must be signed in to change notification settings - Fork 114
Expand file tree
/
Copy pathlaunch_qa.py
More file actions
44 lines (35 loc) · 1.36 KB
/
launch_qa.py
File metadata and controls
44 lines (35 loc) · 1.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
#!/usr/bin/env python3
"""InternAgent QA mode — direct one-shot question answering."""
import argparse
import asyncio
import os
import sys
import traceback
from dotenv import load_dotenv
load_dotenv(override=True)
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from internagent.mas.agents.dr_agent import DRAgent
def main():
parser = argparse.ArgumentParser(description='InternAgent QA — one-shot question answering')
parser.add_argument('--question', '-q', required=True, help='Research question to answer')
parser.add_argument('--file', '-f', default=None, help='Optional file attachment')
parser.add_argument('--output', '-o', default=None, help='Write answer to this file path')
args = parser.parse_args()
agent = DRAgent(model='o4-mini', config={'mode': 'qa'})
answer = str(asyncio.run(
agent.execute({'task': args.question, 'file_path': args.file}, {})
))
print(answer)
if args.output:
os.makedirs(os.path.dirname(os.path.abspath(args.output)), exist_ok=True)
with open(args.output, 'w', encoding='utf-8') as f:
f.write(answer)
if __name__ == '__main__':
try:
main()
except KeyboardInterrupt:
print("\n\nQA pipeline interrupted by user")
sys.exit(1)
except Exception as e:
print(f"\n\nFatal error: {str(e)}")
traceback.print_exc()