File size: 1,909 Bytes
9cef3a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""VELA Framework - ๊ฐ„๋‹จํ•œ ์‚ฌ์šฉ ์˜ˆ์ œ

ํ™˜๊ฒฝ ์„ค์ • ํ›„ ์‹คํ–‰:
    cp .env.example .env
    # .env์— API ํ‚ค ์„ค์ •
    python examples/simple_analysis.py
"""

from dotenv import load_dotenv

load_dotenv()

from vela import ResearchAgent
from vela.schemas import ResearchOptions


def main():
    # 1. ์—์ด์ „ํŠธ ์ดˆ๊ธฐํ™” (MLX ๋ฐฑ์—”๋“œ ์‚ฌ์šฉ)
    agent = ResearchAgent(llm_backend="mlx")

    # 2. ๋ฆฌ์„œ์น˜ ์˜ต์…˜ ์„ค์ •
    options = ResearchOptions(
        max_iterations=3,          # ๋น ๋ฅธ ๋ฐ๋ชจ๋ฅผ ์œ„ํ•ด 3ํšŒ
        extract_content=True,      # ์›นํŽ˜์ด์ง€ ๋ณธ๋ฌธ ์ถ”์ถœ
        enable_verification=False, # ๊ฒ€์ฆ ๋น„ํ™œ์„ฑํ™” (Perplexity ํ‚ค ๋ถˆํ•„์š”)
    )

    # 3. ๋ฆฌ์„œ์น˜ ์‹คํ–‰
    result = agent.research(
        query="SKํ•˜์ด๋‹‰์Šค HBM ์‹œ์žฅ ์ „๋ง",
        options=options,
    )

    # 4. ๊ฒฐ๊ณผ ํ™•์ธ
    print(f"=== ๋ฆฌ์„œ์น˜ ๊ฒฐ๊ณผ ===")
    print(f"์ฟผ๋ฆฌ: {result.query}")
    print(f"์‹ ๋ขฐ๋„: {result.confidence:.0%}")
    print(f"์†Œ์Šค ์ˆ˜: {len(result.sources)}๊ฐœ")
    print(f"์†Œ์š” ์‹œ๊ฐ„: {result.metadata.elapsed_seconds:.1f}์ดˆ")
    print()

    # ํ•ต์‹ฌ ๋ฐœ๊ฒฌ
    print("=== ํ•ต์‹ฌ ๋ฐœ๊ฒฌ ===")
    for i, finding in enumerate(result.key_findings or [], 1):
        print(f"  {i}. {finding}")
    print()

    # ๊ฒฐ๋ก  (์•ž๋ถ€๋ถ„)
    print("=== ๊ฒฐ๋ก  (์š”์•ฝ) ===")
    if result.conclusion:
        print(result.conclusion[:500])
    print()

    # ์†Œ์Šค ๋ชฉ๋ก
    print("=== ์†Œ์Šค ===")
    for src in result.sources[:5]:
        print(f"  [{src.source_type}] {src.title[:60]}")

    # 5. JSON์œผ๋กœ ์ €์žฅ (์„ ํƒ)
    from pathlib import Path

    output_dir = Path("output")
    output_dir.mkdir(exist_ok=True)

    saved = ResearchAgent.save_with_metadata(
        result=result,
        output_path=output_dir / "example_result.json",
    )
    print(f"\n์ €์žฅ ์™„๋ฃŒ: {saved['result']}")


if __name__ == "__main__":
    main()