Spaces:
Sleeping
Sleeping
Heewon Oh
feat: initial release of VELA Framework v1.0.0 - Korean financial market research agent
9cef3a3 | #!/usr/bin/env python3 | |
| """VELA Framework - ์ถ๋ก ๋ฐ๋ชจ | |
| ์ฌ์ฉ๋ฒ: | |
| # RunPod ๋ฐฑ์๋ (๊ธฐ๋ณธ) | |
| python inference.py --query "SKํ์ด๋์ค HBM ์์ฅ ์ ๋ง" | |
| # MLX ๋ฐฑ์๋ (Apple Silicon) | |
| python inference.py --query "์ผ์ฑ์ ์ ๋ถ์" --backend mlx | |
| # vLLM ๋ฐฑ์๋ | |
| python inference.py --query "๋ค์ด๋ฒ AI ์ ๋ต" --backend vllm | |
| # Adversary ๊ฒ์ฆ ํฌํจ | |
| python inference.py --query "SKํ์ด๋์ค HBM" --verify | |
| # JSON ํ์ผ๋ก ์ ์ฅ | |
| python inference.py --query "์ผ์ฑ์ ์ ๋ฐ๋์ฒด" --output result.json | |
| """ | |
| import argparse | |
| import json | |
| import logging | |
| import sys | |
| from dotenv import load_dotenv | |
| load_dotenv() | |
| from vela import ResearchAgent | |
| from vela.schemas import ResearchOptions | |
| def main(): | |
| parser = argparse.ArgumentParser( | |
| description="VELA Research Agent - Korean Financial Research", | |
| formatter_class=argparse.RawDescriptionHelpFormatter, | |
| epilog=""" | |
| ์์: | |
| python inference.py -q "SKํ์ด๋์ค HBM ์์ฅ ์ ๋ง" | |
| python inference.py -q "์ผ์ฑ์ ์ ๋ถ์" -b mlx | |
| python inference.py -q "๋ค์ด๋ฒ AI" -b vllm --verify | |
| python inference.py -q "์นด์นด์ค ์ค์ " -o result.json --markdown | |
| """, | |
| ) | |
| parser.add_argument( | |
| "--query", "-q", type=str, required=True, help="๋ฆฌ์์น ์ฟผ๋ฆฌ", | |
| ) | |
| parser.add_argument( | |
| "--backend", "-b", type=str, default="runpod", | |
| choices=["runpod", "mlx", "vllm"], | |
| help="LLM ๋ฐฑ์๋ (๊ธฐ๋ณธ: runpod)", | |
| ) | |
| parser.add_argument( | |
| "--max-iterations", "-i", type=int, default=5, | |
| help="์ต๋ ์ถ๋ก ๋ฐ๋ณต ํ์ (๊ธฐ๋ณธ: 5)", | |
| ) | |
| parser.add_argument( | |
| "--no-content", action="store_true", | |
| help="์ฝํ ์ธ ๋ณธ๋ฌธ ์ถ์ถ ๋นํ์ฑํ (์๋ ํฅ์)", | |
| ) | |
| parser.add_argument( | |
| "--verify", action="store_true", | |
| help="Adversary Agent ๊ฒ์ฆ ํ์ฑํ (Perplexity API ํ์)", | |
| ) | |
| parser.add_argument( | |
| "--verify-model", type=str, default="sonar", | |
| help="๊ฒ์ฆ Perplexity ๋ชจ๋ธ (๊ธฐ๋ณธ: sonar)", | |
| ) | |
| parser.add_argument( | |
| "--output", "-o", type=str, help="๊ฒฐ๊ณผ ์ ์ฅ ๊ฒฝ๋ก (JSON)", | |
| ) | |
| parser.add_argument( | |
| "--markdown", action="store_true", help="๋งํฌ๋ค์ด ํ์์ผ๋ก ์ถ๋ ฅ", | |
| ) | |
| parser.add_argument( | |
| "--verbose", "-v", action="store_true", help="์์ธ ๋ก๊น ", | |
| ) | |
| parser.add_argument( | |
| "--stock-code", type=str, help="์ข ๋ชฉ์ฝ๋ (์: 005930)", | |
| ) | |
| args = parser.parse_args() | |
| # ๋ก๊น ์ค์ | |
| log_level = logging.DEBUG if args.verbose else logging.INFO | |
| logging.basicConfig( | |
| level=log_level, | |
| format="%(asctime)s [%(levelname)s] %(name)s: %(message)s", | |
| ) | |
| # ์์ด์ ํธ ์ด๊ธฐํ | |
| print(f"\n[VELA] ๋ฐฑ์๋: {args.backend}") | |
| print(f"[VELA] ๋ฆฌ์์น ์์: {args.query}\n") | |
| agent = ResearchAgent( | |
| llm_backend=args.backend, | |
| extract_content=not args.no_content, | |
| ) | |
| options = ResearchOptions( | |
| max_iterations=args.max_iterations, | |
| extract_content=not args.no_content, | |
| enable_verification=args.verify, | |
| verification_model=args.verify_model, | |
| ) | |
| # ๋ฆฌ์์น ์คํ | |
| result = agent.research( | |
| query=args.query, | |
| options=options, | |
| stock_code=args.stock_code, | |
| ) | |
| # ๊ฒฐ๊ณผ ์ถ๋ ฅ | |
| if args.markdown: | |
| print(result.to_markdown()) | |
| else: | |
| print(json.dumps(result.to_dict(), ensure_ascii=False, indent=2)) | |
| # ํ์ผ ์ ์ฅ | |
| if args.output: | |
| from pathlib import Path | |
| saved = ResearchAgent.save_with_metadata( | |
| result=result, | |
| output_path=Path(args.output), | |
| save_markdown=args.markdown, | |
| ) | |
| print(f"\n[VELA] ๊ฒฐ๊ณผ ์ ์ฅ: {saved['result']}") | |
| print(f"[VELA] ๋ฉํ๋ฐ์ดํฐ ์ ์ฅ: {saved['metadata']}") | |
| # ์์ฝ | |
| print(f"\n{'='*50}") | |
| print(f"[VELA] ๋ฆฌ์์น ์๋ฃ") | |
| print(f" ์ ๋ขฐ๋: {result.confidence:.0%}") | |
| print(f" ์์ค: {len(result.sources)}๊ฐ") | |
| print(f" ๋ฐ๋ณต: {result.metadata.iterations}ํ") | |
| print(f" ์์: {result.metadata.elapsed_seconds:.1f}์ด") | |
| print(f"{'='*50}") | |
| if __name__ == "__main__": | |
| main() | |