Spaces:
Sleeping
Sleeping
github-actions[bot] commited on
Commit ยท
bc7389c
1
Parent(s): 190bb76
sync from 363ba27
Browse filesThis view is limited to 50 files because it contains too many changes. ย See raw diff
- .streamlit/config.toml +0 -7
- Dockerfile +18 -0
- README.md +1 -3
- README_PROJECT.md +1108 -0
- app.py +0 -623
- pyproject.toml +240 -0
- requirements.txt +0 -4
- src/dartlab/API_SPEC.md +450 -0
- src/dartlab/STATUS.md +81 -0
- src/dartlab/__init__.py +1008 -0
- src/dartlab/ai/DEV.md +224 -0
- src/dartlab/ai/STATUS.md +200 -0
- src/dartlab/ai/__init__.py +119 -0
- src/dartlab/ai/agent.py +30 -0
- src/dartlab/ai/aiParser.py +500 -0
- src/dartlab/ai/context/__init__.py +9 -0
- src/dartlab/ai/context/builder.py +1960 -0
- src/dartlab/ai/context/company_adapter.py +86 -0
- src/dartlab/ai/context/dartOpenapi.py +485 -0
- src/dartlab/ai/context/finance_context.py +945 -0
- src/dartlab/ai/context/formatting.py +439 -0
- src/dartlab/ai/context/snapshot.py +198 -0
- src/dartlab/ai/conversation/__init__.py +1 -0
- src/dartlab/ai/conversation/data_ready.py +71 -0
- src/dartlab/ai/conversation/dialogue.py +476 -0
- src/dartlab/ai/conversation/focus.py +231 -0
- src/dartlab/ai/conversation/history.py +126 -0
- src/dartlab/ai/conversation/intent.py +291 -0
- src/dartlab/ai/conversation/prompts.py +565 -0
- src/dartlab/ai/conversation/suggestions.py +70 -0
- src/dartlab/ai/conversation/templates/__init__.py +1 -0
- src/dartlab/ai/conversation/templates/analysis_rules.py +897 -0
- src/dartlab/ai/conversation/templates/benchmarkData.py +281 -0
- src/dartlab/ai/conversation/templates/benchmarks.py +125 -0
- src/dartlab/ai/conversation/templates/self_critique.py +94 -0
- src/dartlab/ai/conversation/templates/system_base.py +495 -0
- src/dartlab/ai/eval/__init__.py +81 -0
- src/dartlab/ai/eval/batchResults/batch_ollama_20260324_180122.jsonl +2 -0
- src/dartlab/ai/eval/batchResults/batch_ollama_20260325_093749.jsonl +4 -0
- src/dartlab/ai/eval/diagnoser.py +309 -0
- src/dartlab/ai/eval/diagnosisReports/diagnosis_batch_20260325_093749.md +14 -0
- src/dartlab/ai/eval/golden.json +82 -0
- src/dartlab/ai/eval/personaCases.json +2441 -0
- src/dartlab/ai/eval/remediation.py +191 -0
- src/dartlab/ai/eval/replayRunner.py +416 -0
- src/dartlab/ai/eval/reviewLog/accountant.jsonl +1 -0
- src/dartlab/ai/eval/reviewLog/analyst.jsonl +2 -0
- src/dartlab/ai/eval/reviewLog/investor.jsonl +4 -0
- src/dartlab/ai/eval/reviewLog/research_gather.jsonl +2 -0
- src/dartlab/ai/eval/scorer.py +466 -0
.streamlit/config.toml
DELETED
|
@@ -1,7 +0,0 @@
|
|
| 1 |
-
[theme]
|
| 2 |
-
base = "dark"
|
| 3 |
-
primaryColor = "#ea4647"
|
| 4 |
-
backgroundColor = "#050811"
|
| 5 |
-
secondaryBackgroundColor = "#0f1219"
|
| 6 |
-
textColor = "#f1f5f9"
|
| 7 |
-
font = "sans serif"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Dockerfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
FROM python:3.12-slim
|
| 2 |
+
|
| 3 |
+
WORKDIR /app
|
| 4 |
+
|
| 5 |
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
| 6 |
+
build-essential \
|
| 7 |
+
&& rm -rf /var/lib/apt/lists/*
|
| 8 |
+
|
| 9 |
+
COPY pyproject.toml README.md ./
|
| 10 |
+
COPY src/ src/
|
| 11 |
+
|
| 12 |
+
RUN pip install --no-cache-dir -e ".[ai]"
|
| 13 |
+
|
| 14 |
+
ENV SPACE_ID=1
|
| 15 |
+
|
| 16 |
+
EXPOSE 7860
|
| 17 |
+
|
| 18 |
+
CMD ["python", "-m", "dartlab.server"]
|
README.md
CHANGED
|
@@ -3,9 +3,7 @@ title: DartLab
|
|
| 3 |
emoji: ๐
|
| 4 |
colorFrom: red
|
| 5 |
colorTo: yellow
|
| 6 |
-
sdk:
|
| 7 |
-
sdk_version: "1.45.1"
|
| 8 |
-
app_file: app.py
|
| 9 |
pinned: true
|
| 10 |
license: mit
|
| 11 |
short_description: DART + EDGAR disclosure analysis
|
|
|
|
| 3 |
emoji: ๐
|
| 4 |
colorFrom: red
|
| 5 |
colorTo: yellow
|
| 6 |
+
sdk: docker
|
|
|
|
|
|
|
| 7 |
pinned: true
|
| 8 |
license: mit
|
| 9 |
short_description: DART + EDGAR disclosure analysis
|
README_PROJECT.md
ADDED
|
@@ -0,0 +1,1108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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.png" width="180">
|
| 6 |
+
|
| 7 |
+
<h3>DartLab</h3>
|
| 8 |
+
|
| 9 |
+
<p><b>One stock code. The whole story.</b></p>
|
| 10 |
+
<p>DART + EDGAR filings, structured and comparable โ in one line of Python.</p>
|
| 11 |
+
|
| 12 |
+
<p>
|
| 13 |
+
<a href="https://pypi.org/project/dartlab/"><img src="https://img.shields.io/pypi/v/dartlab?style=for-the-badge&color=ea4647&labelColor=050811&logo=pypi&logoColor=white" alt="PyPI"></a>
|
| 14 |
+
<a href="https://pypi.org/project/dartlab/"><img src="https://img.shields.io/pypi/pyversions/dartlab?style=for-the-badge&color=c83232&labelColor=050811&logo=python&logoColor=white" alt="Python"></a>
|
| 15 |
+
<a href="LICENSE"><img src="https://img.shields.io/badge/License-MIT-94a3b8?style=for-the-badge&labelColor=050811" alt="License"></a>
|
| 16 |
+
<a href="https://github.com/eddmpython/dartlab/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/eddmpython/dartlab/ci.yml?branch=master&style=for-the-badge&labelColor=050811&logo=github&logoColor=white&label=CI" alt="CI"></a>
|
| 17 |
+
<a href="https://eddmpython.github.io/dartlab/"><img src="https://img.shields.io/badge/Docs-GitHub_Pages-38bdf8?style=for-the-badge&labelColor=050811&logo=github-pages&logoColor=white" alt="Docs"></a>
|
| 18 |
+
<a href="https://eddmpython.github.io/dartlab/blog/"><img src="https://img.shields.io/badge/Blog-120%2B_Articles-fbbf24?style=for-the-badge&labelColor=050811&logo=rss&logoColor=white" alt="Blog"></a>
|
| 19 |
+
</p>
|
| 20 |
+
|
| 21 |
+
<p>
|
| 22 |
+
<a href="https://eddmpython.github.io/dartlab/">Docs</a> ยท <a href="https://eddmpython.github.io/dartlab/blog/">Blog</a> ยท <a href="https://huggingface.co/spaces/eddmpython/dartlab">Live Demo</a> ยท <a href="notebooks/marimo/">Marimo Notebooks</a> ยท <a href="https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/showcase/01_quickstart.ipynb">Open in Colab</a> ยท <a href="README_KR.md">ํ๊ตญ์ด</a> ยท <a href="https://buymeacoffee.com/eddmpython">Sponsor</a>
|
| 23 |
+
</p>
|
| 24 |
+
|
| 25 |
+
<p>
|
| 26 |
+
<a href="https://huggingface.co/datasets/eddmpython/dartlab-data"><img src="https://img.shields.io/badge/Data-HuggingFace-ffd21e?style=for-the-badge&labelColor=050811&logo=huggingface&logoColor=white" alt="HuggingFace Data"></a>
|
| 27 |
+
</p>
|
| 28 |
+
|
| 29 |
+
</div>
|
| 30 |
+
|
| 31 |
+
> **Note:** DartLab is under active development. APIs may change between versions, and documentation may lag behind the latest code.
|
| 32 |
+
|
| 33 |
+
## Install
|
| 34 |
+
|
| 35 |
+
Requires **Python 3.12+**.
|
| 36 |
+
|
| 37 |
+
```bash
|
| 38 |
+
# Core โ financial statements, sections, Company
|
| 39 |
+
uv add dartlab
|
| 40 |
+
|
| 41 |
+
# or with pip
|
| 42 |
+
pip install dartlab
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
### Optional Extras
|
| 46 |
+
|
| 47 |
+
Install only what you need:
|
| 48 |
+
|
| 49 |
+
```bash
|
| 50 |
+
uv add "dartlab[ai]" # web UI, server, streaming (FastAPI + uvicorn)
|
| 51 |
+
uv add "dartlab[llm]" # LLM analysis (OpenAI)
|
| 52 |
+
uv add "dartlab[charts]" # Plotly charts, network graphs (plotly + networkx + scipy)
|
| 53 |
+
uv add "dartlab[mcp]" # MCP server for Claude Desktop / Code / Cursor
|
| 54 |
+
uv add "dartlab[channel]" # web UI + cloudflared tunnel sharing
|
| 55 |
+
uv add "dartlab[channel-ngrok]" # web UI + ngrok tunnel sharing
|
| 56 |
+
uv add "dartlab[channel-full]" # all channels + Telegram / Slack / Discord bots
|
| 57 |
+
uv add "dartlab[all]" # everything above (except channel bots)
|
| 58 |
+
```
|
| 59 |
+
|
| 60 |
+
**Common combinations:**
|
| 61 |
+
|
| 62 |
+
```bash
|
| 63 |
+
# financial analysis + AI chat
|
| 64 |
+
uv add "dartlab[ai,llm]"
|
| 65 |
+
|
| 66 |
+
# full analysis suite โ charts, AI, LLM
|
| 67 |
+
uv add "dartlab[ai,llm,charts]"
|
| 68 |
+
|
| 69 |
+
# share analysis with team via tunnel
|
| 70 |
+
uv add "dartlab[channel]"
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
### From Source
|
| 74 |
+
|
| 75 |
+
```bash
|
| 76 |
+
git clone https://github.com/eddmpython/dartlab.git
|
| 77 |
+
cd dartlab && uv pip install -e ".[all]"
|
| 78 |
+
|
| 79 |
+
# or with pip
|
| 80 |
+
pip install -e ".[all]"
|
| 81 |
+
```
|
| 82 |
+
|
| 83 |
+
PyPI releases are published only when the core is stable. If you want the latest features (including experimental ones like audit, forecast, valuation), clone the repo directly โ but expect occasional breaking changes.
|
| 84 |
+
|
| 85 |
+
### Desktop App (Alpha)
|
| 86 |
+
|
| 87 |
+
Skip all installation steps โ download the standalone Windows launcher:
|
| 88 |
+
|
| 89 |
+
- **[Download DartLab.exe](https://github.com/eddmpython/dartlab-desktop/releases/latest/download/DartLab.exe)** from [dartlab-desktop](https://github.com/eddmpython/dartlab-desktop)
|
| 90 |
+
- Also available from the [DartLab landing page](https://eddmpython.github.io/dartlab/)
|
| 91 |
+
|
| 92 |
+
One-click launch โ no Python, no terminal, no package manager required. The desktop app bundles the web UI with a built-in Python runtime.
|
| 93 |
+
|
| 94 |
+
> **Alpha** โ functional but incomplete. The desktop app is a Windows-only `.exe` launcher. macOS/Linux are not yet supported.
|
| 95 |
+
|
| 96 |
+
---
|
| 97 |
+
|
| 98 |
+
**No data setup required.** When you create a `Company`, dartlab automatically downloads the required data from [HuggingFace](https://huggingface.co/datasets/eddmpython/dartlab-data) (DART) or SEC API (EDGAR). The second run loads instantly from local cache.
|
| 99 |
+
|
| 100 |
+
## Quick Start
|
| 101 |
+
|
| 102 |
+
Pick any company. Get the whole picture.
|
| 103 |
+
|
| 104 |
+
```python
|
| 105 |
+
import dartlab
|
| 106 |
+
|
| 107 |
+
# Samsung Electronics โ from raw filings to structured data
|
| 108 |
+
c = dartlab.Company("005930")
|
| 109 |
+
c.sections # every topic, every period, side by side
|
| 110 |
+
c.show("businessOverview") # what this company actually does
|
| 111 |
+
c.diff("businessOverview") # what changed since last year
|
| 112 |
+
c.BS # standardized balance sheet
|
| 113 |
+
c.ratios # 47 financial ratios, already calculated
|
| 114 |
+
|
| 115 |
+
# Apple โ same interface, different country
|
| 116 |
+
us = dartlab.Company("AAPL")
|
| 117 |
+
us.show("business")
|
| 118 |
+
us.ratios
|
| 119 |
+
|
| 120 |
+
# No code needed โ ask in natural language
|
| 121 |
+
dartlab.ask("Analyze Samsung Electronics financial health")
|
| 122 |
+
```
|
| 123 |
+
|
| 124 |
+
## What DartLab Is
|
| 125 |
+
|
| 126 |
+
A public company files hundreds of pages every quarter. Inside those pages is everything โ revenue trends, risk warnings, management strategy, competitive position. The complete truth about a company, written by the company itself.
|
| 127 |
+
|
| 128 |
+
Nobody reads it.
|
| 129 |
+
|
| 130 |
+
Not because they don't want to. Because the same information is named differently by every company, structured differently every year, and scattered across formats designed for regulators, not readers. The same "revenue" appears as `ifrs-full_Revenue`, `dart_Revenue`, `SalesRevenue`, or dozens of Korean variations.
|
| 131 |
+
|
| 132 |
+
DartLab changes who can access this information. Two engines turn raw filings into one comparable map:
|
| 133 |
+
|
| 134 |
+
### The Two Problems DartLab Solves
|
| 135 |
+
|
| 136 |
+
**1. The same company says different things differently every year.**
|
| 137 |
+
|
| 138 |
+
Sections horizontalization normalizes every disclosure section into a **topic ร period** grid. Different titles across years and industries all resolve to the same canonical topic:
|
| 139 |
+
|
| 140 |
+
```
|
| 141 |
+
2025Q4 2024Q4 2024Q3 2023Q4 โฆ
|
| 142 |
+
companyOverview โ โ โ โ
|
| 143 |
+
businessOverview โ โ โ โ
|
| 144 |
+
productService โ โ โ โ
|
| 145 |
+
salesOrder โ โ โ โ
|
| 146 |
+
employee โ โ โ โ
|
| 147 |
+
dividend โ โ โ โ
|
| 148 |
+
audit โ โ โ โ
|
| 149 |
+
โฆ (98 canonical topics)
|
| 150 |
+
```
|
| 151 |
+
|
| 152 |
+
```
|
| 153 |
+
Before (raw section titles): After (canonical topic):
|
| 154 |
+
Samsung "II. ์ฌ์
์ ๋ด์ฉ" โ businessOverview
|
| 155 |
+
Hyundai "II. ์ฌ์
์ ๋ด์ฉ [์๋์ฐจ๋ถ๋ฌธ]" โ businessOverview
|
| 156 |
+
Kakao "2. ์ฌ์
์ ๋ด์ฉ" โ businessOverview
|
| 157 |
+
```
|
| 158 |
+
|
| 159 |
+
The mapping pipeline: **text normalization** โ **545 hardcoded title mappings** โ **73 regex patterns** โ canonical topic. ~95%+ mapping rate across all listed companies. Each cell keeps the full text with heading/body separation, tables, and original evidence. Comparing "what did the company say about risk last year vs. this year" becomes a single `diff()` call.
|
| 160 |
+
|
| 161 |
+
**2. Every company names the same number differently.**
|
| 162 |
+
|
| 163 |
+
Account standardization normalizes every XBRL account through a 4-step pipeline:
|
| 164 |
+
|
| 165 |
+
```
|
| 166 |
+
Raw XBRL account_id
|
| 167 |
+
โ Strip prefixes (ifrs-full_, dart_, ifrs_, ifrs-smes_)
|
| 168 |
+
โ English ID synonyms (59 rules)
|
| 169 |
+
โ Korean name synonyms (104 rules)
|
| 170 |
+
โ Learned mapping table (34,249 entries)
|
| 171 |
+
โ Result: revenue, operatingIncome, totalAssets, โฆ
|
| 172 |
+
```
|
| 173 |
+
|
| 174 |
+
```
|
| 175 |
+
Before (raw XBRL): After (standardized):
|
| 176 |
+
Company account_id account_nm โ snakeId label
|
| 177 |
+
Samsung ifrs-full_Revenue ์์ต(๋งค์ถ์ก) โ revenue ๋งค์ถ์ก
|
| 178 |
+
SK Hynix dart_Revenue ๋งค์ถ์ก โ revenue ๋งค์ถ์ก
|
| 179 |
+
LG Energy Revenue ๋งค์ถ โ revenue ๋งค์ถ์ก
|
| 180 |
+
```
|
| 181 |
+
|
| 182 |
+
~97% mapping rate. Cross-company comparison requires zero manual work. Combined with `scanAccount` / `scanRatio`, you can compare a single metric across **2,700+ companies** in one call.
|
| 183 |
+
|
| 184 |
+
### Principles โ Accessibility and Reliability
|
| 185 |
+
|
| 186 |
+
These two principles govern every public API:
|
| 187 |
+
|
| 188 |
+
**Accessibility** โ One stock code is all you need. `import dartlab` provides access to every feature. No internal DTOs, no extra imports, no data setup. `Company("005930")` auto-downloads from [HuggingFace](https://huggingface.co/datasets/eddmpython/dartlab-data).
|
| 189 |
+
|
| 190 |
+
**Reliability** โ Numbers are raw originals from DART/EDGAR. Missing data returns `None`, never a guess. `trace(topic)` shows which source was chosen and why. Errors are never swallowed.
|
| 191 |
+
|
| 192 |
+
### Company โ The Merged Map
|
| 193 |
+
|
| 194 |
+
`Company` uses `sections` as the spine, then overlays stronger data sources:
|
| 195 |
+
|
| 196 |
+
```
|
| 197 |
+
Layer What it provides Priority
|
| 198 |
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 199 |
+
docs Section text, tables, evidence Base spine
|
| 200 |
+
finance BS, IS, CF, ratios, time series Replaces numeric topics
|
| 201 |
+
report 28 structured APIs (DART only) Fills structured topics
|
| 202 |
+
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 203 |
+
profile Merged view (default for users) Highest
|
| 204 |
+
```
|
| 205 |
+
|
| 206 |
+
```python
|
| 207 |
+
c.docs.sections # pure text source (sections spine)
|
| 208 |
+
c.finance.BS # authoritative financial statements
|
| 209 |
+
c.report.extract() # structured DART API data
|
| 210 |
+
c.profile.sections # merged view โ what users see by default
|
| 211 |
+
```
|
| 212 |
+
|
| 213 |
+
`c.sections` is the merged view. `c.trace("BS")` tells you which source was chosen and why.
|
| 214 |
+
|
| 215 |
+
### Architecture โ Layered by Responsibility
|
| 216 |
+
|
| 217 |
+
DartLab follows a strict layered architecture where each layer only depends on layers below it:
|
| 218 |
+
|
| 219 |
+
```
|
| 220 |
+
L0 core/ Protocols, finance utils, docs utils, registry
|
| 221 |
+
L1 providers/ Country-specific data (DART, EDGAR, EDINET)
|
| 222 |
+
gather/ External market data (Naver, Yahoo, FRED)
|
| 223 |
+
market/ Market-wide scanning (2,700+ companies)
|
| 224 |
+
L2 analysis/ Analytical engines (valuation, risk, insights, event study)
|
| 225 |
+
L3 ai/ LLM-powered analysis (9 providers)
|
| 226 |
+
```
|
| 227 |
+
|
| 228 |
+
Import direction is enforced by CI โ no reverse dependencies allowed.
|
| 229 |
+
|
| 230 |
+
### Extensibility โ Zero Core Modification
|
| 231 |
+
|
| 232 |
+
Adding a new country requires zero changes to core code:
|
| 233 |
+
|
| 234 |
+
1. Create a provider package under `providers/`
|
| 235 |
+
2. Implement `canHandle(code) -> bool` and `priority() -> int`
|
| 236 |
+
3. Register via `entry_points` in `pyproject.toml`
|
| 237 |
+
|
| 238 |
+
```python
|
| 239 |
+
dartlab.Company("005930") # โ DART provider (priority 10)
|
| 240 |
+
dartlab.Company("AAPL") # โ EDGAR provider (priority 20)
|
| 241 |
+
```
|
| 242 |
+
|
| 243 |
+
The facade iterates providers by priority โ first match wins. This follows the same pattern as OpenBB's provider system and scikit-learn's estimator registration.
|
| 244 |
+
|
| 245 |
+
## Core Features
|
| 246 |
+
|
| 247 |
+
### Show, Trace, Diff
|
| 248 |
+
|
| 249 |
+
```python
|
| 250 |
+
c = dartlab.Company("005930")
|
| 251 |
+
|
| 252 |
+
# show โ open any topic with source-aware priority
|
| 253 |
+
c.show("BS") # โ finance DataFrame
|
| 254 |
+
c.show("overview") # โ sections-based text + tables
|
| 255 |
+
c.show("dividend") # โ report DataFrame (all quarters)
|
| 256 |
+
c.show("IS", period=["2024Q4", "2023Q4"]) # compare specific periods
|
| 257 |
+
|
| 258 |
+
# trace โ why a topic came from docs, finance, or report
|
| 259 |
+
c.trace("BS") # โ {"primarySource": "finance", ...}
|
| 260 |
+
|
| 261 |
+
# diff โ text change detection (3 modes)
|
| 262 |
+
c.diff() # full summary
|
| 263 |
+
c.diff("businessOverview") # topic history
|
| 264 |
+
c.diff("businessOverview", "2024", "2025") # line-by-line diff
|
| 265 |
+
```
|
| 266 |
+
|
| 267 |
+
What the output looks like:
|
| 268 |
+
|
| 269 |
+
```
|
| 270 |
+
>>> c.show("businessOverview")
|
| 271 |
+
shape: (12, 5)
|
| 272 |
+
โโโโโโโโโโโโโฌโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 273 |
+
โ blockType โ nodeType โ 2024 โ 2023 โ
|
| 274 |
+
โโโโโโโโโโโโโผโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
| 275 |
+
โ text โ heading โ 1. ์ฐ์
์ ํน์ฑ โ 1. ์ฐ์
์ ํน์ฑ โ
|
| 276 |
+
โ text โ body โ ๋ฐ๋์ฒด ์ฐ์
์ ๊ธฐ์ ์ง์ฝ์ โฆ โ ๋ฐ๋์ฒด ์ฐ์
์ ๊ธฐ์ ์ง์ฝ์ โฆ โ
|
| 277 |
+
โ table โ null โ DataFrame(5ร3) โ DataFrame(5ร3) โ
|
| 278 |
+
โโโโโโโโโโโโโดโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 279 |
+
|
| 280 |
+
>>> c.diff("businessOverview", "2023", "2024")
|
| 281 |
+
โโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 282 |
+
โ status โ text โ
|
| 283 |
+
โโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
| 284 |
+
โ added โ AI ๋ฐ๋์ฒด ์์ ๊ธ์ฆ์ ๋ฐ๋ฅธ HBM ๋งค์ถ ํ๋ โฆ โ
|
| 285 |
+
โ modified โ ๋งค์ถ์ก 258.9์กฐ์ โ 300.9์กฐ์ โ
|
| 286 |
+
โ removed โ ๋ฐ๋์ฒด ๋ถ๋ฌธ ์์ต์ฑ ์
ํ ์ฐ๋ ค โฆ โ
|
| 287 |
+
โโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 288 |
+
```
|
| 289 |
+
|
| 290 |
+
### Finance
|
| 291 |
+
|
| 292 |
+
```python
|
| 293 |
+
c.BS # balance sheet (account ร period, newest first)
|
| 294 |
+
c.IS # income statement
|
| 295 |
+
c.CF # cash flow
|
| 296 |
+
c.ratios # ratio time series DataFrame (6 categories ร period)
|
| 297 |
+
c.finance.ratioSeries # ratio time series across years
|
| 298 |
+
c.finance.timeseries # raw account time series
|
| 299 |
+
c.annual # annual time series
|
| 300 |
+
c.filings() # disclosure document list (Tier 1 Stable)
|
| 301 |
+
```
|
| 302 |
+
|
| 303 |
+
All accounts are normalized through the 4-step standardization pipeline โ Samsung's `revenue` and LG's `revenue` are the same `snakeId`. Ratios cover 6 categories: profitability, stability, growth, efficiency, cashflow, and valuation.
|
| 304 |
+
|
| 305 |
+
### Market-wide Financial Screening
|
| 306 |
+
|
| 307 |
+
Scan a single account or ratio across **all listed companies** in one call โ 2,700+ DART firms or 500+ EDGAR firms. Returns a wide Polars DataFrame (rows = companies, columns = periods, newest first).
|
| 308 |
+
|
| 309 |
+
```python
|
| 310 |
+
import dartlab
|
| 311 |
+
|
| 312 |
+
# scan a single account across all listed companies
|
| 313 |
+
dartlab.scanAccount("๋งค์ถ์ก") # revenue, quarterly standalone
|
| 314 |
+
dartlab.scanAccount("operating_profit", annual=True) # annual basis
|
| 315 |
+
dartlab.scanAccount("total_assets", market="edgar") # US EDGAR
|
| 316 |
+
|
| 317 |
+
# scan a ratio across all listed companies
|
| 318 |
+
dartlab.scanRatio("roe") # quarterly ROE for all firms
|
| 319 |
+
dartlab.scanRatio("debtRatio", annual=True) # annual debt-to-equity
|
| 320 |
+
|
| 321 |
+
# list available ratios (13 ratios: profitability, stability, growth, efficiency, cashflow)
|
| 322 |
+
dartlab.scanRatioList()
|
| 323 |
+
```
|
| 324 |
+
|
| 325 |
+
Accepts both Korean names (`๋งค์ถ์ก`) and English snakeIds (`sales`) โ same 4-step normalization as Company finance. Reads 2,700+ parquet files in parallel via ThreadPool, typically completes in ~3 seconds.
|
| 326 |
+
|
| 327 |
+
> **Requires pre-downloaded data.** Market-wide functions (`scanAccount`, `screen`, `digest`, etc.) operate on local data โ individual `Company()` calls only download one firm at a time. Download all data first:
|
| 328 |
+
> ```python
|
| 329 |
+
> pip install dartlab[hf]
|
| 330 |
+
> dartlab.downloadAll("finance") # ~600 MB, 2,700+ firms
|
| 331 |
+
> dartlab.downloadAll("report") # ~320 MB (governance/workforce/capital/debt)
|
| 332 |
+
> dartlab.downloadAll("docs") # ~8 GB (digest/signal โ large)
|
| 333 |
+
> ```
|
| 334 |
+
|
| 335 |
+
## Review โ Structured Company Analysis
|
| 336 |
+
|
| 337 |
+
> **Experimental** โ the review system is under active development. Templates, blocks, and output formats may change between versions.
|
| 338 |
+
|
| 339 |
+
DartLab's review system assembles financial data into structured, readable reports.
|
| 340 |
+
|
| 341 |
+
### Templates
|
| 342 |
+
|
| 343 |
+
Pre-built block combinations that cover key analysis areas:
|
| 344 |
+
|
| 345 |
+
```python
|
| 346 |
+
c = dartlab.Company("005930")
|
| 347 |
+
|
| 348 |
+
c.review("์์ต๊ตฌ์กฐ") # revenue structure โ segments, growth, concentration
|
| 349 |
+
c.review("์๊ธ์กฐ๋ฌ") # capital structure โ debt, liquidity, interest burden
|
| 350 |
+
c.review() # all templates
|
| 351 |
+
```
|
| 352 |
+
|
| 353 |
+
### Block Assembly
|
| 354 |
+
|
| 355 |
+
Every review is built from reusable blocks. Get the full block dictionary and assemble your own:
|
| 356 |
+
|
| 357 |
+
```python
|
| 358 |
+
from dartlab.review import blocks, Review
|
| 359 |
+
|
| 360 |
+
b = blocks(c) # dict of 16 pre-built blocks
|
| 361 |
+
list(b.keys()) # โ ["profile", "segmentComposition", "growth", ...]
|
| 362 |
+
|
| 363 |
+
# pick what you need
|
| 364 |
+
Review([
|
| 365 |
+
b["segmentComposition"],
|
| 366 |
+
b["growth"],
|
| 367 |
+
c.select("IS", ["๋งค์ถ์ก"]), # mix with raw data
|
| 368 |
+
])
|
| 369 |
+
```
|
| 370 |
+
|
| 371 |
+
### Reviewer โ AI Layer
|
| 372 |
+
|
| 373 |
+
Add LLM-powered opinions on top of data blocks. Works with any provider:
|
| 374 |
+
|
| 375 |
+
```python
|
| 376 |
+
c.reviewer() # all sections + AI opinion
|
| 377 |
+
c.reviewer("์์ต๊ตฌ์กฐ") # single section + AI
|
| 378 |
+
c.reviewer(guide="Evaluate from semiconductor cycle perspective") # custom guide
|
| 379 |
+
```
|
| 380 |
+
|
| 381 |
+
**Free AI providers** โ no paid API key required:
|
| 382 |
+
|
| 383 |
+
| Provider | Setup |
|
| 384 |
+
|----------|-------|
|
| 385 |
+
| Gemini | `dartlab setup gemini` |
|
| 386 |
+
| Groq | `dartlab setup groq` |
|
| 387 |
+
| Cerebras | `dartlab setup cerebras` |
|
| 388 |
+
| Mistral | `dartlab setup mistral` |
|
| 389 |
+
|
| 390 |
+
Or use any OpenAI-compatible endpoint:
|
| 391 |
+
```bash
|
| 392 |
+
dartlab setup custom --base-url http://localhost:11434/v1 # Ollama local
|
| 393 |
+
```
|
| 394 |
+
|
| 395 |
+
### Customization
|
| 396 |
+
|
| 397 |
+
- **Templates**: Pre-defined block combinations (`์์ต๊ตฌ์กฐ`, `์๊ธ์กฐ๋ฌ`)
|
| 398 |
+
- **Free assembly**: Mix any blocks + raw DataFrames in `Review([...])`
|
| 399 |
+
- **Guide**: Pass `guide="..."` to `c.reviewer()` for domain-specific AI analysis
|
| 400 |
+
- **Layout**: `ReviewLayout(indentH1=2, gapAfterH1=1, ...)` for rendering control
|
| 401 |
+
- **Render formats**: `review.render("rich" | "html" | "markdown" | "json")`
|
| 402 |
+
|
| 403 |
+
See [notebooks/marimo/sampleReview.py](notebooks/marimo/sampleReview.py) for interactive examples.
|
| 404 |
+
|
| 405 |
+
## Additional Features
|
| 406 |
+
|
| 407 |
+
> Features below are **beta** or **experimental** โ APIs may change. See [stability](docs/stability.md).
|
| 408 |
+
|
| 409 |
+
### Insights (beta)
|
| 410 |
+
|
| 411 |
+
> **Beta** โ API may change after a warning. See [stability](docs/stability.md).
|
| 412 |
+
|
| 413 |
+
```python
|
| 414 |
+
c.insights # 10-area analysis
|
| 415 |
+
c.insights.grades() # โ {"performance": "A", "profitability": "B", โฆ}
|
| 416 |
+
c.insights.performance.grade # โ "A"
|
| 417 |
+
c.insights.performance.details # โ ["Revenue growth +8.3%", โฆ]
|
| 418 |
+
c.insights.anomalies # โ outliers and red flags
|
| 419 |
+
|
| 420 |
+
# distress scorecard โ 6-model bankruptcy/fraud prediction
|
| 421 |
+
c.insights.distress # Altman Z-Score, Beneish M-Score, Ohlson O-Score,
|
| 422 |
+
# Merton Distance-to-Default, Piotroski F-Score, Sloan Ratio
|
| 423 |
+
```
|
| 424 |
+
|
| 425 |
+
### Valuation, Forecast & Simulation
|
| 426 |
+
|
| 427 |
+
```python
|
| 428 |
+
dartlab.valuation("005930") # DCF + DDM + relative valuation
|
| 429 |
+
dartlab.forecast("005930") # revenue forecast (4-source ensemble)
|
| 430 |
+
dartlab.simulation("005930") # scenario simulation (macro presets)
|
| 431 |
+
|
| 432 |
+
# also available as Company methods
|
| 433 |
+
c.valuation()
|
| 434 |
+
c.forecast(horizon=3)
|
| 435 |
+
c.simulation(scenarios=["adverse", "rate_hike"])
|
| 436 |
+
```
|
| 437 |
+
|
| 438 |
+
Auto-detects currency โ KRW for DART companies, USD for EDGAR. Works with both `dartlab.valuation("AAPL")` and `dartlab.valuation("005930")`.
|
| 439 |
+
|
| 440 |
+
### Audit (beta)
|
| 441 |
+
|
| 442 |
+
> **Beta** โ API may change after a warning. See [stability](docs/stability.md).
|
| 443 |
+
|
| 444 |
+
```python
|
| 445 |
+
dartlab.audit("005930") # 11 red flag detectors
|
| 446 |
+
|
| 447 |
+
# Benford's Law (digit distribution), auditor change (PCAOB AS 3101),
|
| 448 |
+
# going concern (ISA 570), internal control (SOX 302/404),
|
| 449 |
+
# revenue quality (Dechow & Dichev), Merton default probability, ...
|
| 450 |
+
```
|
| 451 |
+
|
| 452 |
+
### Market Intelligence (beta)
|
| 453 |
+
|
| 454 |
+
> **Beta** โ API may change after a warning. See [stability](docs/stability.md).
|
| 455 |
+
|
| 456 |
+
```python
|
| 457 |
+
dartlab.digest() # market-wide disclosure change digest
|
| 458 |
+
dartlab.digest(sector="๋ฐ๋์ฒด") # sector filter
|
| 459 |
+
dartlab.groupHealth() # group health: network ร financial ratios
|
| 460 |
+
```
|
| 461 |
+
|
| 462 |
+
### Modules
|
| 463 |
+
|
| 464 |
+
DartLab exposes 100+ modules across 6 categories:
|
| 465 |
+
|
| 466 |
+
```bash
|
| 467 |
+
dartlab modules # list all modules
|
| 468 |
+
dartlab modules --category finance # filter by category
|
| 469 |
+
dartlab modules --search dividend # search by keyword
|
| 470 |
+
```
|
| 471 |
+
|
| 472 |
+
```python
|
| 473 |
+
c.topics # list all available topics for this company
|
| 474 |
+
```
|
| 475 |
+
|
| 476 |
+
Categories: `finance` (statements, ratios), `report` (dividend, governance, audit), `notes` (K-IFRS annotations), `disclosure` (narrative text), `analysis` (insights, rankings), `raw` (original parquets).
|
| 477 |
+
|
| 478 |
+
### Charts & Visualization (beta)
|
| 479 |
+
|
| 480 |
+
> **Beta** โ API may change after a warning. See [stability](docs/stability.md).
|
| 481 |
+
|
| 482 |
+
```python
|
| 483 |
+
c = dartlab.Company("005930")
|
| 484 |
+
|
| 485 |
+
# one-liner Plotly charts
|
| 486 |
+
dartlab.chart.revenue(c).show() # revenue + operating margin combo
|
| 487 |
+
dartlab.chart.cashflow(c).show() # operating/investing/financing CF
|
| 488 |
+
dartlab.chart.dividend(c).show() # DPS + yield + payout ratio
|
| 489 |
+
dartlab.chart.profitability(c).show() # ROE, operating margin, net margin
|
| 490 |
+
|
| 491 |
+
# auto-detect all available charts
|
| 492 |
+
specs = dartlab.chart.auto_chart(c)
|
| 493 |
+
dartlab.chart.chart_from_spec(specs[0]).show()
|
| 494 |
+
|
| 495 |
+
# generic charts from any DataFrame
|
| 496 |
+
dartlab.chart.line(c.dividend, y=["dps"])
|
| 497 |
+
dartlab.chart.bar(df, x="year", y=["revenue", "operating_income"], stacked=True)
|
| 498 |
+
```
|
| 499 |
+
|
| 500 |
+
Data tools:
|
| 501 |
+
|
| 502 |
+
```python
|
| 503 |
+
dartlab.table.yoy_change(c.dividend, value_cols=["dps"]) # add YoY% columns
|
| 504 |
+
dartlab.table.format_korean(c.BS, unit="๋ฐฑ๋ง์") # 1.2์กฐ์, 350์ต์
|
| 505 |
+
dartlab.table.summary_stats(c.dividend, value_cols=["dps"]) # mean/CAGR/trend
|
| 506 |
+
dartlab.text.extract_keywords(narrative) # frequency-based keywords
|
| 507 |
+
dartlab.text.sentiment_indicators(narrative) # positive/negative/risk
|
| 508 |
+
```
|
| 509 |
+
|
| 510 |
+
Install chart dependencies: `uv add "dartlab[charts]"`
|
| 511 |
+
|
| 512 |
+
### Network โ Affiliate Map (beta)
|
| 513 |
+
|
| 514 |
+
> **Beta** โ API may change after a warning. See [stability](docs/stability.md).
|
| 515 |
+
|
| 516 |
+
```python
|
| 517 |
+
c = dartlab.Company("005930")
|
| 518 |
+
|
| 519 |
+
# interactive vis.js graph in browser
|
| 520 |
+
c.network().show() # ego view (1 hop)
|
| 521 |
+
c.network(hops=2).show() # 2-hop neighborhood
|
| 522 |
+
|
| 523 |
+
# DataFrame views
|
| 524 |
+
c.network("members") # group affiliates
|
| 525 |
+
c.network("edges") # investment/shareholder connections
|
| 526 |
+
c.network("cycles") # circular ownership paths
|
| 527 |
+
|
| 528 |
+
# full market network
|
| 529 |
+
dartlab.network().show()
|
| 530 |
+
```
|
| 531 |
+
|
| 532 |
+
### Market Scan (beta)
|
| 533 |
+
|
| 534 |
+
> **Beta** โ API may change after a warning. See [stability](docs/stability.md).
|
| 535 |
+
|
| 536 |
+
```python
|
| 537 |
+
c = dartlab.Company("005930")
|
| 538 |
+
|
| 539 |
+
# one company โ market-wide
|
| 540 |
+
c.governance() # single company
|
| 541 |
+
c.governance("all") # full market DataFrame
|
| 542 |
+
dartlab.governance() # module-level scan
|
| 543 |
+
dartlab.workforce()
|
| 544 |
+
dartlab.capital()
|
| 545 |
+
dartlab.debt()
|
| 546 |
+
|
| 547 |
+
# screening & benchmarking
|
| 548 |
+
dartlab.screen() # multi-factor screening
|
| 549 |
+
dartlab.benchmark() # peer comparison
|
| 550 |
+
dartlab.signal() # change detection signals
|
| 551 |
+
```
|
| 552 |
+
|
| 553 |
+
### Market Data Collection (beta)
|
| 554 |
+
|
| 555 |
+
> **Beta** โ API may change after a warning. See [stability](docs/stability.md).
|
| 556 |
+
|
| 557 |
+
The Gather engine collects external market data as **Polars DataFrames** โ timeseries by default. Every request goes through automatic fallback chains, circuit breaker isolation, and TTL caching. All methods are synchronous โ async parallel execution is handled internally.
|
| 558 |
+
|
| 559 |
+
```python
|
| 560 |
+
import dartlab
|
| 561 |
+
|
| 562 |
+
# OHLCV timeseries โ adjusted prices, 6000+ trading days in a single request
|
| 563 |
+
dartlab.price("005930") # KR: 1-year default, Polars DataFrame
|
| 564 |
+
dartlab.price("005930", start="2015-01-01") # custom range
|
| 565 |
+
dartlab.price("AAPL", market="US") # US via Yahoo Finance chart API
|
| 566 |
+
dartlab.price("005930", snapshot=True) # opt-in: current price snapshot
|
| 567 |
+
|
| 568 |
+
# supply/demand flow timeseries (KR only)
|
| 569 |
+
dartlab.flow("005930") # DataFrame (date, foreignNet, institutionNet, ...)
|
| 570 |
+
|
| 571 |
+
# macro indicators โ full wide DataFrame
|
| 572 |
+
dartlab.macro() # KR 12 indicators (CPI, rates, FX, production, ...)
|
| 573 |
+
dartlab.macro("US") # US 25 indicators (GDP, CPI, Fed Funds, S&P500, ...)
|
| 574 |
+
dartlab.macro("CPI") # single indicator (auto-detects KR)
|
| 575 |
+
dartlab.macro("FEDFUNDS") # single indicator (auto-detects US)
|
| 576 |
+
|
| 577 |
+
# consensus, news
|
| 578 |
+
dartlab.consensus("005930") # target price & analyst opinion
|
| 579 |
+
dartlab.news("์ผ์ฑ์ ์") # Google News RSS โ DataFrame
|
| 580 |
+
```
|
| 581 |
+
|
| 582 |
+
**How data is collected โ don't worry, it's safe:**
|
| 583 |
+
|
| 584 |
+
| Source | Data | Method |
|
| 585 |
+
|--------|------|--------|
|
| 586 |
+
| Naver Chart API | KR OHLCV (adjusted prices) | `fchart.stock.naver.com` โ 1 request per stock, max 6000 days |
|
| 587 |
+
| Yahoo Finance v8 | US/Global OHLCV | `query2.finance.yahoo.com/v8/finance/chart` โ public chart API |
|
| 588 |
+
| ECOS (Bank of Korea) | KR macro indicators | Official API with user's own key |
|
| 589 |
+
| FRED (St. Louis Fed) | US macro indicators | Official API with user's own key |
|
| 590 |
+
| Naver Mobile API | Consensus, flow, sector PER | `m.stock.naver.com/api` โ JSON endpoints |
|
| 591 |
+
| FMP | Fallback for US history | Financial Modeling Prep API (optional) |
|
| 592 |
+
|
| 593 |
+
**Safety infrastructure:**
|
| 594 |
+
|
| 595 |
+
- **Rate limiting** โ per-domain RPM caps (Naver 30, ECOS 30, FRED 120) with async queue
|
| 596 |
+
- **Circuit breaker** โ 3 consecutive failures โ source disabled for 60s, half-open retry
|
| 597 |
+
- **Fallback chains** โ KR: naver โ yahoo_direct โ yahoo / US: yahoo_direct โ fmp โ yahoo
|
| 598 |
+
- **Stale-while-revalidate** โ returns cached data on failure, warns via `log.warning`
|
| 599 |
+
- **User-Agent rotation** โ randomized per request to avoid fingerprinting
|
| 600 |
+
- **No silent failures** โ all API errors logged at warning level, never swallowed
|
| 601 |
+
- **No scraping** โ all sources are public APIs or official data endpoints
|
| 602 |
+
|
| 603 |
+
### Cross-Border Analysis (beta)
|
| 604 |
+
|
| 605 |
+
> **Beta** โ API may change after a warning. See [stability](docs/stability.md).
|
| 606 |
+
|
| 607 |
+
```python
|
| 608 |
+
c = dartlab.Company("005930")
|
| 609 |
+
|
| 610 |
+
# keyword frequency across disclosure periods
|
| 611 |
+
c.keywordTrend(keyword="AI") # topic ร period ร keyword count
|
| 612 |
+
c.keywordTrend() # all 54 built-in keywords
|
| 613 |
+
|
| 614 |
+
# news headlines
|
| 615 |
+
c.news() # recent 30 days
|
| 616 |
+
dartlab.news("AAPL", market="US") # US company news
|
| 617 |
+
|
| 618 |
+
# global peer mapping (WICS โ GICS sector)
|
| 619 |
+
dartlab.crossBorderPeers("005930") # โ ["AAPL", "MSFT", "NVDA", "TSM", "AVGO"]
|
| 620 |
+
|
| 621 |
+
# currency conversion (FRED-based)
|
| 622 |
+
from dartlab.engines.common.finance import getExchangeRate, convertValue
|
| 623 |
+
getExchangeRate("KRW") # KRW/USD rate
|
| 624 |
+
convertValue(1_000_000, "KRW", "USD") # โ ~730.0
|
| 625 |
+
|
| 626 |
+
# audit opinion normalization (KR/EN/JP โ canonical code)
|
| 627 |
+
from dartlab.engines.common.audit import normalizeAuditOpinion
|
| 628 |
+
normalizeAuditOpinion("์ ์ ") # โ "unqualified"
|
| 629 |
+
normalizeAuditOpinion("Qualified") # โ "qualified"
|
| 630 |
+
```
|
| 631 |
+
|
| 632 |
+
Disclosure gap detection runs automatically inside `c.insights` โ flags mismatches between text changes and financial health (e.g. risk text surges while financials are stable).
|
| 633 |
+
|
| 634 |
+
### Export (experimental)
|
| 635 |
+
|
| 636 |
+
> **Experimental** โ Breaking changes possible. Not for production.
|
| 637 |
+
|
| 638 |
+
```bash
|
| 639 |
+
dartlab excel "005930" -o samsung.xlsx
|
| 640 |
+
```
|
| 641 |
+
|
| 642 |
+
Install: `uv add "dartlab[ai]"` (Excel export is included in the AI extras).
|
| 643 |
+
|
| 644 |
+
### Plugins
|
| 645 |
+
|
| 646 |
+
```python
|
| 647 |
+
dartlab.plugins() # list loaded plugins
|
| 648 |
+
dartlab.reload_plugins() # rescan after installing a plugin
|
| 649 |
+
```
|
| 650 |
+
|
| 651 |
+
Plugins can extend DartLab with custom data sources, tools, or analysis engines. See `dartlab plugin create --help` for scaffolding.
|
| 652 |
+
|
| 653 |
+
## EDGAR (US)
|
| 654 |
+
|
| 655 |
+
Same `Company` interface, same account standardization pipeline, different data source. EDGAR data is auto-fetched from the SEC API โ no pre-download needed:
|
| 656 |
+
|
| 657 |
+
```python
|
| 658 |
+
us = dartlab.Company("AAPL")
|
| 659 |
+
|
| 660 |
+
us.sections # 10-K/10-Q sections with heading/body
|
| 661 |
+
us.show("business") # business description
|
| 662 |
+
us.show("10-K::item1ARiskFactors") # risk factors
|
| 663 |
+
us.BS # SEC XBRL balance sheet
|
| 664 |
+
us.ratios # same 47 ratios
|
| 665 |
+
us.diff("10-K::item7Mdna") # MD&A text changes
|
| 666 |
+
us.insights # 10-area grades (A~F)
|
| 667 |
+
|
| 668 |
+
# analyst functions โ auto-detect USD
|
| 669 |
+
dartlab.valuation("AAPL") # DCF + DDM + relative (USD)
|
| 670 |
+
dartlab.forecast("AAPL") # revenue forecast (USD)
|
| 671 |
+
dartlab.simulation("AAPL") # scenario simulation (US macro presets)
|
| 672 |
+
```
|
| 673 |
+
|
| 674 |
+
The interface is identical โ same methods, same structure:
|
| 675 |
+
|
| 676 |
+
```python
|
| 677 |
+
# Korea (DART) # US (EDGAR)
|
| 678 |
+
c = dartlab.Company("005930") c = dartlab.Company("AAPL")
|
| 679 |
+
c.sections c.sections
|
| 680 |
+
c.show("businessOverview") c.show("business")
|
| 681 |
+
c.BS c.BS
|
| 682 |
+
c.ratios c.ratios
|
| 683 |
+
c.diff("businessOverview") c.diff("10-K::item7Mdna")
|
| 684 |
+
c.insights.grades() c.insights.grades()
|
| 685 |
+
```
|
| 686 |
+
|
| 687 |
+
### DART vs EDGAR Namespaces
|
| 688 |
+
|
| 689 |
+
| | DART | EDGAR |
|
| 690 |
+
|---------------|:--------------:|:--------------:|
|
| 691 |
+
| `docs` | โ | โ |
|
| 692 |
+
| `finance` | โ | โ |
|
| 693 |
+
| `report` | โ (28 API types) | โ (not applicable) |
|
| 694 |
+
| `profile` | โ | โ |
|
| 695 |
+
|
| 696 |
+
DART has a `report` namespace with 28 structured disclosure APIs (dividend, governance, executive compensation, etc.). This does not exist in EDGAR โ SEC filings are structured differently.
|
| 697 |
+
|
| 698 |
+
**EDGAR topic naming**: Topics use `{formType}::{itemId}` format. Short aliases also work:
|
| 699 |
+
|
| 700 |
+
```python
|
| 701 |
+
us.show("10-K::item1Business") # full form
|
| 702 |
+
us.show("business") # short alias
|
| 703 |
+
us.show("risk") # โ 10-K::item1ARiskFactors
|
| 704 |
+
us.show("mdna") # โ 10-K::item7Mdna
|
| 705 |
+
```
|
| 706 |
+
|
| 707 |
+
## AI Analysis
|
| 708 |
+
|
| 709 |
+
> **Experimental** โ the AI analysis layer and `analysis/` engines are under active development. APIs, output formats, and available tools may change between versions.
|
| 710 |
+
|
| 711 |
+
> **Tip:** New to financial analysis or prefer natural language? Use `dartlab.ask()` โ the AI assistant handles everything from data download to analysis. No coding knowledge required.
|
| 712 |
+
|
| 713 |
+
DartLab includes a built-in AI analysis layer that feeds structured company data to LLMs. **No code required** โ you can ask questions in plain language and DartLab handles everything: data selection, context assembly, and streaming the answer.
|
| 714 |
+
|
| 715 |
+
```bash
|
| 716 |
+
# terminal one-liner โ no Python needed
|
| 717 |
+
dartlab ask "์ผ์ฑ์ ์ ์ฌ๋ฌด๊ฑด์ ์ฑ ๋ถ์ํด์ค"
|
| 718 |
+
```
|
| 719 |
+
|
| 720 |
+
DartLab structures the data, selects relevant context (financials, insights, sector benchmarks), and lets the LLM explain:
|
| 721 |
+
|
| 722 |
+
```
|
| 723 |
+
$ dartlab ask "์ผ์ฑ์ ์ ์ฌ๋ฌด๊ฑด์ ์ฑ ๋ถ์ํด์ค"
|
| 724 |
+
|
| 725 |
+
์ผ์ฑ์ ์์ ์ฌ๋ฌด๊ฑด์ ์ฑ์ A๋ฑ๊ธ์
๋๋ค.
|
| 726 |
+
|
| 727 |
+
โธ ๋ถ์ฑ๋น์จ 31.8% โ ์
์ข
ํ๊ท (45.2%) ๋๋น ์ํธ
|
| 728 |
+
โธ ์ ๋๋น์จ 258.6% โ 200% ์์ ๊ธฐ์ค ์ํ
|
| 729 |
+
โธ ์ด์๋ณด์๋ฐฐ์ 22.1๋ฐฐ โ ์ด์ ๋ถ๋ด ๋งค์ฐ ๋ฎ์
|
| 730 |
+
โธ ROE ํ๋ณต์ธ: 1.6% โ 10.2% (4๋ถ๊ธฐ ์ฐ์ ๊ฐ์ )
|
| 731 |
+
|
| 732 |
+
[๋ฐ์ดํฐ ์ถ์ฒ: 2024Q4 ์ฌ์
๋ณด๊ณ ์, dartlab insights ์์ง]
|
| 733 |
+
```
|
| 734 |
+
|
| 735 |
+
For real-time market-wide disclosure questions (e.g. "์ต๊ทผ 7์ผ ์์ฃผ๊ณต์ ์๋ ค์ค"), the AI uses your `OpenDART API key` to search recent filings directly. Store the key in project `.env` or via UI Settings.
|
| 736 |
+
|
| 737 |
+
The 2-tier architecture means basic analysis works with any provider, while tool-calling providers (OpenAI, Claude) can go deeper by requesting additional data mid-conversation.
|
| 738 |
+
|
| 739 |
+
### Python API
|
| 740 |
+
|
| 741 |
+
```python
|
| 742 |
+
import dartlab
|
| 743 |
+
|
| 744 |
+
# streams to stdout, returns full text
|
| 745 |
+
answer = dartlab.ask("์ผ์ฑ์ ์ ์ฌ๋ฌด๊ฑด์ ์ฑ ๋ถ์ํด์ค")
|
| 746 |
+
|
| 747 |
+
# provider + model override
|
| 748 |
+
answer = dartlab.ask("์ผ์ฑ์ ์ ๋ถ์", provider="openai", model="gpt-4o")
|
| 749 |
+
|
| 750 |
+
# data filtering
|
| 751 |
+
answer = dartlab.ask("์ผ์ฑ์ ์ ํต์ฌ ํฌ์ธํธ", include=["BS", "IS"])
|
| 752 |
+
|
| 753 |
+
# analysis pattern (framework-guided)
|
| 754 |
+
answer = dartlab.ask("์ผ์ฑ์ ์ ๋ถ์", pattern="financial")
|
| 755 |
+
|
| 756 |
+
# agent mode โ LLM selects tools for deeper analysis
|
| 757 |
+
answer = dartlab.chat("005930", "๋ฐฐ๋น ์ถ์ธ๋ฅผ ๋ถ์ํ๊ณ ์ด์ ์งํ๋ฅผ ์ฐพ์์ค")
|
| 758 |
+
```
|
| 759 |
+
|
| 760 |
+
### CLI
|
| 761 |
+
|
| 762 |
+
```bash
|
| 763 |
+
# provider setup โ free providers first
|
| 764 |
+
dartlab setup # list all providers
|
| 765 |
+
dartlab setup gemini # Google Gemini (free)
|
| 766 |
+
dartlab setup groq # Groq (free)
|
| 767 |
+
|
| 768 |
+
# status
|
| 769 |
+
dartlab status # all providers (table view)
|
| 770 |
+
dartlab status --cost # cumulative token/cost stats
|
| 771 |
+
|
| 772 |
+
# ask questions (streaming by default)
|
| 773 |
+
dartlab ask "์ผ์ฑ์ ์ ์ฌ๋ฌด๊ฑด์ ์ฑ ๋ถ์ํด์ค"
|
| 774 |
+
dartlab ask "AAPL risk analysis" -p ollama
|
| 775 |
+
dartlab ask --continue "๋ฐฐ๋น ์ถ์ธ๋?"
|
| 776 |
+
|
| 777 |
+
# auto-generate report
|
| 778 |
+
dartlab report "์ผ์ฑ์ ์" -o report.md
|
| 779 |
+
|
| 780 |
+
# web UI
|
| 781 |
+
dartlab # open browser UI
|
| 782 |
+
dartlab --help # show all commands
|
| 783 |
+
```
|
| 784 |
+
|
| 785 |
+
<details>
|
| 786 |
+
<summary>All CLI commands (16)</summary>
|
| 787 |
+
|
| 788 |
+
| Category | Command | Description |
|
| 789 |
+
|----------|---------|-------------|
|
| 790 |
+
| Data | `show` | Open any topic by name |
|
| 791 |
+
| Data | `search` | Find companies by name or code |
|
| 792 |
+
| Data | `statement` | BS / IS / CF / SCE output |
|
| 793 |
+
| Data | `sections` | Raw docs sections |
|
| 794 |
+
| Data | `profile` | Company index and facts |
|
| 795 |
+
| Data | `modules` | List all available modules |
|
| 796 |
+
| AI | `ask` | Natural language question |
|
| 797 |
+
| AI | `report` | Auto-generate analysis report |
|
| 798 |
+
| Export | `excel` | Export to Excel (experimental) |
|
| 799 |
+
| Collect | `collect` | Download / refresh / batch collect |
|
| 800 |
+
| Collect | `collect --check` | Check freshness (new filings) |
|
| 801 |
+
| Collect | `collect --incremental` | Incremental collect (missing only) |
|
| 802 |
+
| Server | `ai` | Launch web UI (localhost:8400) |
|
| 803 |
+
| Server | `share` | Tunnel sharing (ngrok / cloudflared) |
|
| 804 |
+
| Server | `status` | Provider connection status |
|
| 805 |
+
| Server | `setup` | Provider setup wizard |
|
| 806 |
+
| MCP | `mcp` | Start MCP stdio server |
|
| 807 |
+
| Plugin | `plugin` | Create / list plugins |
|
| 808 |
+
|
| 809 |
+
</details>
|
| 810 |
+
|
| 811 |
+
### Providers
|
| 812 |
+
|
| 813 |
+
**Free API key providers** โ sign up, paste the key, start analyzing:
|
| 814 |
+
|
| 815 |
+
| Provider | Free Tier | Model | Setup |
|
| 816 |
+
|----------|-----------|-------|-------|
|
| 817 |
+
| `gemini` | Gemini 2.5 Pro/Flash free | Gemini 2.5 | `dartlab setup gemini` |
|
| 818 |
+
| `groq` | 6Kโ30K TPM free | LLaMA 3.3 70B | `dartlab setup groq` |
|
| 819 |
+
| `cerebras` | 1M tokens/day permanent | LLaMA 3.3 70B | `dartlab setup cerebras` |
|
| 820 |
+
| `mistral` | 1B tokens/month free | Mistral Small | `dartlab setup mistral` |
|
| 821 |
+
|
| 822 |
+
**Other providers:**
|
| 823 |
+
|
| 824 |
+
| Provider | Auth | Cost | Tool Calling |
|
| 825 |
+
|----------|------|------|:---:|
|
| 826 |
+
| `oauth-codex` | ChatGPT subscription (Plus/Team/Enterprise) | Included in subscription | Yes |
|
| 827 |
+
| `openai` | API key (`OPENAI_API_KEY`) | Pay-per-token | Yes |
|
| 828 |
+
| `ollama` | Local install, no account needed | Free | Depends on model |
|
| 829 |
+
| `codex` | Codex CLI installed locally | Free (uses your Codex session) | Yes |
|
| 830 |
+
| `custom` | Any OpenAI-compatible endpoint | Varies | Varies |
|
| 831 |
+
|
| 832 |
+
**Auto-fallback:** Set multiple free API keys and DartLab automatically switches to the next provider when one hits its rate limit. Use `provider="free"` to enable the fallback chain:
|
| 833 |
+
|
| 834 |
+
```python
|
| 835 |
+
dartlab.ask("์ผ์ฑ์ ์ ๋ถ์", provider="free")
|
| 836 |
+
```
|
| 837 |
+
|
| 838 |
+
**Why no Claude provider?** Anthropic does not offer OAuth-based access. Without OAuth, there is no way to let users authenticate with their existing subscription โ we would have to ask users to paste API keys, which goes against DartLab's frictionless design. If Anthropic adds OAuth support in the future, we will add a Claude provider. For now, Claude works through **MCP** (see below) โ Claude Desktop, Claude Code, and Cursor can call DartLab's 60 tools directly.
|
| 839 |
+
|
| 840 |
+
**`oauth-codex`** is the recommended provider โ if you have a ChatGPT subscription, it works out of the box with no API keys. Run `dartlab setup oauth-codex` to authenticate.
|
| 841 |
+
|
| 842 |
+
**Web UI (`dartlab`)** launches a browser-based chat interface for interactive analysis. This feature is currently **experimental** โ we are evaluating the right scope and UX for visualization and collaborative features.
|
| 843 |
+
|
| 844 |
+
Install AI dependencies: `uv add "dartlab[ai]"`
|
| 845 |
+
|
| 846 |
+
### Project Settings (`.dartlab.yml`)
|
| 847 |
+
|
| 848 |
+
```yaml
|
| 849 |
+
company: 005930 # default company
|
| 850 |
+
provider: openai # default LLM provider
|
| 851 |
+
model: gpt-4o # default model
|
| 852 |
+
verbose: false
|
| 853 |
+
```
|
| 854 |
+
|
| 855 |
+
## MCP โ AI Assistant Integration
|
| 856 |
+
|
| 857 |
+
DartLab includes a built-in [MCP](https://modelcontextprotocol.io/) server that exposes 60 tools (16 global + 44 per-company) to Claude Desktop, Claude Code, Cursor, and any MCP-compatible client.
|
| 858 |
+
|
| 859 |
+
```bash
|
| 860 |
+
uv add "dartlab[mcp]"
|
| 861 |
+
```
|
| 862 |
+
|
| 863 |
+
### Claude Desktop
|
| 864 |
+
|
| 865 |
+
Add to `claude_desktop_config.json`:
|
| 866 |
+
|
| 867 |
+
```json
|
| 868 |
+
{
|
| 869 |
+
"mcpServers": {
|
| 870 |
+
"dartlab": {
|
| 871 |
+
"command": "uv",
|
| 872 |
+
"args": ["run", "dartlab", "mcp"]
|
| 873 |
+
}
|
| 874 |
+
}
|
| 875 |
+
}
|
| 876 |
+
```
|
| 877 |
+
|
| 878 |
+
### Claude Code
|
| 879 |
+
|
| 880 |
+
```bash
|
| 881 |
+
claude mcp add dartlab -- uv run dartlab mcp
|
| 882 |
+
```
|
| 883 |
+
|
| 884 |
+
Or add to `~/.claude/settings.json`:
|
| 885 |
+
|
| 886 |
+
```json
|
| 887 |
+
{
|
| 888 |
+
"mcpServers": {
|
| 889 |
+
"dartlab": {
|
| 890 |
+
"command": "uv",
|
| 891 |
+
"args": ["run", "dartlab", "mcp"]
|
| 892 |
+
}
|
| 893 |
+
}
|
| 894 |
+
}
|
| 895 |
+
```
|
| 896 |
+
|
| 897 |
+
### Cursor
|
| 898 |
+
|
| 899 |
+
Add to `.cursor/mcp.json` with the same config format as Claude Desktop.
|
| 900 |
+
|
| 901 |
+
### What's Available
|
| 902 |
+
|
| 903 |
+
Once connected, your AI assistant can:
|
| 904 |
+
|
| 905 |
+
- **Search** โ find companies by name or code (`search_company`)
|
| 906 |
+
- **Show** โ read any disclosure topic (`show_topic`, `list_topics`, `diff_topic`)
|
| 907 |
+
- **Finance** โ balance sheet, income statement, cash flow, ratios (`get_financial_statements`, `get_ratios`)
|
| 908 |
+
- **Analysis** โ insights, sector ranking, valuation (`get_insight`, `get_ranking`)
|
| 909 |
+
- **EDGAR** โ same tools work for US companies (`stock_code: "AAPL"`)
|
| 910 |
+
|
| 911 |
+
Auto-generate config for your platform:
|
| 912 |
+
|
| 913 |
+
```bash
|
| 914 |
+
dartlab mcp --config claude-desktop
|
| 915 |
+
dartlab mcp --config claude-code
|
| 916 |
+
dartlab mcp --config cursor
|
| 917 |
+
```
|
| 918 |
+
|
| 919 |
+
## OpenAPI โ Raw Public APIs
|
| 920 |
+
|
| 921 |
+
Use source-native wrappers when you want raw disclosure APIs directly.
|
| 922 |
+
|
| 923 |
+
### OpenDart (Korea)
|
| 924 |
+
|
| 925 |
+
> **Note:** `Company` does **not** require an API key โ it uses pre-built datasets.
|
| 926 |
+
> `OpenDart` uses the raw DART API and requires a key from [opendart.fss.or.kr](https://opendart.fss.or.kr) (free).
|
| 927 |
+
> Recent filing-list AI questions across the whole market also use this key. In the UI, open Settings and manage `OpenDART API key` there.
|
| 928 |
+
|
| 929 |
+
```python
|
| 930 |
+
from dartlab import OpenDart
|
| 931 |
+
|
| 932 |
+
d = OpenDart()
|
| 933 |
+
d.search("์นด์นด์ค", listed=True)
|
| 934 |
+
d.filings("์ผ์ฑ์ ์", "2024")
|
| 935 |
+
d.finstate("์ผ์ฑ์ ์", 2024)
|
| 936 |
+
d.report("์ผ์ฑ์ ์", "๋ฐฐ๋น", 2024)
|
| 937 |
+
```
|
| 938 |
+
|
| 939 |
+
### OpenEdgar (US)
|
| 940 |
+
|
| 941 |
+
> **No API key required.** SEC EDGAR is a public API โ no registration needed.
|
| 942 |
+
|
| 943 |
+
```python
|
| 944 |
+
from dartlab import OpenEdgar
|
| 945 |
+
|
| 946 |
+
e = OpenEdgar()
|
| 947 |
+
e.search("Apple")
|
| 948 |
+
e.filings("AAPL", forms=["10-K", "10-Q"])
|
| 949 |
+
e.companyFactsJson("AAPL")
|
| 950 |
+
```
|
| 951 |
+
|
| 952 |
+
## Data
|
| 953 |
+
|
| 954 |
+
**No manual setup required.** When you create a `Company`, dartlab automatically downloads the required data.
|
| 955 |
+
|
| 956 |
+
| Dataset | Coverage | Size | Source |
|
| 957 |
+
|---------|----------|------|--------|
|
| 958 |
+
| DART docs | 2,500+ companies | ~8 GB | [HuggingFace](https://huggingface.co/datasets/eddmpython/dartlab-data/tree/main/dart/docs) |
|
| 959 |
+
| DART finance | 2,700+ companies | ~600 MB | [HuggingFace](https://huggingface.co/datasets/eddmpython/dartlab-data/tree/main/dart/finance) |
|
| 960 |
+
| DART report | 2,700+ companies | ~320 MB | [HuggingFace](https://huggingface.co/datasets/eddmpython/dartlab-data/tree/main/dart/report) |
|
| 961 |
+
| EDGAR | On-demand | โ | SEC API (auto-fetched) |
|
| 962 |
+
|
| 963 |
+
### 3-Step Data Pipeline
|
| 964 |
+
|
| 965 |
+
```
|
| 966 |
+
dartlab.Company("005930")
|
| 967 |
+
โ
|
| 968 |
+
โโ 1. Local cache โโโโ already have it? done (instant)
|
| 969 |
+
โ
|
| 970 |
+
โโ 2. HuggingFace โโโโ auto-download (~seconds, no key needed)
|
| 971 |
+
โ
|
| 972 |
+
โโ 3. DART API โโโโโโโโ collect with your API key (needs key)
|
| 973 |
+
```
|
| 974 |
+
|
| 975 |
+
If a company is not in HuggingFace, dartlab collects data directly from DART โ this requires an API key:
|
| 976 |
+
|
| 977 |
+
```bash
|
| 978 |
+
dartlab setup dart-key
|
| 979 |
+
```
|
| 980 |
+
|
| 981 |
+
### Freshness โ Automatic Update Detection
|
| 982 |
+
|
| 983 |
+
DartLab uses a 3-layer freshness system to keep your local data current:
|
| 984 |
+
|
| 985 |
+
| Layer | Method | Cost |
|
| 986 |
+
|-------|--------|------|
|
| 987 |
+
| L1 | HTTP HEAD โ ETag comparison with HuggingFace | ~0.5s, few hundred bytes |
|
| 988 |
+
| L2 | Local file age (90-day TTL fallback) | instant (local) |
|
| 989 |
+
| L3 | DART API โ `rcept_no` diff (requires API key) | 1 API call, ~1s |
|
| 990 |
+
|
| 991 |
+
When you open a `Company`, dartlab checks if newer data exists. If a new disclosure was filed:
|
| 992 |
+
|
| 993 |
+
```python
|
| 994 |
+
c = dartlab.Company("005930")
|
| 995 |
+
# [dartlab] โ 005930 โ ์ ๊ณต์ 2๊ฑด ๋ฐ๊ฒฌ (์ฌ์
๋ณด๊ณ ์ (2024.12))
|
| 996 |
+
# โข ์ฆ๋ถ ์์ง: dartlab collect --incremental 005930
|
| 997 |
+
# โข ๋๋ Python: c.update()
|
| 998 |
+
|
| 999 |
+
c.update() # incremental collect โ only missing filings
|
| 1000 |
+
```
|
| 1001 |
+
|
| 1002 |
+
```bash
|
| 1003 |
+
# CLI freshness check
|
| 1004 |
+
dartlab collect --check 005930 # single company
|
| 1005 |
+
dartlab collect --check # scan all local companies (7 days)
|
| 1006 |
+
|
| 1007 |
+
# incremental collect โ only missing filings
|
| 1008 |
+
dartlab collect --incremental 005930 # single company
|
| 1009 |
+
dartlab collect --incremental # all local companies with new filings
|
| 1010 |
+
```
|
| 1011 |
+
|
| 1012 |
+
### Batch Collection (DART API)
|
| 1013 |
+
|
| 1014 |
+
```bash
|
| 1015 |
+
dartlab collect --batch # all listed, missing only
|
| 1016 |
+
dartlab collect --batch -c finance 005930 # specific category + company
|
| 1017 |
+
dartlab collect --batch --mode all # re-collect everything
|
| 1018 |
+
```
|
| 1019 |
+
|
| 1020 |
+
## Try It Now
|
| 1021 |
+
|
| 1022 |
+
### Live Demo (No Install)
|
| 1023 |
+
|
| 1024 |
+
Try DartLab instantly โ no Python, no terminal, no setup:
|
| 1025 |
+
|
| 1026 |
+
**[โ Open Live Demo](https://huggingface.co/spaces/eddmpython/dartlab)** โ enter a stock code, see financials immediately
|
| 1027 |
+
|
| 1028 |
+
Or open a [Colab notebook](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/showcase/01_quickstart.ipynb) in your browser.
|
| 1029 |
+
|
| 1030 |
+
### Marimo Notebooks
|
| 1031 |
+
|
| 1032 |
+
> Data is automatically downloaded on first use. No setup required unless collecting new companies directly from DART.
|
| 1033 |
+
|
| 1034 |
+
```bash
|
| 1035 |
+
uv add dartlab marimo
|
| 1036 |
+
marimo edit notebooks/marimo/dartCompany.py # Korean company (DART)
|
| 1037 |
+
marimo edit notebooks/marimo/edgarCompany.py # US company (EDGAR)
|
| 1038 |
+
marimo edit notebooks/marimo/aiAnalysis.py # AI analysis examples
|
| 1039 |
+
```
|
| 1040 |
+
|
| 1041 |
+
### Colab Notebooks
|
| 1042 |
+
|
| 1043 |
+
**Showcase** (English โ global audience):
|
| 1044 |
+
|
| 1045 |
+
| Notebook | Topic |
|
| 1046 |
+
|---|---|
|
| 1047 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/showcase/01_quickstart.ipynb) | **Quick Start** โ analyze any company in 3 lines |
|
| 1048 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/showcase/02_financial_analysis.ipynb) | **Financial Analysis** โ statements, time series, ratios |
|
| 1049 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/showcase/03_kr_us_compare.ipynb) | **Korea vs US** โ Samsung vs Apple side-by-side |
|
| 1050 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/showcase/04_risk_diff.ipynb) | **Risk Diff** โ track disclosure changes (Bloomberg can't) |
|
| 1051 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/showcase/05_sector_screening.ipynb) | **Sector Screening** โ 8 presets, sector benchmarks |
|
| 1052 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/showcase/06_insight_anomaly.ipynb) | **Insight & Anomaly** โ 10-area grading, 6 anomaly rules |
|
| 1053 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/showcase/07_network_governance.ipynb) | **Network & Governance** โ corporate relationship graph |
|
| 1054 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/showcase/08_signal_trend.ipynb) | **Signal Trends** โ 48-keyword disclosure monitoring |
|
| 1055 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/showcase/09_ai_analysis.ipynb) | **AI Analysis** โ `dartlab.ask()` with 9 LLM providers |
|
| 1056 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/showcase/10_disclosure_deep_dive.ipynb) | **Disclosure Deep Dive** โ sections architecture |
|
| 1057 |
+
|
| 1058 |
+
<details>
|
| 1059 |
+
<summary>ํ๊ตญ์ด Tutorials</summary>
|
| 1060 |
+
|
| 1061 |
+
| Notebook | Topic |
|
| 1062 |
+
|---|---|
|
| 1063 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/getting-started/quickstart.ipynb) | **๋น ๋ฅธ ์์** โ sections, show, trace, diff |
|
| 1064 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/tutorials/02_financial_statements.ipynb) | **์ฌ๋ฌด์ ํ** โ BS, IS, CF |
|
| 1065 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/tutorials/04_ratios.ipynb) | **์ฌ๋ฌด๋น์จ** โ 47๊ฐ ๋น์จ |
|
| 1066 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/tutorials/06_disclosure.ipynb) | **๊ณต์ ํ
์คํธ** โ sections ํ์ฑ |
|
| 1067 |
+
| [](https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/tutorials/09_edgar.ipynb) | **EDGAR** โ ๋ฏธ๊ตญ SEC |
|
| 1068 |
+
|
| 1069 |
+
</details>
|
| 1070 |
+
|
| 1071 |
+
## Documentation
|
| 1072 |
+
|
| 1073 |
+
- Docs: https://eddmpython.github.io/dartlab/
|
| 1074 |
+
- Sections guide: https://eddmpython.github.io/dartlab/docs/getting-started/sections
|
| 1075 |
+
- Quick start: https://eddmpython.github.io/dartlab/docs/getting-started/quickstart
|
| 1076 |
+
- API overview: https://eddmpython.github.io/dartlab/docs/api/overview
|
| 1077 |
+
- Beginner guide (Korean): https://eddmpython.github.io/dartlab/blog/dartlab-easy-start/
|
| 1078 |
+
|
| 1079 |
+
### Blog
|
| 1080 |
+
|
| 1081 |
+
The [DartLab Blog](https://eddmpython.github.io/dartlab/blog/) covers practical disclosure analysis โ how to read reports, interpret patterns, and spot risk signals. 120+ articles across three categories:
|
| 1082 |
+
|
| 1083 |
+
- **Disclosure Systems** โ structure and mechanics of DART/EDGAR filings
|
| 1084 |
+
- **Report Reading** โ practical guide to audit reports, preliminary earnings, restatements
|
| 1085 |
+
- **Financial Interpretation** โ financial statements, ratios, and disclosure signals
|
| 1086 |
+
|
| 1087 |
+
## Stability
|
| 1088 |
+
|
| 1089 |
+
| Tier | Scope |
|
| 1090 |
+
|------|-------|
|
| 1091 |
+
| **Stable** | DART Company (sections, show, trace, diff, BS/IS/CF, CIS, index, filings, profile), EDGAR Company core, valuation, forecast, simulation |
|
| 1092 |
+
| **Beta** | EDGAR power-user (SCE, notes, freq, coverage), insights, distress, ratios, timeseries, network, governance, workforce, capital, debt, chart/table/text tools, ask/chat, OpenDart, OpenEdgar, Server API, MCP, CLI subcommands |
|
| 1093 |
+
| **Experimental** | AI tool calling, export |
|
| 1094 |
+
| **Alpha** | Desktop App (Windows .exe) โ functional but incomplete, Sections Viewer โ not yet fully structured |
|
| 1095 |
+
|
| 1096 |
+
See [docs/stability.md](docs/stability.md).
|
| 1097 |
+
|
| 1098 |
+
## Contributing
|
| 1099 |
+
|
| 1100 |
+
The project prefers **experiments before engine changes**. If you want to propose a parser or mapping change, validate it in `experiments/` first and bring the verified result back into the engine.
|
| 1101 |
+
|
| 1102 |
+
- **Experiment folder**: `experiments/XXX_camelCaseName/` โ each file must be independently runnable with actual results in its docstring
|
| 1103 |
+
- **Data contributions** (e.g. `accountMappings.json`, `sectionMappings.json`): only accepted when backed by experiment evidence โ no manual bulk edits
|
| 1104 |
+
- Issues and PRs in Korean or English are both welcome
|
| 1105 |
+
|
| 1106 |
+
## License
|
| 1107 |
+
|
| 1108 |
+
MIT
|
app.py
DELETED
|
@@ -1,623 +0,0 @@
|
|
| 1 |
-
"""DartLab Streamlit Demo โ AI ์ฑํ
๊ธฐ๋ฐ ๊ธฐ์
๋ถ์."""
|
| 2 |
-
|
| 3 |
-
from __future__ import annotations
|
| 4 |
-
|
| 5 |
-
import gc
|
| 6 |
-
import io
|
| 7 |
-
import os
|
| 8 |
-
import re
|
| 9 |
-
|
| 10 |
-
import pandas as pd
|
| 11 |
-
import streamlit as st
|
| 12 |
-
|
| 13 |
-
import dartlab
|
| 14 |
-
|
| 15 |
-
# โโ ์ค์ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 16 |
-
|
| 17 |
-
_MAX_CACHE = 2
|
| 18 |
-
_LOGO_URL = "https://raw.githubusercontent.com/eddmpython/dartlab/master/.github/assets/logo.png"
|
| 19 |
-
_BLOG_URL = "https://eddmpython.github.io/dartlab/blog/dartlab-easy-start/"
|
| 20 |
-
_DOCS_URL = "https://eddmpython.github.io/dartlab/docs/getting-started/quickstart"
|
| 21 |
-
_COLAB_URL = "https://colab.research.google.com/github/eddmpython/dartlab/blob/master/notebooks/showcase/01_quickstart.ipynb"
|
| 22 |
-
_REPO_URL = "https://github.com/eddmpython/dartlab"
|
| 23 |
-
|
| 24 |
-
_HAS_OPENAI = bool(os.environ.get("OPENAI_API_KEY"))
|
| 25 |
-
|
| 26 |
-
if _HAS_OPENAI:
|
| 27 |
-
dartlab.llm.configure(provider="openai", api_key=os.environ["OPENAI_API_KEY"])
|
| 28 |
-
|
| 29 |
-
# โโ ํ์ด์ง ์ค์ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 30 |
-
|
| 31 |
-
st.set_page_config(
|
| 32 |
-
page_title="DartLab โ AI ๊ธฐ์
๋ถ์",
|
| 33 |
-
page_icon=None,
|
| 34 |
-
layout="centered",
|
| 35 |
-
)
|
| 36 |
-
|
| 37 |
-
# โโ CSS โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 38 |
-
|
| 39 |
-
st.markdown("""
|
| 40 |
-
<style>
|
| 41 |
-
/* ๋คํฌ ํ
๋ง ๊ฐ์ */
|
| 42 |
-
html, body, [data-testid="stAppViewContainer"],
|
| 43 |
-
[data-testid="stApp"], .main, .block-container {
|
| 44 |
-
background-color: #050811 !important;
|
| 45 |
-
color: #f1f5f9 !important;
|
| 46 |
-
}
|
| 47 |
-
[data-testid="stHeader"] { background: #050811 !important; }
|
| 48 |
-
[data-testid="stSidebar"] { background: #0f1219 !important; }
|
| 49 |
-
|
| 50 |
-
/* ์
๋ ฅ ํ๋ */
|
| 51 |
-
input, textarea,
|
| 52 |
-
[data-baseweb="input"] input, [data-baseweb="textarea"] textarea,
|
| 53 |
-
[data-baseweb="input"], [data-baseweb="base-input"] {
|
| 54 |
-
background-color: #0f1219 !important;
|
| 55 |
-
color: #f1f5f9 !important;
|
| 56 |
-
border-color: #1e2433 !important;
|
| 57 |
-
}
|
| 58 |
-
|
| 59 |
-
/* ์
๋ ํธ/๋๋กญ๋ค์ด */
|
| 60 |
-
[data-baseweb="select"] > div {
|
| 61 |
-
background-color: #0f1219 !important;
|
| 62 |
-
border-color: #1e2433 !important;
|
| 63 |
-
color: #f1f5f9 !important;
|
| 64 |
-
}
|
| 65 |
-
[data-baseweb="popover"], [data-baseweb="menu"] {
|
| 66 |
-
background-color: #0f1219 !important;
|
| 67 |
-
}
|
| 68 |
-
[data-baseweb="menu"] li { color: #f1f5f9 !important; }
|
| 69 |
-
[data-baseweb="menu"] li:hover { background-color: #1a1f2b !important; }
|
| 70 |
-
|
| 71 |
-
/* ๋ผ๋์ค */
|
| 72 |
-
[data-testid="stRadio"] label { color: #f1f5f9 !important; }
|
| 73 |
-
|
| 74 |
-
/* ๋ฒํผ โ dartlab primary ํต์ผ */
|
| 75 |
-
button, [data-testid="stBaseButton-primary"],
|
| 76 |
-
[data-testid="stBaseButton-secondary"],
|
| 77 |
-
[data-testid="stFormSubmitButton"] button,
|
| 78 |
-
[data-testid="stChatInputSubmitButton"] {
|
| 79 |
-
background-color: #ea4647 !important;
|
| 80 |
-
color: #fff !important;
|
| 81 |
-
border: none !important;
|
| 82 |
-
font-weight: 600 !important;
|
| 83 |
-
}
|
| 84 |
-
button:hover, [data-testid="stBaseButton-primary"]:hover,
|
| 85 |
-
[data-testid="stChatInputSubmitButton"]:hover {
|
| 86 |
-
background-color: #c83232 !important;
|
| 87 |
-
}
|
| 88 |
-
[data-testid="stDownloadButton"] button {
|
| 89 |
-
background-color: #0f1219 !important;
|
| 90 |
-
color: #f1f5f9 !important;
|
| 91 |
-
border: 1px solid #1e2433 !important;
|
| 92 |
-
}
|
| 93 |
-
[data-testid="stDownloadButton"] button:hover {
|
| 94 |
-
border-color: #ea4647 !important;
|
| 95 |
-
color: #ea4647 !important;
|
| 96 |
-
background-color: #0f1219 !important;
|
| 97 |
-
}
|
| 98 |
-
/* expander ํ ๊ธ์ ๋ฐฐ๊ฒฝ์ ์ ๊ฑฐ */
|
| 99 |
-
[data-testid="stExpander"] button {
|
| 100 |
-
background-color: transparent !important;
|
| 101 |
-
color: #f1f5f9 !important;
|
| 102 |
-
}
|
| 103 |
-
|
| 104 |
-
/* Expander */
|
| 105 |
-
[data-testid="stExpander"] {
|
| 106 |
-
background-color: #0f1219 !important;
|
| 107 |
-
border-color: #1e2433 !important;
|
| 108 |
-
}
|
| 109 |
-
|
| 110 |
-
/* Chat */
|
| 111 |
-
[data-testid="stChatMessage"] {
|
| 112 |
-
background-color: #0a0e17 !important;
|
| 113 |
-
border-color: #1e2433 !important;
|
| 114 |
-
}
|
| 115 |
-
[data-testid="stChatInput"], [data-testid="stChatInput"] textarea {
|
| 116 |
-
background-color: #0f1219 !important;
|
| 117 |
-
border-color: #1e2433 !important;
|
| 118 |
-
color: #f1f5f9 !important;
|
| 119 |
-
}
|
| 120 |
-
|
| 121 |
-
/* ํ
์คํธ */
|
| 122 |
-
p, span, label, h1, h2, h3, h4, h5, h6,
|
| 123 |
-
[data-testid="stMarkdownContainer"],
|
| 124 |
-
[data-testid="stMarkdownContainer"] p {
|
| 125 |
-
color: #f1f5f9 !important;
|
| 126 |
-
}
|
| 127 |
-
[data-testid="stCaption"] { color: #64748b !important; }
|
| 128 |
-
|
| 129 |
-
/* DataFrame */
|
| 130 |
-
[data-testid="stDataFrame"] { font-variant-numeric: tabular-nums; }
|
| 131 |
-
|
| 132 |
-
/* ์ปค์คํ
*/
|
| 133 |
-
.dl-header {
|
| 134 |
-
text-align: center;
|
| 135 |
-
padding: 1.5rem 0 0.5rem;
|
| 136 |
-
}
|
| 137 |
-
.dl-header img {
|
| 138 |
-
border-radius: 50%;
|
| 139 |
-
box-shadow: 0 0 48px rgba(234,70,71,0.25);
|
| 140 |
-
}
|
| 141 |
-
.dl-header h1 {
|
| 142 |
-
background: linear-gradient(135deg, #ea4647, #f87171, #ea4647);
|
| 143 |
-
-webkit-background-clip: text;
|
| 144 |
-
-webkit-text-fill-color: transparent;
|
| 145 |
-
background-clip: text;
|
| 146 |
-
font-size: 2.4rem !important;
|
| 147 |
-
font-weight: 800 !important;
|
| 148 |
-
margin: 0.5rem 0 0.1rem !important;
|
| 149 |
-
letter-spacing: -0.03em;
|
| 150 |
-
}
|
| 151 |
-
.dl-header .tagline { color: #94a3b8 !important; font-size: 1rem; margin: 0; }
|
| 152 |
-
.dl-header .sub { color: #64748b !important; font-size: 0.82rem; margin: 0.15rem 0 0; }
|
| 153 |
-
|
| 154 |
-
.dl-card {
|
| 155 |
-
background: linear-gradient(135deg, #0f1219 0%, #0a0d16 100%);
|
| 156 |
-
border: 1px solid #1e2433;
|
| 157 |
-
border-radius: 12px;
|
| 158 |
-
padding: 1.2rem 1.5rem;
|
| 159 |
-
margin: 0.8rem 0;
|
| 160 |
-
position: relative;
|
| 161 |
-
overflow: hidden;
|
| 162 |
-
}
|
| 163 |
-
.dl-card::before {
|
| 164 |
-
content: '';
|
| 165 |
-
position: absolute;
|
| 166 |
-
top: 0; left: 0; right: 0;
|
| 167 |
-
height: 3px;
|
| 168 |
-
background: linear-gradient(90deg, #ea4647, #f87171, #fb923c);
|
| 169 |
-
}
|
| 170 |
-
.dl-card h3 { color: #f1f5f9 !important; font-size: 1.3rem !important; margin: 0 0 0.8rem !important; }
|
| 171 |
-
.dl-card .meta { display: flex; gap: 2.5rem; flex-wrap: wrap; }
|
| 172 |
-
.dl-card .meta-item { display: flex; flex-direction: column; gap: 0.1rem; }
|
| 173 |
-
.dl-card .meta-label {
|
| 174 |
-
color: #64748b !important; font-size: 0.72rem;
|
| 175 |
-
text-transform: uppercase; letter-spacing: 0.08em;
|
| 176 |
-
}
|
| 177 |
-
.dl-card .meta-value {
|
| 178 |
-
color: #e2e8f0 !important; font-size: 1.1rem; font-weight: 600;
|
| 179 |
-
font-family: 'JetBrains Mono', monospace;
|
| 180 |
-
}
|
| 181 |
-
|
| 182 |
-
.dl-section {
|
| 183 |
-
color: #ea4647 !important;
|
| 184 |
-
font-weight: 700 !important;
|
| 185 |
-
font-size: 1.05rem !important;
|
| 186 |
-
border-bottom: 2px solid #ea4647;
|
| 187 |
-
padding-bottom: 0.3rem;
|
| 188 |
-
margin: 1rem 0 0.6rem;
|
| 189 |
-
}
|
| 190 |
-
|
| 191 |
-
.dl-footer {
|
| 192 |
-
text-align: center;
|
| 193 |
-
padding: 1.5rem 0 0.8rem;
|
| 194 |
-
border-top: 1px solid #1e2433;
|
| 195 |
-
margin-top: 2rem;
|
| 196 |
-
color: #475569 !important;
|
| 197 |
-
font-size: 0.82rem;
|
| 198 |
-
}
|
| 199 |
-
.dl-footer a { color: #94a3b8 !important; text-decoration: none; margin: 0 0.5rem; }
|
| 200 |
-
.dl-footer a:hover { color: #ea4647 !important; }
|
| 201 |
-
|
| 202 |
-
.dl-hero-glow {
|
| 203 |
-
position: fixed;
|
| 204 |
-
top: 0; left: 50%;
|
| 205 |
-
transform: translateX(-50%);
|
| 206 |
-
width: 600px; height: 400px;
|
| 207 |
-
background: radial-gradient(ellipse at top, rgba(234,70,71,0.05) 0%, transparent 60%);
|
| 208 |
-
pointer-events: none; z-index: 0;
|
| 209 |
-
}
|
| 210 |
-
</style>
|
| 211 |
-
""", unsafe_allow_html=True)
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
# โโ ์ ํธ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
def _toPandas(df):
|
| 218 |
-
"""Polars/pandas DataFrame -> pandas."""
|
| 219 |
-
if df is None:
|
| 220 |
-
return None
|
| 221 |
-
if hasattr(df, "to_pandas"):
|
| 222 |
-
return df.to_pandas()
|
| 223 |
-
return df
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
def _formatDf(df: pd.DataFrame) -> pd.DataFrame:
|
| 227 |
-
"""์ซ์๋ฅผ ์ฒ๋จ์ ์ฝค๋ง ๋ฌธ์์ด๋ก ๋ณํ (์์์ ์ ๊ฑฐ)."""
|
| 228 |
-
if df is None or df.empty:
|
| 229 |
-
return df
|
| 230 |
-
result = df.copy()
|
| 231 |
-
for col in result.columns:
|
| 232 |
-
if pd.api.types.is_numeric_dtype(result[col]):
|
| 233 |
-
result[col] = result[col].apply(
|
| 234 |
-
lambda x: f"{int(x):,}" if pd.notna(x) and x == x else ""
|
| 235 |
-
)
|
| 236 |
-
return result
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
def _toExcel(df: pd.DataFrame) -> bytes:
|
| 240 |
-
"""DataFrame -> Excel bytes."""
|
| 241 |
-
buf = io.BytesIO()
|
| 242 |
-
df.to_excel(buf, index=False, engine="openpyxl")
|
| 243 |
-
return buf.getvalue()
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
def _showDf(df: pd.DataFrame, key: str = "", downloadName: str = ""):
|
| 247 |
-
"""DataFrame ํ์ + Excel ๋ค์ด๋ก๋."""
|
| 248 |
-
if df is None or df.empty:
|
| 249 |
-
st.caption("๋ฐ์ดํฐ ์์")
|
| 250 |
-
return
|
| 251 |
-
st.dataframe(_formatDf(df), use_container_width=True, hide_index=True, key=key or None)
|
| 252 |
-
if downloadName:
|
| 253 |
-
st.download_button(
|
| 254 |
-
label="Excel ๋ค์ด๋ก๋",
|
| 255 |
-
data=_toExcel(df),
|
| 256 |
-
file_name=f"{downloadName}.xlsx",
|
| 257 |
-
mime="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
| 258 |
-
key=f"dl_{key}" if key else None,
|
| 259 |
-
)
|
| 260 |
-
|
| 261 |
-
|
| 262 |
-
@st.cache_resource(max_entries=_MAX_CACHE)
|
| 263 |
-
def _getCompany(code: str):
|
| 264 |
-
"""์บ์๋ Company."""
|
| 265 |
-
gc.collect()
|
| 266 |
-
return dartlab.Company(code)
|
| 267 |
-
|
| 268 |
-
|
| 269 |
-
# โโ ์ข
๋ชฉ์ฝ๋ ์ถ์ถ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 270 |
-
|
| 271 |
-
|
| 272 |
-
def _extractCode(message: str) -> str | None:
|
| 273 |
-
"""๋ฉ์์ง์์ ์ข
๋ชฉ์ฝ๋/ํ์ฌ๋ช
์ถ์ถ."""
|
| 274 |
-
msg = message.strip()
|
| 275 |
-
|
| 276 |
-
# 6์๋ฆฌ ์ซ์
|
| 277 |
-
m = re.search(r"\b(\d{6})\b", msg)
|
| 278 |
-
if m:
|
| 279 |
-
return m.group(1)
|
| 280 |
-
|
| 281 |
-
# ์๋ฌธ ํฐ์ปค (๋จ๋
๋๋ฌธ์ 1~5์)
|
| 282 |
-
m = re.search(r"\b([A-Z]{1,5})\b", msg)
|
| 283 |
-
if m:
|
| 284 |
-
return m.group(1)
|
| 285 |
-
|
| 286 |
-
# ํ๊ธ ํ์ฌ๋ช
โ dartlab.search
|
| 287 |
-
cleaned = re.sub(
|
| 288 |
-
r"(์\s*๋ํด|์\s*๋ํ|์๋ํด|์ข|์|๋ฅผ|์|์|๋|์ด|๊ฐ|๋|๋ง|๋ถํฐ|๊น์ง|ํ๊ณ |์ด๋|๋|๋ก|์ผ๋ก|์|๊ณผ|ํํ
|์์|์๊ฒ)\b",
|
| 289 |
-
" ",
|
| 290 |
-
msg,
|
| 291 |
-
)
|
| 292 |
-
# ๋ถํ์ํ ๋์ฌ/์กฐ๋์ฌ ์ ๊ฑฐ
|
| 293 |
-
cleaned = re.sub(
|
| 294 |
-
r"\b(์๋ ค์ค|๋ณด์ฌ์ค|๋ถ์|ํด์ค|ํด๋ด|์ด๋|๋ณด์|๋ณผ๋|์ค|ํด|์ข|์)\b",
|
| 295 |
-
" ",
|
| 296 |
-
cleaned,
|
| 297 |
-
)
|
| 298 |
-
tokens = re.findall(r"[๊ฐ-ํฃA-Za-z0-9]+", cleaned)
|
| 299 |
-
# ๊ธด ํ ํฐ ์ฐ์ (ํ์ฌ๋ช
์ผ ๊ฐ๋ฅ์ฑ ๋์)
|
| 300 |
-
tokens.sort(key=len, reverse=True)
|
| 301 |
-
for token in tokens:
|
| 302 |
-
if len(token) >= 2:
|
| 303 |
-
try:
|
| 304 |
-
results = dartlab.search(token)
|
| 305 |
-
if results is not None and len(results) > 0:
|
| 306 |
-
return str(results[0, "์ข
๋ชฉ์ฝ๋"])
|
| 307 |
-
except Exception:
|
| 308 |
-
continue
|
| 309 |
-
return None
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
def _detectTopic(message: str) -> str | None:
|
| 313 |
-
"""๋ฉ์์ง์์ ํน์ topic ํค์๋ ๊ฐ์ง."""
|
| 314 |
-
topicMap = {
|
| 315 |
-
"๋ฐฐ๋น": "dividend",
|
| 316 |
-
"์ฃผ์ฃผ": "majorHolder",
|
| 317 |
-
"๋์ฃผ์ฃผ": "majorHolder",
|
| 318 |
-
"์ง์": "employee",
|
| 319 |
-
"์์": "executive",
|
| 320 |
-
"์์๋ณด์": "executivePay",
|
| 321 |
-
"๋ณด์": "executivePay",
|
| 322 |
-
"์ธ๊ทธ๋จผํธ": "segments",
|
| 323 |
-
"๋ถ๋ฌธ": "segments",
|
| 324 |
-
"์ฌ์
๋ถ": "segments",
|
| 325 |
-
"์ ํ์์ฐ": "tangibleAsset",
|
| 326 |
-
"๋ฌดํ์์ฐ": "intangibleAsset",
|
| 327 |
-
"์์ฌ๋ฃ": "rawMaterial",
|
| 328 |
-
"์์ฃผ": "salesOrder",
|
| 329 |
-
"์ ํ": "productService",
|
| 330 |
-
"์ํ์ฌ": "subsidiary",
|
| 331 |
-
"์ข
์": "subsidiary",
|
| 332 |
-
"๋ถ์ฑ": "contingentLiability",
|
| 333 |
-
"์ฐ๋ฐ": "contingentLiability",
|
| 334 |
-
"ํ์": "riskDerivative",
|
| 335 |
-
"์ฌ์ฑ": "bond",
|
| 336 |
-
"์ด์ฌํ": "boardOfDirectors",
|
| 337 |
-
"๊ฐ์ฌ": "audit",
|
| 338 |
-
"์๋ณธ๋ณ๋": "capitalChange",
|
| 339 |
-
"์๊ธฐ์ฃผ์": "treasuryStock",
|
| 340 |
-
"์ฌ์
๊ฐ์": "business",
|
| 341 |
-
"์ฌ์
๋ณด๊ณ ": "business",
|
| 342 |
-
"์ฐํ": "companyHistory",
|
| 343 |
-
}
|
| 344 |
-
msg = message.lower()
|
| 345 |
-
for keyword, topic in topicMap.items():
|
| 346 |
-
if keyword in msg:
|
| 347 |
-
return topic
|
| 348 |
-
return None
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
# โโ AI โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
def _askAi(stockCode: str, question: str) -> str:
|
| 355 |
-
"""AI ์ง๋ฌธ. OpenAI ์ฐ์ , HF ๋ฌด๋ฃ fallback."""
|
| 356 |
-
if _HAS_OPENAI:
|
| 357 |
-
try:
|
| 358 |
-
q = f"{stockCode} {question}" if stockCode else question
|
| 359 |
-
answer = dartlab.ask(q, stream=False, raw=False)
|
| 360 |
-
return answer or "์๋ต ์์"
|
| 361 |
-
except Exception as e:
|
| 362 |
-
return f"๋ถ์ ์คํจ: {e}"
|
| 363 |
-
|
| 364 |
-
try:
|
| 365 |
-
from huggingface_hub import InferenceClient
|
| 366 |
-
token = os.environ.get("HF_TOKEN")
|
| 367 |
-
client = InferenceClient(
|
| 368 |
-
model="meta-llama/Llama-3.1-8B-Instruct",
|
| 369 |
-
token=token if token else None,
|
| 370 |
-
)
|
| 371 |
-
context = _buildAiContext(stockCode)
|
| 372 |
-
systemMsg = (
|
| 373 |
-
"๋น์ ์ ํ๊ตญ ๊ธฐ์
์ฌ๋ฌด ๋ถ์ ์ ๋ฌธ๊ฐ์
๋๋ค. "
|
| 374 |
-
"์๋ ์ฌ๋ฌด ๋ฐ์ดํฐ๋ฅผ ๋ฐํ์ผ๋ก ์ฌ์ฉ์์ ์ง๋ฌธ์ ํ๊ตญ์ด๋ก ๋ต๋ณํ์ธ์. "
|
| 375 |
-
"์ซ์๋ ์ฒ๋จ์ ์ฝค๋ง๋ฅผ ์ฌ์ฉํ๊ณ , ๊ทผ๊ฑฐ๋ฅผ ๋ช
ํํ ์ ์ํ์ธ์.\n\n"
|
| 376 |
-
f"{context}"
|
| 377 |
-
)
|
| 378 |
-
response = client.chat_completion(
|
| 379 |
-
messages=[
|
| 380 |
-
{"role": "system", "content": systemMsg},
|
| 381 |
-
{"role": "user", "content": question},
|
| 382 |
-
],
|
| 383 |
-
max_tokens=1024,
|
| 384 |
-
)
|
| 385 |
-
return response.choices[0].message.content or "์๋ต ์์"
|
| 386 |
-
except Exception as e:
|
| 387 |
-
return f"AI ๋ถ์ ์คํจ: {e}"
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
def _buildAiContext(stockCode: str) -> str:
|
| 391 |
-
"""AI ์ปจํ
์คํธ ๊ตฌ์ฑ."""
|
| 392 |
-
try:
|
| 393 |
-
c = _getCompany(stockCode)
|
| 394 |
-
except Exception:
|
| 395 |
-
return f"์ข
๋ชฉ์ฝ๋: {stockCode}"
|
| 396 |
-
|
| 397 |
-
parts = [f"๊ธฐ์
: {c.corpName} ({c.stockCode}), ์์ฅ: {c.market}"]
|
| 398 |
-
for name, attr in [("์์ต๊ณ์ฐ์", "IS"), ("์ฌ๋ฌด์ํํ", "BS"), ("์ฌ๋ฌด๋น์จ", "ratios")]:
|
| 399 |
-
try:
|
| 400 |
-
df = _toPandas(getattr(c, attr, None))
|
| 401 |
-
if df is not None and not df.empty:
|
| 402 |
-
parts.append(f"\n[{name}]\n{df.head(15).to_string()}")
|
| 403 |
-
except Exception:
|
| 404 |
-
pass
|
| 405 |
-
return "\n".join(parts)
|
| 406 |
-
|
| 407 |
-
|
| 408 |
-
# โโ ๋์๋ณด๋ ๋ ๋๋ง โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
def _renderCompanyCard(c):
|
| 412 |
-
"""๊ธฐ์
์นด๋."""
|
| 413 |
-
currency = ""
|
| 414 |
-
if hasattr(c, "currency") and c.currency:
|
| 415 |
-
currency = c.currency
|
| 416 |
-
currencyHtml = (
|
| 417 |
-
f"<div class='meta-item'><span class='meta-label'>ํตํ</span>"
|
| 418 |
-
f"<span class='meta-value'>{currency}</span></div>"
|
| 419 |
-
if currency else ""
|
| 420 |
-
)
|
| 421 |
-
st.markdown(f"""
|
| 422 |
-
<div class="dl-card">
|
| 423 |
-
<h3>{c.corpName}</h3>
|
| 424 |
-
<div class="meta">
|
| 425 |
-
<div class="meta-item">
|
| 426 |
-
<span class="meta-label">์ข
๋ชฉ์ฝ๋</span>
|
| 427 |
-
<span class="meta-value">{c.stockCode}</span>
|
| 428 |
-
</div>
|
| 429 |
-
<div class="meta-item">
|
| 430 |
-
<span class="meta-label">์์ฅ</span>
|
| 431 |
-
<span class="meta-value">{c.market}</span>
|
| 432 |
-
</div>
|
| 433 |
-
{currencyHtml}
|
| 434 |
-
</div>
|
| 435 |
-
</div>
|
| 436 |
-
""", unsafe_allow_html=True)
|
| 437 |
-
|
| 438 |
-
|
| 439 |
-
def _renderFullDashboard(c, code: str):
|
| 440 |
-
"""์ ์ฒด ์ฌ๋ฌด ๋์๋ณด๋."""
|
| 441 |
-
_renderCompanyCard(c)
|
| 442 |
-
|
| 443 |
-
# ์ฌ๋ฌด์ ํ
|
| 444 |
-
st.markdown('<div class="dl-section">์ฌ๋ฌด์ ํ</div>', unsafe_allow_html=True)
|
| 445 |
-
for label, attr in [("IS (์์ต๊ณ์ฐ์)", "IS"), ("BS (์ฌ๋ฌด์ํํ)", "BS"),
|
| 446 |
-
("CF (ํ๊ธํ๋ฆํ)", "CF"), ("ratios (์ฌ๋ฌด๋น์จ)", "ratios")]:
|
| 447 |
-
with st.expander(label, expanded=(attr == "IS")):
|
| 448 |
-
try:
|
| 449 |
-
df = _toPandas(getattr(c, attr, None))
|
| 450 |
-
_showDf(df, key=f"dash_{attr}", downloadName=f"{code}_{attr}")
|
| 451 |
-
except Exception:
|
| 452 |
-
st.caption("๋ก๋ ์คํจ")
|
| 453 |
-
|
| 454 |
-
# Sections
|
| 455 |
-
topics = []
|
| 456 |
-
try:
|
| 457 |
-
topics = list(c.topics) if c.topics else []
|
| 458 |
-
except Exception:
|
| 459 |
-
pass
|
| 460 |
-
|
| 461 |
-
if topics:
|
| 462 |
-
st.markdown('<div class="dl-section">๊ณต์ ๋ฐ์ดํฐ</div>', unsafe_allow_html=True)
|
| 463 |
-
selectedTopic = st.selectbox("topic", topics, label_visibility="collapsed", key="dash_topic")
|
| 464 |
-
if selectedTopic:
|
| 465 |
-
try:
|
| 466 |
-
result = c.show(selectedTopic)
|
| 467 |
-
if result is not None:
|
| 468 |
-
if hasattr(result, "to_pandas"):
|
| 469 |
-
_showDf(_toPandas(result), key="dash_sec", downloadName=f"{code}_{selectedTopic}")
|
| 470 |
-
else:
|
| 471 |
-
st.markdown(str(result))
|
| 472 |
-
except Exception as e:
|
| 473 |
-
st.caption(f"์กฐํ ์คํจ: {e}")
|
| 474 |
-
|
| 475 |
-
|
| 476 |
-
def _renderTopicData(c, code: str, topic: str):
|
| 477 |
-
"""ํน์ topic ๋ฐ์ดํฐ๋ง ๋ ๋๋ง."""
|
| 478 |
-
try:
|
| 479 |
-
result = c.show(topic)
|
| 480 |
-
if result is not None:
|
| 481 |
-
if hasattr(result, "to_pandas"):
|
| 482 |
-
_showDf(_toPandas(result), key=f"topic_{topic}", downloadName=f"{code}_{topic}")
|
| 483 |
-
else:
|
| 484 |
-
st.markdown(str(result))
|
| 485 |
-
else:
|
| 486 |
-
st.caption(f"'{topic}' ๋ฐ์ดํฐ ์์")
|
| 487 |
-
except Exception as e:
|
| 488 |
-
st.caption(f"์กฐํ ์คํจ: {e}")
|
| 489 |
-
|
| 490 |
-
|
| 491 |
-
# โโ ํ๋ฆฌ๋ก๋ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 492 |
-
|
| 493 |
-
@st.cache_resource
|
| 494 |
-
def _warmup():
|
| 495 |
-
"""listing ์บ์."""
|
| 496 |
-
try:
|
| 497 |
-
dartlab.search("์ผ์ฑ์ ์")
|
| 498 |
-
except Exception:
|
| 499 |
-
pass
|
| 500 |
-
return True
|
| 501 |
-
|
| 502 |
-
_warmup()
|
| 503 |
-
|
| 504 |
-
|
| 505 |
-
# โโ ํค๋ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 506 |
-
|
| 507 |
-
st.markdown(f"""
|
| 508 |
-
<div class="dl-hero-glow"></div>
|
| 509 |
-
<div class="dl-header">
|
| 510 |
-
<img src="{_LOGO_URL}" width="80" height="80" alt="DartLab">
|
| 511 |
-
<h1>DartLab</h1>
|
| 512 |
-
<p class="tagline">์ข
๋ชฉ์ฝ๋ ํ๋. ๊ธฐ์
์ ์ ์ฒด ์ด์ผ๊ธฐ.</p>
|
| 513 |
-
<p class="sub">DART / EDGAR ๊ณต์ ๋ฐ์ดํฐ๋ฅผ ๊ตฌ์กฐํํ์ฌ ์ ๊ณตํฉ๋๋ค</p>
|
| 514 |
-
</div>
|
| 515 |
-
""", unsafe_allow_html=True)
|
| 516 |
-
|
| 517 |
-
|
| 518 |
-
# โโ ์ธ์
์ด๊ธฐํ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 519 |
-
|
| 520 |
-
if "messages" not in st.session_state:
|
| 521 |
-
st.session_state.messages = []
|
| 522 |
-
if "code" not in st.session_state:
|
| 523 |
-
st.session_state.code = ""
|
| 524 |
-
|
| 525 |
-
|
| 526 |
-
# โโ ๋์๋ณด๋ ์์ญ (์ข
๋ชฉ์ด ์์ผ๋ฉด ํ์) โโโโโโโโโโโโโโโโ
|
| 527 |
-
|
| 528 |
-
if st.session_state.code:
|
| 529 |
-
try:
|
| 530 |
-
_dashCompany = _getCompany(st.session_state.code)
|
| 531 |
-
_renderFullDashboard(_dashCompany, st.session_state.code)
|
| 532 |
-
except Exception as e:
|
| 533 |
-
st.error(f"๊ธฐ์
๋ก๋ ์คํจ: {e}")
|
| 534 |
-
|
| 535 |
-
st.markdown("---")
|
| 536 |
-
|
| 537 |
-
|
| 538 |
-
# โโ ์ฑํ
์์ญ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 539 |
-
|
| 540 |
-
# ํ์คํ ๋ฆฌ ํ์
|
| 541 |
-
for msg in st.session_state.messages:
|
| 542 |
-
with st.chat_message(msg["role"]):
|
| 543 |
-
st.markdown(msg["content"])
|
| 544 |
-
|
| 545 |
-
# ์
๋ ฅ
|
| 546 |
-
if prompt := st.chat_input("์ผ์ฑ์ ์์ ๋ํด ์๋ ค์ค, ๋ฐฐ๋น ํํฉ์? ..."):
|
| 547 |
-
# ์ฌ์ฉ์ ๋ฉ์์ง ํ์
|
| 548 |
-
st.session_state.messages.append({"role": "user", "content": prompt})
|
| 549 |
-
with st.chat_message("user"):
|
| 550 |
-
st.markdown(prompt)
|
| 551 |
-
|
| 552 |
-
# ์ข
๋ชฉ์ฝ๋ ์ถ์ถ ์๋
|
| 553 |
-
newCode = _extractCode(prompt)
|
| 554 |
-
if newCode and newCode != st.session_state.code:
|
| 555 |
-
st.session_state.code = newCode
|
| 556 |
-
|
| 557 |
-
code = st.session_state.code
|
| 558 |
-
|
| 559 |
-
if not code:
|
| 560 |
-
# ์ข
๋ชฉ ๋ชป ์ฐพ์
|
| 561 |
-
reply = "์ข
๋ชฉ์ ์ฐพ์ง ๋ชปํ์ต๋๋ค. ํ์ฌ๋ช
์ด๋ ์ข
๋ชฉ์ฝ๋๋ฅผ ํฌํจํด์ ๋ค์ ์ง๋ฌธํด์ฃผ์ธ์.\n\n์: ์ผ์ฑ์ ์์ ๋ํด ์๋ ค์ค, 005930 ๋ถ์, AAPL ์ฌ๋ฌด"
|
| 562 |
-
st.session_state.messages.append({"role": "assistant", "content": reply})
|
| 563 |
-
with st.chat_message("assistant"):
|
| 564 |
-
st.markdown(reply)
|
| 565 |
-
else:
|
| 566 |
-
# ์๋ต ์์ฑ
|
| 567 |
-
with st.chat_message("assistant"):
|
| 568 |
-
# ํน์ topic ๊ฐ์ง
|
| 569 |
-
topic = _detectTopic(prompt)
|
| 570 |
-
|
| 571 |
-
if topic:
|
| 572 |
-
# ํน์ topic๋ง ๋ณด์ฌ์ฃผ๊ธฐ
|
| 573 |
-
try:
|
| 574 |
-
c = _getCompany(code)
|
| 575 |
-
_renderTopicData(c, code, topic)
|
| 576 |
-
except Exception:
|
| 577 |
-
pass
|
| 578 |
-
|
| 579 |
-
# AI ์์ฝ
|
| 580 |
-
with st.spinner("๋ถ์ ์ค..."):
|
| 581 |
-
aiAnswer = _askAi(code, prompt)
|
| 582 |
-
st.markdown(aiAnswer)
|
| 583 |
-
|
| 584 |
-
st.session_state.messages.append({"role": "assistant", "content": aiAnswer})
|
| 585 |
-
|
| 586 |
-
# ๋์๋ณด๋ ๊ฐฑ์ ์ ์ํด rerun
|
| 587 |
-
if newCode and newCode != "":
|
| 588 |
-
st.rerun()
|
| 589 |
-
|
| 590 |
-
|
| 591 |
-
# โโ ์ด๊ธฐ ์๋ด (๋ํ ์์ ๋) โโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 592 |
-
|
| 593 |
-
if not st.session_state.messages and not st.session_state.code:
|
| 594 |
-
st.markdown("""
|
| 595 |
-
<div style="text-align: center; color: #64748b; padding: 2rem 1rem;">
|
| 596 |
-
<p style="font-size: 1.1rem; color: #94a3b8;">
|
| 597 |
-
์๋ ์
๋ ฅ๏ฟฝ๏ฟฝ๏ฟฝ์ ์์ฐ์ด๋ก ์ง๋ฌธํ์ธ์
|
| 598 |
-
</p>
|
| 599 |
-
<p style="margin-top: 0.5rem;">
|
| 600 |
-
<code>์ผ์ฑ์ ์์ ๋ํด ์๋ ค์ค</code> ·
|
| 601 |
-
<code>005930 ๋ถ์</code> ·
|
| 602 |
-
<code>AAPL ์ฌ๋ฌด ๋ณด์ฌ์ค</code>
|
| 603 |
-
</p>
|
| 604 |
-
<p style="margin-top: 0.3rem; font-size: 0.85rem;">
|
| 605 |
-
์ข
๋ชฉ์ ๋งํ๋ฉด ์ฌ๋ฌด์ ํ/๊ณต์ ๋ฐ์ดํฐ๊ฐ ๋ฐ๋ก ํ์๋๊ณ , AI๊ฐ ๋ถ์์ ๋ง๋ถ์
๋๋ค
|
| 606 |
-
</p>
|
| 607 |
-
</div>
|
| 608 |
-
""", unsafe_allow_html=True)
|
| 609 |
-
|
| 610 |
-
|
| 611 |
-
# โโ ํธํฐ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 612 |
-
|
| 613 |
-
st.markdown(f"""
|
| 614 |
-
<div class="dl-footer">
|
| 615 |
-
<a href="{_BLOG_URL}">์ด๋ณด์ ๊ฐ์ด๋</a> /
|
| 616 |
-
<a href="{_DOCS_URL}">๊ณต์ ๋ฌธ์</a> /
|
| 617 |
-
<a href="{_COLAB_URL}">Colab</a> /
|
| 618 |
-
<a href="{_REPO_URL}">GitHub</a>
|
| 619 |
-
<br><span style="color:#334155; font-size:0.78rem; margin-top:0.4rem; display:inline-block;">
|
| 620 |
-
pip install dartlab
|
| 621 |
-
</span>
|
| 622 |
-
</div>
|
| 623 |
-
""", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[project]
|
| 2 |
+
name = "dartlab"
|
| 3 |
+
version = "0.7.10"
|
| 4 |
+
description = "DART ์ ์๊ณต์ + EDGAR ๊ณต์๋ฅผ ํ๋์ ํ์ฌ ๋งต์ผ๋ก โ Python ์ฌ๋ฌด ๋ถ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ"
|
| 5 |
+
readme = "README.md"
|
| 6 |
+
license = {file = "LICENSE"}
|
| 7 |
+
requires-python = ">=3.12"
|
| 8 |
+
authors = [
|
| 9 |
+
{name = "eddmpython"}
|
| 10 |
+
]
|
| 11 |
+
keywords = [
|
| 12 |
+
"dart",
|
| 13 |
+
"edgar",
|
| 14 |
+
"sec",
|
| 15 |
+
"financial-statements",
|
| 16 |
+
"korea",
|
| 17 |
+
"disclosure",
|
| 18 |
+
"accounting",
|
| 19 |
+
"polars",
|
| 20 |
+
"sections",
|
| 21 |
+
"mcp",
|
| 22 |
+
"ai-analysis",
|
| 23 |
+
"annual-report",
|
| 24 |
+
"10-k",
|
| 25 |
+
"xbrl",
|
| 26 |
+
"์ ์๊ณต์",
|
| 27 |
+
"์ฌ๋ฌด์ ํ",
|
| 28 |
+
"์ฌ์
๋ณด๊ณ ์",
|
| 29 |
+
"๊ณต์๋ถ์",
|
| 30 |
+
"๋คํธ",
|
| 31 |
+
]
|
| 32 |
+
classifiers = [
|
| 33 |
+
"Development Status :: 5 - Production/Stable",
|
| 34 |
+
"Intended Audience :: Developers",
|
| 35 |
+
"Intended Audience :: Science/Research",
|
| 36 |
+
"Intended Audience :: Financial and Insurance Industry",
|
| 37 |
+
"Intended Audience :: End Users/Desktop",
|
| 38 |
+
"License :: OSI Approved :: MIT License",
|
| 39 |
+
"Operating System :: OS Independent",
|
| 40 |
+
"Programming Language :: Python :: 3",
|
| 41 |
+
"Programming Language :: Python :: 3.12",
|
| 42 |
+
"Programming Language :: Python :: 3.13",
|
| 43 |
+
"Topic :: Office/Business :: Financial",
|
| 44 |
+
"Topic :: Office/Business :: Financial :: Accounting",
|
| 45 |
+
"Topic :: Office/Business :: Financial :: Investment",
|
| 46 |
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
| 47 |
+
"Natural Language :: Korean",
|
| 48 |
+
"Natural Language :: English",
|
| 49 |
+
"Typing :: Typed",
|
| 50 |
+
]
|
| 51 |
+
dependencies = [
|
| 52 |
+
"alive-progress>=3.3.0,<4",
|
| 53 |
+
"beautifulsoup4>=4.14.3,<5",
|
| 54 |
+
"lxml>=6.0.2,<7",
|
| 55 |
+
"marimo>=0.20.4,<1",
|
| 56 |
+
"openpyxl>=3.1.5,<4",
|
| 57 |
+
"diff-match-patch>=20230430",
|
| 58 |
+
"httpx>=0.28.1,<1",
|
| 59 |
+
"orjson>=3.10.0,<4",
|
| 60 |
+
"polars>=1.0.0,<2",
|
| 61 |
+
"requests>=2.32.5,<3",
|
| 62 |
+
"rich>=14.3.3,<15",
|
| 63 |
+
"plotly>=5.0.0,<6",
|
| 64 |
+
"mcp[cli]>=1.0",
|
| 65 |
+
]
|
| 66 |
+
|
| 67 |
+
[project.optional-dependencies]
|
| 68 |
+
llm = [
|
| 69 |
+
"openai>=1.0.0,<3",
|
| 70 |
+
"google-genai>=1.0.0,<2",
|
| 71 |
+
]
|
| 72 |
+
llm-anthropic = [
|
| 73 |
+
"openai>=1.0.0,<3",
|
| 74 |
+
"google-genai>=1.0.0,<2",
|
| 75 |
+
"anthropic>=0.30.0,<2",
|
| 76 |
+
]
|
| 77 |
+
charts = [
|
| 78 |
+
"networkx>=3.6.1,<4",
|
| 79 |
+
"scipy>=1.17.1,<2",
|
| 80 |
+
]
|
| 81 |
+
ai = [
|
| 82 |
+
"fastapi>=0.135.1,<1",
|
| 83 |
+
"httpx>=0.28.1,<1",
|
| 84 |
+
"msgpack>=1.1.0,<2",
|
| 85 |
+
"uvicorn[standard]>=0.30.0,<1",
|
| 86 |
+
"sse-starlette>=2.0.0,<3",
|
| 87 |
+
]
|
| 88 |
+
mcp = [
|
| 89 |
+
"mcp[cli]>=1.0,<2",
|
| 90 |
+
]
|
| 91 |
+
display = [
|
| 92 |
+
"great-tables>=0.15.0,<1",
|
| 93 |
+
"itables>=2.0.0,<3",
|
| 94 |
+
]
|
| 95 |
+
altair = [
|
| 96 |
+
"altair>=5.0.0,<6",
|
| 97 |
+
]
|
| 98 |
+
hf = [
|
| 99 |
+
"huggingface-hub>=0.20.0,<1",
|
| 100 |
+
]
|
| 101 |
+
ui = [
|
| 102 |
+
"dartlab[ai]",
|
| 103 |
+
]
|
| 104 |
+
channel = [
|
| 105 |
+
"dartlab[ai]",
|
| 106 |
+
"pycloudflared>=0.3",
|
| 107 |
+
]
|
| 108 |
+
channel-ngrok = [
|
| 109 |
+
"dartlab[ai]",
|
| 110 |
+
"pyngrok>=7.0,<8",
|
| 111 |
+
]
|
| 112 |
+
channel-full = [
|
| 113 |
+
"dartlab[channel,channel-ngrok]",
|
| 114 |
+
"python-telegram-bot>=21.0,<22",
|
| 115 |
+
"slack-bolt>=1.18,<2",
|
| 116 |
+
"discord.py>=2.4,<3",
|
| 117 |
+
]
|
| 118 |
+
all = [
|
| 119 |
+
"openai>=1.0.0,<3",
|
| 120 |
+
"anthropic>=0.30.0,<2",
|
| 121 |
+
"networkx>=3.6.1,<4",
|
| 122 |
+
"scipy>=1.17.1,<2",
|
| 123 |
+
"fastapi>=0.135.1,<1",
|
| 124 |
+
"httpx>=0.28.1,<1",
|
| 125 |
+
"msgpack>=1.1.0,<2",
|
| 126 |
+
"uvicorn[standard]>=0.30.0,<1",
|
| 127 |
+
"sse-starlette>=2.0.0,<3",
|
| 128 |
+
]
|
| 129 |
+
|
| 130 |
+
[project.scripts]
|
| 131 |
+
dartlab = "dartlab.cli.main:main"
|
| 132 |
+
|
| 133 |
+
[project.entry-points."dartlab.plugins"]
|
| 134 |
+
|
| 135 |
+
[project.urls]
|
| 136 |
+
Homepage = "https://eddmpython.github.io/dartlab/"
|
| 137 |
+
Repository = "https://github.com/eddmpython/dartlab"
|
| 138 |
+
Documentation = "https://eddmpython.github.io/dartlab/docs/"
|
| 139 |
+
Issues = "https://github.com/eddmpython/dartlab/issues"
|
| 140 |
+
Changelog = "https://eddmpython.github.io/dartlab/docs/changelog"
|
| 141 |
+
Demo = "https://huggingface.co/spaces/eddmpython/dartlab"
|
| 142 |
+
|
| 143 |
+
[build-system]
|
| 144 |
+
requires = ["hatchling"]
|
| 145 |
+
build-backend = "hatchling.build"
|
| 146 |
+
|
| 147 |
+
[tool.hatch.build.targets.wheel]
|
| 148 |
+
packages = ["src/dartlab"]
|
| 149 |
+
exclude = [
|
| 150 |
+
"**/_reference/**",
|
| 151 |
+
"src/dartlab/engines/edinet/**",
|
| 152 |
+
"src/dartlab/engines/esg/**",
|
| 153 |
+
"src/dartlab/engines/event/**",
|
| 154 |
+
"src/dartlab/engines/supply/**",
|
| 155 |
+
"src/dartlab/engines/watch/**",
|
| 156 |
+
]
|
| 157 |
+
|
| 158 |
+
[tool.hatch.build.targets.sdist]
|
| 159 |
+
include = [
|
| 160 |
+
"src/dartlab/**/*.py",
|
| 161 |
+
"src/dartlab/**/*.json",
|
| 162 |
+
"src/dartlab/**/*.parquet",
|
| 163 |
+
"README.md",
|
| 164 |
+
"LICENSE",
|
| 165 |
+
]
|
| 166 |
+
exclude = [
|
| 167 |
+
"**/_reference/**",
|
| 168 |
+
"src/dartlab/engines/edinet/**",
|
| 169 |
+
"src/dartlab/engines/esg/**",
|
| 170 |
+
"src/dartlab/engines/event/**",
|
| 171 |
+
"src/dartlab/engines/supply/**",
|
| 172 |
+
"src/dartlab/engines/watch/**",
|
| 173 |
+
]
|
| 174 |
+
|
| 175 |
+
[tool.ruff]
|
| 176 |
+
target-version = "py312"
|
| 177 |
+
line-length = 120
|
| 178 |
+
exclude = ["experiments", "*/_reference"]
|
| 179 |
+
|
| 180 |
+
[tool.ruff.lint]
|
| 181 |
+
select = ["E", "F", "I"]
|
| 182 |
+
ignore = ["E402", "E501", "E741", "F841"]
|
| 183 |
+
|
| 184 |
+
[tool.pytest.ini_options]
|
| 185 |
+
testpaths = ["tests"]
|
| 186 |
+
addopts = "-v --tb=short"
|
| 187 |
+
asyncio_mode = "auto"
|
| 188 |
+
markers = [
|
| 189 |
+
"requires_data: ๋ก์ปฌ parquet ๋ฐ์ดํฐ ํ์ (CI์์ skip)",
|
| 190 |
+
"unit: ์์ ๋ก์ง/mock๋ง โ ๋ฐ์ดํฐ ๋ก๋ ์์, ๋ณ๋ ฌ ์์ ",
|
| 191 |
+
"integration: Company 1๊ฐ ๋ก๋ฉ ํ์ โ ์ค๊ฐ ๋ฌด๊ฒ",
|
| 192 |
+
"heavy: ๋๋ ๋ฐ์ดํฐ ๋ก๋ โ ๋จ๋
์คํ ํ์",
|
| 193 |
+
]
|
| 194 |
+
|
| 195 |
+
[tool.coverage.run]
|
| 196 |
+
source = ["dartlab"]
|
| 197 |
+
omit = [
|
| 198 |
+
"src/dartlab/ui/*",
|
| 199 |
+
"src/dartlab/engines/ai/providers/*",
|
| 200 |
+
]
|
| 201 |
+
|
| 202 |
+
[tool.coverage.report]
|
| 203 |
+
show_missing = true
|
| 204 |
+
skip_empty = true
|
| 205 |
+
exclude_lines = [
|
| 206 |
+
"pragma: no cover",
|
| 207 |
+
"if __name__",
|
| 208 |
+
"raise NotImplementedError",
|
| 209 |
+
]
|
| 210 |
+
|
| 211 |
+
[tool.pyright]
|
| 212 |
+
pythonVersion = "3.12"
|
| 213 |
+
typeCheckingMode = "basic"
|
| 214 |
+
include = ["src/dartlab"]
|
| 215 |
+
exclude = [
|
| 216 |
+
"src/dartlab/engines/ai/providers/**",
|
| 217 |
+
"src/dartlab/ui/**",
|
| 218 |
+
"experiments/**",
|
| 219 |
+
]
|
| 220 |
+
reportMissingTypeStubs = false
|
| 221 |
+
reportUnknownParameterType = false
|
| 222 |
+
reportUnknownMemberType = false
|
| 223 |
+
reportUnknownVariableType = false
|
| 224 |
+
|
| 225 |
+
[tool.bandit]
|
| 226 |
+
exclude_dirs = ["experiments", "tests"]
|
| 227 |
+
skips = ["B101"]
|
| 228 |
+
|
| 229 |
+
[dependency-groups]
|
| 230 |
+
dev = [
|
| 231 |
+
"build>=1.4.0",
|
| 232 |
+
"dartlab[all]",
|
| 233 |
+
"hatchling>=1.29.0",
|
| 234 |
+
"pillow>=12.1.1",
|
| 235 |
+
"pre-commit>=4.0.0",
|
| 236 |
+
"pyright>=1.1.0",
|
| 237 |
+
"pytest>=9.0.2",
|
| 238 |
+
"pytest-asyncio>=0.24.0",
|
| 239 |
+
"pytest-cov>=6.0.0",
|
| 240 |
+
]
|
requirements.txt
DELETED
|
@@ -1,4 +0,0 @@
|
|
| 1 |
-
dartlab>=0.7.8
|
| 2 |
-
streamlit>=1.45,<2
|
| 3 |
-
openpyxl>=3.1
|
| 4 |
-
huggingface_hub>=0.25
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
src/dartlab/API_SPEC.md
ADDED
|
@@ -0,0 +1,450 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# dartlab API ์คํ
|
| 2 |
+
|
| 3 |
+
์ด ๋ฌธ์๋ `scripts/generateSpec.py`์ ์ํด ์๋ ์์ฑ๋ฉ๋๋ค. ์ง์ ์์ ํ์ง ๋ง์ธ์.
|
| 4 |
+
|
| 5 |
+
|
| 6 |
+
---
|
| 7 |
+
|
| 8 |
+
## Company (ํตํฉ facade)
|
| 9 |
+
|
| 10 |
+
์
๋ ฅ์ ์๋ ํ๋ณํ์ฌ DART ๋๋ EDGAR ์์ฅ ์ ์ฉ Company๋ฅผ ์์ฑํ๋ค.
|
| 11 |
+
ํ์ฌ DART Company์ ๊ณต๊ฐ ์ง์
์ ์ **index โ show(topic) โ trace(topic)** ์ด๋ค.
|
| 12 |
+
`profile`์ ํฅํ terminal/notebook ๋ฌธ์ํ ๋ณด๊ณ ์ ๋ทฐ๋ก ํ์ฅ๋ ์์ ์ด๋ค.
|
| 13 |
+
|
| 14 |
+
```python
|
| 15 |
+
import dartlab
|
| 16 |
+
|
| 17 |
+
kr = dartlab.Company("005930")
|
| 18 |
+
kr = dartlab.Company("์ผ์ฑ์ ์")
|
| 19 |
+
us = dartlab.Company("AAPL")
|
| 20 |
+
|
| 21 |
+
kr.market # "KR"
|
| 22 |
+
us.market # "US"
|
| 23 |
+
```
|
| 24 |
+
|
| 25 |
+
### ํ๋ณ ๊ท์น
|
| 26 |
+
|
| 27 |
+
| ์
๋ ฅ | ๊ฒฐ๊ณผ | ์์ |
|
| 28 |
+
|------|------|------|
|
| 29 |
+
| 6์๋ฆฌ ์ซ์ | DART Company | `Company("005930")` |
|
| 30 |
+
| ํ๊ธ ํฌํจ | DART Company | `Company("์ผ์ฑ์ ์")` |
|
| 31 |
+
| ์๋ฌธ 1~5์๋ฆฌ | EDGAR Company | `Company("AAPL")` |
|
| 32 |
+
|
| 33 |
+
## DART Company
|
| 34 |
+
|
| 35 |
+
### ํ์ฌ ๊ณต๊ฐ ์ง์
์
|
| 36 |
+
|
| 37 |
+
| surface | ์ค๋ช
|
|
| 38 |
+
|---------|------|
|
| 39 |
+
| `index` | ํ์ฌ ๋ฐ์ดํฐ ๊ตฌ์กฐ ์ธ๋ฑ์ค DataFrame |
|
| 40 |
+
| `show(topic)` | topic์ ์ค์ ๋ฐ์ดํฐ payload ์กฐํ |
|
| 41 |
+
| `trace(topic, period)` | docs / finance / report source provenance ์กฐํ |
|
| 42 |
+
| `docs` | pure docs source namespace |
|
| 43 |
+
| `finance` | authoritative finance source namespace |
|
| 44 |
+
| `report` | authoritative structured disclosure source namespace |
|
| 45 |
+
| `profile` | ํฅํ ๋ณด๊ณ ์ํ ๋ ๋์ฉ ์์ฝ ๋ทฐ |
|
| 46 |
+
|
| 47 |
+
### ์ ์ ๋ฉ์๋
|
| 48 |
+
|
| 49 |
+
| ๋ฉ์๋ | ๋ฐํ | ์ค๋ช
|
|
| 50 |
+
|--------|------|------|
|
| 51 |
+
| `dartlab.providers.dart.Company.listing()` | DataFrame | KRX ์ ์ฒด ์์ฅ๋ฒ์ธ ๋ชฉ๋ก |
|
| 52 |
+
| `dartlab.providers.dart.Company.search(keyword)` | DataFrame | ํ์ฌ๋ช
๋ถ๋ถ ๊ฒ์ |
|
| 53 |
+
| `dartlab.providers.dart.Company.status()` | DataFrame | ๋ก์ปฌ ๋ณด์ ์ ์ฒด ์ข
๋ชฉ ์ธ๋ฑ์ค |
|
| 54 |
+
| `dartlab.providers.dart.Company.resolve(codeOrName)` | str \| None | ์ข
๋ชฉ์ฝ๋/ํ์ฌ๋ช
โ ์ข
๋ชฉ์ฝ๋ |
|
| 55 |
+
|
| 56 |
+
### ํต์ฌ property
|
| 57 |
+
|
| 58 |
+
| property | ๋ฐํ | ์ค๋ช
|
|
| 59 |
+
|----------|------|------|
|
| 60 |
+
| `BS` | DataFrame | ์ฌ๋ฌด์ํํ |
|
| 61 |
+
| `IS` | DataFrame | ์์ต๊ณ์ฐ์ |
|
| 62 |
+
| `CIS` | DataFrame | ํฌ๊ด์์ต๊ณ์ฐ์ |
|
| 63 |
+
| `CF` | DataFrame | ํ๊ธํ๋ฆํ |
|
| 64 |
+
| `SCE` | tuple \| DataFrame | ์๋ณธ๋ณ๋ํ |
|
| 65 |
+
| `sections` | DataFrame | merged topic x period company table |
|
| 66 |
+
| `timeseries` | (series, periods) | ๋ถ๊ธฐ๋ณ standalone ์๊ณ์ด |
|
| 67 |
+
| `annual` | (series, years) | ์ฐ๋๋ณ ์๊ณ์ด |
|
| 68 |
+
| `ratios` | RatioResult | ์ฌ๋ฌด๋น์จ |
|
| 69 |
+
| `index` | DataFrame | ํ์ฌ ๊ตฌ์กฐ ์ธ๋ฑ์ค |
|
| 70 |
+
| `docs` | Accessor | pure docs source |
|
| 71 |
+
| `finance` | Accessor | authoritative finance source |
|
| 72 |
+
| `report` | Accessor | authoritative report source |
|
| 73 |
+
| `profile` | _BoardView | ํฅํ ๋ณด๊ณ ์ํ ๋ทฐ ์์ฝ |
|
| 74 |
+
| `sector` | SectorInfo | ์นํฐ ๋ถ๋ฅ |
|
| 75 |
+
| `insights` | AnalysisResult | 7์์ญ ์ธ์ฌ์ดํธ ๋ฑ๊ธ |
|
| 76 |
+
| `rank` | RankInfo | ์์ฅ ์์ |
|
| 77 |
+
| `notes` | Notes | K-IFRS ์ฃผ์ ์ ๊ทผ |
|
| 78 |
+
| `market` | str | `"KR"` |
|
| 79 |
+
|
| 80 |
+
### ๋ฉ์๋
|
| 81 |
+
|
| 82 |
+
| ๋ฉ์๋ | ๋ฐํ | ์ค๋ช
|
|
| 83 |
+
|--------|------|------|
|
| 84 |
+
| `get(name)` | Result | ๋ชจ๋ ์ ์ฒด Result ๊ฐ์ฒด |
|
| 85 |
+
| `all()` | dict | ์ ์ฒด ๋ฐ์ดํฐ dict |
|
| 86 |
+
| `show(topic, period=None, raw=False)` | Any | topic payload ์กฐํ |
|
| 87 |
+
| `trace(topic, period=None)` | dict \| None | ์ ํ source provenance ์กฐํ |
|
| 88 |
+
| `fsSummary(period)` | AnalysisResult | ์์ฝ์ฌ๋ฌด์ ๋ณด |
|
| 89 |
+
| `getTimeseries(period, fsDivPref)` | (series, periods) | ์ปค์คํ
์๊ณ์ด |
|
| 90 |
+
| `getRatios(fsDivPref)` | RatioResult | ์ปค์คํ
๋น์จ |
|
| 91 |
+
|
| 92 |
+
`index`๋ ํ์ฌ ์ ์ฒด ๊ตฌ์กฐ๋ฅผ ๋จผ์ ๋ณด์ฌ์ฃผ๊ณ , `show(topic)`๊ฐ ์ค์ ๋ฐ์ดํฐ๋ฅผ ์ฐ๋ค.
|
| 93 |
+
`trace(topic)`๋ ๊ฐ์ topic์์ docs / finance / report ์ค ์ด๋ค source๊ฐ ์ฑํ๋๋์ง ์ค๋ช
ํ๋ค.
|
| 94 |
+
docs๊ฐ ์๋ ํ์ฌ๋ `docsStatus` ์๋ด row์ `ํ์ฌ ์ฌ์
๋ณด๊ณ ์ ๋ถ์ฌ` notice๊ฐ ํ์๋๋ค.
|
| 95 |
+
|
| 96 |
+
report/disclosure property๋ registry์์ ์๋ ๋์คํจ์น๋๋ค (`_MODULE_REGISTRY`).
|
| 97 |
+
๋ฑ๋ก๋ ๋ชจ๋ property๋ ์๋ "๋ฐ์ดํฐ ๋ ์ง์คํธ๋ฆฌ" ์น์
์ฐธ์กฐ.
|
| 98 |
+
|
| 99 |
+
## EDGAR Company
|
| 100 |
+
|
| 101 |
+
```python
|
| 102 |
+
import dartlab
|
| 103 |
+
|
| 104 |
+
us = dartlab.Company("AAPL")
|
| 105 |
+
us.ticker # "AAPL"
|
| 106 |
+
us.cik # "0000320193"
|
| 107 |
+
```
|
| 108 |
+
|
| 109 |
+
### property
|
| 110 |
+
|
| 111 |
+
| property | ๋ฐํ | ์ค๋ช
|
|
| 112 |
+
|----------|------|------|
|
| 113 |
+
| `timeseries` | (series, periods) | ๋ถ๊ธฐ๋ณ standalone ์๊ณ์ด |
|
| 114 |
+
| `annual` | (series, years) | ์ฐ๋๋ณ ์๊ณ์ด |
|
| 115 |
+
| `ratios` | RatioResult | ์ฌ๋ฌด๋น์จ |
|
| 116 |
+
| `insights` | AnalysisResult | 7์์ญ ์ธ์ฌ์ดํธ ๋ฑ๊ธ |
|
| 117 |
+
| `market` | str | `"US"` |
|
| 118 |
+
|
| 119 |
+
---
|
| 120 |
+
|
| 121 |
+
## ๋ฐ์ดํฐ ๋ ์ง์คํธ๋ฆฌ
|
| 122 |
+
|
| 123 |
+
`core/registry.py`์ ๋ฑ๋ก๋ ์ ์ฒด ๋ฐ์ดํฐ ์์ค ๋ชฉ๋ก.
|
| 124 |
+
|
| 125 |
+
๋ชจ๋ ์ถ๊ฐ = registry์ DataEntry ํ ์ค ์ถ๊ฐ โ Company, Excel, LLM, Server, Skills ์ ๋ถ ์๋ ๋ฐ์.
|
| 126 |
+
|
| 127 |
+
### ์๊ณ์ด ์ฌ๋ฌด์ ํ (finance)
|
| 128 |
+
|
| 129 |
+
| name | label | dataType | description |
|
| 130 |
+
|------|-------|----------|-------------|
|
| 131 |
+
| `annual.IS` | ์์ต๊ณ์ฐ์(์ฐ๋๋ณ) | `timeseries` | ์ฐ๋๋ณ ์์ต๊ณ์ฐ์ ์๊ณ์ด. ๋งค์ถ์ก, ์์
์ด์ต, ์์ด์ต ๋ฑ ์ ์ฒด ๊ณ์ . |
|
| 132 |
+
| `annual.BS` | ์ฌ๋ฌด์ํํ(์ฐ๋๋ณ) | `timeseries` | ์ฐ๋๋ณ ์ฌ๋ฌด์ํํ ์๊ณ์ด. ์์ฐ, ๋ถ์ฑ, ์๋ณธ ์ ์ฒด ๊ณ์ . |
|
| 133 |
+
| `annual.CF` | ํ๊ธํ๋ฆํ(์ฐ๋๋ณ) | `timeseries` | ์ฐ๋๋ณ ํ๊ธํ๋ฆํ ์๊ณ์ด. ์์
/ํฌ์/์ฌ๋ฌดํ๋ ํ๊ธํ๋ฆ. |
|
| 134 |
+
| `timeseries.IS` | ์์ต๊ณ์ฐ์(๋ถ๊ธฐ๋ณ) | `timeseries` | ๋ถ๊ธฐ๋ณ ์์ต๊ณ์ฐ์ standalone ์๊ณ์ด. |
|
| 135 |
+
| `timeseries.BS` | ์ฌ๋ฌด์ํํ(๋ถ๊ธฐ๋ณ) | `timeseries` | ๋ถ๊ธฐ๋ณ ์ฌ๋ฌด์ํํ ์์ ์์ก ์๊ณ์ด. |
|
| 136 |
+
| `timeseries.CF` | ํ๊ธํ๋ฆํ(๋ถ๊ธฐ๋ณ) | `timeseries` | ๋ถ๊ธฐ๋ณ ํ๊ธํ๋ฆํ standalone ์๊ณ์ด. |
|
| 137 |
+
|
| 138 |
+
### ๊ณต์ ํ์ฑ ๋ชจ๋ (report)
|
| 139 |
+
|
| 140 |
+
| name | label | dataType | description |
|
| 141 |
+
|------|-------|----------|-------------|
|
| 142 |
+
| `BS` | ์ฌ๋ฌด์ํํ | `dataframe` | K-IFRS ์ฐ๊ฒฐ ์ฌ๋ฌด์ํํ. finance XBRL ์ ๊ทํ(snakeId) ๊ธฐ๋ฐ, ํ์ฌ๊ฐ ๋น๊ต ๊ฐ๋ฅ. finance ์์ผ๋ฉด docs fallback. |
|
| 143 |
+
| `IS` | ์์ต๊ณ์ฐ์ | `dataframe` | K-IFRS ์ฐ๊ฒฐ ์์ต๊ณ์ฐ์. finance XBRL ์ ๊ทํ ๊ธฐ๋ฐ. ๋งค์ถ์ก, ์์
์ด์ต, ์์ด์ต ๋ฑ ์ ์ฒด ๊ณ์ ํฌํจ. |
|
| 144 |
+
| `CF` | ํ๊ธํ๋ฆํ | `dataframe` | K-IFRS ์ฐ๊ฒฐ ํ๊ธํ๋ฆํ. finance XBRL ์ ๊ทํ ๊ธฐ๋ฐ. ์์
/ํฌ์/์ฌ๋ฌดํ๋ ํ๊ธํ๋ฆ. |
|
| 145 |
+
| `fsSummary` | ์์ฝ์ฌ๋ฌด์ ๋ณด | `dataframe` | DART ๊ณต์ ์์ฝ์ฌ๋ฌด์ ๋ณด. ๋ค๋
๊ฐ ์ฃผ์ ์ฌ๋ฌด์งํ ๋น๊ต. |
|
| 146 |
+
| `segments` | ๋ถ๋ฌธ์ ๋ณด | `dataframe` | ์ฌ์
๋ถ๋ฌธ๋ณ ๋งค์ถยท์ด์ต ๋ฐ์ดํฐ. ๋ถ๋ฌธ๊ฐ ์์ต์ฑ ๋น๊ต ๊ฐ๋ฅ. |
|
| 147 |
+
| `tangibleAsset` | ์ ํ์์ฐ | `dataframe` | ์ ํ์์ฐ ๋ณ๋ํ. ์ทจ๋/์ฒ๋ถ/๊ฐ๊ฐ์๊ฐ ๋ด์ญ. |
|
| 148 |
+
| `costByNature` | ๋น์ฉ์ฑ๊ฒฉ๋ณ๋ถ๋ฅ | `dataframe` | ๋น์ฉ์ ์ฑ๊ฒฉ๋ณ๋ก ๋ถ๋ฅํ ์๊ณ์ด. ์์ฌ๋ฃ๋น, ์ธ๊ฑด๋น, ๊ฐ๊ฐ์๊ฐ๋น ๋ฑ. |
|
| 149 |
+
| `dividend` | ๋ฐฐ๋น | `dataframe` | ๋ฐฐ๋น ์๊ณ์ด. ์ฐ๋๋ณ DPS, ๋ฐฐ๋น์ด์ก, ๋ฐฐ๋น์ฑํฅ, ๋ฐฐ๋น์์ต๋ฅ . |
|
| 150 |
+
| `majorHolder` | ์ต๋์ฃผ์ฃผ | `dataframe` | ์ต๋์ฃผ์ฃผ ์ง๋ถ์จ ์๊ณ์ด. ์ง๋ถ ๋ณ๋์ ๊ฒฝ์๊ถ ์์ ์ฑ์ ํต์ฌ ์งํ. |
|
| 151 |
+
| `employee` | ์ง์ํํฉ | `dataframe` | ์ง์ ์, ํ๊ท ๊ทผ์์ฐ์, ํ๊ท ์ฐ๋ด ์๊ณ์ด. |
|
| 152 |
+
| `subsidiary` | ์ํ์ฌํฌ์ | `dataframe` | ์ข
์ํ์ฌ ํฌ์ ์๊ณ์ด. ์ง๋ถ์จ, ์ฅ๋ถ๊ฐ์ก ๋ณ๋. |
|
| 153 |
+
| `bond` | ์ฑ๋ฌด์ฆ๊ถ | `dataframe` | ์ฌ์ฑ, CP ๋ฑ ์ฑ๋ฌด์ฆ๊ถ ๋ฐํยท์ํ ์๊ณ์ด. |
|
| 154 |
+
| `shareCapital` | ์ฃผ์ํํฉ | `dataframe` | ๋ฐํ์ฃผ์์, ์๊ธฐ์ฃผ์, ์ ํต์ฃผ์์ ์๊ณ์ด. |
|
| 155 |
+
| `executive` | ์์ํํฉ | `dataframe` | ๋ฑ๊ธฐ์์ ๊ตฌ์ฑ ์๊ณ์ด. ์ฌ๋ด์ด์ฌ/์ฌ์ธ์ด์ฌ/๋น์๋ฌด์ด์ฌ ๊ตฌ๋ถ. |
|
| 156 |
+
| `executivePay` | ์์๋ณด์ | `dataframe` | ์์ ์ ํ๋ณ ๋ณด์ ์๊ณ์ด. ๋ฑ๊ธฐ์ด์ฌ/์ฌ์ธ์ด์ฌ/๊ฐ์ฌ ๊ตฌ๋ถ. |
|
| 157 |
+
| `audit` | ๊ฐ์ฌ์๊ฒฌ | `dataframe` | ์ธ๋ถ๊ฐ์ฌ์ธ์ ๊ฐ์ฌ์๊ฒฌ๊ณผ ๊ฐ์ฌ๋ณด์ ์๊ณ์ด. ์ ์ ์ธ ์๊ฒฌ์ ์ค๋ ์ํ ์ ํธ. |
|
| 158 |
+
| `boardOfDirectors` | ์ด์ฌํ | `dataframe` | ์ด์ฌํ ๊ตฌ์ฑ ๋ฐ ํ๋ ์๊ณ์ด. ๊ฐ์ตํ์, ์ถ์๋ฅ ํฌํจ. |
|
| 159 |
+
| `capitalChange` | ์๋ณธ๋ณ๋ | `dataframe` | ์๋ณธ๊ธ ๋ณ๋ ์๊ณ์ด. ๋ณดํต์ฃผ/์ฐ์ ์ฃผ ์ฃผ์์ยท์ก๋ฉด ๋ณ๋. |
|
| 160 |
+
| `contingentLiability` | ์ฐ๋ฐ๋ถ์ฑ | `dataframe` | ์ฑ๋ฌด๋ณด์ฆ, ์์ก ํํฉ. ์ ์ฌ์ ์ฌ๋ฌด ๋ฆฌ์คํฌ ์งํ. |
|
| 161 |
+
| `internalControl` | ๋ด๋ถํต์ | `dataframe` | ๋ด๋ถํ๊ณ๊ด๋ฆฌ์ ๋ ๊ฐ์ฌ์๊ฒฌ ์๊ณ์ด. |
|
| 162 |
+
| `relatedPartyTx` | ๊ด๊ณ์๊ฑฐ๋ | `dataframe` | ๋์ฃผ์ฃผ ๋ฑ๊ณผ์ ๋งค์ถยท๋งค์
๊ฑฐ๋ ์๊ณ์ด. ์ด์ ๊ฐ๊ฒฉ ๋ฆฌ์คํฌ ํ์ธ. |
|
| 163 |
+
| `rnd` | R&D | `dataframe` | ์ฐ๊ตฌ๊ฐ๋ฐ๋น์ฉ ์๊ณ์ด. ๊ธฐ์ ํฌ์ ๊ฐ๋ ํ๋จ. |
|
| 164 |
+
| `sanction` | ์ ์ฌํํฉ | `dataframe` | ํ์ ์ ์ฌ, ๊ณผ์ง๊ธ, ์์
์ ์ง ๋ฑ ๊ท์ ์กฐ์น ์ด๋ ฅ. |
|
| 165 |
+
| `affiliateGroup` | ๊ณ์ด์ฌ | `dataframe` | ๊ธฐ์
์ง๋จ ์์ ๊ณ์ดํ์ฌ ํํฉ. ์์ฅ/๋น์์ฅ ๊ตฌ๋ถ. |
|
| 166 |
+
| `fundraising` | ์ฆ์๊ฐ์ | `dataframe` | ์ ์์ฆ์, ๋ฌด์์ฆ์, ๊ฐ์ ์ด๋ ฅ. |
|
| 167 |
+
| `productService` | ์ฃผ์์ ํ | `dataframe` | ์ฃผ์ ์ ํ/์๋น์ค๋ณ ๋งค์ถ์ก๊ณผ ๋น์ค. |
|
| 168 |
+
| `salesOrder` | ๋งค์ถ์์ฃผ | `dataframe` | ๋งค์ถ์ค์ ๋ฐ ์์ฃผ ํํฉ. |
|
| 169 |
+
| `riskDerivative` | ์ํ๊ด๋ฆฌ | `dataframe` | ํ์จยท์ด์์จยท์ํ๊ฐ๊ฒฉ ๋ฆฌ์คํฌ ๊ด๋ฆฌ. ํ์์ํ ๋ณด์ ํํฉ. |
|
| 170 |
+
| `articlesOfIncorporation` | ์ ๊ด | `dataframe` | ์ ๊ด ๋ณ๊ฒฝ ์ด๋ ฅ. ์ฌ์
๋ชฉ์ ์ถ๊ฐยท๋ณ๊ฒฝ์ผ๋ก ์ ์ฌ์
์ง์ถ ํ์
. |
|
| 171 |
+
| `otherFinance` | ๊ธฐํ์ฌ๋ฌด | `dataframe` | ๋์์ถฉ๋น๊ธ, ์ฌ๊ณ ์์ฐ ๊ด๋ จ ๊ธฐํ ์ฌ๋ฌด ๋ฐ์ดํฐ. |
|
| 172 |
+
| `companyHistory` | ์ฐํ | `dataframe` | ํ์ฌ ์ฃผ์ ์ฐํ ์ด๋ฒคํธ ๋ชฉ๋ก. |
|
| 173 |
+
| `shareholderMeeting` | ์ฃผ์ฃผ์ดํ | `dataframe` | ์ฃผ์ฃผ์ดํ ์๊ฑด ๋ฐ ์๊ฒฐ ๊ฒฐ๊ณผ. |
|
| 174 |
+
| `auditSystem` | ๊ฐ์ฌ์ ๋ | `dataframe` | ๊ฐ์ฌ์์ํ ๊ตฌ์ฑ ๋ฐ ํ๋ ํํฉ. |
|
| 175 |
+
| `affiliate` | ๊ด๊ณ๊ธฐ์
ํฌ์ | `dataframe` | ๊ด๊ณ๊ธฐ์
/๊ณต๋๊ธฐ์
ํฌ์ ๋ณ๋ ์๊ณ์ด. ์ง๋ถ๋ฒ์์ต, ๊ธฐ์ด/๊ธฐ๋ง ์ฅ๋ถ๊ฐ ํฌํจ. |
|
| 176 |
+
| `investmentInOther` | ํ๋ฒ์ธ์ถ์ | `dataframe` | ํ๋ฒ์ธ ์ถ์ ํํฉ. ํฌ์๋ชฉ์ , ์ง๋ถ์จ, ์ฅ๋ถ๊ฐ ๋ฑ. |
|
| 177 |
+
| `companyOverviewDetail` | ํ์ฌ๊ฐ์ | `dict` | ์ค๋ฆฝ์ผ, ์์ฅ์ผ, ๋ํ์ด์ฌ, ์ฃผ์, ์ฃผ์์ฌ์
๋ฑ ๊ธฐ๋ณธ ์ ๋ณด. |
|
| 178 |
+
| `holderOverview` | ์ฃผ์ฃผํํฉ | `custom` | 5% ์ด์ ์ฃผ์ฃผ, ์์ก์ฃผ์ฃผ ํํฉ, ์๊ฒฐ๊ถ ํํฉ. majorHolder๋ณด๋ค ์์ธํ ์ฃผ์ฃผ ๊ตฌ์ฑ. |
|
| 179 |
+
|
| 180 |
+
### ์์ ํ ๊ณต์ (disclosure)
|
| 181 |
+
|
| 182 |
+
| name | label | dataType | description |
|
| 183 |
+
|------|-------|----------|-------------|
|
| 184 |
+
| `business` | ์ฌ์
์๋ด์ฉ | `text` | ์ฌ์
๋ณด๊ณ ์ '์ฌ์
์ ๋ด์ฉ' ์์ . ์ฌ์
๊ตฌ์กฐ์ ํํฉ ํ์
. |
|
| 185 |
+
| `companyOverview` | ํ์ฌ๊ฐ์์ ๋ | `dict` | ๊ณต์ ๊ธฐ๋ฐ ํ์ฌ ์ ๋ ๊ฐ์ ๋ฐ์ดํฐ. |
|
| 186 |
+
| `mdna` | MD&A | `text` | ์ด์ฌ์ ๊ฒฝ์์ง๋จ ๋ฐ ๋ถ์์๊ฒฌ. ๊ฒฝ์์ง ์๊ฐ์ ์ค์ ํ๊ฐ์ ์ ๋ง. |
|
| 187 |
+
| `rawMaterial` | ์์ฌ๋ฃ์ค๋น | `dict` | ์์ฌ๋ฃ ๋งค์
, ์ ํ์์ฐ ํํฉ, ์์คํฌ์ ๋ฐ์ดํฐ. |
|
| 188 |
+
| `sections` | ์ฌ์
๋ณด๊ณ ์์น์
| `dataframe` | ์ฌ์
๋ณด๊ณ ์ ์ ์ฒด ์น์
ํ
์คํธ๋ฅผ topic(ํ) ร period(์ด) DataFrame์ผ๋ก ๊ตฌ์กฐํ. leaf title ๊ธฐ์ค ์ํ ๋น๊ต ๊ฐ๋ฅ. ์ฐ๊ฐ+๋ถ๊ธฐ+๋ฐ๊ธฐ ์ ๊ธฐ๊ฐ ํฌํจ. |
|
| 189 |
+
|
| 190 |
+
### K-IFRS ์ฃผ์ (notes)
|
| 191 |
+
|
| 192 |
+
| name | label | dataType | description |
|
| 193 |
+
|------|-------|----------|-------------|
|
| 194 |
+
| `notes.receivables` | ๋งค์ถ์ฑ๊ถ | `dataframe` | K-IFRS ๋งค์ถ์ฑ๊ถ ์ฃผ์. ์ฑ๊ถ ์์ก ๋ฐ ๋์์ถฉ๋น๊ธ ๋ด์ญ. |
|
| 195 |
+
| `notes.inventory` | ์ฌ๊ณ ์์ฐ | `dataframe` | K-IFRS ์ฌ๊ณ ์์ฐ ์ฃผ์. ์์ฌ๋ฃ/์ฌ๊ณตํ/์ ํ ๋ด์ญ๋ณ ๊ธ์ก. |
|
| 196 |
+
| `notes.tangibleAsset` | ์ ํ์์ฐ(์ฃผ์) | `dataframe` | K-IFRS ์ ํ์์ฐ ๋ณ๋ ์ฃผ์. ํ ์ง, ๊ฑด๋ฌผ, ๊ธฐ๊ณ ๋ฑ ํญ๋ชฉ๋ณ ๋ณ๋. |
|
| 197 |
+
| `notes.intangibleAsset` | ๋ฌดํ์์ฐ | `dataframe` | K-IFRS ๋ฌดํ์์ฐ ์ฃผ์. ์์
๊ถ, ๊ฐ๋ฐ๋น ๋ฑ ํญ๋ชฉ๋ณ ๋ณ๋. |
|
| 198 |
+
| `notes.investmentProperty` | ํฌ์๋ถ๋์ฐ | `dataframe` | K-IFRS ํฌ์๋ถ๋์ฐ ์ฃผ์. ๊ณต์ ๊ฐ์น ๋ฐ ๋ณ๋ ๋ด์ญ. |
|
| 199 |
+
| `notes.affiliates` | ๊ด๊ณ๊ธฐ์
(์ฃผ์) | `dataframe` | K-IFRS ๊ด๊ณ๊ธฐ์
ํฌ์ ์ฃผ์. ์ง๋ถ๋ฒ ์ ์ฉ ๋ด์ญ. |
|
| 200 |
+
| `notes.borrowings` | ์ฐจ์
๊ธ | `dataframe` | K-IFRS ์ฐจ์
๊ธ ์ฃผ์. ๋จ๊ธฐ/์ฅ๊ธฐ ์ฐจ์
์์ก ๋ฐ ์ด์์จ. |
|
| 201 |
+
| `notes.provisions` | ์ถฉ๋น๋ถ์ฑ | `dataframe` | K-IFRS ์ถฉ๋น๋ถ์ฑ ์ฃผ์. ํ๋งค๋ณด์ฆ, ์์ก, ๋ณต๊ตฌ ๋ฑ. |
|
| 202 |
+
| `notes.eps` | ์ฃผ๋น์ด์ต | `dataframe` | K-IFRS ์ฃผ๋น์ด์ต ์ฃผ์. ๊ธฐ๋ณธ/ํฌ์ EPS ๊ณ์ฐ ๋ด์ญ. |
|
| 203 |
+
| `notes.lease` | ๋ฆฌ์ค | `dataframe` | K-IFRS ๋ฆฌ์ค ์ฃผ์. ์ฌ์ฉ๊ถ์์ฐ, ๋ฆฌ์ค๋ถ์ฑ ๋ด์ญ. |
|
| 204 |
+
| `notes.segments` | ๋ถ๋ฌธ์ ๋ณด(์ฃผ์) | `dataframe` | K-IFRS ๋ถ๋ฌธ์ ๋ณด ์ฃผ์. ์ฌ์
๋ถ๋ฌธ๋ณ ์์ธ ๋ฐ์ดํฐ. |
|
| 205 |
+
| `notes.costByNature` | ๋น์ฉ์์ฑ๊ฒฉ๋ณ๋ถ๋ฅ(์ฃผ์) | `dataframe` | K-IFRS ๋น์ฉ์ ์ฑ๊ฒฉ๋ณ ๋ถ๋ฅ ์ฃผ์. |
|
| 206 |
+
|
| 207 |
+
### ์๋ณธ ๋ฐ์ดํฐ (raw)
|
| 208 |
+
|
| 209 |
+
| name | label | dataType | description |
|
| 210 |
+
|------|-------|----------|-------------|
|
| 211 |
+
| `rawDocs` | ๊ณต์ ์๋ณธ | `dataframe` | ๊ณต์ ๋ฌธ์ ์๋ณธ parquet. ๊ฐ๊ณต ์ ์ ์ฒด ํ
์ด๋ธ๊ณผ ํ
์คํธ. |
|
| 212 |
+
| `rawFinance` | XBRL ์๋ณธ | `dataframe` | XBRL ์ฌ๋ฌด์ ํ ์๋ณธ parquet. ๋งคํ/์ ๊ทํ ์ ์๋ณธ ๋ฐ์ดํฐ. |
|
| 213 |
+
| `rawReport` | ๋ณด๊ณ ์ ์๋ณธ | `dataframe` | ์ ๊ธฐ๋ณด๊ณ ์ API ์๋ณธ parquet. ํ์ฑ ์ ์๋ณธ ๋ฐ์ดํฐ. |
|
| 214 |
+
|
| 215 |
+
### ๋ถ์ ์์ง (analysis)
|
| 216 |
+
|
| 217 |
+
| name | label | dataType | description |
|
| 218 |
+
|------|-------|----------|-------------|
|
| 219 |
+
| `ratios` | ์ฌ๋ฌด๋น์จ | `ratios` | financeEngine์ด ์๋๊ณ์ฐํ ์์ต์ฑยท์์ ์ฑยท๋ฐธ๋ฅ์์ด์
๋น์จ. |
|
| 220 |
+
| `insight` | ์ธ์ฌ์ดํธ | `custom` | 7์์ญ A~F ๋ฑ๊ธ ๋ถ์ (์ค์ , ์์ต์ฑ, ๊ฑด์ ์ฑ, ํ๊ธํ๋ฆ, ์ง๋ฐฐ๊ตฌ์กฐ, ๋ฆฌ์คํฌ, ๊ธฐํ). |
|
| 221 |
+
| `sector` | ์นํฐ๋ถ๋ฅ | `custom` | WICS 11๋ ์นํฐ ๋ถ๋ฅ. ๋๋ถ๋ฅ/์ค๋ถ๋ฅ + ์นํฐ๋ณ ํ๋ผ๋ฏธํฐ. |
|
| 222 |
+
| `rank` | ์์ฅ์์ | `custom` | ์ ์ฒด ์์ฅ ๋ฐ ์นํฐ ๋ด ๋งค์ถ/์์ฐ/์ฑ์ฅ๋ฅ ์์. |
|
| 223 |
+
| `keywordTrend` | ํค์๋ ํธ๋ ๋ | `dataframe` | ๊ณต์ ํ
์คํธ ํค์๋ ๋น๋ ์ถ์ด (topic ร period ร keyword). 54๊ฐ ๋ด์ฅ ํค์๋ ๋๋ ์ฌ์ฉ์ ์ง์ . |
|
| 224 |
+
| `news` | ๋ด์ค | `dataframe` | ์ต๊ทผ ๋ด์ค ์์ง (KR: Google News ํ๊ตญ์ด, US: Google News ์์ด). ๋ ์ง/์ ๋ชฉ/์ถ์ฒ/URL. |
|
| 225 |
+
| `crossBorderPeers` | ๊ธ๋ก๋ฒ ํผ์ด | `custom` | WICSโGICS ์นํฐ ๋งคํ ๊ธฐ๋ฐ ๊ธ๋ก๋ฒ ํผ์ด ์ถ์ฒ. ํ๊ตญ ์ข
๋ชฉ์ ๋ฏธ๊ตญ ๋์ข
๊ธฐ์
๋ฆฌ์คํธ. |
|
| 226 |
+
|
| 227 |
+
---
|
| 228 |
+
|
| 229 |
+
## ์ฃผ์ ๋ฐ์ดํฐ ํ์
|
| 230 |
+
|
| 231 |
+
### RatioResult
|
| 232 |
+
|
| 233 |
+
๋น์จ ๊ณ์ฐ ๊ฒฐ๊ณผ (์ต์ ๋จ์ผ ์์ ).
|
| 234 |
+
|
| 235 |
+
| ํ๋ | ํ์
| ๊ธฐ๋ณธ๊ฐ |
|
| 236 |
+
|------|------|--------|
|
| 237 |
+
| `revenueTTM` | `float | None` | None |
|
| 238 |
+
| `operatingIncomeTTM` | `float | None` | None |
|
| 239 |
+
| `netIncomeTTM` | `float | None` | None |
|
| 240 |
+
| `operatingCashflowTTM` | `float | None` | None |
|
| 241 |
+
| `investingCashflowTTM` | `float | None` | None |
|
| 242 |
+
| `totalAssets` | `float | None` | None |
|
| 243 |
+
| `totalEquity` | `float | None` | None |
|
| 244 |
+
| `ownersEquity` | `float | None` | None |
|
| 245 |
+
| `totalLiabilities` | `float | None` | None |
|
| 246 |
+
| `currentAssets` | `float | None` | None |
|
| 247 |
+
| `currentLiabilities` | `float | None` | None |
|
| 248 |
+
| `cash` | `float | None` | None |
|
| 249 |
+
| `shortTermBorrowings` | `float | None` | None |
|
| 250 |
+
| `longTermBorrowings` | `float | None` | None |
|
| 251 |
+
| `bonds` | `float | None` | None |
|
| 252 |
+
| `grossProfit` | `float | None` | None |
|
| 253 |
+
| `costOfSales` | `float | None` | None |
|
| 254 |
+
| `sga` | `float | None` | None |
|
| 255 |
+
| `inventories` | `float | None` | None |
|
| 256 |
+
| `receivables` | `float | None` | None |
|
| 257 |
+
| `payables` | `float | None` | None |
|
| 258 |
+
| `tangibleAssets` | `float | None` | None |
|
| 259 |
+
| `intangibleAssets` | `float | None` | None |
|
| 260 |
+
| `retainedEarnings` | `float | None` | None |
|
| 261 |
+
| `profitBeforeTax` | `float | None` | None |
|
| 262 |
+
| `incomeTaxExpense` | `float | None` | None |
|
| 263 |
+
| `financeIncome` | `float | None` | None |
|
| 264 |
+
| `financeCosts` | `float | None` | None |
|
| 265 |
+
| `capex` | `float | None` | None |
|
| 266 |
+
| `dividendsPaid` | `float | None` | None |
|
| 267 |
+
| `depreciationExpense` | `float | None` | None |
|
| 268 |
+
| `noncurrentAssets` | `float | None` | None |
|
| 269 |
+
| `noncurrentLiabilities` | `float | None` | None |
|
| 270 |
+
| `roe` | `float | None` | None |
|
| 271 |
+
| `roa` | `float | None` | None |
|
| 272 |
+
| `roce` | `float | None` | None |
|
| 273 |
+
| `operatingMargin` | `float | None` | None |
|
| 274 |
+
| `netMargin` | `float | None` | None |
|
| 275 |
+
| `preTaxMargin` | `float | None` | None |
|
| 276 |
+
| `grossMargin` | `float | None` | None |
|
| 277 |
+
| `ebitdaMargin` | `float | None` | None |
|
| 278 |
+
| `costOfSalesRatio` | `float | None` | None |
|
| 279 |
+
| `sgaRatio` | `float | None` | None |
|
| 280 |
+
| `effectiveTaxRate` | `float | None` | None |
|
| 281 |
+
| `incomeQualityRatio` | `float | None` | None |
|
| 282 |
+
| `debtRatio` | `float | None` | None |
|
| 283 |
+
| `currentRatio` | `float | None` | None |
|
| 284 |
+
| `quickRatio` | `float | None` | None |
|
| 285 |
+
| `cashRatio` | `float | None` | None |
|
| 286 |
+
| `equityRatio` | `float | None` | None |
|
| 287 |
+
| `interestCoverage` | `float | None` | None |
|
| 288 |
+
| `netDebt` | `float | None` | None |
|
| 289 |
+
| `netDebtRatio` | `float | None` | None |
|
| 290 |
+
| `noncurrentRatio` | `float | None` | None |
|
| 291 |
+
| `workingCapital` | `float | None` | None |
|
| 292 |
+
| `revenueGrowth` | `float | None` | None |
|
| 293 |
+
| `operatingProfitGrowth` | `float | None` | None |
|
| 294 |
+
| `netProfitGrowth` | `float | None` | None |
|
| 295 |
+
| `assetGrowth` | `float | None` | None |
|
| 296 |
+
| `equityGrowthRate` | `float | None` | None |
|
| 297 |
+
| `revenueGrowth3Y` | `float | None` | None |
|
| 298 |
+
| `totalAssetTurnover` | `float | None` | None |
|
| 299 |
+
| `fixedAssetTurnover` | `float | None` | None |
|
| 300 |
+
| `inventoryTurnover` | `float | None` | None |
|
| 301 |
+
| `receivablesTurnover` | `float | None` | None |
|
| 302 |
+
| `payablesTurnover` | `float | None` | None |
|
| 303 |
+
| `operatingCycle` | `float | None` | None |
|
| 304 |
+
| `fcf` | `float | None` | None |
|
| 305 |
+
| `operatingCfMargin` | `float | None` | None |
|
| 306 |
+
| `operatingCfToNetIncome` | `float | None` | None |
|
| 307 |
+
| `operatingCfToCurrentLiab` | `float | None` | None |
|
| 308 |
+
| `capexRatio` | `float | None` | None |
|
| 309 |
+
| `dividendPayoutRatio` | `float | None` | None |
|
| 310 |
+
| `fcfToOcfRatio` | `float | None` | None |
|
| 311 |
+
| `roic` | `float | None` | None |
|
| 312 |
+
| `dupontMargin` | `float | None` | None |
|
| 313 |
+
| `dupontTurnover` | `float | None` | None |
|
| 314 |
+
| `dupontLeverage` | `float | None` | None |
|
| 315 |
+
| `debtToEbitda` | `float | None` | None |
|
| 316 |
+
| `ccc` | `float | None` | None |
|
| 317 |
+
| `dso` | `float | None` | None |
|
| 318 |
+
| `dio` | `float | None` | None |
|
| 319 |
+
| `dpo` | `float | None` | None |
|
| 320 |
+
| `piotroskiFScore` | `int | None` | None |
|
| 321 |
+
| `piotroskiMaxScore` | `int` | 9 |
|
| 322 |
+
| `altmanZScore` | `float | None` | None |
|
| 323 |
+
| `beneishMScore` | `float | None` | None |
|
| 324 |
+
| `sloanAccrualRatio` | `float | None` | None |
|
| 325 |
+
| `ohlsonOScore` | `float | None` | None |
|
| 326 |
+
| `ohlsonProbability` | `float | None` | None |
|
| 327 |
+
| `altmanZppScore` | `float | None` | None |
|
| 328 |
+
| `springateSScore` | `float | None` | None |
|
| 329 |
+
| `zmijewskiXScore` | `float | None` | None |
|
| 330 |
+
| `eps` | `float | None` | None |
|
| 331 |
+
| `bps` | `float | None` | None |
|
| 332 |
+
| `dps` | `float | None` | None |
|
| 333 |
+
| `per` | `float | None` | None |
|
| 334 |
+
| `pbr` | `float | None` | None |
|
| 335 |
+
| `psr` | `float | None` | None |
|
| 336 |
+
| `evEbitda` | `float | None` | None |
|
| 337 |
+
| `marketCap` | `float | None` | None |
|
| 338 |
+
| `sharesOutstanding` | `int | None` | None |
|
| 339 |
+
| `ebitdaEstimated` | `bool` | True |
|
| 340 |
+
| `currency` | `str` | KRW |
|
| 341 |
+
| `warnings` | `list` | [] |
|
| 342 |
+
|
| 343 |
+
### InsightResult
|
| 344 |
+
|
| 345 |
+
๋จ์ผ ์์ญ ๋ถ์ ๊ฒฐ๊ณผ.
|
| 346 |
+
|
| 347 |
+
| ํ๋ | ํ์
| ๊ธฐ๋ณธ๊ฐ |
|
| 348 |
+
|------|------|--------|
|
| 349 |
+
| `grade` | `str` | |
|
| 350 |
+
| `summary` | `str` | |
|
| 351 |
+
| `details` | `list` | [] |
|
| 352 |
+
| `risks` | `list` | [] |
|
| 353 |
+
| `opportunities` | `list` | [] |
|
| 354 |
+
|
| 355 |
+
### Anomaly
|
| 356 |
+
|
| 357 |
+
์ด์์น ํ์ง ๊ฒฐ๊ณผ.
|
| 358 |
+
|
| 359 |
+
| ํ๋ | ํ์
| ๊ธฐ๋ณธ๊ฐ |
|
| 360 |
+
|------|------|--------|
|
| 361 |
+
| `severity` | `str` | |
|
| 362 |
+
| `category` | `str` | |
|
| 363 |
+
| `text` | `str` | |
|
| 364 |
+
| `value` | `Optional` | None |
|
| 365 |
+
|
| 366 |
+
### Flag
|
| 367 |
+
|
| 368 |
+
๋ฆฌ์คํฌ/๊ธฐํ ํ๋๊ทธ.
|
| 369 |
+
|
| 370 |
+
| ํ๋ | ํ์
| ๊ธฐ๋ณธ๊ฐ |
|
| 371 |
+
|------|------|--------|
|
| 372 |
+
| `level` | `str` | |
|
| 373 |
+
| `category` | `str` | |
|
| 374 |
+
| `text` | `str` | |
|
| 375 |
+
|
| 376 |
+
### AnalysisResult
|
| 377 |
+
|
| 378 |
+
์ข
ํฉ ๋ถ์ ๊ฒฐ๊ณผ.
|
| 379 |
+
|
| 380 |
+
| ํ๋ | ํ์
| ๊ธฐ๋ณธ๊ฐ |
|
| 381 |
+
|------|------|--------|
|
| 382 |
+
| `corpName` | `str` | |
|
| 383 |
+
| `stockCode` | `str` | |
|
| 384 |
+
| `isFinancial` | `bool` | |
|
| 385 |
+
| `performance` | `InsightResult` | |
|
| 386 |
+
| `profitability` | `InsightResult` | |
|
| 387 |
+
| `health` | `InsightResult` | |
|
| 388 |
+
| `cashflow` | `InsightResult` | |
|
| 389 |
+
| `governance` | `InsightResult` | |
|
| 390 |
+
| `risk` | `InsightResult` | |
|
| 391 |
+
| `opportunity` | `InsightResult` | |
|
| 392 |
+
| `predictability` | `Optional` | None |
|
| 393 |
+
| `uncertainty` | `Optional` | None |
|
| 394 |
+
| `coreEarnings` | `Optional` | None |
|
| 395 |
+
| `anomalies` | `list` | [] |
|
| 396 |
+
| `distress` | `Optional` | None |
|
| 397 |
+
| `summary` | `str` | |
|
| 398 |
+
| `profile` | `str` | |
|
| 399 |
+
|
| 400 |
+
### SectorInfo
|
| 401 |
+
|
| 402 |
+
์นํฐ ๋ถ๋ฅ ๊ฒฐ๊ณผ.
|
| 403 |
+
|
| 404 |
+
| ํ๋ | ํ์
| ๊ธฐ๋ณธ๊ฐ |
|
| 405 |
+
|------|------|--------|
|
| 406 |
+
| `sector` | `Sector` | |
|
| 407 |
+
| `industryGroup` | `IndustryGroup` | |
|
| 408 |
+
| `confidence` | `float` | |
|
| 409 |
+
| `source` | `str` | |
|
| 410 |
+
|
| 411 |
+
### SectorParams
|
| 412 |
+
|
| 413 |
+
์นํฐ๋ณ ๋ฐธ๋ฅ์์ด์
ํ๋ผ๋ฏธํฐ.
|
| 414 |
+
|
| 415 |
+
| ํ๋ | ํ์
| ๊ธฐ๋ณธ๊ฐ |
|
| 416 |
+
|------|------|--------|
|
| 417 |
+
| `discountRate` | `float` | |
|
| 418 |
+
| `growthRate` | `float` | |
|
| 419 |
+
| `perMultiple` | `float` | |
|
| 420 |
+
| `pbrMultiple` | `float` | |
|
| 421 |
+
| `evEbitdaMultiple` | `float` | |
|
| 422 |
+
| `label` | `str` | |
|
| 423 |
+
| `description` | `str` | |
|
| 424 |
+
|
| 425 |
+
### RankInfo
|
| 426 |
+
|
| 427 |
+
๋จ์ผ ์ข
๋ชฉ์ ๋ญํฌ ์ ๋ณด.
|
| 428 |
+
|
| 429 |
+
| ํ๋ | ํ์
| ๊ธฐ๋ณธ๊ฐ |
|
| 430 |
+
|------|------|--------|
|
| 431 |
+
| `stockCode` | `str` | |
|
| 432 |
+
| `corpName` | `str` | |
|
| 433 |
+
| `sector` | `str` | |
|
| 434 |
+
| `industryGroup` | `str` | |
|
| 435 |
+
| `revenue` | `Optional` | None |
|
| 436 |
+
| `totalAssets` | `Optional` | None |
|
| 437 |
+
| `revenueGrowth3Y` | `Optional` | None |
|
| 438 |
+
| `revenueRank` | `Optional` | None |
|
| 439 |
+
| `revenueTotal` | `int` | 0 |
|
| 440 |
+
| `revenueRankInSector` | `Optional` | None |
|
| 441 |
+
| `revenueSectorTotal` | `int` | 0 |
|
| 442 |
+
| `assetRank` | `Optional` | None |
|
| 443 |
+
| `assetTotal` | `int` | 0 |
|
| 444 |
+
| `assetRankInSector` | `Optional` | None |
|
| 445 |
+
| `assetSectorTotal` | `int` | 0 |
|
| 446 |
+
| `growthRank` | `Optional` | None |
|
| 447 |
+
| `growthTotal` | `int` | 0 |
|
| 448 |
+
| `growthRankInSector` | `Optional` | None |
|
| 449 |
+
| `growthSectorTotal` | `int` | 0 |
|
| 450 |
+
| `sizeClass` | `str` | |
|
src/dartlab/STATUS.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# src/dartlab
|
| 2 |
+
|
| 3 |
+
## ๊ฐ์
|
| 4 |
+
DART ๊ณต์ ๋ฐ์ดํฐ ํ์ฉ ๋ผ์ด๋ธ๋ฌ๋ฆฌ. ์ข
๋ชฉ์ฝ๋ ๊ธฐ๋ฐ API.
|
| 5 |
+
|
| 6 |
+
## ๊ตฌ์กฐ
|
| 7 |
+
```
|
| 8 |
+
dartlab/
|
| 9 |
+
โโโ core/ # ๊ณตํต ๊ธฐ๋ฐ (๋ฐ์ดํฐ ๋ก๋ฉ, ๋ณด๊ณ ์ ์ ํ, ํ
์ด๋ธ ํ์ฑ, ์ฃผ์ ์ถ์ถ)
|
| 10 |
+
โโโ finance/ # ์ฌ๋ฌด ๋ฐ์ดํฐ (36๊ฐ ๋ชจ๋)
|
| 11 |
+
โ โโโ summary/ # ์์ฝ์ฌ๋ฌด์ ๋ณด ์๊ณ์ด
|
| 12 |
+
โ โโโ statements/ # ์ฐ๊ฒฐ์ฌ๋ฌด์ ํ (BS, IS, CF)
|
| 13 |
+
โ โโโ segment/ # ๋ถ๋ฌธ๋ณ ๋ณด๊ณ (์ฃผ์)
|
| 14 |
+
โ โโโ affiliate/ # ๊ด๊ณ๊ธฐ์
ยท๊ณต๋๊ธฐ์
(์ฃผ์)
|
| 15 |
+
โ โโโ costByNature/ # ๋น์ฉ์ ์ฑ๊ฒฉ๋ณ ๋ถ๋ฅ (์ฃผ์)
|
| 16 |
+
โ โโโ tangibleAsset/ # ์ ํ์์ฐ (์ฃผ์)
|
| 17 |
+
โ โโโ notesDetail/ # ์ฃผ์ ์์ธ (23๊ฐ ํค์๋)
|
| 18 |
+
โ โโโ dividend/ # ๋ฐฐ๋น
|
| 19 |
+
โ โโโ majorHolder/ # ์ต๋์ฃผ์ฃผยท์ฃผ์ฃผํํฉ
|
| 20 |
+
โ โโโ shareCapital/ # ์ฃผ์ ํํฉ
|
| 21 |
+
โ โโโ employee/ # ์ง์ ํํฉ
|
| 22 |
+
โ โโโ subsidiary/ # ์ํ์ฌ ํฌ์
|
| 23 |
+
โ โโโ bond/ # ์ฑ๋ฌด์ฆ๊ถ
|
| 24 |
+
โ โโโ audit/ # ๊ฐ์ฌ์๊ฒฌยท๋ณด์
|
| 25 |
+
โ โโโ executive/ # ์์ ํํฉ
|
| 26 |
+
โ โโโ executivePay/ # ์์ ๋ณด์
|
| 27 |
+
โ โโโ boardOfDirectors/ # ์ด์ฌํ
|
| 28 |
+
โ โโโ capitalChange/ # ์๋ณธ๊ธ ๋ณ๋
|
| 29 |
+
โ โโโ contingentLiability/ # ์ฐ๋ฐ๋ถ์ฑ
|
| 30 |
+
โ โโโ internalControl/ # ๋ด๋ถํต์
|
| 31 |
+
โ โโโ relatedPartyTx/ # ๊ด๊ณ์ ๊ฑฐ๋
|
| 32 |
+
โ โโโ rnd/ # R&D ๋น์ฉ
|
| 33 |
+
โ โโโ sanction/ # ์ ์ฌ ํํฉ
|
| 34 |
+
โ โโโ affiliateGroup/ # ๊ณ์ด์ฌ ๋ชฉ๋ก
|
| 35 |
+
โ โโโ fundraising/ # ์ฆ์/๊ฐ์
|
| 36 |
+
โ โโโ productService/ # ์ฃผ์ ์ ํ/์๋น์ค
|
| 37 |
+
โ โโโ salesOrder/ # ๋งค์ถ/์์ฃผ
|
| 38 |
+
โ โโโ riskDerivative/ # ์ํ๊ด๋ฆฌ/ํ์๊ฑฐ๋
|
| 39 |
+
โ โโโ articlesOfIncorporation/ # ์ ๊ด
|
| 40 |
+
โ โโโ otherFinance/ # ๊ธฐํ ์ฌ๋ฌด
|
| 41 |
+
โ โโโ companyHistory/ # ํ์ฌ ์ฐํ
|
| 42 |
+
โ โโโ shareholderMeeting/ # ์ฃผ์ฃผ์ดํ
|
| 43 |
+
โ โโโ auditSystem/ # ๊ฐ์ฌ์ ๋
|
| 44 |
+
โ โโโ investmentInOther/ # ํ๋ฒ์ธ์ถ์
|
| 45 |
+
โ โโโ companyOverviewDetail/ # ํ์ฌ๊ฐ์ ์์ธ
|
| 46 |
+
โโโ disclosure/ # ๊ณต์ ์์ ํ (4๊ฐ ๋ชจ๋)
|
| 47 |
+
โ โโโ business/ # ์ฌ์
์ ๋ด์ฉ
|
| 48 |
+
โ โโโ companyOverview/ # ํ์ฌ์ ๊ฐ์ (์ ๋)
|
| 49 |
+
โ โโโ mdna/ # MD&A
|
| 50 |
+
โ โโโ rawMaterial/ # ์์ฌ๋ฃยท์ค๋น
|
| 51 |
+
โโโ company.py # ํตํฉ ์ ๊ทผ (property ๊ธฐ๋ฐ, lazy + cache)
|
| 52 |
+
โโโ notes.py # K-IFRS ์ฃผ์ ํตํฉ ์ ๊ทผ
|
| 53 |
+
โโโ config.py # ์ ์ญ ์ค์ (verbose)
|
| 54 |
+
```
|
| 55 |
+
|
| 56 |
+
## API ์์ฝ
|
| 57 |
+
```python
|
| 58 |
+
import dartlab
|
| 59 |
+
|
| 60 |
+
c = dartlab.Company("005930")
|
| 61 |
+
c.index # ํ์ฌ ๊ตฌ์กฐ ์ธ๋ฑ์ค
|
| 62 |
+
c.show("BS") # topic payload
|
| 63 |
+
c.trace("dividend") # source trace
|
| 64 |
+
c.BS # ์ฌ๋ฌด์ํํ DataFrame
|
| 65 |
+
c.dividend # ๋ฐฐ๋น ์๊ณ์ด DataFrame
|
| 66 |
+
|
| 67 |
+
import dartlab
|
| 68 |
+
dartlab.verbose = False # ์งํ ํ์ ๋๊ธฐ
|
| 69 |
+
```
|
| 70 |
+
|
| 71 |
+
## ํํฉ
|
| 72 |
+
- 2026-03-06: core/ + finance/summary/ ์ด๊ธฐ ๊ตฌ์ถ
|
| 73 |
+
- 2026-03-06: finance/statements/, segment/, affiliate/ ์ถ๊ฐ
|
| 74 |
+
- 2026-03-06: ์ ์ฒด ํจํค์ง ๊ฐ์ โ stockCode ์๊ทธ๋์ฒ, ํซ๋ผ์ธ ์ค๊ณ, API_SPEC.md
|
| 75 |
+
- 2026-03-07: finance/ 11๊ฐ ๋ชจ๋ ์ถ๊ฐ (dividend~bond, costByNature)
|
| 76 |
+
- 2026-03-07: disclosure/ 4๊ฐ ๋ชจ๋ ์ถ๊ฐ (business, companyOverview, mdna, rawMaterial)
|
| 77 |
+
- 2026-03-07: finance/ ์ฃผ์ ๋ชจ๋ ์ถ๊ฐ (notesDetail, tangibleAsset)
|
| 78 |
+
- 2026-03-07: finance/ 7๊ฐ ๋ชจ๋ ์ถ๊ฐ (audit~internalControl, rnd, sanction)
|
| 79 |
+
- 2026-03-07: finance/ 7๊ฐ ๋ชจ๋ ์ถ๊ฐ (affiliateGroup~companyHistory, shareholderMeeting~investmentInOther, companyOverviewDetail)
|
| 80 |
+
- 2026-03-08: analyze โ fsSummary ๋ฆฌ๋ค์ด๋ฐ, ๊ณ์ ๋ช
ํน์๋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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""DART ๊ณต์ ๋ฐ์ดํฐ ํ์ฉ ๋ผ์ด๋ธ๋ฌ๋ฆฌ."""
|
| 2 |
+
|
| 3 |
+
import sys
|
| 4 |
+
from importlib.metadata import PackageNotFoundError
|
| 5 |
+
from importlib.metadata import version as _pkg_version
|
| 6 |
+
|
| 7 |
+
from dartlab import ai as llm
|
| 8 |
+
from dartlab import config, core
|
| 9 |
+
from dartlab.company import Company
|
| 10 |
+
from dartlab.core.env import loadEnv as _loadEnv
|
| 11 |
+
from dartlab.core.select import ChartResult, SelectResult
|
| 12 |
+
from dartlab.gather.fred import Fred
|
| 13 |
+
from dartlab.gather.listing import codeToName, fuzzySearch, getKindList, nameToCode, searchName
|
| 14 |
+
from dartlab.providers.dart.company import Company as _DartEngineCompany
|
| 15 |
+
from dartlab.providers.dart.openapi.dart import Dart, OpenDart
|
| 16 |
+
from dartlab.providers.edgar.openapi.edgar import OpenEdgar
|
| 17 |
+
from dartlab.review import Review
|
| 18 |
+
|
| 19 |
+
# .env ์๋ ๋ก๋ โ API ํค ๋ฑ ํ๊ฒฝ๋ณ์
|
| 20 |
+
_loadEnv()
|
| 21 |
+
|
| 22 |
+
try:
|
| 23 |
+
__version__ = _pkg_version("dartlab")
|
| 24 |
+
except PackageNotFoundError:
|
| 25 |
+
__version__ = "0.0.0"
|
| 26 |
+
|
| 27 |
+
|
| 28 |
+
def search(keyword: str):
|
| 29 |
+
"""์ข
๋ชฉ ๊ฒ์ (KR + US ํตํฉ).
|
| 30 |
+
|
| 31 |
+
Example::
|
| 32 |
+
|
| 33 |
+
import dartlab
|
| 34 |
+
dartlab.search("์ผ์ฑ์ ์")
|
| 35 |
+
dartlab.search("AAPL")
|
| 36 |
+
"""
|
| 37 |
+
if any("\uac00" <= ch <= "\ud7a3" for ch in keyword):
|
| 38 |
+
return _DartEngineCompany.search(keyword)
|
| 39 |
+
if keyword.isascii() and keyword.isalpha():
|
| 40 |
+
try:
|
| 41 |
+
from dartlab.providers.edgar.company import Company as _US
|
| 42 |
+
|
| 43 |
+
return _US.search(keyword)
|
| 44 |
+
except (ImportError, AttributeError, NotImplementedError):
|
| 45 |
+
pass
|
| 46 |
+
return _DartEngineCompany.search(keyword)
|
| 47 |
+
|
| 48 |
+
|
| 49 |
+
def listing(market: str | None = None):
|
| 50 |
+
"""์ ์ฒด ์์ฅ๋ฒ์ธ ๋ชฉ๋ก.
|
| 51 |
+
|
| 52 |
+
Args:
|
| 53 |
+
market: "KR" ๋๋ "US". None์ด๋ฉด KR ๊ธฐ๋ณธ.
|
| 54 |
+
|
| 55 |
+
Example::
|
| 56 |
+
|
| 57 |
+
import dartlab
|
| 58 |
+
dartlab.listing() # KR ์ ์ฒด
|
| 59 |
+
dartlab.listing("US") # US ์ ์ฒด (ํฅํ)
|
| 60 |
+
"""
|
| 61 |
+
if market and market.upper() == "US":
|
| 62 |
+
try:
|
| 63 |
+
from dartlab.providers.edgar.company import Company as _US
|
| 64 |
+
|
| 65 |
+
return _US.listing()
|
| 66 |
+
except (ImportError, AttributeError, NotImplementedError):
|
| 67 |
+
raise NotImplementedError("US listing์ ์์ง ์ง์๋์ง ์์ต๋๋ค")
|
| 68 |
+
return _DartEngineCompany.listing()
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def collect(
|
| 72 |
+
*codes: str,
|
| 73 |
+
categories: list[str] | None = None,
|
| 74 |
+
incremental: bool = True,
|
| 75 |
+
) -> dict[str, dict[str, int]]:
|
| 76 |
+
"""์ง์ ์ข
๋ชฉ DART ๋ฐ์ดํฐ ์์ง (OpenAPI). ๋ฉํฐํค ์ ๋ณ๋ ฌ.
|
| 77 |
+
|
| 78 |
+
Example::
|
| 79 |
+
|
| 80 |
+
import dartlab
|
| 81 |
+
dartlab.collect("005930") # ์ผ์ฑ์ ์ ์ ์ฒด
|
| 82 |
+
dartlab.collect("005930", "000660", categories=["finance"]) # ์ฌ๋ฌด๋ง
|
| 83 |
+
"""
|
| 84 |
+
from dartlab.providers.dart.openapi.batch import batchCollect
|
| 85 |
+
|
| 86 |
+
return batchCollect(list(codes), categories=categories, incremental=incremental)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def collectAll(
|
| 90 |
+
*,
|
| 91 |
+
categories: list[str] | None = None,
|
| 92 |
+
mode: str = "new",
|
| 93 |
+
maxWorkers: int | None = None,
|
| 94 |
+
incremental: bool = True,
|
| 95 |
+
) -> dict[str, dict[str, int]]:
|
| 96 |
+
"""์ ์ฒด ์์ฅ์ข
๋ชฉ DART ๋ฐ์ดํฐ ์์ง. DART_API_KEY(S) ํ์. ๋ฉํฐํค ์ ๋ณ๋ ฌ.
|
| 97 |
+
|
| 98 |
+
Example::
|
| 99 |
+
|
| 100 |
+
import dartlab
|
| 101 |
+
dartlab.collectAll() # ์ ์ฒด ๋ฏธ์์ง ์ข
๋ชฉ
|
| 102 |
+
dartlab.collectAll(categories=["finance"]) # ์ฌ๋ฌด๋ง
|
| 103 |
+
dartlab.collectAll(mode="all") # ๊ธฐ์์ง ํฌํจ ์ ์ฒด
|
| 104 |
+
"""
|
| 105 |
+
from dartlab.providers.dart.openapi.batch import batchCollectAll
|
| 106 |
+
|
| 107 |
+
return batchCollectAll(
|
| 108 |
+
categories=categories,
|
| 109 |
+
mode=mode,
|
| 110 |
+
maxWorkers=maxWorkers,
|
| 111 |
+
incremental=incremental,
|
| 112 |
+
)
|
| 113 |
+
|
| 114 |
+
|
| 115 |
+
def downloadAll(category: str = "finance", *, forceUpdate: bool = False) -> None:
|
| 116 |
+
"""HuggingFace์์ ์ ์ฒด ์์ฅ ๋ฐ์ดํฐ๋ฅผ ๋ค์ด๋ก๋. pip install dartlab[hf] ํ์.
|
| 117 |
+
|
| 118 |
+
scanAccount, screen, digest ๋ฑ ์ ์ฌ(ๅ
จ็คพ) ๋ถ์ ๊ธฐ๋ฅ์ ๋ก์ปฌ์ ์ ์ฒด ๋ฐ์ดํฐ๊ฐ ์์ด์ผ ๋์ํฉ๋๋ค.
|
| 119 |
+
์ด ํจ์๋ก ์นดํ
๊ณ ๋ฆฌ๋ณ ์ ์ฒด ๋ฐ์ดํฐ๋ฅผ ์ฌ์ ๋ค์ด๋ก๋ํ์ธ์.
|
| 120 |
+
|
| 121 |
+
Args:
|
| 122 |
+
category: "finance" (์ฌ๋ฌด ~600MB), "docs" (๊ณต์ ~8GB), "report" (๋ณด๊ณ ์ ~320MB).
|
| 123 |
+
forceUpdate: True๋ฉด ์ด๋ฏธ ์๋ ํ์ผ๋ ์ต์ ์ผ๋ก ๊ฐฑ์ .
|
| 124 |
+
|
| 125 |
+
Examples::
|
| 126 |
+
|
| 127 |
+
import dartlab
|
| 128 |
+
dartlab.downloadAll("finance") # ์ฌ๋ฌด ์ ์ฒด โ scanAccount/screen/benchmark ๋ฑ์ ํ์
|
| 129 |
+
dartlab.downloadAll("report") # ๋ณด๊ณ ์ ์ ์ฒด โ governance/workforce/capital/debt์ ํ์
|
| 130 |
+
dartlab.downloadAll("docs") # ๊ณต์ ์ ์ฒด โ digest/signal์ ํ์ (๋์ฉ๋ ~8GB)
|
| 131 |
+
"""
|
| 132 |
+
from dartlab.core.dataLoader import downloadAll as _downloadAll
|
| 133 |
+
|
| 134 |
+
_downloadAll(category, forceUpdate=forceUpdate)
|
| 135 |
+
|
| 136 |
+
|
| 137 |
+
def checkFreshness(stockCode: str, *, forceCheck: bool = False):
|
| 138 |
+
"""์ข
๋ชฉ์ ๋ก์ปฌ ๋ฐ์ดํฐ๊ฐ ์ต์ ์ธ์ง DART API๋ก ํ์ธ.
|
| 139 |
+
|
| 140 |
+
Example::
|
| 141 |
+
|
| 142 |
+
import dartlab
|
| 143 |
+
result = dartlab.checkFreshness("005930")
|
| 144 |
+
result.isFresh # True/False
|
| 145 |
+
result.missingCount # ๋๋ฝ ๊ณต์ ์
|
| 146 |
+
"""
|
| 147 |
+
from dartlab.providers.dart.openapi.freshness import (
|
| 148 |
+
checkFreshness as _check,
|
| 149 |
+
)
|
| 150 |
+
|
| 151 |
+
return _check(stockCode, forceCheck=forceCheck)
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
def network():
|
| 155 |
+
"""ํ๊ตญ ์์ฅ์ฌ ์ ์ฒด ๊ด๊ณ ์ง๋.
|
| 156 |
+
|
| 157 |
+
Example::
|
| 158 |
+
|
| 159 |
+
import dartlab
|
| 160 |
+
dartlab.network().show() # ๋ธ๋ผ์ฐ์ ์์ ์ ์ฒด ๋คํธ์ํฌ
|
| 161 |
+
"""
|
| 162 |
+
from dartlab.market.network import build_graph, export_full
|
| 163 |
+
from dartlab.tools.network import render_network
|
| 164 |
+
|
| 165 |
+
data = build_graph()
|
| 166 |
+
full = export_full(data)
|
| 167 |
+
return render_network(
|
| 168 |
+
full["nodes"],
|
| 169 |
+
full["edges"],
|
| 170 |
+
"ํ๊ตญ ์์ฅ์ฌ ๊ด๊ณ ๋คํธ์ํฌ",
|
| 171 |
+
)
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def governance():
|
| 175 |
+
"""ํ๊ตญ ์์ฅ์ฌ ์ ์ฒด ์ง๋ฐฐ๊ตฌ์กฐ ์ค์บ.
|
| 176 |
+
|
| 177 |
+
Example::
|
| 178 |
+
|
| 179 |
+
import dartlab
|
| 180 |
+
df = dartlab.governance()
|
| 181 |
+
"""
|
| 182 |
+
from dartlab.market.governance import scan_governance
|
| 183 |
+
|
| 184 |
+
return scan_governance()
|
| 185 |
+
|
| 186 |
+
|
| 187 |
+
def workforce():
|
| 188 |
+
"""ํ๊ตญ ์์ฅ์ฌ ์ ์ฒด ์ธ๋ ฅ/๊ธ์ฌ ์ค์บ.
|
| 189 |
+
|
| 190 |
+
Example::
|
| 191 |
+
|
| 192 |
+
import dartlab
|
| 193 |
+
df = dartlab.workforce()
|
| 194 |
+
"""
|
| 195 |
+
from dartlab.market.workforce import scan_workforce
|
| 196 |
+
|
| 197 |
+
return scan_workforce()
|
| 198 |
+
|
| 199 |
+
|
| 200 |
+
def capital():
|
| 201 |
+
"""ํ๊ตญ ์์ฅ์ฌ ์ ์ฒด ์ฃผ์ฃผํ์ ์ค์บ.
|
| 202 |
+
|
| 203 |
+
Example::
|
| 204 |
+
|
| 205 |
+
import dartlab
|
| 206 |
+
df = dartlab.capital()
|
| 207 |
+
"""
|
| 208 |
+
from dartlab.market.capital import scan_capital
|
| 209 |
+
|
| 210 |
+
return scan_capital()
|
| 211 |
+
|
| 212 |
+
|
| 213 |
+
def debt():
|
| 214 |
+
"""ํ๊ตญ ์์ฅ์ฌ ์ ์ฒด ๋ถ์ฑ ๊ตฌ์กฐ ์ค์บ.
|
| 215 |
+
|
| 216 |
+
Example::
|
| 217 |
+
|
| 218 |
+
import dartlab
|
| 219 |
+
df = dartlab.debt()
|
| 220 |
+
"""
|
| 221 |
+
from dartlab.market.debt import scan_debt
|
| 222 |
+
|
| 223 |
+
return scan_debt()
|
| 224 |
+
|
| 225 |
+
|
| 226 |
+
def screen(preset: str = "๊ฐ์น์ฃผ"):
|
| 227 |
+
"""์์ฅ ์คํฌ๋ฆฌ๋ โ ํ๋ฆฌ์
๊ธฐ๋ฐ ์ข
๋ชฉ ํํฐ.
|
| 228 |
+
|
| 229 |
+
Args:
|
| 230 |
+
preset: ํ๋ฆฌ์
์ด๋ฆ ("๊ฐ์น์ฃผ", "์ฑ์ฅ์ฃผ", "ํด์ด๋ผ์ด๋", "ํ๊ธ๋ถ์",
|
| 231 |
+
"๊ณ ์ํ", "์๋ณธ์ ์", "์ํ๊ณ ์์ต", "๋ํ์์ ").
|
| 232 |
+
|
| 233 |
+
Example::
|
| 234 |
+
|
| 235 |
+
import dartlab
|
| 236 |
+
df = dartlab.screen("๊ฐ์น์ฃผ") # ROEโฅ10, ๋ถ์ฑโค100 ๋ฑ
|
| 237 |
+
df = dartlab.screen("๊ณ ์ํ") # ๋ถ์ฑโฅ200, ICR<3
|
| 238 |
+
"""
|
| 239 |
+
from dartlab.analysis.comparative.rank.screen import screen as _screen
|
| 240 |
+
|
| 241 |
+
return _screen(preset)
|
| 242 |
+
|
| 243 |
+
|
| 244 |
+
def benchmark():
|
| 245 |
+
"""์นํฐ๋ณ ํต์ฌ ๋น์จ ๋ฒค์น๋งํฌ (P10, median, P90).
|
| 246 |
+
|
| 247 |
+
Example::
|
| 248 |
+
|
| 249 |
+
import dartlab
|
| 250 |
+
bm = dartlab.benchmark() # ์นํฐ ร ๋น์จ ์ ์ ๋ฒ์
|
| 251 |
+
"""
|
| 252 |
+
from dartlab.analysis.comparative.rank.screen import benchmark as _benchmark
|
| 253 |
+
|
| 254 |
+
return _benchmark()
|
| 255 |
+
|
| 256 |
+
|
| 257 |
+
def signal(keyword: str | None = None):
|
| 258 |
+
"""์์ ํ ๊ณต์ ์์ฅ ์๊ทธ๋ โ ํค์๋ ํธ๋ ๋ ํ์ง.
|
| 259 |
+
|
| 260 |
+
Args:
|
| 261 |
+
keyword: ํน์ ํค์๋๋ง ํํฐ. None์ด๋ฉด ์ ์ฒด 48๊ฐ ํค์๋.
|
| 262 |
+
|
| 263 |
+
Example::
|
| 264 |
+
|
| 265 |
+
import dartlab
|
| 266 |
+
df = dartlab.signal() # ์ ์ฒด ํค์๋ ํธ๋ ๋
|
| 267 |
+
df = dartlab.signal("AI") # AI ํค์๋ ์ฐ๋๋ณ ์ถ์ด
|
| 268 |
+
"""
|
| 269 |
+
from dartlab.market.signal import scan_signal
|
| 270 |
+
|
| 271 |
+
return scan_signal(keyword)
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
def news(query: str, *, market: str = "KR", days: int = 30):
|
| 275 |
+
"""๊ธฐ์
๋ด์ค ์์ง.
|
| 276 |
+
|
| 277 |
+
Args:
|
| 278 |
+
query: ๊ธฐ์
๋ช
๋๋ ํฐ์ปค.
|
| 279 |
+
market: "KR" ๋๋ "US".
|
| 280 |
+
days: ์ต๊ทผ N์ผ.
|
| 281 |
+
|
| 282 |
+
Example::
|
| 283 |
+
|
| 284 |
+
import dartlab
|
| 285 |
+
dartlab.news("์ผ์ฑ์ ์")
|
| 286 |
+
dartlab.news("AAPL", market="US")
|
| 287 |
+
"""
|
| 288 |
+
from dartlab.gather import getDefaultGather
|
| 289 |
+
|
| 290 |
+
return getDefaultGather().news(query, market=market, days=days)
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
def price(
|
| 294 |
+
stockCode: str, *, market: str = "KR", start: str | None = None, end: str | None = None, snapshot: bool = False
|
| 295 |
+
):
|
| 296 |
+
"""์ฃผ๊ฐ ์๊ณ์ด (๊ธฐ๋ณธ 1๋
OHLCV) ๋๋ ์ค๋
์ท.
|
| 297 |
+
|
| 298 |
+
Example::
|
| 299 |
+
|
| 300 |
+
import dartlab
|
| 301 |
+
dartlab.price("005930") # 1๋
OHLCV ์๊ณ์ด
|
| 302 |
+
dartlab.price("005930", start="2020-01-01") # ๊ธฐ๊ฐ ์ง์
|
| 303 |
+
dartlab.price("005930", snapshot=True) # ํ์ฌ๊ฐ ์ค๋
์ท
|
| 304 |
+
"""
|
| 305 |
+
from dartlab.gather import getDefaultGather
|
| 306 |
+
|
| 307 |
+
return getDefaultGather().price(stockCode, market=market, start=start, end=end, snapshot=snapshot)
|
| 308 |
+
|
| 309 |
+
|
| 310 |
+
def consensus(stockCode: str, *, market: str = "KR"):
|
| 311 |
+
"""์ปจ์ผ์์ค โ ๋ชฉํ๊ฐ, ํฌ์์๊ฒฌ.
|
| 312 |
+
|
| 313 |
+
Example::
|
| 314 |
+
|
| 315 |
+
import dartlab
|
| 316 |
+
dartlab.consensus("005930")
|
| 317 |
+
dartlab.consensus("AAPL", market="US")
|
| 318 |
+
"""
|
| 319 |
+
from dartlab.gather import getDefaultGather
|
| 320 |
+
|
| 321 |
+
return getDefaultGather().consensus(stockCode, market=market)
|
| 322 |
+
|
| 323 |
+
|
| 324 |
+
def flow(stockCode: str, *, market: str = "KR"):
|
| 325 |
+
"""์๊ธ ์๊ณ์ด โ ์ธ๊ตญ์ธ/๊ธฐ๊ด ๋งค๋งค ๋ํฅ (KR ์ ์ฉ).
|
| 326 |
+
|
| 327 |
+
Example::
|
| 328 |
+
|
| 329 |
+
import dartlab
|
| 330 |
+
dartlab.flow("005930")
|
| 331 |
+
# [{"date": "20260325", "foreignNet": -6165053, "institutionNet": 2908773, ...}, ...]
|
| 332 |
+
"""
|
| 333 |
+
from dartlab.gather import getDefaultGather
|
| 334 |
+
|
| 335 |
+
return getDefaultGather().flow(stockCode, market=market)
|
| 336 |
+
|
| 337 |
+
|
| 338 |
+
def macro(market: str = "KR", indicator: str | None = None, *, start: str | None = None, end: str | None = None):
|
| 339 |
+
"""๊ฑฐ์ ์งํ ์๊ณ์ด โ ECOS(KR) / FRED(US).
|
| 340 |
+
|
| 341 |
+
์ธ์ ์์ผ๋ฉด ์นดํ๋ก๊ทธ ์ ์ฒด ์งํ๋ฅผ wide DataFrame์ผ๋ก ๋ฐํ.
|
| 342 |
+
|
| 343 |
+
Example::
|
| 344 |
+
|
| 345 |
+
import dartlab
|
| 346 |
+
dartlab.macro() # KR ์ ์ฒด ์งํ wide DF (22๊ฐ)
|
| 347 |
+
dartlab.macro("US") # US ์ ์ฒด ์งํ wide DF (50๊ฐ)
|
| 348 |
+
dartlab.macro("CPI") # CPI (์๋ KR ๊ฐ์ง)
|
| 349 |
+
dartlab.macro("FEDFUNDS") # ์ฐ๋ฐฉ๊ธฐ๊ธ๊ธ๋ฆฌ (์๋ US ๊ฐ์ง)
|
| 350 |
+
dartlab.macro("KR", "CPI") # ๋ช
์์ KR + CPI
|
| 351 |
+
dartlab.macro("US", "SP500") # ๋ช
์์ US + S&P500
|
| 352 |
+
"""
|
| 353 |
+
from dartlab.gather import getDefaultGather
|
| 354 |
+
|
| 355 |
+
return getDefaultGather().macro(market, indicator, start=start, end=end)
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
def crossBorderPeers(stockCode: str, *, topK: int = 5):
|
| 359 |
+
"""ํ๊ตญ ์ข
๋ชฉ์ ๊ธ๋ก๋ฒ ํผ์ด ์ถ์ฒ (WICSโGICS ๋งคํ).
|
| 360 |
+
|
| 361 |
+
Args:
|
| 362 |
+
stockCode: ํ๊ตญ ์ข
๋ชฉ์ฝ๋.
|
| 363 |
+
topK: ๋ฐํํ ํผ์ด ์.
|
| 364 |
+
|
| 365 |
+
Example::
|
| 366 |
+
|
| 367 |
+
import dartlab
|
| 368 |
+
dartlab.crossBorderPeers("005930") # โ ["AAPL", "MSFT", ...]
|
| 369 |
+
"""
|
| 370 |
+
from dartlab.analysis.comparative.peer.discover import crossBorderPeers as _cb
|
| 371 |
+
|
| 372 |
+
return _cb(stockCode, topK=topK)
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
def setup(provider: str | None = None):
|
| 376 |
+
"""AI provider ์ค์ ์๋ด + ์ธํฐ๋ํฐ๋ธ ์ค์ .
|
| 377 |
+
|
| 378 |
+
Args:
|
| 379 |
+
provider: ํน์ provider ์ค์ . None์ด๋ฉด ์ ์ฒด ํํฉ.
|
| 380 |
+
|
| 381 |
+
Example::
|
| 382 |
+
|
| 383 |
+
import dartlab
|
| 384 |
+
dartlab.setup() # ์ ์ฒด provider ํํฉ
|
| 385 |
+
dartlab.setup("chatgpt") # ChatGPT OAuth ๋ธ๋ผ์ฐ์ ๋ก๊ทธ์ธ
|
| 386 |
+
dartlab.setup("openai") # OpenAI API ํค ์ค์
|
| 387 |
+
dartlab.setup("ollama") # Ollama ์ค์น ์๋ด
|
| 388 |
+
"""
|
| 389 |
+
from dartlab.core.ai.guide import (
|
| 390 |
+
provider_guide,
|
| 391 |
+
providers_status,
|
| 392 |
+
resolve_alias,
|
| 393 |
+
)
|
| 394 |
+
|
| 395 |
+
if provider is None:
|
| 396 |
+
print(providers_status())
|
| 397 |
+
return
|
| 398 |
+
|
| 399 |
+
provider = resolve_alias(provider)
|
| 400 |
+
|
| 401 |
+
if provider == "oauth-codex":
|
| 402 |
+
_setup_oauth_interactive()
|
| 403 |
+
elif provider == "openai":
|
| 404 |
+
_setup_openai_interactive()
|
| 405 |
+
else:
|
| 406 |
+
print(provider_guide(provider))
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
def _setup_oauth_interactive():
|
| 410 |
+
"""๋
ธํธ๋ถ/CLI์์ ChatGPT OAuth ๋ธ๋ผ์ฐ์ ๋ก๊ทธ์ธ."""
|
| 411 |
+
try:
|
| 412 |
+
from dartlab.ai.providers.support.oauth_token import is_authenticated
|
| 413 |
+
|
| 414 |
+
if is_authenticated():
|
| 415 |
+
print("\n โ ChatGPT OAuth ์ด๋ฏธ ์ธ์ฆ๋์ด ์์ต๋๋ค.")
|
| 416 |
+
print(' ์ฌ์ธ์ฆ: dartlab.setup("chatgpt") # ์ฌ์คํํ๋ฉด ๊ฐฑ์ \n')
|
| 417 |
+
return
|
| 418 |
+
except ImportError:
|
| 419 |
+
pass
|
| 420 |
+
|
| 421 |
+
try:
|
| 422 |
+
from dartlab.cli.commands.setup import _do_oauth_login
|
| 423 |
+
|
| 424 |
+
_do_oauth_login()
|
| 425 |
+
except ImportError:
|
| 426 |
+
print("\n ChatGPT OAuth ๋ธ๋ผ์ฐ์ ๋ก๊ทธ์ธ:")
|
| 427 |
+
print(" CLI์์ ์คํ: dartlab setup oauth-codex\n")
|
| 428 |
+
|
| 429 |
+
|
| 430 |
+
def _setup_openai_interactive():
|
| 431 |
+
"""๋
ธํธ๋ถ์์ OpenAI API ํค ์ธ๋ผ์ธ ์ค์ ."""
|
| 432 |
+
import os
|
| 433 |
+
|
| 434 |
+
from dartlab.core.ai.guide import provider_guide
|
| 435 |
+
|
| 436 |
+
existing_key = os.environ.get("OPENAI_API_KEY")
|
| 437 |
+
if existing_key:
|
| 438 |
+
print(f"\n โ OPENAI_API_KEY ํ๊ฒฝ๋ณ์๊ฐ ์ค์ ๋์ด ์์ต๋๋ค. (sk-...{existing_key[-4:]})\n")
|
| 439 |
+
return
|
| 440 |
+
|
| 441 |
+
print(provider_guide("openai"))
|
| 442 |
+
print()
|
| 443 |
+
|
| 444 |
+
try:
|
| 445 |
+
from getpass import getpass
|
| 446 |
+
|
| 447 |
+
key = getpass(" API ํค ์
๋ ฅ (Enter๋ก ๊ฑด๋๋ฐ๊ธฐ): ").strip()
|
| 448 |
+
if key:
|
| 449 |
+
llm.configure(provider="openai", api_key=key)
|
| 450 |
+
print("\n โ OpenAI API ํค๊ฐ ์ค์ ๋์์ต๋๋ค.\n")
|
| 451 |
+
else:
|
| 452 |
+
print("\n ๊ฑด๋๋ฐ์์ต๋๋ค.\n")
|
| 453 |
+
except (EOFError, KeyboardInterrupt):
|
| 454 |
+
print("\n ๊ฑด๋๋ฐ์์ต๋๋ค.\n")
|
| 455 |
+
|
| 456 |
+
|
| 457 |
+
def _auto_stream(gen) -> str:
|
| 458 |
+
"""Generator๋ฅผ ์๋นํ๋ฉด์ stdout์ ์คํธ๋ฆฌ๋ฐ ์ถ๋ ฅ, ์ ์ฒด ํ
์คํธ ๋ฐํ."""
|
| 459 |
+
import sys
|
| 460 |
+
|
| 461 |
+
chunks: list[str] = []
|
| 462 |
+
for chunk in gen:
|
| 463 |
+
chunks.append(chunk)
|
| 464 |
+
sys.stdout.write(chunk)
|
| 465 |
+
sys.stdout.flush()
|
| 466 |
+
sys.stdout.write("\n")
|
| 467 |
+
sys.stdout.flush()
|
| 468 |
+
return "".join(chunks)
|
| 469 |
+
|
| 470 |
+
|
| 471 |
+
def ask(
|
| 472 |
+
*args: str,
|
| 473 |
+
include: list[str] | None = None,
|
| 474 |
+
exclude: list[str] | None = None,
|
| 475 |
+
provider: str | None = None,
|
| 476 |
+
model: str | None = None,
|
| 477 |
+
stream: bool = True,
|
| 478 |
+
raw: bool = False,
|
| 479 |
+
reflect: bool = False,
|
| 480 |
+
pattern: str | None = None,
|
| 481 |
+
**kwargs,
|
| 482 |
+
):
|
| 483 |
+
"""LLM์๊ฒ ๊ธฐ์
์ ๋ํด ์ง๋ฌธ.
|
| 484 |
+
|
| 485 |
+
Args:
|
| 486 |
+
*args: ์์ฐ์ด ์ง๋ฌธ (1๊ฐ) ๋๋ (์ข
๋ชฉ, ์ง๋ฌธ) 2๊ฐ.
|
| 487 |
+
provider: LLM provider ("openai", "codex", "oauth-codex", "ollama").
|
| 488 |
+
model: ๋ชจ๋ธ override.
|
| 489 |
+
stream: True๋ฉด ์คํธ๋ฆฌ๋ฐ ์ถ๋ ฅ (๊ธฐ๋ณธ๊ฐ). False๋ฉด ์กฐ์ฉํ ์ ์ฒด ํ
์คํธ ๋ฐํ.
|
| 490 |
+
raw: True๋ฉด Generator๋ฅผ ์ง์ ๋ฐํ (์ปค์คํ
UI์ฉ).
|
| 491 |
+
include: ํฌํจํ ๋ฐ์ดํฐ ๋ชจ๋.
|
| 492 |
+
exclude: ์ ์ธํ ๋ฐ์ดํฐ ๋ชจ๋.
|
| 493 |
+
reflect: True๋ฉด ๋ต๋ณ ์์ฒด ๊ฒ์ฆ (1ํ reflection).
|
| 494 |
+
|
| 495 |
+
Returns:
|
| 496 |
+
str: ์ ์ฒด ๋ต๋ณ ํ
์คํธ. (raw=True์ผ ๋๋ง Generator[str])
|
| 497 |
+
|
| 498 |
+
Example::
|
| 499 |
+
|
| 500 |
+
import dartlab
|
| 501 |
+
dartlab.llm.configure(provider="openai", api_key="sk-...")
|
| 502 |
+
|
| 503 |
+
# ํธ์ถํ๋ฉด ์คํธ๋ฆฌ๋ฐ ์ถ๋ ฅ + ์ ์ฒด ํ
์คํธ ๋ฐ๏ฟฝ๏ฟฝ
|
| 504 |
+
answer = dartlab.ask("์ผ์ฑ์ ์ ์ฌ๋ฌด๊ฑด์ ์ฑ ๋ถ์ํด์ค")
|
| 505 |
+
|
| 506 |
+
# provider + model ์ง์
|
| 507 |
+
answer = dartlab.ask("์ผ์ฑ์ ์ ๋ถ์", provider="openai", model="gpt-4o")
|
| 508 |
+
|
| 509 |
+
# (์ข
๋ชฉ, ์ง๋ฌธ) ๋ถ๋ฆฌ
|
| 510 |
+
answer = dartlab.ask("005930", "์์
์ด์ต๋ฅ ์ถ์ธ๋?")
|
| 511 |
+
|
| 512 |
+
# ์กฐ์ฉํ ์ ์ฒด ํ
์คํธ๋ง (๋ฐฐ์น์ฉ)
|
| 513 |
+
answer = dartlab.ask("์ผ์ฑ์ ์ ๋ถ์", stream=False)
|
| 514 |
+
|
| 515 |
+
# Generator ์ง์ ์ ์ด (์ปค์คํ
UI์ฉ)
|
| 516 |
+
for chunk in dartlab.ask("์ผ์ฑ์ ์ ๋ถ์", raw=True):
|
| 517 |
+
custom_process(chunk)
|
| 518 |
+
"""
|
| 519 |
+
from dartlab.ai.runtime.standalone import ask as _ask
|
| 520 |
+
|
| 521 |
+
# provider ๋ฏธ์ง์ ์ auto-detect
|
| 522 |
+
if provider is None:
|
| 523 |
+
from dartlab.core.ai.detect import auto_detect_provider
|
| 524 |
+
|
| 525 |
+
detected = auto_detect_provider()
|
| 526 |
+
if detected is None:
|
| 527 |
+
from dartlab.core.ai.guide import no_provider_message
|
| 528 |
+
|
| 529 |
+
msg = no_provider_message()
|
| 530 |
+
print(msg)
|
| 531 |
+
raise RuntimeError("AI provider๊ฐ ์ค์ ๋์ง ์์์ต๋๋ค. dartlab.setup()์ ์คํํ์ธ์.")
|
| 532 |
+
provider = detected
|
| 533 |
+
|
| 534 |
+
if len(args) == 2:
|
| 535 |
+
company = Company(args[0])
|
| 536 |
+
question = args[1]
|
| 537 |
+
elif len(args) == 1:
|
| 538 |
+
from dartlab.core.resolve import resolve_from_text
|
| 539 |
+
|
| 540 |
+
company, question = resolve_from_text(args[0])
|
| 541 |
+
if company is None:
|
| 542 |
+
raise ValueError(
|
| 543 |
+
f"์ข
๋ชฉ์ ์ฐพ์ ์ ์์ต๋๋ค: '{args[0]}'\n"
|
| 544 |
+
"์ข
๋ชฉ๋ช
๋๋ ์ข
๋ชฉ์ฝ๋๋ฅผ ํฌํจํด ์ฃผ์ธ์.\n"
|
| 545 |
+
"์: dartlab.ask('์ผ์ฑ์ ์ ์ฌ๋ฌด๊ฑด์ ์ฑ ๋ถ์ํด์ค')"
|
| 546 |
+
)
|
| 547 |
+
elif len(args) == 0:
|
| 548 |
+
raise TypeError("์ง๋ฌธ์ ์
๋ ฅํด ์ฃผ์ธ์. ์: dartlab.ask('์ผ์ฑ์ ์ ๋ถ์ํด์ค')")
|
| 549 |
+
else:
|
| 550 |
+
raise TypeError(f"์ธ์๋ 1~2๊ฐ๋ง ํ์ฉ๋ฉ๋๋ค (๋ฐ์ ์: {len(args)})")
|
| 551 |
+
|
| 552 |
+
if raw:
|
| 553 |
+
return _ask(
|
| 554 |
+
company,
|
| 555 |
+
question,
|
| 556 |
+
include=include,
|
| 557 |
+
exclude=exclude,
|
| 558 |
+
provider=provider,
|
| 559 |
+
model=model,
|
| 560 |
+
stream=stream,
|
| 561 |
+
reflect=reflect,
|
| 562 |
+
pattern=pattern,
|
| 563 |
+
**kwargs,
|
| 564 |
+
)
|
| 565 |
+
|
| 566 |
+
if not stream:
|
| 567 |
+
return _ask(
|
| 568 |
+
company,
|
| 569 |
+
question,
|
| 570 |
+
include=include,
|
| 571 |
+
exclude=exclude,
|
| 572 |
+
provider=provider,
|
| 573 |
+
model=model,
|
| 574 |
+
stream=False,
|
| 575 |
+
reflect=reflect,
|
| 576 |
+
pattern=pattern,
|
| 577 |
+
**kwargs,
|
| 578 |
+
)
|
| 579 |
+
|
| 580 |
+
gen = _ask(
|
| 581 |
+
company,
|
| 582 |
+
question,
|
| 583 |
+
include=include,
|
| 584 |
+
exclude=exclude,
|
| 585 |
+
provider=provider,
|
| 586 |
+
model=model,
|
| 587 |
+
stream=True,
|
| 588 |
+
reflect=reflect,
|
| 589 |
+
pattern=pattern,
|
| 590 |
+
**kwargs,
|
| 591 |
+
)
|
| 592 |
+
return _auto_stream(gen)
|
| 593 |
+
|
| 594 |
+
|
| 595 |
+
def chat(
|
| 596 |
+
codeOrName: str,
|
| 597 |
+
question: str,
|
| 598 |
+
*,
|
| 599 |
+
provider: str | None = None,
|
| 600 |
+
model: str | None = None,
|
| 601 |
+
max_turns: int = 5,
|
| 602 |
+
on_tool_call=None,
|
| 603 |
+
on_tool_result=None,
|
| 604 |
+
**kwargs,
|
| 605 |
+
) -> str:
|
| 606 |
+
"""์์ด์ ํธ ๋ชจ๋: LLM์ด ๋๊ตฌ๋ฅผ ์ ํํ์ฌ ์ฌํ ๋ถ์.
|
| 607 |
+
|
| 608 |
+
Args:
|
| 609 |
+
codeOrName: ์ข
๋ชฉ์ฝ๋, ํ์ฌ๋ช
, ๋๋ US ticker.
|
| 610 |
+
question: ์ง๋ฌธ ํ
์คํธ.
|
| 611 |
+
provider: LLM provider.
|
| 612 |
+
model: ๋ชจ๋ธ override.
|
| 613 |
+
max_turns: ์ต๋ ๋๊ตฌ ํธ์ถ ๋ฐ๋ณต ํ์.
|
| 614 |
+
|
| 615 |
+
Example::
|
| 616 |
+
|
| 617 |
+
import dartlab
|
| 618 |
+
dartlab.chat("005930", "๋ฐฐ๋น ์ถ์ธ๋ฅผ ๋ถ์ํ๊ณ ์ด์ ์งํ๋ฅผ ์ฐพ์์ค")
|
| 619 |
+
"""
|
| 620 |
+
from dartlab.ai.runtime.standalone import chat as _chat
|
| 621 |
+
|
| 622 |
+
company = Company(codeOrName)
|
| 623 |
+
return _chat(
|
| 624 |
+
company,
|
| 625 |
+
question,
|
| 626 |
+
provider=provider,
|
| 627 |
+
model=model,
|
| 628 |
+
max_turns=max_turns,
|
| 629 |
+
on_tool_call=on_tool_call,
|
| 630 |
+
on_tool_result=on_tool_result,
|
| 631 |
+
**kwargs,
|
| 632 |
+
)
|
| 633 |
+
|
| 634 |
+
|
| 635 |
+
def plugins():
|
| 636 |
+
"""๋ก๋๋ ํ๋ฌ๊ทธ์ธ ๋ชฉ๋ก ๋ฐํ.
|
| 637 |
+
|
| 638 |
+
Example::
|
| 639 |
+
|
| 640 |
+
import dartlab
|
| 641 |
+
dartlab.plugins() # [PluginMeta(name="esg-scores", ...)]
|
| 642 |
+
"""
|
| 643 |
+
from dartlab.core.plugins import discover, get_loaded_plugins
|
| 644 |
+
|
| 645 |
+
discover()
|
| 646 |
+
return get_loaded_plugins()
|
| 647 |
+
|
| 648 |
+
|
| 649 |
+
def reload_plugins():
|
| 650 |
+
"""ํ๋ฌ๊ทธ์ธ ์ฌ์ค์บ โ pip install ํ ์ฌ์์ ์์ด ์ฆ์ ์ธ์.
|
| 651 |
+
|
| 652 |
+
Example::
|
| 653 |
+
|
| 654 |
+
# 1. ์ ํ๋ฌ๊ทธ์ธ ์ค์น
|
| 655 |
+
# !uv pip install dartlab-plugin-esg
|
| 656 |
+
|
| 657 |
+
# 2. ์ฌ์ค์บ
|
| 658 |
+
dartlab.reload_plugins()
|
| 659 |
+
|
| 660 |
+
# 3. ์ฆ์ ์ฌ์ฉ
|
| 661 |
+
dartlab.Company("005930").show("esgScore")
|
| 662 |
+
"""
|
| 663 |
+
from dartlab.core.plugins import rediscover
|
| 664 |
+
|
| 665 |
+
return rediscover()
|
| 666 |
+
|
| 667 |
+
|
| 668 |
+
def audit(codeOrName: str):
|
| 669 |
+
"""๊ฐ์ฌ Red Flag ๋ถ์.
|
| 670 |
+
|
| 671 |
+
Example::
|
| 672 |
+
|
| 673 |
+
import dartlab
|
| 674 |
+
dartlab.audit("005930")
|
| 675 |
+
"""
|
| 676 |
+
c = Company(codeOrName)
|
| 677 |
+
from dartlab.analysis.financial.insight.pipeline import analyzeAudit
|
| 678 |
+
|
| 679 |
+
return analyzeAudit(c)
|
| 680 |
+
|
| 681 |
+
|
| 682 |
+
def forecast(codeOrName: str, *, horizon: int = 3):
|
| 683 |
+
"""๋งค์ถ ์์๋ธ ์์ธก.
|
| 684 |
+
|
| 685 |
+
Example::
|
| 686 |
+
|
| 687 |
+
import dartlab
|
| 688 |
+
dartlab.forecast("005930")
|
| 689 |
+
"""
|
| 690 |
+
c = Company(codeOrName)
|
| 691 |
+
from dartlab.analysis.forecast.revenueForecast import forecastRevenue
|
| 692 |
+
|
| 693 |
+
ts = c.finance.timeseries
|
| 694 |
+
if ts is None:
|
| 695 |
+
return None
|
| 696 |
+
series = ts[0] if isinstance(ts, tuple) else ts
|
| 697 |
+
currency = getattr(c, "currency", "KRW")
|
| 698 |
+
return forecastRevenue(
|
| 699 |
+
series,
|
| 700 |
+
stockCode=getattr(c, "stockCode", None),
|
| 701 |
+
sectorKey=getattr(c, "sectorKey", None),
|
| 702 |
+
market=getattr(c, "market", "KR"),
|
| 703 |
+
horizon=horizon,
|
| 704 |
+
currency=currency,
|
| 705 |
+
)
|
| 706 |
+
|
| 707 |
+
|
| 708 |
+
def valuation(codeOrName: str, *, shares: int | None = None):
|
| 709 |
+
"""์ข
ํฉ ๋ฐธ๋ฅ์์ด์
(DCF + DDM + ์๋๊ฐ์น).
|
| 710 |
+
|
| 711 |
+
Example::
|
| 712 |
+
|
| 713 |
+
import dartlab
|
| 714 |
+
dartlab.valuation("005930")
|
| 715 |
+
"""
|
| 716 |
+
c = Company(codeOrName)
|
| 717 |
+
from dartlab.analysis.valuation.valuation import fullValuation
|
| 718 |
+
|
| 719 |
+
ts = c.finance.timeseries
|
| 720 |
+
if ts is None:
|
| 721 |
+
return None
|
| 722 |
+
series = ts[0] if isinstance(ts, tuple) else ts
|
| 723 |
+
currency = getattr(c, "currency", "KRW")
|
| 724 |
+
if shares is None:
|
| 725 |
+
profile = getattr(c, "profile", None)
|
| 726 |
+
if profile:
|
| 727 |
+
shares = getattr(profile, "sharesOutstanding", None)
|
| 728 |
+
if shares:
|
| 729 |
+
shares = int(shares)
|
| 730 |
+
return fullValuation(series, shares=shares, currency=currency)
|
| 731 |
+
|
| 732 |
+
|
| 733 |
+
def insights(codeOrName: str):
|
| 734 |
+
"""7์์ญ ๋ฑ๊ธ ๋ถ์.
|
| 735 |
+
|
| 736 |
+
Example::
|
| 737 |
+
|
| 738 |
+
import dartlab
|
| 739 |
+
dartlab.insights("005930")
|
| 740 |
+
"""
|
| 741 |
+
c = Company(codeOrName)
|
| 742 |
+
from dartlab.analysis.financial.insight import analyze
|
| 743 |
+
|
| 744 |
+
return analyze(c.stockCode, company=c)
|
| 745 |
+
|
| 746 |
+
|
| 747 |
+
def simulation(codeOrName: str, *, scenarios: list[str] | None = None):
|
| 748 |
+
"""๊ฒฝ์ ์๋๋ฆฌ์ค ์๋ฎฌ๋ ์ด์
.
|
| 749 |
+
|
| 750 |
+
Example::
|
| 751 |
+
|
| 752 |
+
import dartlab
|
| 753 |
+
dartlab.simulation("005930")
|
| 754 |
+
"""
|
| 755 |
+
c = Company(codeOrName)
|
| 756 |
+
from dartlab.analysis.forecast.simulation import simulateAllScenarios
|
| 757 |
+
|
| 758 |
+
ts = c.finance.timeseries
|
| 759 |
+
if ts is None:
|
| 760 |
+
return None
|
| 761 |
+
series = ts[0] if isinstance(ts, tuple) else ts
|
| 762 |
+
return simulateAllScenarios(
|
| 763 |
+
series,
|
| 764 |
+
sectorKey=getattr(c, "sectorKey", None),
|
| 765 |
+
scenarios=scenarios,
|
| 766 |
+
)
|
| 767 |
+
|
| 768 |
+
|
| 769 |
+
def research(codeOrName: str, *, sections: list[str] | None = None, includeMarket: bool = True):
|
| 770 |
+
"""์ข
ํฉ ๊ธฐ์
๋ถ์ ๋ฆฌํฌํธ.
|
| 771 |
+
|
| 772 |
+
Example::
|
| 773 |
+
|
| 774 |
+
import dartlab
|
| 775 |
+
dartlab.research("005930")
|
| 776 |
+
"""
|
| 777 |
+
c = Company(codeOrName)
|
| 778 |
+
from dartlab.analysis.financial.research import generateResearch
|
| 779 |
+
|
| 780 |
+
return generateResearch(c, sections=sections, includeMarket=includeMarket)
|
| 781 |
+
|
| 782 |
+
|
| 783 |
+
def groupHealth():
|
| 784 |
+
"""๊ทธ๋ฃน์ฌ ๊ฑด์ ์ฑ ๋ถ์ โ ๋คํธ์ํฌ ร ์ฌ๋ฌด๋น์จ ๊ต์ฐจ.
|
| 785 |
+
|
| 786 |
+
Returns:
|
| 787 |
+
(summary, weakLinks) ํํ.
|
| 788 |
+
|
| 789 |
+
Example::
|
| 790 |
+
|
| 791 |
+
import dartlab
|
| 792 |
+
summary, weakLinks = dartlab.groupHealth()
|
| 793 |
+
"""
|
| 794 |
+
from dartlab.market.network.health import groupHealth as _groupHealth
|
| 795 |
+
|
| 796 |
+
return _groupHealth()
|
| 797 |
+
|
| 798 |
+
|
| 799 |
+
def scanAccount(
|
| 800 |
+
snakeId: str,
|
| 801 |
+
*,
|
| 802 |
+
market: str = "dart",
|
| 803 |
+
sjDiv: str | None = None,
|
| 804 |
+
fsPref: str = "CFS",
|
| 805 |
+
annual: bool = False,
|
| 806 |
+
):
|
| 807 |
+
"""์ ์ข
๋ชฉ ๋จ์ผ ๊ณ์ ์๊ณ์ด.
|
| 808 |
+
|
| 809 |
+
Args:
|
| 810 |
+
snakeId: ๊ณ์ ์๋ณ์. ์๋ฌธ("sales") ๋๋ ํ๊ธ("๋งค์ถ์ก") ๋ชจ๋ ๊ฐ๋ฅ.
|
| 811 |
+
market: "dart" (ํ๊ตญ, ๊ธฐ๋ณธ) ๋๋ "edgar" (๋ฏธ๊ตญ).
|
| 812 |
+
sjDiv: ์ฌ๋ฌด์ ํ ๊ตฌ๋ถ ("IS", "BS", "CF"). None์ด๋ฉด ์๋ ๊ฒฐ์ . (dart๋ง)
|
| 813 |
+
fsPref: ์ฐ๊ฒฐ/๋ณ๋ ์ฐ์ ์์ ("CFS"=์ฐ๊ฒฐ ์ฐ์ , "OFS"=๋ณ๋ ์ฐ์ ). (dart๋ง)
|
| 814 |
+
annual: True๋ฉด ์ฐ๊ฐ (๊ธฐ๋ณธ False=๋ถ๊ธฐ๋ณ standalone).
|
| 815 |
+
|
| 816 |
+
Example::
|
| 817 |
+
|
| 818 |
+
import dartlab
|
| 819 |
+
dartlab.scanAccount("๋งค์ถ์ก") # DART ๋ถ๊ธฐ๋ณ
|
| 820 |
+
dartlab.scanAccount("๋งค์ถ์ก", annual=True) # DART ์ฐ๊ฐ
|
| 821 |
+
dartlab.scanAccount("sales", market="edgar") # EDGAR ๋ถ๊ธฐ๋ณ
|
| 822 |
+
dartlab.scanAccount("total_assets", market="edgar", annual=True)
|
| 823 |
+
"""
|
| 824 |
+
if market == "edgar":
|
| 825 |
+
from dartlab.providers.edgar.finance.scanAccount import scanAccount as _edgarScan
|
| 826 |
+
|
| 827 |
+
return _edgarScan(snakeId, annual=annual)
|
| 828 |
+
|
| 829 |
+
from dartlab.providers.dart.finance.scanAccount import scanAccount as _scan
|
| 830 |
+
|
| 831 |
+
return _scan(snakeId, sjDiv=sjDiv, fsPref=fsPref, annual=annual)
|
| 832 |
+
|
| 833 |
+
|
| 834 |
+
def scanRatio(
|
| 835 |
+
ratioName: str,
|
| 836 |
+
*,
|
| 837 |
+
market: str = "dart",
|
| 838 |
+
fsPref: str = "CFS",
|
| 839 |
+
annual: bool = False,
|
| 840 |
+
):
|
| 841 |
+
"""์ ์ข
๋ชฉ ๋จ์ผ ์ฌ๋ฌด๋น์จ ์๊ณ์ด.
|
| 842 |
+
|
| 843 |
+
Args:
|
| 844 |
+
ratioName: ๋น์จ ์๋ณ์ ("roe", "operatingMargin", "debtRatio" ๋ฑ).
|
| 845 |
+
market: "dart" (ํ๊ตญ, ๊ธฐ๋ณธ) ๋๋ "edgar" (๋ฏธ๊ตญ).
|
| 846 |
+
fsPref: ์ฐ๊ฒฐ/๋ณ๋ ์ฐ์ ์์. (dart๋ง)
|
| 847 |
+
annual: True๋ฉด ์ฐ๊ฐ (๊ธฐ๋ณธ False=๋ถ๊ธฐ๋ณ).
|
| 848 |
+
|
| 849 |
+
Example::
|
| 850 |
+
|
| 851 |
+
import dartlab
|
| 852 |
+
dartlab.scanRatio("roe") # DART ๋ถ๊ธฐ๋ณ
|
| 853 |
+
dartlab.scanRatio("operatingMargin", annual=True) # DART ์ฐ๊ฐ
|
| 854 |
+
dartlab.scanRatio("roe", market="edgar", annual=True) # EDGAR ์ฐ๊ฐ
|
| 855 |
+
"""
|
| 856 |
+
if market == "edgar":
|
| 857 |
+
from dartlab.providers.edgar.finance.scanAccount import scanRatio as _edgarRatio
|
| 858 |
+
|
| 859 |
+
return _edgarRatio(ratioName, annual=annual)
|
| 860 |
+
|
| 861 |
+
from dartlab.providers.dart.finance.scanAccount import scanRatio as _ratio
|
| 862 |
+
|
| 863 |
+
return _ratio(ratioName, fsPref=fsPref, annual=annual)
|
| 864 |
+
|
| 865 |
+
|
| 866 |
+
def scanRatioList():
|
| 867 |
+
"""์ฌ์ฉ ๊ฐ๋ฅํ ๋น์จ ๋ชฉ๋ก.
|
| 868 |
+
|
| 869 |
+
Example::
|
| 870 |
+
|
| 871 |
+
import dartlab
|
| 872 |
+
dartlab.scanRatioList()
|
| 873 |
+
"""
|
| 874 |
+
from dartlab.providers.dart.finance.scanAccount import scanRatioList as _list
|
| 875 |
+
|
| 876 |
+
return _list()
|
| 877 |
+
|
| 878 |
+
|
| 879 |
+
def digest(
|
| 880 |
+
*,
|
| 881 |
+
sector: str | None = None,
|
| 882 |
+
top_n: int = 20,
|
| 883 |
+
format: str = "dataframe",
|
| 884 |
+
stock_codes: list[str] | None = None,
|
| 885 |
+
verbose: bool = False,
|
| 886 |
+
):
|
| 887 |
+
"""์์ฅ ์ ์ฒด ๊ณต์ ๋ณํ ๋ค์ด์ ์คํธ.
|
| 888 |
+
|
| 889 |
+
๋ก์ปฌ์ ๋ค์ด๋ก๋๋ docs ๋ฐ์ดํฐ๋ฅผ ์ํํ๋ฉฐ ์ค์๋ ๋์ ๋ณํ๋ฅผ ์ง๊ณํ๋ค.
|
| 890 |
+
|
| 891 |
+
Args:
|
| 892 |
+
sector: ์นํฐ ํํฐ (์: "๋ฐ๋์ฒด"). None์ด๋ฉด ์ ์ฒด.
|
| 893 |
+
top_n: ์์ N๊ฐ.
|
| 894 |
+
format: "dataframe", "markdown", "json".
|
| 895 |
+
stock_codes: ์ง์ ์ข
๋ชฉ์ฝ๋ ๋ชฉ๋ก ์ง์ .
|
| 896 |
+
verbose: ์งํ ์ํฉ ์ถ๋ ฅ.
|
| 897 |
+
|
| 898 |
+
Example::
|
| 899 |
+
|
| 900 |
+
import dartlab
|
| 901 |
+
dartlab.digest() # ์ ์ฒด ์์ฅ
|
| 902 |
+
dartlab.digest(sector="๋ฐ๋์ฒด") # ์นํฐ๋ณ
|
| 903 |
+
dartlab.digest(format="markdown") # ๋งํฌ๋ค์ด ์ถ๋ ฅ
|
| 904 |
+
"""
|
| 905 |
+
from dartlab.analysis.accounting.watch.digest import build_digest
|
| 906 |
+
from dartlab.analysis.accounting.watch.scanner import scan_market
|
| 907 |
+
|
| 908 |
+
scan_df = scan_market(
|
| 909 |
+
sector=sector,
|
| 910 |
+
top_n=top_n,
|
| 911 |
+
stock_codes=stock_codes,
|
| 912 |
+
verbose=verbose,
|
| 913 |
+
)
|
| 914 |
+
|
| 915 |
+
if format == "dataframe":
|
| 916 |
+
return scan_df
|
| 917 |
+
|
| 918 |
+
title = f"{sector} ์นํฐ ๋ณํ ๋ค์ด์ ์คํธ" if sector else None
|
| 919 |
+
return build_digest(scan_df, format=format, title=title, top_n=top_n)
|
| 920 |
+
|
| 921 |
+
|
| 922 |
+
class _Module(sys.modules[__name__].__class__):
|
| 923 |
+
"""dartlab.verbose / dartlab.dataDir / dartlab.chart|table|text ํ๋ก์."""
|
| 924 |
+
|
| 925 |
+
@property
|
| 926 |
+
def verbose(self):
|
| 927 |
+
return config.verbose
|
| 928 |
+
|
| 929 |
+
@verbose.setter
|
| 930 |
+
def verbose(self, value):
|
| 931 |
+
config.verbose = value
|
| 932 |
+
|
| 933 |
+
@property
|
| 934 |
+
def dataDir(self):
|
| 935 |
+
return config.dataDir
|
| 936 |
+
|
| 937 |
+
@dataDir.setter
|
| 938 |
+
def dataDir(self, value):
|
| 939 |
+
config.dataDir = str(value)
|
| 940 |
+
|
| 941 |
+
def __getattr__(self, name):
|
| 942 |
+
if name in ("chart", "table", "text"):
|
| 943 |
+
import importlib
|
| 944 |
+
|
| 945 |
+
mod = importlib.import_module(f"dartlab.tools.{name}")
|
| 946 |
+
setattr(self, name, mod)
|
| 947 |
+
return mod
|
| 948 |
+
raise AttributeError(f"module 'dartlab' has no attribute {name!r}")
|
| 949 |
+
|
| 950 |
+
|
| 951 |
+
sys.modules[__name__].__class__ = _Module
|
| 952 |
+
|
| 953 |
+
|
| 954 |
+
__all__ = [
|
| 955 |
+
"Company",
|
| 956 |
+
"Dart",
|
| 957 |
+
"Fred",
|
| 958 |
+
"OpenDart",
|
| 959 |
+
"OpenEdgar",
|
| 960 |
+
"config",
|
| 961 |
+
"core",
|
| 962 |
+
"engines",
|
| 963 |
+
"llm",
|
| 964 |
+
"ask",
|
| 965 |
+
"chat",
|
| 966 |
+
"setup",
|
| 967 |
+
"search",
|
| 968 |
+
"listing",
|
| 969 |
+
"collect",
|
| 970 |
+
"collectAll",
|
| 971 |
+
"downloadAll",
|
| 972 |
+
"network",
|
| 973 |
+
"screen",
|
| 974 |
+
"benchmark",
|
| 975 |
+
"signal",
|
| 976 |
+
"news",
|
| 977 |
+
"crossBorderPeers",
|
| 978 |
+
"audit",
|
| 979 |
+
"forecast",
|
| 980 |
+
"valuation",
|
| 981 |
+
"insights",
|
| 982 |
+
"simulation",
|
| 983 |
+
"governance",
|
| 984 |
+
"workforce",
|
| 985 |
+
"capital",
|
| 986 |
+
"debt",
|
| 987 |
+
"groupHealth",
|
| 988 |
+
"research",
|
| 989 |
+
"digest",
|
| 990 |
+
"scanAccount",
|
| 991 |
+
"scanRatio",
|
| 992 |
+
"scanRatioList",
|
| 993 |
+
"plugins",
|
| 994 |
+
"reload_plugins",
|
| 995 |
+
"verbose",
|
| 996 |
+
"dataDir",
|
| 997 |
+
"getKindList",
|
| 998 |
+
"codeToName",
|
| 999 |
+
"nameToCode",
|
| 1000 |
+
"searchName",
|
| 1001 |
+
"fuzzySearch",
|
| 1002 |
+
"chart",
|
| 1003 |
+
"table",
|
| 1004 |
+
"text",
|
| 1005 |
+
"Review",
|
| 1006 |
+
"SelectResult",
|
| 1007 |
+
"ChartResult",
|
| 1008 |
+
]
|
src/dartlab/ai/DEV.md
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AI Engine Development Guide
|
| 2 |
+
|
| 3 |
+
## Source Of Truth
|
| 4 |
+
|
| 5 |
+
- ๋ฐ์ดํฐ source-of-truth: `src/dartlab/core/registry.py`
|
| 6 |
+
- AI capability source-of-truth: `src/dartlab/core/capabilities.py`
|
| 7 |
+
|
| 8 |
+
## ํ์ฌ ๊ตฌ์กฐ ์์น
|
| 9 |
+
|
| 10 |
+
- `core.analyze()`๊ฐ AI ์ค์ผ์คํธ๋ ์ด์
์ ๋จ์ผ ์ง์
์ ์ด๋ค.
|
| 11 |
+
- `tools/registry.py`๋ capability ์ ์๋ฅผ runtime์ ๋ฐ์ธ๋ฉํ๋ ๋ ์ด์ด๋ค.
|
| 12 |
+
- `server/streaming.py`, `mcp/__init__.py`, UI SSE client๋ capability ๊ฒฐ๊ณผ๋ฅผ ์๋นํ๋ adapter๋ค.
|
| 13 |
+
- Svelte UI๋ source-of-truth๊ฐ ์๋๋ผ render sink๋ค.
|
| 14 |
+
- OpenDART ์ต๊ทผ ๊ณต์๋ชฉ๋ก retrieval๋ `core.analyze()`์์ company ์ ๋ฌด์ ๋ฌด๊ดํ๊ฒ ๊ฐ์ ๊ฒฝ๋ก๋ก ํฉ๋ฅํ๋ค.
|
| 15 |
+
|
| 16 |
+
## ํจํค์ง ๊ตฌ์กฐ
|
| 17 |
+
|
| 18 |
+
- `runtime/`
|
| 19 |
+
- `core.py`: ์ค์ผ์คํธ๋ ์ดํฐ
|
| 20 |
+
- `events.py`: canonical/legacy ์ด๋ฒคํธ ๊ณ์ฝ
|
| 21 |
+
- `pipeline.py`: pre-compute pipeline
|
| 22 |
+
- `post_processing.py`: navigate/validation/auto-artifact ํ์ฒ๋ฆฌ
|
| 23 |
+
- `standalone.py`: public ask/chat bridge
|
| 24 |
+
- `validation.py`: ์ซ์ ๊ฒ์ฆ
|
| 25 |
+
- `conversation/`
|
| 26 |
+
- `dialogue.py`, `history.py`, `intent.py`, `focus.py`, `prompts.py`
|
| 27 |
+
- `suggestions.py`: ํ์ฌ ์ํ ๊ธฐ๋ฐ ์ถ์ฒ ์ง๋ฌธ ์์ฑ
|
| 28 |
+
- `data_ready.py`: docs/finance/report ๊ฐ์ฉ์ฑ ์์ฝ
|
| 29 |
+
- `context/`
|
| 30 |
+
- `builder.py`: structured context build
|
| 31 |
+
- `snapshot.py`: headline snapshot
|
| 32 |
+
- `company_adapter.py`: facade mismatch adapter
|
| 33 |
+
- `dartOpenapi.py`: OpenDART filing intent ํ์ฑ + recent filing context
|
| 34 |
+
- `tools/`
|
| 35 |
+
- `registry.py`: tool/capability binding (`useSuperTools` ํ๋๊ทธ๋ก ๋ชจ๋ ์ ํ)
|
| 36 |
+
- `runtime.py`: tool execution runtime
|
| 37 |
+
- `selector.py`: capability ๊ธฐ๋ฐ ๋๊ตฌ ์ ํ + Super Tool ์ ์ฉ prompt ๋ถ๊ธฐ
|
| 38 |
+
- `plugin.py`: external tool plugin bridge
|
| 39 |
+
- `coding.py`: coding runtime bridge
|
| 40 |
+
- `recipes.py`: ์ง๋ฌธ ์ ํ๋ณ ์ ํ ๋ถ์ ๋ ์ํผ
|
| 41 |
+
- `routeHint.py`: ํค์๋โ๋๊ตฌ ๋งคํ (Super Tool ๋ชจ๋์์ deprecated)
|
| 42 |
+
- `superTools/`: **7๊ฐ Super Tool dispatcher** (explore/finance/analyze/market/openapi/system/chart)
|
| 43 |
+
- `defaults/`: ๊ธฐ์กด 101๊ฐ ๋๊ตฌ ๋ฑ๋ก (๋ ๊ฑฐ์ ๋ชจ๋์์ ์ฌ์ฉ)
|
| 44 |
+
- `providers/support/`
|
| 45 |
+
- `codex_cli.py`, `cli_setup.py`, `ollama_setup.py`, `oauth_token.py`
|
| 46 |
+
- provider ๊ตฌํ์ด ์ง์ ์ฐ๋ CLI/OAuth ๋ณด์กฐ ๊ณ์ธต
|
| 47 |
+
|
| 48 |
+
๋ฃจํธ shim ๋ชจ๋(`core.py`, `tools_registry.py`, `dialogue.py` ๋ฑ)์ ์ ๊ฑฐ๋์๋ค. ์ ์ฝ๋๋ ๋ฐ๋์ ํ์ ํจํค์ง ๊ฒฝ๋ก(`runtime/`, `conversation/`, `context/`, `tools/`, `providers/support/`)๋ฅผ ์ง์ importํ๋ค.
|
| 49 |
+
|
| 50 |
+
## Super Tool ์ํคํ
์ฒ (2026-03-25)
|
| 51 |
+
|
| 52 |
+
101๊ฐ ๋๊ตฌ๋ฅผ 7๊ฐ Super Tool dispatcher๋ก ํตํฉ. ollama(์ํ ๋ชจ๋ธ)์์ ์๋ ํ์ฑํ.
|
| 53 |
+
|
| 54 |
+
### ๋ชจ๋ธ ์๊ตฌ์ฌํญ
|
| 55 |
+
- **์ต์**: tool calling ์ง์ + 14B ํ๋ผ๋ฏธํฐ ์ด์ (์: qwen3:14b, llama3.1:8b-instruct)
|
| 56 |
+
- **๊ถ์ฅ**: GPT-4o, Claude Sonnet ์ด์ โ tool calling + ํ๊ตญ์ด + ๋ณตํฉ ํ๋ผ๋ฏธํฐ ๋์ ์ฒ๋ฆฌ
|
| 57 |
+
- **๋ถ์ ํฉ**: 8B ์ดํ ์ํ ๋ชจ๋ธ (qwen3:4b/8b) โ action dispatch ํจํด์ ์ดํดํ์ง ๋ชปํจ, hallucination ๋ค๋ฐ
|
| 58 |
+
- ์คํ 009 ๊ฒ์ฆ ๊ฒฐ๊ณผ: qwen3:4b tool ์ ํ๋ 33%, qwen3:8b 0%. ์ํ ๋ชจ๋ธ์ tool calling AI ๋ถ์์ ์ฌ์ฉ ๋ถ๊ฐ.
|
| 59 |
+
|
| 60 |
+
### ํ์ฑํ ์กฐ๊ฑด
|
| 61 |
+
- **๋ชจ๋ provider์์ Super Tool ๊ธฐ๋ณธ ํ์ฑํ** (`_useSuperTools = True`)
|
| 62 |
+
- `build_tool_runtime(company, useSuperTools=False)`๋ก ๋ ๊ฑฐ์ ๋ชจ๋ ์๋ ์ ํ ๊ฐ๋ฅ
|
| 63 |
+
- Route Hint(`routeHint.py`)๋ deprecated โ Super Tool enum description์ด ๋์ฒด
|
| 64 |
+
|
| 65 |
+
### 7๊ฐ Super Tool
|
| 66 |
+
| Tool | ํตํฉ ๋์ | action enum |
|
| 67 |
+
|------|----------|-------------|
|
| 68 |
+
| `explore` | show_topic, list_topics, trace, diff, info, filings, search | 7 |
|
| 69 |
+
| `finance` | get_data, list_modules, ratios, growth, yoy, anomalies, report, search | 8 |
|
| 70 |
+
| `analyze` | insight, sector, rank, esg, valuation, changes, audit | 7 |
|
| 71 |
+
| `market` | price, consensus, history, screen | 4 |
|
| 72 |
+
| `openapi` | dartCall, searchFilings, capabilities | 3 |
|
| 73 |
+
| `system` | spec, features, searchCompany, dataStatus, suggest | 5 |
|
| 74 |
+
| `chart` | navigate, chart | 2 |
|
| 75 |
+
|
| 76 |
+
### ๋์ enum
|
| 77 |
+
- `explore.target`: company.topics์์ ์ถ์ถ (์ผ์ฑ์ ์ ๊ธฐ์ค 53๊ฐ) + ํ๊ตญ์ด ๋ผ๋ฒจ
|
| 78 |
+
- `finance.module`: scan_available_modules์์ ์ถ์ถ (9๊ฐ) + ํ๊ตญ์ด ๋ผ๋ฒจ
|
| 79 |
+
- `finance.apiType`: company.report.availableApiTypes์์ ์ถ์ถ (24๊ฐ) + ํ๊ตญ์ด ๋ผ๋ฒจ
|
| 80 |
+
- enum description์ `topicLabels.py`์ ํ๊ตญ์ด ๋ผ๋ฒจ๊ณผ aliases ํฌํจ
|
| 81 |
+
|
| 82 |
+
### ํ๊ตญ์ด ๋ผ๋ฒจ source of truth
|
| 83 |
+
- `core/topicLabels.py`: 70๊ฐ topic ร ํ๊ตญ์ด ๋ผ๋ฒจ + ๊ฒ์ aliases
|
| 84 |
+
- UI์ `topicLabels.js`์ ๋์ผ ๋งคํ + AI์ฉ aliases ์ถ๊ฐ
|
| 85 |
+
|
| 86 |
+
## UI Action ๊ณ์ฝ
|
| 87 |
+
|
| 88 |
+
- canonical payload๋ `UiAction`์ด๋ค.
|
| 89 |
+
- render payload๋ `ViewSpec` + `WidgetSpec` schema๋ฅผ ๊ธฐ์ค์ผ๋ก ํ๋ค.
|
| 90 |
+
- widget id(`chart`, `comparison`, `insight_dashboard`, `table`)๋ UI widget registry์ ๋ฑ๋ก๋ ๊ฒ๋ง ์ฌ์ฉํ๋ค.
|
| 91 |
+
- ํ์ฉ action:
|
| 92 |
+
- `navigate`
|
| 93 |
+
- `render`
|
| 94 |
+
- `update`
|
| 95 |
+
- `toast`
|
| 96 |
+
- canonical SSE UI ์ด๋ฒคํธ๋ `ui_action` ํ๋๋ง ์ ์งํ๋ค.
|
| 97 |
+
- auto artifact๋ ๋ณ๋ chart ์ด๋ฒคํธ๊ฐ ์๋๋ผ canonical `render` UI action์ผ๋ก ์ฃผ์
ํ๋ค.
|
| 98 |
+
- Svelte ์ธก AI bridge/helper๋ `src/dartlab/ui/src/lib/ai/`์ ๋๋ค. `App.svelte`๋ provider/profile ๋๊ธฐํ์ stream wiring๋ง ์ฐ๊ฒฐํ๋ shell๋ก ์ ์งํ๋ค.
|
| 99 |
+
|
| 100 |
+
## Provider Surface
|
| 101 |
+
|
| 102 |
+
- ๊ณต์ GPT ๊ตฌ๋
๊ณ์ ๊ฒฝ๋ก๋ ๋ ๊ฐ๋ค.
|
| 103 |
+
- `codex`: Codex CLI ๋ก๊ทธ์ธ ๊ธฐ๋ฐ
|
| 104 |
+
- `oauth-codex`: ChatGPT OAuth ์ง์ ์ฐ๊ฒฐ ๊ธฐ๋ฐ
|
| 105 |
+
- ๊ณต๊ฐ provider surface๋ `codex`, `oauth-codex`, `openai`, `ollama`, `custom`๋ง ์ ์งํ๋ค.
|
| 106 |
+
- `claude` provider๋ public surface์์ ์ ๊ฑฐ๋์๋ค. ๋จ์ Claude ๊ด๋ จ ์ฝ๋๋ legacy/internal ์ฉ๋๋ก๋ง ์ทจ๊ธํ๋ค.
|
| 107 |
+
- provider alias(`chatgpt`, `chatgpt-oauth`)๋ ๋ ์ด์ ๊ณต๊ฐ/ํธํ surface์ ๋์ง ์๋๋ค.
|
| 108 |
+
- ask/CLI/server/UI๋ ๊ฐ์ provider ๋ฌธ์์ด์ ๊ณต์ ํด์ผ ํ๋ฉฐ, ์ GPT ๊ฒฝ๋ก๋ฅผ ์ถ๊ฐํ ๋๋ ์ด ๋ฌธ์์ `core/ai/providers.py`, `server/api/ai.py`, `ui/src/App.svelte`, `cli/context.py`๋ฅผ ๊ฐ์ด ๊ฐฑ์ ํ๋ค.
|
| 109 |
+
|
| 110 |
+
## Shared Profile
|
| 111 |
+
|
| 112 |
+
- AI ์ค์ source-of-truth๋ `~/.dartlab/ai_profile.json`๊ณผ ๊ณตํต secret store๋ค.
|
| 113 |
+
- `dartlab.llm.configure()`๋ ๋ฉ๋ชจ๋ฆฌ ์ ์ฉ setter๊ฐ ์๋๋ผ shared profile writer๋ค.
|
| 114 |
+
- profile schema๋ `defaultProvider + roles(analysis, summary, coding, ui_control)` ๊ตฌ์กฐ๋ค.
|
| 115 |
+
- UI๋ provider/model์ localStorage์ ์ ์ฅํ์ง ์๊ณ `/api/ai/profile`๊ณผ `/api/ai/profile/events`๋ฅผ ํตํด ๋๊ธฐํํ๋ค.
|
| 116 |
+
- API key๋ profile JSON์ ์ ์ฅํ์ง ์๊ณ secret store์๋ง ์ ์ฅํ๋ค.
|
| 117 |
+
- OAuth ํ ํฐ๋ legacy `oauth_token.json` ๋์ ๊ณตํต secret store๋ก ์ด๋ํ๋ค.
|
| 118 |
+
- Ollama preload/probe๋ ์ ํ provider๊ฐ `ollama`์ผ ๋๋ง ์ ๊ทน์ ์ผ๋ก ์ํํ๋ค. ๋ค๋ฅธ provider๊ฐ ์ ํ๋ ์ํ์์๋ ์ํ ์กฐํ๋ lazy probe๊ฐ ๊ธฐ๋ณธ์ด๋ค.
|
| 119 |
+
- OpenDART ํค๋ provider secret store๋ก ํก์ํ์ง ์๊ณ ํ๋ก์ ํธ `.env`๋ฅผ source-of-truth๋ก ์ ์งํ๋ค.
|
| 120 |
+
|
| 121 |
+
## Company Adapter ์์น
|
| 122 |
+
|
| 123 |
+
- AI ๋ ์ด์ด๋ `company.ratios` ๊ฐ์ facade surface๋ฅผ ์ง์ ์ ๋ขฐํ์ง ์๋๋ค.
|
| 124 |
+
- headline ratio / ratio series๋ `src/dartlab/ai/context/company_adapter.py`๋ก๋ง ์ ๊ทผํ๋ค.
|
| 125 |
+
- facade์ ์์ง surface mismatch๋ฅผ ๋ฐ๊ฒฌํ๋ฉด AI ์ฝ๋ ๊ณณ๊ณณ์์ ๋ถ๊ธฐํ์ง ๋ง๊ณ adapter์ ํก์ํ๋ค.
|
| 126 |
+
|
| 127 |
+
## Ask Context ์ ์ฑ
|
| 128 |
+
|
| 129 |
+
- ๊ธฐ๋ณธ `ask`๋ cheap-first๋ค. ์ง๋ฌธ์ ๋ง๋ ์ต์ source๋ง ์ฝ๊ณ , `docs/finance/report` ์ ์ฒด ์ ๋ก๋ฉ์ ๊ธ์งํ๋ค.
|
| 130 |
+
- ์ผ๋ฐ `ask`์ ๊ธฐ๋ณธ context tier๋ `focused`๋ค. `full` tier๋ `report_mode=True`์ผ ๋๋ง ํ์ฉํ๋ค.
|
| 131 |
+
- tool-capable provider(`openai`, `ollama`, `custom`)๋ง `use_tools=True`์ผ ๋ `skeleton` tier๋ฅผ ์ฌ์ฉํ๋ค.
|
| 132 |
+
- `oauth-codex` ๊ธฐ๋ณธ ask๋ ๋ ์ด์ `full`๋ก ๋จ์ด์ง์ง ์๋๋ค.
|
| 133 |
+
- `auto diff`๋ `full` tier์์๋ง ์๋ ๊ณ์ฐํ๋ค. ๊ธฐ๋ณธ ask์์๋ `company.diff()`๋ฅผ ์ ํ ํธ์ถํ์ง ์๋๋ค.
|
| 134 |
+
- ์ง๋ฌธ ํด์์ route-first๊ฐ ์๋๋ผ **candidate-module-first**๋ค. ๋จผ์ `sections / notes / report / finance` ํ๋ณด๋ฅผ ๋์์ ๋ชจ์ผ๊ณ , ์ค์ ์กด์ฌํ๋ ๋ชจ๋๋ง ์ปจํ
์คํธ์ ์ฃ๋๋ค.
|
| 135 |
+
- `costByNature`, `rnd`, `segments`์ฒ๋ผ sections topic์ด ์๋์ด๋ direct/notes ๊ฒฝ๋ก๋ก ์กด์ฌํ๋ฉด `ask`๊ฐ ์ฐ์ ํ์ํ๋ค.
|
| 136 |
+
- ์ผ๋ฐ `ask`์์ ํฌํจ๋ ๋ชจ๋์ด ์์ผ๋ฉด `"๋ฐ์ดํฐ ์์"`์ด๋ผ๊ณ ๋ตํ๋ฉด ์คํจ๋ก ๋ณธ๋ค. false-unavailable ๋ฐฉ์ง๊ฐ ๊ธฐ๋ณธ ๊ณ์ฝ์ด๋ค.
|
| 137 |
+
- tool calling์ด ๋นํ์ฑํ๋ ask์์๋ `show_topic()` ๊ฐ์ ํธ์ถ ๊ณํ์ ๋ฌธ์ฅ์ผ๋ก ์ถ๋ ฅํ์ง ์๋๋ค. ์ด๋ฏธ ์ ๊ณต๋ ์ปจํ
์คํธ๋ง์ผ๋ก ๋ฐ๋ก ๋ตํ๊ณ , ๋ชจํธํ ๋๋ง ํ ๋ฌธ์ฅ ํ์ธ ์ง๋ฌธ์ ํ๋ค.
|
| 138 |
+
- **๋ถ๊ธฐ ์ง๋ฌธ ์ ์ฑ
**: "๋ถ๊ธฐ", "๋ถ๊ธฐ๋ณ", "quarterly", "QoQ", "์ ๋ถ๊ธฐ" ๋ฑ ๋ถ๊ธฐ ํค์๋๊ฐ ๊ฐ์ง๋๋ฉด:
|
| 139 |
+
- route๋ฅผ `hybrid`๋ก ์ ํํ์ฌ sections + finance ์์ชฝ ๋ชจ๋ ํฌํจํ๋ค.
|
| 140 |
+
- `company.timeseries`์์ IS/CF ๋ถ๊ธฐ๋ณ standalone ๋ฐ์ดํฐ๋ฅผ ์ต๊ทผ 8๋ถ๊ธฐ๋ง ์ถ์ถํ์ฌ context์ ์ฃผ์
ํ๋ค.
|
| 141 |
+
- `fsSummary`๋ฅผ sections exclude ๋ชฉ๋ก์์ ์ผ์ ํด์ ํ์ฌ ๋ถ๊ธฐ ์์ฝ๋ ํฌํจํ๋ค.
|
| 142 |
+
- response_contract์ ๋ถ๊ธฐ ๋ฐ์ดํฐ ํ์ฉ ์ง์๋ฅผ ์ถ๊ฐํ๋ค.
|
| 143 |
+
- **finance route sections ๋ณด์กฐ ์ ์ฑ
**: route=finance์ผ ๋๋ `businessStatus`, `businessOverview` ์ค ์กด์ฌํ๋ topic 1๊ฐ๋ฅผ ๊ฒฝ๋ outline์ผ๋ก ์ฃผ์
ํ๋ค. "์ ์ด์ต๋ฅ ์ด ๋ณํ๋์ง" ๊ฐ์ ๋งฅ๋ฝ์ LLM์ด ์ค๋ช
ํ ์ ์๊ฒ ํ๋ค.
|
| 144 |
+
- **context budget**: focused=10000, full=16000. ๋ถ๊ธฐ ๋ฐ์ดํฐ + sections ๋ณด์กฐ๋ฅผ ์์ฉํ ์ ์๋ ํฌ๊ธฐ.
|
| 145 |
+
|
| 146 |
+
## Persona Eval ๋ฃจํ
|
| 147 |
+
|
| 148 |
+
- ask ์ฅ๊ธฐ ๊ฐ์ ์ ๊ธฐ๋ณธ ๋จ์๋ **์ค์ฌ์ฉ ๋ก๊ทธ๊ฐ ์๋๋ผ curated ์ง๋ฌธ ์ธํธ replay**๋ค.
|
| 149 |
+
- source-of-truth๋ `src/dartlab/ai/eval/personaCases.json`์ด๋ค.
|
| 150 |
+
- ์ฌ๋ ๊ฒ์ ์ด๋ ฅ source-of-truth๋ `src/dartlab/ai/eval/reviewLog/<persona>.jsonl`์ด๋ค.
|
| 151 |
+
- persona ์ถ์ ์ต์ `assistant`, `data_manager`, `operator`, `installer`, `research_gather`, `accountant`, `business_owner`, `investor`, `analyst`๋ฅผ ์ ์งํ๋ค.
|
| 152 |
+
- ๊ฐ case๋ ์ง๋ฌธ๋ง ์ ์ฅํ์ง ์๋๋ค.
|
| 153 |
+
- `expectedRoute`
|
| 154 |
+
- `expectedModules`
|
| 155 |
+
- `mustInclude`
|
| 156 |
+
- `mustNotSay`
|
| 157 |
+
- `forbiddenUiTerms`
|
| 158 |
+
- `allowedClarification`
|
| 159 |
+
- `expectedFollowups`
|
| 160 |
+
- `groundTruthFacts`
|
| 161 |
+
- ์ ask ์คํจ๋ ๋ฐ๋ก ํ๋กฌํํธ hotfix๋ก ๋ฎ์ง ์๊ณ ๋จผ์ ์๋๋ก ๋ถ๏ฟฝ๏ฟฝํ๋ค.
|
| 162 |
+
- `routing_failure`
|
| 163 |
+
- `retrieval_failure`
|
| 164 |
+
- `false_unavailable`
|
| 165 |
+
- `generation_failure`
|
| 166 |
+
- `ui_wording_failure`
|
| 167 |
+
- `data_gap`
|
| 168 |
+
- `runtime_error`
|
| 169 |
+
- replay runner source-of-truth๋ `src/dartlab/ai/eval/replayRunner.py`๋ค.
|
| 170 |
+
- ์ค์ replay๋ฅผ ๊ฒํ ํ ๋๋ ๊ฒฐ๊ณผ๋ง ๋จ๊ธฐ์ง ์๊ณ ๋ฐ๋์ `reviewedAt / effectiveness / improvementActions / notes`๋ฅผ ๊ฐ์ด ๋จ๊ธด๋ค.
|
| 171 |
+
- review log๋ persona๋ณ๋ก ๋ถ๋ฆฌํ๋ค.
|
| 172 |
+
- `reviewLog/accountant.jsonl`
|
| 173 |
+
- `reviewLog/investor.jsonl`
|
| 174 |
+
- `reviewLog/analyst.jsonl`
|
| 175 |
+
- ๋ค์ ํ์ฐจ replay๋ ๊ฐ์ persona ํ์ผ์ ์ด์ด์ ๋ณด๊ณ , `ํจ๊ณผ์ ์ด์๋์ง`์ `์ด๋ฒ ๊ฐ์ ์ผ๋ก ์ค์ฌ์ผ ํ failure type`์ ๊ฐ์ด ์ ๋๋ค.
|
| 176 |
+
- ๊ฐ์ ๋ฃจํ๋ ํญ์ `์ง๋ฌธ ์ธํธ ์ถ๊ฐ โ replay โ failure taxonomy ํ์ธ โ AI fix vs DartLab core fix ๋ถ๋ฆฌ โ ํ๊ท ์ฌ์คํ` ์์๋ก ๊ฐ๋ค.
|
| 177 |
+
- "์ฅ๊ธฐ ํ์ต"์ ๋ชจ๋ธ ํ์ต์ด ์๋๋ผ ์ด replay/backlog ๋ฃจํ๋ฅผ ๋ปํ๋ค.
|
| 178 |
+
- replay์์ ๋ฐ๋ณต ์คํจํ ์ง๋ฌธ ๋ฌถ์์ generic ambiguity๋ก ๋จ๊ธฐ์ง ๋ง๊ณ ๊ฐ์ ๊ท์น์ผ๋ก ์น๊ฒฉํ๋ค.
|
| 179 |
+
- `๋ถ์ค ์งํ`๋ฅ ์ง๋ฌธ โ `finance` route ๊ณ ์
|
| 180 |
+
- `์์
์ด์ต๋ฅ + ๋น์ฉ ๊ตฌ์กฐ + ์ฌ์
๋ณํ` โ `IS + costByNature + businessOverview/productService` ๊ฐ์ hybrid, clarification ๊ธ์ง
|
| 181 |
+
- `์ต๊ทผ ๊ณต์ + ์ฌ์
๊ตฌ์กฐ ๋ณํ` โ `disclosureChanges`์ `businessOverview/productService`๋ฅผ ๊ฐ์ด ํ์
|
| 182 |
+
- **groundTruthFacts๋ ์๋ ํ๋์ฝ๋ฉ์ด ์๋๋ผ `truthHarvester`๋ก ์๋ ์์ฑํ๋ค.**
|
| 183 |
+
- `scripts/harvestEvalTruth.py`๋ก ๋ฐฐ์น ์คํ, `--severity critical,high`๋ถํฐ ์ฐ์ ์ฑ์
|
| 184 |
+
- finance ์์ง์์ IS/BS/CF ํต์ฌ ๊ณ์ + ratios๋ฅผ ์๋ ์ถ์ถ
|
| 185 |
+
- `truthAsOf` ๋ ์ง๋ก ๋ฐ์ดํฐ ์์ ์ ๊ธฐ๋ก
|
| 186 |
+
- **๊ฒฐ์ ๋ก ์ ๊ฒ์ฆ(๋ผ์ฐํ
/๋ชจ๋)์ LLM ํธ์ถ ์์ด CI์์ ๋งค ์ปค๋ฐ ๊ฒ์ฆํ๋ค.**
|
| 187 |
+
- `tests/test_eval_deterministic.py` โ personaCases.json์ expectedRoute/๋ชจ๋/๊ตฌ์กฐ ๋ฌด๊ฒฐ์ฑ ๊ฒ์ฆ
|
| 188 |
+
- personaCases์ ์ผ์ด์ค๋ฅผ ์ถ๊ฐํ๋ฉด ์๋์ผ๋ก ๊ฒฐ์ ๋ก ์ ํ
์คํธ๋ ์คํ๋จ
|
| 189 |
+
- `@pytest.mark.unit` โ `test-lock.sh` 1๋จ๊ณ์์ ์คํ
|
| 190 |
+
- **๋ฐฐ์น replay๋ `scripts/runEvalBatch.py`๋ก ์๋ํํ๋ค.**
|
| 191 |
+
- `--provider`, `--model`, `--severity`, `--persona`, `--compare latest` ํํฐ
|
| 192 |
+
- ๊ฒฐ๊ณผ๋ `eval/batchResults/` JSONL๋ก ์ ์ฅ, ์ด์ ๋ฐฐ์น์ ํ๊ท ๋น๊ต ์ง์
|
| 193 |
+
- **replaySuite()๋ Company ์บ์ 3๊ฐ ์ ํ์ผ๋ก OOM์ ๋ฐฉ์งํ๋ค.**
|
| 194 |
+
- 4๋ฒ์งธ Company ๋ก๋ ์ ๊ฐ์ฅ ์ค๋๋ ์บ์ ์ ๊ฑฐ + `gc.collect()`
|
| 195 |
+
|
| 196 |
+
## User Language ์์น
|
| 197 |
+
|
| 198 |
+
- UI ๊ธฐ๋ณธ surface์์๋ internal module/method ์ด๋ฆ์ ์ง์ ๋
ธ์ถํ์ง ์๋๋ค.
|
| 199 |
+
- ask ๋ด๋ถ debug/meta์ eval/log์์๋ raw module ์ด๋ฆ์ ์ ์งํด๋ ๋๋ค.
|
| 200 |
+
- runtime `meta` / `done`์๋ raw `includedModules`์ ํจ๊ป ์ฌ์ฉ์์ฉ `includedEvidence` label์ ๊ฐ์ด ์ค์ด ๋ณด๋ธ๋ค.
|
| 201 |
+
- UI evidence panel, transparency badges, modal title์ ์ฌ์ฉ์์ฉ evidence label์ ์ฐ์ ์ฌ์ฉํ๋ค.
|
| 202 |
+
- tool ์ด๋ฆ๋ UI์์๋ ์ฌ์ฉ์ ํ๋ ๊ธฐ์ค ๋ฌธ๊ตฌ๋ก ๋ณด์ฌ์ค๋ค.
|
| 203 |
+
- ์: `list_live_filings` โ `์ค์๊ฐ ๊ณต์ ๋ชฉ๋ก ์กฐํ`
|
| 204 |
+
- ์: `get_data` โ `์ฌ๋ฌดยท๊ณต์ ๋ฐ์ดํฐ ์กฐํ`
|
| 205 |
+
- ask ๋ณธ๋ฌธ๋ ๊ธฐ๋ณธ์ ์ผ๋ก ์ฌ์ฉ์ ์ธ์ด๋ฅผ ์ด๋ค.
|
| 206 |
+
- `IS/BS/CF/ratios/TTM` โ `์์ต๊ณ์ฐ์/์ฌ๋ฌด์ํํ/ํ๊ธํ๋ฆํ/์ฌ๋ฌด๋น์จ/์ต๊ทผ 4๋ถ๊ธฐ ํฉ์ฐ`
|
| 207 |
+
- `costByNature/businessOverview/productService` โ `์ฑ๊ฒฉ๋ณ ๋น์ฉ ๋ถ๋ฅ/์ฌ์
์ ๊ฐ์/์ ํยท์๋น์ค`
|
| 208 |
+
- `topic/period/source` โ `ํญ๋ชฉ/์์ /์ถ์ฒ`
|
| 209 |
+
|
| 210 |
+
## Sections First Retrieval
|
| 211 |
+
|
| 212 |
+
- `sections`๋ ๊ธฐ๋ณธ์ ์ผ๋ก โ๋ณธ๋ฌธ ๋ฉ์ด๋ฆฌโ๊ฐ ์๋๋ผ โretrieval indexโ๋ก ์ด๋ค.
|
| 213 |
+
- sections ๊ณ์ด ์ง๋ฌธ์ `topics() -> outline(topic) -> contextSlices -> raw docs sections block` ์์๋ก ์ขํ๋ค.
|
| 214 |
+
- `contextSlices`๊ฐ ask์ ๊ธฐ๋ณธ evidence layer๋ค. `outline(topic)`๋ ์ธ๋ฑ์ค/์ปค๋ฒ๋ฆฌ์ง ํ์ธ์ฉ์ด๊ณ , ์ค์ ๊ทผ๊ฑฐ ๋ฌธ์ฅ์ `contextSlices`์์ ๋จผ์ ํ์ํ๋ค.
|
| 215 |
+
- `retrievalBlocks/raw sections`๋ `contextSlices`๋ง์ผ๋ก ๊ทผ๊ฑฐ๊ฐ ๋ถ์กฑํ ๋๋ง ์ถ๊ฐ๋ก ์ฐ๋ค.
|
| 216 |
+
- ์ผ๋ฐ ์ฌ๋ฌด ์ง๋ฌธ์์๋ `sections`, `report`, `insights`, `change summary`๋ฅผ ์๋์ผ๋ก ๋ถ์ด์ง ์๋๋ค.
|
| 217 |
+
- ๋ฐฐ๋น/์ง์/์ต๋์ฃผ์ฃผ/๊ฐ์ฌ์ฒ๋ผ ๋ช
์์ ์ธ report ์ง๋ฌธ์์๋ง report pivot/context๋ฅผ ์ฌ๋ฆฐ๋ค.
|
| 218 |
+
|
| 219 |
+
## Follow-up Continuity
|
| 220 |
+
|
| 221 |
+
- ํ์ ํด์ด `์ต๊ทผ 5๊ฐ๋
`, `๊ทธ๋ผ`, `์ด์ด์`์ฒ๋ผ ์งง์ ๊ธฐ๊ฐ/์ฐ์ ์ง๋ฌธ์ด๋ฉด ์ง์ assistant `includedModules`๋ฅผ ์ด์ด๋ฐ์ ๊ฐ์ ๋ถ์ ์ถ์ ์ ์งํ๋ค.
|
| 222 |
+
- ์ด ์์์ ์๋ฌด ์ง๋ฌธ์๋ ์ ์ฉํ์ง ์๊ณ `follow_up` ๋ชจ๋ + ๊ธฐ๊ฐ/์ฐ์ ํํธ๊ฐ ์์ ๋๋ง ์ ์ฉํ๋ค.
|
| 223 |
+
- ๊ฐํ direct intent ์ง๋ฌธ(`์ฑ๊ฒฉ๋ณ ๋น์ฉ`, `์ธ๊ฑด๋น`, `๊ฐ๊ฐ์๊ฐ`, `๋ฌผ๋ฅ๋น`)์ clarification ์์ด ๋ฐ๋ก `costByNature`๋ฅผ ํ์ํ๋ค.
|
| 224 |
+
- `costByNature` ๊ฐ์ ๋ค๊ธฐ๊ฐ direct module์ด ํฌํจ๋๋ฉด ๊ธฐ๊ฐ์ด ๋น์ด ์์ด๋ ์ต์ ์์ ๊ณผ ์ต๊ทผ ์ถ์ธ๋ฅผ ๋จผ์ ๋ตํ๋ค. ์ฐ๋ ๊ธฐ์ค์ ๋จผ์ ๋ค์ ๋ฌป์ง ์๋๋ค.
|
src/dartlab/ai/STATUS.md
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# AI Engine โ Provider ํํฉ ๋ฐ ์ ์ง๋ณด์ ์ฒดํฌ๋ฆฌ์คํธ
|
| 2 |
+
|
| 3 |
+
## Provider ๋ชฉ๋ก (7๊ฐ)
|
| 4 |
+
|
| 5 |
+
| Provider | ํ์ผ | ์ธ์ฆ | ๊ธฐ๋ณธ ๋ชจ๋ธ | ์์ ์ฑ |
|
| 6 |
+
|----------|------|------|----------|--------|
|
| 7 |
+
| `openai` | openai_compat.py | API Key | gpt-4o | **์์ ** โ ๊ณต์ SDK |
|
| 8 |
+
| `ollama` | ollama.py | ์์ (localhost) | llama3.1 | **์์ ** โ ๋ก์ปฌ |
|
| 9 |
+
| `custom` | openai_compat.py | API Key | gpt-4o | **์์ ** โ OpenAI ํธํ |
|
| 10 |
+
| `chatgpt` | providers/__init__.py alias | `codex`๋ก ์ ๊ทํ | codex mirror | **ํธํ์ฉ alias** โ ๊ณต๊ฐ surface ๋น๋
ธ์ถ |
|
| 11 |
+
| `codex` | codex.py | CLI ์ธ์
| CLI config ๋๋ gpt-4.1 | **๊ณต์ ๊ฒฝ๋ก ์ฐ์ ** โ Codex CLI ์์กด |
|
| 12 |
+
| `oauth-codex` | oauthCodex.py | ChatGPT OAuth | gpt-5.4 | **๊ณต๊ฐ ๊ฒฝ๋ก** โ ๋น๊ณต์ backend API ์์กด |
|
| 13 |
+
| `claude-code` | claude_code.py | CLI ์ธ์
| sonnet | **๋ณด๋ฅ์ค** โ OAuth ์ง์ ์ ๋น๊ณต๊ฐ |
|
| 14 |
+
|
| 15 |
+
---
|
| 16 |
+
|
| 17 |
+
## ํ์ฌ ๊ณต๊ฐ ๊ฒฝ๋ก
|
| 18 |
+
|
| 19 |
+
- ChatGPT ๊ตฌ๋
๊ณ์ ๊ฒฝ๋ก๋ 2๊ฐ๋ค.
|
| 20 |
+
- `codex`: Codex CLI ๋ก๊ทธ์ธ ๊ธฐ๋ฐ
|
| 21 |
+
- `oauth-codex`: ChatGPT OAuth ์ง์ ์ฐ๊ฒฐ ๊ธฐ๋ฐ
|
| 22 |
+
- ๊ณต๊ฐ provider surface๋ `codex`, `oauth-codex`, `openai`, `ollama`, `custom`๋ง ์ ์งํ๋ค.
|
| 23 |
+
- `claude` provider๋ public surface์์ ์ ๊ฑฐ๋์๊ณ legacy/internal ์ฝ๋๋ก๋ง ๋จ์ ์๋ค.
|
| 24 |
+
- `chatgpt`๋ ๊ธฐ์กด ์ค์ /ํธํ์ฑ ๋๋ฌธ์ ๋ด๋ถ alias๋ก๋ง ๋จ์ ์์ผ๋ฉฐ ์ค์ ๊ตฌํ์ `codex`๋ก ์ ๊ทํ๋๋ค.
|
| 25 |
+
- `chatgpt-oauth`๋ ๋ด๋ถ/ํธํ alias๋ก๋ง ๋จ์ ์์ผ๋ฉฐ ์ค์ ๊ตฌํ์ `oauth-codex`๋ก ์ ๊ทํ๋๋ค.
|
| 26 |
+
|
| 27 |
+
## Tool Runtime ๊ธฐ๋ฐ
|
| 28 |
+
|
| 29 |
+
- ๋๊ตฌ ๋ฑ๋ก/์คํ์ `tool_runtime.py`์ `ToolRuntime`์ผ๋ก ๋ถ๋ฆฌ๋๊ธฐ ์์ํ๋ค.
|
| 30 |
+
- `tools_registry.py`๋ ํ์ฌ ํธํ ๋ํผ ์ญํ ์ ํ๋ฉฐ, ์ธ์
๋ณ/์์ด์ ํธ๋ณ isolated runtime ์์ฑ์ด ๊ฐ๋ฅํ๋ค.
|
| 31 |
+
- coding executor๋ `coding_runtime.py`๋ก ๋ถ๋ฆฌ๋๊ธฐ ์์ํ๊ณ , backend registry๋ฅผ ํตํด ๊ด๋ฆฌํ๋ค.
|
| 32 |
+
- ํ์ค ์ฝ๋ ์์
์ง์
์ ์ `run_coding_task`์ด๋ฉฐ `run_codex_task`๋ Codex compatibility alias๋ก ์ ์งํ๋ค.
|
| 33 |
+
- ๋ค์ ๋จ๊ณ๋ Codex ์ธ backend๋ฅผ ์ด runtime ๋ค์ ์ถ๊ฐํ๋, ๊ณต๊ฐ provider surface์๋ ๋ถ๋ฆฌํ๋ ๊ฒ์ด๋ค.
|
| 34 |
+
|
| 35 |
+
## ChatGPT OAuth Provider โ ํต์ฌ ๋ฆฌ์คํฌ
|
| 36 |
+
|
| 37 |
+
### ์ ์ทจ์ฝํ๊ฐ
|
| 38 |
+
|
| 39 |
+
`oauth-codex` provider๋ **OpenAI ๋น๊ณต์ ๋ด๋ถ API** (`chatgpt.com/backend-api/codex/responses`)๋ฅผ ์ฌ์ฉํ๋ค.
|
| 40 |
+
๊ณต์ OpenAI API (`api.openai.com`)๊ฐ ์๋๋ฏ๋ก **์๊ณ ์์ด ๋ณ๊ฒฝ/์ฐจ๋จ๋ ์ ์๋ค**.
|
| 41 |
+
|
| 42 |
+
### ์ ๊ธฐ ์ฒดํฌ ํญ๋ชฉ
|
| 43 |
+
|
| 44 |
+
**1. ์๋ํฌ์ธํธ ๋ณ๊ฒฝ**
|
| 45 |
+
- ํ์ฌ: `https://chatgpt.com/backend-api/codex/responses`
|
| 46 |
+
- ํ์ผ: [oauthCodex.py](providers/oauthCodex.py) `CODEX_API_BASE`, `CODEX_RESPONSES_PATH`
|
| 47 |
+
- OpenAI๊ฐ URL ๊ฒฝ๋ก๋ฅผ ๋ณ๊ฒฝํ๋ฉด ์ฆ์ 404/403 ๋ฐ์
|
| 48 |
+
- ํ์ธ๋ฒ: `dartlab status` ์คํ โ chatgpt available ํ์ธ
|
| 49 |
+
|
| 50 |
+
**2. OAuth ์ธ์ฆ ํ๋ผ๋ฏธํฐ**
|
| 51 |
+
- Client ID: `app_EMoamEEZ73f0CkXaXp7hrann` (Codex CLI์์ ์ถ์ถ)
|
| 52 |
+
- ํ์ผ: [oauthToken.py](../oauthToken.py) `CHATGPT_CLIENT_ID`
|
| 53 |
+
- OpenAI๊ฐ client_id๋ฅผ ๊ฐฑ์ ํ๊ฑฐ๋ revokeํ๋ฉด ๋ก๊ทธ์ธ ๋ถ๊ฐ
|
| 54 |
+
- ํ์ธ๋ฒ: OAuth ๋ก๊ทธ์ธ ์๋ โ "invalid_client" ์๋ฌ ์ฌ๋ถ
|
| 55 |
+
|
| 56 |
+
**3. SSE ์ด๋ฒคํธ ํ์
**
|
| 57 |
+
- ํ์ฌ ํ์ฑํ๋ ํ์
3๊ฐ:
|
| 58 |
+
- `response.output_text.delta` โ ํ
์คํธ ์ฒญํฌ
|
| 59 |
+
- `response.content_part.delta` โ ์ปจํ
์ธ ์ฒญํฌ
|
| 60 |
+
- `response.output_item.done` โ ์์ดํ
์๋ฃ
|
| 61 |
+
- ํ์ผ: [oauthCodex.py](providers/oauthCodex.py) `stream()`, `_parse_sse_response()`
|
| 62 |
+
- OpenAI๊ฐ ์ด๋ฒคํธ ์คํค๋ง๋ฅผ ๋ณ๊ฒฝํ๋ฉด ์๋ต์ด ๋น ๋ฌธ์์ด๋ก ๋์์ด
|
| 63 |
+
- ํ์ธ๋ฒ: ์คํธ๋ฆฌ๋ฐ ์๋ต์ด ๋์ฐฉํ๋๋ฐ ํ
์คํธ๊ฐ ๋น์ด์์ผ๋ฉด ์ด๋ฒคํธ ํ์
๋ณ๊ฒฝ ์์ฌ
|
| 64 |
+
|
| 65 |
+
**4. ์์ฒญ ํค๋**
|
| 66 |
+
- `originator: codex_cli_rs` โ Codex CLI ์ฌ์นญ
|
| 67 |
+
- `OpenAI-Beta: responses=experimental` โ ์คํ API ํ๋๊ทธ
|
| 68 |
+
- ํ์ผ: [oauthCodex.py](providers/oauthCodex.py) `_build_headers()`
|
| 69 |
+
- ์ด ํค๋ ์์ด๋ 403 ๋ฐํ๋จ
|
| 70 |
+
- OpenAI๊ฐ originator ๊ฒ์ฆ์ ๊ฐํํ๋ฉด ์ฐจ๋จ๋จ
|
| 71 |
+
|
| 72 |
+
**5. ๋ชจ๋ธ ๋ชฉ๋ก**
|
| 73 |
+
- `AVAILABLE_MODELS` ๋ฆฌ์คํธ๋ ์๋ ๊ด๋ฆฌ
|
| 74 |
+
- ํ์ผ: [oauthCodex.py](providers/oauthCodex.py) `AVAILABLE_MODELS`
|
| 75 |
+
- ์ ๋ชจ๋ธ ์ถ์/ํ๊ธฐ ์ ์๋ ์
๋ฐ์ดํธ ํ์
|
| 76 |
+
- GPT-4 ์๋ฆฌ์ฆ (gpt-4, gpt-4-turbo ๋ฑ)๋ ์ด๋ฏธ ์ ๊ฑฐ๋จ
|
| 77 |
+
|
| 78 |
+
**6. ํ ํฐ ๋ง๋ฃ ์ ์ฑ
**
|
| 79 |
+
- access_token: expires_in ๊ธฐ์ค (ํ์ฌ ~1์๊ฐ)
|
| 80 |
+
- refresh_token: ๋ง๋ฃ ์ ์ฑ
๋ถ๋ช
(OpenAI ๋ฏธ๊ณต๊ฐ)
|
| 81 |
+
- ํ์ผ: [oauthToken.py](../oauthToken.py) `get_valid_token()`, `refresh_access_token()`
|
| 82 |
+
- refresh_token์ด ๋ง๋ฃ๋๋ฉด ์ฌ๋ก๊ทธ์ธ ํ์
|
| 83 |
+
- ํ์ธ๋ฒ: ๋ฉฐ์น ๋ฐฉ์น ํ ์์ฒญ โ 401 + refresh ์คํจ ์ฌ๋ถ
|
| 84 |
+
|
| 85 |
+
### ๋ธ๋ ์ดํน ์ฒด์ธ์ง ๋์ ์์
|
| 86 |
+
|
| 87 |
+
1. ์ฌ์ฉ์๊ฐ "ChatGPT ์๋จ" ๋ณด๊ณ
|
| 88 |
+
2. `dartlab status` ๋ก available ํ์ธ
|
| 89 |
+
3. available=False โ OAuth ๋ก๊ทธ์ธ ์ฌ์๋
|
| 90 |
+
4. ๋ก๊ทธ์ธ ์คํจ โ client_id ๋ณ๊ฒฝ ํ์ธ (opencode-openai-codex-auth ์ฐธ์กฐ)
|
| 91 |
+
5. ๋ก๊ทธ์ธ ์ฑ๊ณต์ธ๋ฐ API ํธ์ถ ์คํจ โ ์๋ํฌ์ธํธ/ํค๋ ๋ณ๊ฒฝ ํ์ธ
|
| 92 |
+
6. API ํธ์ถ ์ฑ๊ณต์ธ๋ฐ ์๋ต ๋น์ด์์ โ SSE ์ด๋ฒคํธ ํ์
๋ณ๊ฒฝ ํ์ธ
|
| 93 |
+
|
| 94 |
+
### ์ํ๊ณ ๋น๊ต โ ๋๊ฐ ๊ฐ์ API๋ฅผ ์ฐ๋๊ฐ
|
| 95 |
+
|
| 96 |
+
ChatGPT OAuth(`chatgpt.com/backend-api`)๋ฅผ ์ฌ์ฉํ๋ ํ๋ก์ ํธ๋ **์ ๋ถ openai/codex CLI ์ญ๊ณตํ** ๊ธฐ๋ฐ์ด๋ค.
|
| 97 |
+
|
| 98 |
+
| ํ๋ก์ ํธ | ์ธ์ด | Client ID | ๋ชจ๋ธ ๋ชฉ๋ก | refresh ์คํจ ์ฒ๋ฆฌ | ํ ํฐ ์ ์ฅ |
|
| 99 |
+
|----------|------|-----------|----------|------------------|----------|
|
| 100 |
+
| **openai/codex** (๊ณต์) | Rust | ํ๋์ฝ๋ฉ | `/models` ๋์ + 5๋ถ ์บ์ | 4๊ฐ์ง ๋ถ๋ฅ | ํ์ผ/ํค๋ง/๋ฉ๋ชจ๋ฆฌ 3์ค |
|
| 101 |
+
| **opencode plugin** | TS | ๋์ผ ๋ณต์ | ์ฌ์ฉ์ ์ค์ ์์กด | ๋จ์ throw | ํ๋ ์์ํฌ ์์ |
|
| 102 |
+
| **ai-sdk-provider** | TS | ๋์ผ ๋ณต์ | 3๊ฐ ํ๋์ฝ๋ฉ | ๋จ์ throw | codex auth.json ์ฌ์ฌ์ฉ |
|
| 103 |
+
| **dartlab** (ํ์ฌ) | Python | ๋์ผ ๋ณต์ | 13๊ฐ ํ๋์ฝ๋ฉ | None ๋ฐํ | `~/.dartlab/oauth_token.json` |
|
| 104 |
+
|
| 105 |
+
**๊ณตํต ํน์ง:**
|
| 106 |
+
- Client ID `app_EMoamEEZ73f0CkXaXp7hrann` ์ ์ ๋์ผ (OpenAI public OAuth client)
|
| 107 |
+
- `originator: codex_cli_rs` ํค๋ ์ ์ ๋์ผ
|
| 108 |
+
- OpenAI๊ฐ ์ด ๊ฐ๋ค์ ๋ฐ๊พธ๋ฉด **์ ๋ถ ๋์์ ๊นจ์ง**
|
| 109 |
+
|
| 110 |
+
**openai/codex๋ง์ ์ฐจ๋ณ์ (dartlab์ ์๋ ๊ฒ):**
|
| 111 |
+
1. Token Exchange โ OAuth ํ ํฐ โ `api.openai.com` ํธํ API Key ๋ณํ
|
| 112 |
+
2. Device Code Flow โ headless ํ๊ฒฝ (์๋ฒ, SSH) ์ธ์ฆ ์ง์
|
| 113 |
+
3. ๋ชจ๋ธ ๋ชฉ๋ก ๋์ ์กฐํ โ `/models` ์๋ํฌ์ธํธ + ์บ์ + bundled fallback
|
| 114 |
+
4. Keyring ์ ์ฅ โ OS ํค์ฒด์ธ (macOS Keychain, Windows Credential Manager)
|
| 115 |
+
5. refresh ์คํจ 4๋จ๊ณ ๋ถ๋ฅ โ expired / reused / revoked / other
|
| 116 |
+
6. WebSocket SSE ์ด์ค ์ง์
|
| 117 |
+
|
| 118 |
+
**์ฐธ๊ณ : opencode์ oh-my-opencode(ํ oh-my-openagent)๋ ChatGPT OAuth๋ฅผ ์ฌ์ฉํ์ง ์๋๋ค.**
|
| 119 |
+
- opencode: GitHub Copilot API ์ธ์ฆ (๋ค๋ฅธ ์์คํ
)
|
| 120 |
+
- oh-my-openagent: MCP ์๋ฒ ํ์ค OAuth 2.0 + PKCE (ํ๋ฌ๊ทธ์ธ)
|
| 121 |
+
|
| 122 |
+
### ์ถ์ ๋์ ๋ ํฌ์งํ ๋ฆฌ
|
| 123 |
+
|
| 124 |
+
๋ณ๊ฒฝ์ฌํญ ๊ฐ์ง๋ฅผ ์ํด ๋ค์ ๋ ํฌ๋ฅผ ์ถ์ ํ๋ค.
|
| 125 |
+
|
| 126 |
+
| ๋ ํฌ | ์ถ์ ์ด์ | Watch ๋์ |
|
| 127 |
+
|------|----------|-----------|
|
| 128 |
+
| **openai/codex** | canonical ๊ตฌํ. Client ID, ์๋ํฌ์ธํธ, ํค๋์ ์๋ณธ | `codex-rs/core/src/auth.rs`, `model_provider_info.rs` |
|
| 129 |
+
| **numman-ali/opencode-openai-codex-auth** | ๋น ๋ฅธ ๋ณ๊ฒฝ ๋ฐ์ (TS๋ผ ์ฝ๊ธฐ ์ฌ์) | `lib/auth/`, `lib/constants.ts` |
|
| 130 |
+
| **ben-vargas/ai-sdk-provider-chatgpt-oauth** | Vercel AI SDK ํธํ ์ฐธ์กฐ | `src/auth/` |
|
| 131 |
+
|
| 132 |
+
### ํฅํ ๊ฐ์ ํ๋ณด (codex์์ ๊ฐ์ ธ์ฌ ์ ์๋ ๊ฒ)
|
| 133 |
+
|
| 134 |
+
1. **๋ชจ๋ธ ๋ชฉ๋ก ๋์ ์กฐํ** โ `chatgpt.com/backend-api/codex/models` ํธ์ถ + JSON ์บ์
|
| 135 |
+
2. **refresh ์คํจ ๋ถ๋ฅ** โ expired/reused/revoked ๊ตฌ๋ถํ์ฌ ์ฌ์ฉ์์๊ฒ ๊ตฌ์ฒด์ ์๋ด
|
| 136 |
+
3. **Token Exchange** โ OAuth โ API Key ๋ณํ์ผ๋ก `api.openai.com` ํธํ (๋์ผ ์๋ํฌ์ธํธ)
|
| 137 |
+
|
| 138 |
+
---
|
| 139 |
+
|
| 140 |
+
## Codex CLI Provider โ ๋ฆฌ์คํฌ
|
| 141 |
+
|
| 142 |
+
### ์ ์ทจ์ฝํ๊ฐ
|
| 143 |
+
|
| 144 |
+
`codex` provider๋ OpenAI `codex` CLI ๋ฐ์ด๋๋ฆฌ๋ฅผ subprocess๋ก ํธ์ถํ๋ค.
|
| 145 |
+
CLI์ JSONL ์ถ๋ ฅ ํฌ๋งท์ด ๋ณ๊ฒฝ๋๋ฉด ํ์ฑ ์คํจ.
|
| 146 |
+
|
| 147 |
+
### ํ์ฌ ๋์
|
| 148 |
+
|
| 149 |
+
- `~/.codex/config.toml`์ model ์ค์ ์ ์ฐ์ ํก์
|
| 150 |
+
- `codex --help`, `codex exec --help`๋ฅผ ์ฝ์ด command/sandbox capability๋ฅผ ๋์ ๊ฐ์ง
|
| 151 |
+
- ์ผ๋ฐ ์ง์๋ `read-only`, ์ฝ๋ ์์ ์๋๋ `workspace-write` sandbox ์ฐ์
|
| 152 |
+
- ๋ณ๋ `run_codex_task` tool๋ก ๋ค๋ฅธ provider์์๋ Codex CLI ์ฝ๋ ์์
์์ ๊ฐ๋ฅ
|
| 153 |
+
|
| 154 |
+
### ์ฒดํฌ ํญ๋ชฉ
|
| 155 |
+
|
| 156 |
+
- CLI ์ถ๋ ฅ ํฌ๋งท: `item.completed.item.agent_message.text` ๊ฒฝ๋ก
|
| 157 |
+
- CLI ํ๋๊ทธ: `--json`, `--sandbox ...`, `--model ...`, `--skip-git-repo-check`
|
| 158 |
+
- CLI ์ค์น: `npm install -g @openai/codex`
|
| 159 |
+
- ํ์ผ: [codex.py](providers/codex.py)
|
| 160 |
+
|
| 161 |
+
---
|
| 162 |
+
|
| 163 |
+
## Claude Code CLI Provider โ ๋ณด๋ฅ์ค
|
| 164 |
+
|
| 165 |
+
### ํ์ฌ ์ํ
|
| 166 |
+
|
| 167 |
+
VSCode ํ๊ฒฝ์์ `CLAUDECODE` ํ๊ฒฝ๋ณ์๊ฐ ์ค์ ๋์ด SDK fallback ๋ชจ๋๋ก ์ง์
ํ์ง๋ง,
|
| 168 |
+
SDK fallback์์ API key ์ถ์ถ(`claude auth status --json`)์ด ๋ subprocess๋ฅผ ํธ์ถํ๋ ์ํ ๋ฌธ์ .
|
| 169 |
+
|
| 170 |
+
### ์๋ ค์ง ์ด์
|
| 171 |
+
|
| 172 |
+
- ํ
์คํธ 31/32 pass, `test_complete_timeout` 1๊ฐ fail
|
| 173 |
+
- VSCode ๋ด์์ CLI ํธ์ถ์ด hang๋๋ ์ผ์ด์ค (์ค์ฒฉ ์ธ์
)
|
| 174 |
+
- `_probe_cli()` 8์ด ํ์์์์ผ๋ก hang ๊ฐ์ง ํ SDK ์ ํ
|
| 175 |
+
- ํ์ผ: [claude_code.py](providers/claude_code.py)
|
| 176 |
+
|
| 177 |
+
---
|
| 178 |
+
|
| 179 |
+
## ์์ Provider โ ํน์ด์ฌํญ ์์
|
| 180 |
+
|
| 181 |
+
### openai / custom (openai_compat.py)
|
| 182 |
+
- ๊ณต์ `openai` Python SDK ์ฌ์ฉ
|
| 183 |
+
- ๋ฒ์ ์
๋ฐ์ดํธ ์ SDK breaking change๋ง ์ฃผ์
|
| 184 |
+
- tool calling ์ง์
|
| 185 |
+
|
| 186 |
+
### claude (claude.py)
|
| 187 |
+
- ๊ณต์ `anthropic` Python SDK + OpenAI ํ๋ก์ ์ด์ค ๋ชจ๋
|
| 188 |
+
- base_url ์์ผ๋ฉด OpenAI ํธํ, ์์ผ๋ฉด Anthropic ๋ค์ดํฐ๋ธ
|
| 189 |
+
|
| 190 |
+
### ollama (ollama.py)
|
| 191 |
+
- localhost:11434 OpenAI ํธํ ์๋ํฌ์ธํธ
|
| 192 |
+
- `preload()`, `get_installed_models()`, `complete_json()` ์ถ๊ฐ ๊ธฐ๋ฅ
|
| 193 |
+
- tool calling ์ง์ (v0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
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from dartlab.ai.types import LLMConfig, LLMResponse
|
| 6 |
+
from dartlab.core.ai import (
|
| 7 |
+
AI_ROLES,
|
| 8 |
+
DEFAULT_ROLE,
|
| 9 |
+
get_profile_manager,
|
| 10 |
+
get_provider_spec,
|
| 11 |
+
normalize_provider,
|
| 12 |
+
normalize_role,
|
| 13 |
+
)
|
| 14 |
+
|
| 15 |
+
|
| 16 |
+
def configure(
|
| 17 |
+
provider: str = "codex",
|
| 18 |
+
model: str | None = None,
|
| 19 |
+
api_key: str | None = None,
|
| 20 |
+
base_url: str | None = None,
|
| 21 |
+
role: str | None = None,
|
| 22 |
+
temperature: float = 0.3,
|
| 23 |
+
max_tokens: int = 4096,
|
| 24 |
+
system_prompt: str | None = None,
|
| 25 |
+
) -> None:
|
| 26 |
+
"""๊ณตํต AI profile์ ๊ฐฑ์ ํ๋ค."""
|
| 27 |
+
normalized = normalize_provider(provider) or provider
|
| 28 |
+
if get_provider_spec(normalized) is None:
|
| 29 |
+
raise ValueError(f"์ง์ํ์ง ์๋ provider: {provider}")
|
| 30 |
+
normalized_role = normalize_role(role)
|
| 31 |
+
if role is not None and normalized_role is None:
|
| 32 |
+
raise ValueError(f"์ง์ํ์ง ์๋ role: {role}. ์ง์: {AI_ROLES}")
|
| 33 |
+
manager = get_profile_manager()
|
| 34 |
+
manager.update(
|
| 35 |
+
provider=normalized,
|
| 36 |
+
model=model,
|
| 37 |
+
role=normalized_role,
|
| 38 |
+
base_url=base_url,
|
| 39 |
+
temperature=temperature,
|
| 40 |
+
max_tokens=max_tokens,
|
| 41 |
+
system_prompt=system_prompt,
|
| 42 |
+
updated_by="code",
|
| 43 |
+
)
|
| 44 |
+
if api_key:
|
| 45 |
+
spec = get_provider_spec(normalized)
|
| 46 |
+
if spec and spec.auth_kind == "api_key":
|
| 47 |
+
manager.save_api_key(normalized, api_key, updated_by="code")
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def get_config(provider: str | None = None, *, role: str | None = None) -> LLMConfig:
|
| 51 |
+
"""ํ์ฌ ๊ธ๋ก๋ฒ LLM ์ค์ ๋ฐํ."""
|
| 52 |
+
normalized_role = normalize_role(role)
|
| 53 |
+
resolved = get_profile_manager().resolve(provider=provider, role=normalized_role)
|
| 54 |
+
return LLMConfig(**resolved)
|
| 55 |
+
|
| 56 |
+
|
| 57 |
+
def status(provider: str | None = None, *, role: str | None = None) -> dict:
|
| 58 |
+
"""LLM ์ค์ ๋ฐ provider ์ํ ํ์ธ."""
|
| 59 |
+
from dartlab.ai.providers import create_provider
|
| 60 |
+
|
| 61 |
+
normalized_role = normalize_role(role)
|
| 62 |
+
config = get_config(provider, role=normalized_role)
|
| 63 |
+
selected_provider = config.provider
|
| 64 |
+
llm = create_provider(config)
|
| 65 |
+
available = llm.check_available()
|
| 66 |
+
|
| 67 |
+
result = {
|
| 68 |
+
"provider": selected_provider,
|
| 69 |
+
"role": normalized_role or DEFAULT_ROLE,
|
| 70 |
+
"model": llm.resolved_model,
|
| 71 |
+
"available": available,
|
| 72 |
+
"defaultProvider": get_profile_manager().load().default_provider,
|
| 73 |
+
}
|
| 74 |
+
|
| 75 |
+
if selected_provider == "ollama":
|
| 76 |
+
from dartlab.ai.providers.support.ollama_setup import detect_ollama
|
| 77 |
+
|
| 78 |
+
result["ollama"] = detect_ollama()
|
| 79 |
+
|
| 80 |
+
if selected_provider == "codex":
|
| 81 |
+
from dartlab.ai.providers.support.cli_setup import detect_codex
|
| 82 |
+
|
| 83 |
+
result["codex"] = detect_codex()
|
| 84 |
+
|
| 85 |
+
if selected_provider == "oauth-codex":
|
| 86 |
+
from dartlab.ai.providers.support import oauth_token as oauthToken
|
| 87 |
+
|
| 88 |
+
token_stored = False
|
| 89 |
+
try:
|
| 90 |
+
token_stored = oauthToken.load_token() is not None
|
| 91 |
+
except (OSError, ValueError):
|
| 92 |
+
token_stored = False
|
| 93 |
+
|
| 94 |
+
try:
|
| 95 |
+
authenticated = oauthToken.is_authenticated()
|
| 96 |
+
account_id = oauthToken.get_account_id() if authenticated else None
|
| 97 |
+
except (
|
| 98 |
+
AttributeError,
|
| 99 |
+
OSError,
|
| 100 |
+
RuntimeError,
|
| 101 |
+
ValueError,
|
| 102 |
+
oauthToken.TokenRefreshError,
|
| 103 |
+
):
|
| 104 |
+
authenticated = False
|
| 105 |
+
account_id = None
|
| 106 |
+
|
| 107 |
+
result["oauth-codex"] = {
|
| 108 |
+
"authenticated": authenticated,
|
| 109 |
+
"tokenStored": token_stored,
|
| 110 |
+
"accountId": account_id,
|
| 111 |
+
}
|
| 112 |
+
|
| 113 |
+
return result
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
from dartlab.ai import aiParser as ai
|
| 117 |
+
from dartlab.ai.tools.plugin import get_plugin_registry, tool
|
| 118 |
+
|
| 119 |
+
__all__ = ["configure", "get_config", "status", "LLMConfig", "LLMResponse", "ai", "tool", "get_plugin_registry"]
|
src/dartlab/ai/agent.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ํธํ shim โ ์ค์ ๊ตฌํ์ runtime/agent.py๋ก ์ด๋๋จ.
|
| 2 |
+
|
| 3 |
+
๊ธฐ์กด import ๊ฒฝ๋ก๋ฅผ ์ ์งํ๊ธฐ ์ํ re-export.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from dartlab.ai.runtime.agent import ( # noqa: F401
|
| 7 |
+
AGENT_SYSTEM_ADDITION,
|
| 8 |
+
PLANNING_PROMPT,
|
| 9 |
+
_reflect_on_answer,
|
| 10 |
+
agent_loop,
|
| 11 |
+
agent_loop_planning,
|
| 12 |
+
agent_loop_stream,
|
| 13 |
+
build_agent_system_addition,
|
| 14 |
+
)
|
| 15 |
+
from dartlab.ai.tools.selector import selectTools # noqa: F401
|
| 16 |
+
|
| 17 |
+
# ํ์ํธํ: _select_tools โ selectTools ๋ํผ
|
| 18 |
+
_select_tools = selectTools
|
| 19 |
+
|
| 20 |
+
__all__ = [
|
| 21 |
+
"AGENT_SYSTEM_ADDITION",
|
| 22 |
+
"PLANNING_PROMPT",
|
| 23 |
+
"_reflect_on_answer",
|
| 24 |
+
"_select_tools",
|
| 25 |
+
"agent_loop",
|
| 26 |
+
"agent_loop_planning",
|
| 27 |
+
"agent_loop_stream",
|
| 28 |
+
"build_agent_system_addition",
|
| 29 |
+
"selectTools",
|
| 30 |
+
]
|
src/dartlab/ai/aiParser.py
ADDED
|
@@ -0,0 +1,500 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""AI ๋ณด์กฐ ํ์ฑ โ ๊ธฐ์กด ํ์ ์ถ๋ ฅ์ AI๊ฐ ํ์ฒ๋ฆฌํ์ฌ ๊ฐํ.
|
| 2 |
+
|
| 3 |
+
๊ธฐ์กด ํ์๋ฅผ ๊ต์ฒดํ์ง ์๋๋ค. ํ์๊ฐ ์์ฐํ DataFrame/ํ
์คํธ๋ฅผ
|
| 4 |
+
LLM์ด ํด์ยท์์ฝยท๊ฒ์ฆํ๋ ํ์ฒ๋ฆฌ ๋ ์ด์ด.
|
| 5 |
+
|
| 6 |
+
๊ธฐ์กด LLM provider ์์คํ
์ฌ์ฌ์ฉ: dartlab.llm.configure() ์ค์ ์ ๊ทธ๋๋ก ํ์ฉ.
|
| 7 |
+
|
| 8 |
+
์ฌ์ฉ๋ฒ::
|
| 9 |
+
|
| 10 |
+
import dartlab
|
| 11 |
+
dartlab.llm.configure(provider="ollama", model="llama3.2")
|
| 12 |
+
|
| 13 |
+
c = dartlab.Company("005930")
|
| 14 |
+
|
| 15 |
+
# ์์ฝ
|
| 16 |
+
dartlab.llm.ai.summarize(c.IS)
|
| 17 |
+
|
| 18 |
+
# ๊ณ์ ํด์
|
| 19 |
+
dartlab.llm.ai.interpret_accounts(c.BS)
|
| 20 |
+
|
| 21 |
+
# ์ด์์น ํ์ง
|
| 22 |
+
dartlab.llm.ai.detect_anomalies(c.dividend)
|
| 23 |
+
|
| 24 |
+
# ํ
์คํธ ๋ถ๋ฅ
|
| 25 |
+
dartlab.llm.ai.classify_text(c.mdna)
|
| 26 |
+
"""
|
| 27 |
+
|
| 28 |
+
from __future__ import annotations
|
| 29 |
+
|
| 30 |
+
from dataclasses import dataclass
|
| 31 |
+
from typing import Any
|
| 32 |
+
|
| 33 |
+
import polars as pl
|
| 34 |
+
|
| 35 |
+
from dartlab.ai.metadata import get_meta
|
| 36 |
+
|
| 37 |
+
_AI_PARSER_ERRORS = (ImportError, OSError, RuntimeError, TypeError, ValueError)
|
| 38 |
+
|
| 39 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 40 |
+
# ๋ด๋ถ LLM ํธ์ถ
|
| 41 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def _llm_call(prompt: str, system: str = "") -> str:
|
| 45 |
+
"""๋ด๋ถ LLM ํธ์ถ. ๊ธ๋ก๋ฒ ์ค์ ๋ provider ์ฌ์ฉ."""
|
| 46 |
+
from dartlab.ai import get_config
|
| 47 |
+
from dartlab.ai.providers import create_provider
|
| 48 |
+
|
| 49 |
+
config = get_config()
|
| 50 |
+
provider = create_provider(config)
|
| 51 |
+
|
| 52 |
+
messages = []
|
| 53 |
+
if system:
|
| 54 |
+
messages.append({"role": "system", "content": system})
|
| 55 |
+
messages.append({"role": "user", "content": prompt})
|
| 56 |
+
|
| 57 |
+
response = provider.complete(messages)
|
| 58 |
+
return response.answer
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 62 |
+
# ์์ฝ
|
| 63 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
def summarize(
|
| 67 |
+
data: pl.DataFrame | str | list,
|
| 68 |
+
*,
|
| 69 |
+
module_name: str | None = None,
|
| 70 |
+
lang: str = "ko",
|
| 71 |
+
) -> str:
|
| 72 |
+
"""DataFrame, ํ
์คํธ, ๋๋ ๋ฆฌ์คํธ๋ฅผ 2~5๋ฌธ์ฅ์ผ๋ก ์์ฝ.
|
| 73 |
+
|
| 74 |
+
Args:
|
| 75 |
+
data: DataFrame (๋งํฌ๋ค์ด ๋ณํ ํ ์์ฝ), str (์ง์ ์์ฝ), list (๊ฒฐํฉ ํ ์์ฝ)
|
| 76 |
+
module_name: ๋ฉํ๋ฐ์ดํฐ ํ์ฉ์ ์ํ ๋ชจ๋๋ช
|
| 77 |
+
lang: "ko" ๋๋ "en"
|
| 78 |
+
|
| 79 |
+
Returns:
|
| 80 |
+
์์ฝ ํ
์คํธ (2~5๋ฌธ์ฅ)
|
| 81 |
+
"""
|
| 82 |
+
from dartlab.ai.context.builder import df_to_markdown
|
| 83 |
+
|
| 84 |
+
# ๋ฐ์ดํฐ โ ํ
์คํธ
|
| 85 |
+
if isinstance(data, pl.DataFrame):
|
| 86 |
+
meta = get_meta(module_name) if module_name else None
|
| 87 |
+
text = df_to_markdown(data, meta=meta)
|
| 88 |
+
elif isinstance(data, list):
|
| 89 |
+
parts = []
|
| 90 |
+
for item in data[:10]:
|
| 91 |
+
if hasattr(item, "title") and hasattr(item, "text"):
|
| 92 |
+
parts.append(f"[{item.title}]\n{item.text[:500]}")
|
| 93 |
+
else:
|
| 94 |
+
parts.append(str(item)[:500])
|
| 95 |
+
text = "\n\n".join(parts)
|
| 96 |
+
else:
|
| 97 |
+
text = str(data)[:3000]
|
| 98 |
+
|
| 99 |
+
# ๋ฉํ๋ฐ์ดํฐ ์ปจํ
์คํธ
|
| 100 |
+
context = ""
|
| 101 |
+
if module_name:
|
| 102 |
+
meta = get_meta(module_name)
|
| 103 |
+
if meta:
|
| 104 |
+
context = f"์ด ๋ฐ์ดํฐ๋ '{meta.label}'์
๋๋ค. {meta.description}\n\n"
|
| 105 |
+
|
| 106 |
+
system = "ํ๊ตญ์ด๋ก ๋ต๋ณํ์ธ์." if lang == "ko" else "Answer in English."
|
| 107 |
+
|
| 108 |
+
prompt = (
|
| 109 |
+
f"{context}"
|
| 110 |
+
f"๋ค์ ๋ฐ์ดํฐ๋ฅผ 2~5๋ฌธ์ฅ์ผ๋ก ํต์ฌ๋ง ์์ฝํ์ธ์.\n"
|
| 111 |
+
f"์์น๋ฅผ ๊ตฌ์ฒด์ ์ผ๋ก ์ธ์ฉํ๊ณ , ์ฃผ์ ์ถ์ธ์ ํน์ด์ฌํญ์ ํฌํจํ์ธ์.\n\n"
|
| 112 |
+
f"{text}"
|
| 113 |
+
)
|
| 114 |
+
|
| 115 |
+
return _llm_call(prompt, system=system)
|
| 116 |
+
|
| 117 |
+
|
| 118 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 119 |
+
# ๊ณ์ ํด์
|
| 120 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
def interpret_accounts(
|
| 124 |
+
df: pl.DataFrame,
|
| 125 |
+
*,
|
| 126 |
+
account_col: str = "๊ณ์ ๋ช
",
|
| 127 |
+
module_name: str | None = None,
|
| 128 |
+
) -> pl.DataFrame:
|
| 129 |
+
"""์ฌ๋ฌด์ ํ์ '์ค๋ช
' ์ปฌ๋ผ ์ถ๊ฐ. ๊ฐ ๊ณ์ ๋ช
์ ์๋ฏธ๋ฅผ LLM์ด ํด์.
|
| 130 |
+
|
| 131 |
+
LLM 1ํ ํธ์ถ๋ก ์ ์ฒด ๊ณ์ ์ผ๊ด ํด์ (๊ฐ๋ณ ํธ์ถ ์๋).
|
| 132 |
+
|
| 133 |
+
Args:
|
| 134 |
+
df: ๊ณ์ ๋ช
์ปฌ๋ผ์ด ์๋ ์ฌ๋ฌด์ ํ DataFrame
|
| 135 |
+
account_col: ๊ณ์ ๋ช
์ปฌ๋ผ๋ช
|
| 136 |
+
module_name: "BS", "IS", "CF" ๋ฑ
|
| 137 |
+
|
| 138 |
+
Returns:
|
| 139 |
+
์๋ณธ + '์ค๋ช
' ์ปฌ๋ผ์ด ์ถ๊ฐ๋ DataFrame
|
| 140 |
+
"""
|
| 141 |
+
if account_col not in df.columns:
|
| 142 |
+
return df
|
| 143 |
+
|
| 144 |
+
accounts = df[account_col].to_list()
|
| 145 |
+
if not accounts:
|
| 146 |
+
return df
|
| 147 |
+
|
| 148 |
+
# ์ ์ผํ ๊ณ์ ๋ช
๋ง ์ถ์ถ
|
| 149 |
+
unique_accounts = list(dict.fromkeys(accounts))
|
| 150 |
+
|
| 151 |
+
module_hint = ""
|
| 152 |
+
if module_name:
|
| 153 |
+
meta = get_meta(module_name)
|
| 154 |
+
if meta:
|
| 155 |
+
module_hint = f"์ด ๋ฐ์ดํฐ๋ '{meta.label}'({meta.description})์
๋๋ค.\n"
|
| 156 |
+
|
| 157 |
+
prompt = (
|
| 158 |
+
f"{module_hint}"
|
| 159 |
+
f"๋ค์ K-IFRS ๊ณ์ ๋ช
๊ฐ๊ฐ์ ๋ํด ํ ์ค(20๏ฟฝ๏ฟฝ๏ฟฝ ์ด๋ด)๋ก ์ค๋ช
ํ์ธ์.\n"
|
| 160 |
+
f"ํ์: ๊ณ์ ๋ช
: ์ค๋ช
\n\n" + "\n".join(unique_accounts)
|
| 161 |
+
)
|
| 162 |
+
|
| 163 |
+
answer = _llm_call(prompt, system="ํ๊ตญ์ด๋ก ๋ต๋ณํ์ธ์. ๊ฐ ๊ณ์ ์ ๋ํด ๊ฐ๊ฒฐํ๊ฒ ์ค๋ช
๋ง ํ์ธ์.")
|
| 164 |
+
|
| 165 |
+
# ์๋ต ํ์ฑ: "๊ณ์ ๋ช
: ์ค๋ช
" ํํ
|
| 166 |
+
desc_map: dict[str, str] = {}
|
| 167 |
+
for line in answer.strip().split("\n"):
|
| 168 |
+
line = line.strip().lstrip("- ").lstrip("ยท ")
|
| 169 |
+
if ":" in line:
|
| 170 |
+
parts = line.split(":", 1)
|
| 171 |
+
key = parts[0].strip()
|
| 172 |
+
val = parts[1].strip()
|
| 173 |
+
desc_map[key] = val
|
| 174 |
+
|
| 175 |
+
# ๋งคํ
|
| 176 |
+
descriptions = []
|
| 177 |
+
for acct in accounts:
|
| 178 |
+
desc = desc_map.get(acct, "")
|
| 179 |
+
if not desc:
|
| 180 |
+
# ๋ถ๋ถ ๋งค์นญ ์๋
|
| 181 |
+
for k, v in desc_map.items():
|
| 182 |
+
if k in acct or acct in k:
|
| 183 |
+
desc = v
|
| 184 |
+
break
|
| 185 |
+
descriptions.append(desc)
|
| 186 |
+
|
| 187 |
+
return df.with_columns(pl.Series("์ค๋ช
", descriptions))
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 191 |
+
# ์ด์์น ํ์ง
|
| 192 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 193 |
+
|
| 194 |
+
|
| 195 |
+
@dataclass
|
| 196 |
+
class Anomaly:
|
| 197 |
+
"""ํ์ง๋ ์ด์์น."""
|
| 198 |
+
|
| 199 |
+
column: str
|
| 200 |
+
year: str
|
| 201 |
+
value: Any
|
| 202 |
+
prev_value: Any
|
| 203 |
+
change_pct: float | None
|
| 204 |
+
anomaly_type: str # "spike", "sign_reversal", "outlier", "missing"
|
| 205 |
+
severity: str = "medium" # "high", "medium", "low"
|
| 206 |
+
description: str = ""
|
| 207 |
+
|
| 208 |
+
|
| 209 |
+
def _statistical_prescreen(
|
| 210 |
+
df: pl.DataFrame,
|
| 211 |
+
*,
|
| 212 |
+
year_col: str = "year",
|
| 213 |
+
threshold_pct: float = 50.0,
|
| 214 |
+
) -> list[Anomaly]:
|
| 215 |
+
"""์์ ํต๊ณ ๊ธฐ๋ฐ ์ด์์น ์ฌ์ ํ์ง (LLM ์์ด ๋์).
|
| 216 |
+
|
| 217 |
+
ํ์ง ๊ธฐ์ค:
|
| 218 |
+
- YoY ๋ณ๋ threshold_pct% ์ด๊ณผ
|
| 219 |
+
- ๋ถํธ ๋ฐ์ (์โ์, ์โ์)
|
| 220 |
+
- 2ฯ ์ดํ
|
| 221 |
+
"""
|
| 222 |
+
if year_col not in df.columns:
|
| 223 |
+
return []
|
| 224 |
+
|
| 225 |
+
df_sorted = df.sort(year_col)
|
| 226 |
+
numeric_cols = [
|
| 227 |
+
c for c in df.columns if c != year_col and df[c].dtype in (pl.Float64, pl.Float32, pl.Int64, pl.Int32)
|
| 228 |
+
]
|
| 229 |
+
|
| 230 |
+
anomalies = []
|
| 231 |
+
years = df_sorted[year_col].to_list()
|
| 232 |
+
|
| 233 |
+
for col in numeric_cols:
|
| 234 |
+
values = df_sorted[col].to_list()
|
| 235 |
+
non_null = [v for v in values if v is not None]
|
| 236 |
+
|
| 237 |
+
if len(non_null) < 2:
|
| 238 |
+
continue
|
| 239 |
+
|
| 240 |
+
mean_val = sum(non_null) / len(non_null)
|
| 241 |
+
if len(non_null) > 1:
|
| 242 |
+
variance = sum((v - mean_val) ** 2 for v in non_null) / (len(non_null) - 1)
|
| 243 |
+
std_val = variance**0.5
|
| 244 |
+
else:
|
| 245 |
+
std_val = 0
|
| 246 |
+
|
| 247 |
+
for i in range(1, len(values)):
|
| 248 |
+
cur = values[i]
|
| 249 |
+
prev = values[i - 1]
|
| 250 |
+
|
| 251 |
+
if cur is None or prev is None:
|
| 252 |
+
continue
|
| 253 |
+
|
| 254 |
+
# YoY ๋ณ๋
|
| 255 |
+
if prev != 0:
|
| 256 |
+
change = (cur - prev) / abs(prev) * 100
|
| 257 |
+
if abs(change) > threshold_pct:
|
| 258 |
+
severity = "high" if abs(change) > 100 else "medium"
|
| 259 |
+
anomalies.append(
|
| 260 |
+
Anomaly(
|
| 261 |
+
column=col,
|
| 262 |
+
year=str(years[i]),
|
| 263 |
+
value=cur,
|
| 264 |
+
prev_value=prev,
|
| 265 |
+
change_pct=round(change, 1),
|
| 266 |
+
anomaly_type="spike",
|
| 267 |
+
severity=severity,
|
| 268 |
+
)
|
| 269 |
+
)
|
| 270 |
+
|
| 271 |
+
# ๋ถํธ ๋ฐ์
|
| 272 |
+
if (prev > 0 and cur < 0) or (prev < 0 and cur > 0):
|
| 273 |
+
anomalies.append(
|
| 274 |
+
Anomaly(
|
| 275 |
+
column=col,
|
| 276 |
+
year=str(years[i]),
|
| 277 |
+
value=cur,
|
| 278 |
+
prev_value=prev,
|
| 279 |
+
change_pct=None,
|
| 280 |
+
anomaly_type="sign_reversal",
|
| 281 |
+
severity="high",
|
| 282 |
+
)
|
| 283 |
+
)
|
| 284 |
+
|
| 285 |
+
# 2ฯ ์ดํ
|
| 286 |
+
if std_val > 0 and abs(cur - mean_val) > 2 * std_val:
|
| 287 |
+
anomalies.append(
|
| 288 |
+
Anomaly(
|
| 289 |
+
column=col,
|
| 290 |
+
year=str(years[i]),
|
| 291 |
+
value=cur,
|
| 292 |
+
prev_value=None,
|
| 293 |
+
change_pct=None,
|
| 294 |
+
anomaly_type="outlier",
|
| 295 |
+
severity="medium",
|
| 296 |
+
)
|
| 297 |
+
)
|
| 298 |
+
|
| 299 |
+
# ์ค๋ณต ์ ๊ฑฐ (๊ฐ์ year+column)
|
| 300 |
+
seen = set()
|
| 301 |
+
unique = []
|
| 302 |
+
for a in anomalies:
|
| 303 |
+
key = (a.column, a.year, a.anomaly_type)
|
| 304 |
+
if key not in seen:
|
| 305 |
+
seen.add(key)
|
| 306 |
+
unique.append(a)
|
| 307 |
+
|
| 308 |
+
return unique
|
| 309 |
+
|
| 310 |
+
|
| 311 |
+
def detect_anomalies(
|
| 312 |
+
df: pl.DataFrame,
|
| 313 |
+
*,
|
| 314 |
+
module_name: str | None = None,
|
| 315 |
+
year_col: str = "year",
|
| 316 |
+
threshold_pct: float = 50.0,
|
| 317 |
+
use_llm: bool = True,
|
| 318 |
+
) -> list[Anomaly]:
|
| 319 |
+
"""2๋จ๊ณ ์ด์์น ํ์ง.
|
| 320 |
+
|
| 321 |
+
Stage 1: ํต๊ณ ์ฌ์ ์คํฌ๋ฆฌ๋ (LLM ์์ด ํญ์ ๋์)
|
| 322 |
+
Stage 2: LLM ํด์ (use_llm=True์ด๊ณ LLM ์ค์ ์)
|
| 323 |
+
|
| 324 |
+
Args:
|
| 325 |
+
df: ์๊ณ์ด DataFrame
|
| 326 |
+
module_name: ๋ชจ๋๋ช
(๋ฉํ๋ฐ์ดํฐ ํ์ฉ)
|
| 327 |
+
threshold_pct: YoY ๋ณ๋ ์๊ณ๊ฐ (%)
|
| 328 |
+
use_llm: True๋ฉด LLM์ผ๋ก ํด์ ์ถ๊ฐ
|
| 329 |
+
|
| 330 |
+
Returns:
|
| 331 |
+
Anomaly ๋ฆฌ์คํธ (severity ๋ด๋ฆผ์ฐจ์)
|
| 332 |
+
"""
|
| 333 |
+
anomalies = _statistical_prescreen(df, year_col=year_col, threshold_pct=threshold_pct)
|
| 334 |
+
|
| 335 |
+
if not anomalies:
|
| 336 |
+
return []
|
| 337 |
+
|
| 338 |
+
# Stage 2: LLM ํด์
|
| 339 |
+
if use_llm and anomalies:
|
| 340 |
+
try:
|
| 341 |
+
meta_ctx = ""
|
| 342 |
+
if module_name:
|
| 343 |
+
meta = get_meta(module_name)
|
| 344 |
+
if meta:
|
| 345 |
+
meta_ctx = f"๋ฐ์ดํฐ: {meta.label} ({meta.description})\n"
|
| 346 |
+
|
| 347 |
+
lines = []
|
| 348 |
+
for a in anomalies[:10]: # ์ต๋ 10๊ฐ๋ง
|
| 349 |
+
if a.anomaly_type == "spike":
|
| 350 |
+
lines.append(
|
| 351 |
+
f"- {a.column} {a.year}๋
: {a.prev_value:,.0f} โ {a.value:,.0f} (YoY {a.change_pct:+.1f}%)"
|
| 352 |
+
)
|
| 353 |
+
elif a.anomaly_type == "sign_reversal":
|
| 354 |
+
lines.append(f"- {a.column} {a.year}๋
: ๋ถํธ ๋ฐ์ {a.prev_value:,.0f} โ {a.value:,.0f}")
|
| 355 |
+
elif a.anomaly_type == "outlier":
|
| 356 |
+
lines.append(f"- {a.column} {a.year}๋
: ์ด์์น {a.value:,.0f}")
|
| 357 |
+
|
| 358 |
+
prompt = (
|
| 359 |
+
f"{meta_ctx}"
|
| 360 |
+
f"๋ค์ ์ฌ๋ฌด ๋ฐ์ดํฐ ์ด์์น๋ค์ ๋ํด ๊ฐ๊ฐ ํ ์ค๋ก ๊ฐ๋ฅํ ์์ธ์ ์ค๋ช
ํ์ธ์.\n\n" + "\n".join(lines)
|
| 361 |
+
)
|
| 362 |
+
|
| 363 |
+
answer = _llm_call(prompt, system="ํ๊ตญ์ด๋ก ๊ฐ๊ฒฐํ๊ฒ ๋ต๋ณํ์ธ์.")
|
| 364 |
+
|
| 365 |
+
# ์๋ต์์ ์ค๋ช
์ถ์ถํ์ฌ anomalies์ ๋งคํ
|
| 366 |
+
desc_lines = [l.strip().lstrip("- ").lstrip("ยท ") for l in answer.strip().split("\n") if l.strip()]
|
| 367 |
+
for i, a in enumerate(anomalies[:10]):
|
| 368 |
+
if i < len(desc_lines):
|
| 369 |
+
a.description = desc_lines[i]
|
| 370 |
+
|
| 371 |
+
except _AI_PARSER_ERRORS:
|
| 372 |
+
# LLM ์คํจ ์ ํต๊ณ ๊ฒฐ๊ณผ๋ง ๋ฐํ
|
| 373 |
+
pass
|
| 374 |
+
|
| 375 |
+
# severity ์ ๋ ฌ
|
| 376 |
+
severity_order = {"high": 0, "medium": 1, "low": 2}
|
| 377 |
+
anomalies.sort(key=lambda a: severity_order.get(a.severity, 1))
|
| 378 |
+
|
| 379 |
+
return anomalies
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 383 |
+
# ํ
์คํธ ๋ถ๋ฅ
|
| 384 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 385 |
+
|
| 386 |
+
|
| 387 |
+
def classify_text(text: str) -> dict:
|
| 388 |
+
"""๊ณต์ ํ
์คํธ์์ ๊ฐ์ฑ, ํต์ฌํ ํฝ, ๋ฆฌ์คํฌ, ๊ธฐํ ์ถ์ถ.
|
| 389 |
+
|
| 390 |
+
MD&A, ์ฌ์
์ ๋ด์ฉ ๋ฑ ์์ ํ ํ
์คํธ๋ฅผ ๊ตฌ์กฐํ๋ ๋ถ์ ๊ฒฐ๊ณผ๋ก ๋ณํ.
|
| 391 |
+
|
| 392 |
+
Returns:
|
| 393 |
+
{
|
| 394 |
+
"sentiment": "๊ธ์ " | "๋ถ์ " | "์ค๋ฆฝ",
|
| 395 |
+
"key_topics": list[str],
|
| 396 |
+
"risks": list[str],
|
| 397 |
+
"opportunities": list[str],
|
| 398 |
+
"summary": str,
|
| 399 |
+
}
|
| 400 |
+
"""
|
| 401 |
+
if not text:
|
| 402 |
+
return {
|
| 403 |
+
"sentiment": "์ค๋ฆฝ",
|
| 404 |
+
"key_topics": [],
|
| 405 |
+
"risks": [],
|
| 406 |
+
"opportunities": [],
|
| 407 |
+
"summary": "",
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
# ํ
์คํธ ๊ธธ์ด ์ ํ
|
| 411 |
+
truncated = text[:3000] if len(text) > 3000 else text
|
| 412 |
+
|
| 413 |
+
prompt = (
|
| 414 |
+
"๋ค์ ๊ณต์ ํ
์คํธ๋ฅผ ๋ถ์ํ์ฌ ์๋ ํ์์ผ๋ก ๋ต๋ณํ์ธ์.\n\n"
|
| 415 |
+
"๊ฐ์ฑ: (๊ธ์ /๋ถ์ /์ค๋ฆฝ)\n"
|
| 416 |
+
"ํต์ฌํ ํฝ: (์ผํ๋ก ๊ตฌ๋ถ, 3~5๊ฐ)\n"
|
| 417 |
+
"๋ฆฌ์คํฌ: (์ผํ๋ก ๊ตฌ๋ถ)\n"
|
| 418 |
+
"๊ธฐํ: (์ผํ๋ก ๊ตฌ๋ถ)\n"
|
| 419 |
+
"์์ฝ: (2~3๋ฌธ์ฅ)\n\n"
|
| 420 |
+
f"ํ
์คํธ:\n{truncated}"
|
| 421 |
+
)
|
| 422 |
+
|
| 423 |
+
answer = _llm_call(prompt, system="ํ๊ตญ์ด๋ก ๋ต๋ณํ์ธ์. ์ฃผ์ด์ง ํ์์ ์ ํํ ๋ฐ๋ฅด์ธ์.")
|
| 424 |
+
|
| 425 |
+
# ์๋ต ํ์ฑ
|
| 426 |
+
result = {
|
| 427 |
+
"sentiment": "์ค๋ฆฝ",
|
| 428 |
+
"key_topics": [],
|
| 429 |
+
"risks": [],
|
| 430 |
+
"opportunities": [],
|
| 431 |
+
"summary": "",
|
| 432 |
+
}
|
| 433 |
+
|
| 434 |
+
for line in answer.strip().split("\n"):
|
| 435 |
+
line = line.strip()
|
| 436 |
+
if line.startswith("๊ฐ์ฑ:"):
|
| 437 |
+
val = line.split(":", 1)[1].strip()
|
| 438 |
+
if "๊ธ์ " in val:
|
| 439 |
+
result["sentiment"] = "๊ธ์ "
|
| 440 |
+
elif "๋ถ์ " in val:
|
| 441 |
+
result["sentiment"] = "๋ถ์ "
|
| 442 |
+
else:
|
| 443 |
+
result["sentiment"] = "์ค๋ฆฝ"
|
| 444 |
+
elif line.startswith("ํต์ฌํ ํฝ:"):
|
| 445 |
+
val = line.split(":", 1)[1].strip()
|
| 446 |
+
result["key_topics"] = [t.strip() for t in val.split(",") if t.strip()]
|
| 447 |
+
elif line.startswith("๋ฆฌ์คํฌ:"):
|
| 448 |
+
val = line.split(":", 1)[1].strip()
|
| 449 |
+
result["risks"] = [t.strip() for t in val.split(",") if t.strip()]
|
| 450 |
+
elif line.startswith("๊ธฐํ:"):
|
| 451 |
+
val = line.split(":", 1)[1].strip()
|
| 452 |
+
result["opportunities"] = [t.strip() for t in val.split(",") if t.strip()]
|
| 453 |
+
elif line.startswith("์์ฝ:"):
|
| 454 |
+
result["summary"] = line.split(":", 1)[1].strip()
|
| 455 |
+
|
| 456 |
+
return result
|
| 457 |
+
|
| 458 |
+
|
| 459 |
+
# ๏ฟฝ๏ฟฝโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 460 |
+
# ํตํฉ ๋ถ์
|
| 461 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 462 |
+
|
| 463 |
+
|
| 464 |
+
def analyze_module(
|
| 465 |
+
company: Any,
|
| 466 |
+
module_name: str,
|
| 467 |
+
) -> dict:
|
| 468 |
+
"""๋จ์ผ ๋ชจ๋ ์ ์ฒด AI ๋ถ์.
|
| 469 |
+
|
| 470 |
+
summarize + detect_anomalies + (interpret_accounts if applicable) ์ผ๊ด ์คํ.
|
| 471 |
+
|
| 472 |
+
Returns:
|
| 473 |
+
{
|
| 474 |
+
"summary": str,
|
| 475 |
+
"anomalies": list[Anomaly],
|
| 476 |
+
"interpreted_df": pl.DataFrame | None,
|
| 477 |
+
}
|
| 478 |
+
"""
|
| 479 |
+
data = getattr(company, module_name, None)
|
| 480 |
+
if data is None:
|
| 481 |
+
return {"summary": "๋ฐ์ดํฐ ์์", "anomalies": [], "interpreted_df": None}
|
| 482 |
+
|
| 483 |
+
result: dict[str, Any] = {}
|
| 484 |
+
|
| 485 |
+
# ์์ฝ
|
| 486 |
+
result["summary"] = summarize(data, module_name=module_name)
|
| 487 |
+
|
| 488 |
+
# ์ด์์น ํ์ง (DataFrame์ธ ๊ฒฝ์ฐ๋ง)
|
| 489 |
+
if isinstance(data, pl.DataFrame):
|
| 490 |
+
result["anomalies"] = detect_anomalies(data, module_name=module_name)
|
| 491 |
+
else:
|
| 492 |
+
result["anomalies"] = []
|
| 493 |
+
|
| 494 |
+
# ๊ณ์ ํด์ (BS/IS/CF๋ง)
|
| 495 |
+
if module_name in ("BS", "IS", "CF") and isinstance(data, pl.DataFrame) and "๊ณ์ ๋ช
" in data.columns:
|
| 496 |
+
result["interpreted_df"] = interpret_accounts(data, module_name=module_name)
|
| 497 |
+
else:
|
| 498 |
+
result["interpreted_df"] = None
|
| 499 |
+
|
| 500 |
+
return result
|
src/dartlab/ai/context/__init__.py
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""AI context package."""
|
| 2 |
+
|
| 3 |
+
from . import builder as _builder
|
| 4 |
+
from . import company_adapter as _company_adapter
|
| 5 |
+
from . import dartOpenapi as _dart_openapi
|
| 6 |
+
from . import snapshot as _snapshot
|
| 7 |
+
|
| 8 |
+
for _module in (_builder, _snapshot, _company_adapter, _dart_openapi):
|
| 9 |
+
globals().update({name: getattr(_module, name) for name in dir(_module) if not name.startswith("__")})
|
src/dartlab/ai/context/builder.py
ADDED
|
@@ -0,0 +1,1960 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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ดํฐ ๊ธฐ๋ฐ ์ปฌ๋ผ ์ค๋ช
, ํ์ ์งํ ์๋๊ณ์ฐ, ๋ถ์ ํํธ๋ฅผ ํฌํจํ์ฌ
|
| 4 |
+
LLM์ด ์ ํํ๊ฒ ๋ถ์ํ ์ ์๋ ๊ตฌ์กฐํ๋ ๋งํฌ๋ค์ด ์ปจํ
์คํธ๋ฅผ ์์ฑํ๋ค.
|
| 5 |
+
|
| 6 |
+
๋ถํ ๋ชจ๋:
|
| 7 |
+
- formatting.py: DataFrame ๋งํฌ๋ค์ด ๋ณํ, ํฌ๋งทํ
, ํ์ ์งํ ๊ณ์ฐ
|
| 8 |
+
- finance_context.py: ์ฌ๋ฌด/๊ณต์ ๋ฐ์ดํฐ โ LLM ์ปจํ
์คํธ ๋งํฌ๋ค์ด ์์ฑ
|
| 9 |
+
"""
|
| 10 |
+
|
| 11 |
+
from __future__ import annotations
|
| 12 |
+
|
| 13 |
+
import re
|
| 14 |
+
from typing import Any
|
| 15 |
+
|
| 16 |
+
import polars as pl
|
| 17 |
+
|
| 18 |
+
from dartlab.ai.context.company_adapter import get_headline_ratios
|
| 19 |
+
from dartlab.ai.context.finance_context import (
|
| 20 |
+
_QUESTION_ACCOUNT_FILTER,
|
| 21 |
+
_QUESTION_MODULES, # noqa: F401 โ re-export for tests
|
| 22 |
+
_build_finance_engine_section,
|
| 23 |
+
_build_ratios_section,
|
| 24 |
+
_build_report_sections,
|
| 25 |
+
_buildQuarterlySection,
|
| 26 |
+
_detect_year_hint,
|
| 27 |
+
_get_quarter_counts,
|
| 28 |
+
_resolve_module_data,
|
| 29 |
+
_topic_name_set,
|
| 30 |
+
detect_year_range,
|
| 31 |
+
scan_available_modules,
|
| 32 |
+
)
|
| 33 |
+
from dartlab.ai.context.formatting import (
|
| 34 |
+
_compute_derived_metrics,
|
| 35 |
+
_filter_key_accounts,
|
| 36 |
+
_format_usd,
|
| 37 |
+
_format_won,
|
| 38 |
+
_get_sector, # noqa: F401 โ re-export for runtime/core.py
|
| 39 |
+
df_to_markdown,
|
| 40 |
+
)
|
| 41 |
+
from dartlab.ai.metadata import MODULE_META
|
| 42 |
+
|
| 43 |
+
_CONTEXT_ERRORS = (AttributeError, KeyError, OSError, RuntimeError, TypeError, ValueError)
|
| 44 |
+
|
| 45 |
+
_ROUTE_FINANCE_TYPES = frozenset({"๊ฑด์ ์ฑ", "์์ต์ฑ", "์ฑ์ฅ์ฑ", "์๋ณธ"})
|
| 46 |
+
_ROUTE_SECTIONS_TYPES = frozenset({"์ฌ์
", "๋ฆฌ์คํฌ", "๊ณต์"})
|
| 47 |
+
_ROUTE_REPORT_KEYWORDS: dict[str, str] = {
|
| 48 |
+
"๋ฐฐ๋น": "dividend",
|
| 49 |
+
"์ง์": "employee",
|
| 50 |
+
"์์": "executive",
|
| 51 |
+
"์ต๋์ฃผ์ฃผ": "majorHolder",
|
| 52 |
+
"์ฃผ์ฃผ": "majorHolder",
|
| 53 |
+
"๊ฐ์ฌ": "audit",
|
| 54 |
+
"์๊ธฐ์ฃผ์": "treasuryStock",
|
| 55 |
+
}
|
| 56 |
+
_ROUTE_SECTIONS_KEYWORDS = frozenset(
|
| 57 |
+
{
|
| 58 |
+
"๊ณต์",
|
| 59 |
+
"์ฌ์
",
|
| 60 |
+
"๋ฆฌ์คํฌ",
|
| 61 |
+
"๊ด๊ณ์ฌ",
|
| 62 |
+
"์ง๋ฐฐ๊ตฌ์กฐ",
|
| 63 |
+
"๊ทผ๊ฑฐ",
|
| 64 |
+
"๋ณํ",
|
| 65 |
+
"์ต๊ทผ ๊ณต์",
|
| 66 |
+
"๋ฌด์จ ์ฌ์
",
|
| 67 |
+
"๋ญํ๋",
|
| 68 |
+
"์ด๋ค ํ์ฌ",
|
| 69 |
+
"ESG",
|
| 70 |
+
"ํ๊ฒฝ",
|
| 71 |
+
"์ฌํ์ ์ฑ
์",
|
| 72 |
+
"ํ์",
|
| 73 |
+
"๊ธฐํ",
|
| 74 |
+
"๊ณต๊ธ๋ง",
|
| 75 |
+
"๊ณต๊ธ์ฌ",
|
| 76 |
+
"๊ณ ๊ฐ ์ง์ค",
|
| 77 |
+
"๋ณํ ๊ฐ์ง",
|
| 78 |
+
"๋ฌด์์ด ๋ฌ๋ผ",
|
| 79 |
+
"๊ณต์ ๋ณ๊ฒฝ",
|
| 80 |
+
}
|
| 81 |
+
)
|
| 82 |
+
_ROUTE_HYBRID_KEYWORDS = frozenset({"์ข
ํฉ", "์ ๋ฐ", "์ ์ฒด", "๋น๊ต", "๋ฐธ๋ฅ์์ด์
", "์ ์ ์ฃผ๊ฐ", "๋ชฉํ๊ฐ", "DCF"})
|
| 83 |
+
_ROUTE_FINANCE_KEYWORDS = frozenset(
|
| 84 |
+
{
|
| 85 |
+
"์ฌ๋ฌด",
|
| 86 |
+
"์์
์ด์ต",
|
| 87 |
+
"์์
์ด์ต๋ฅ ",
|
| 88 |
+
"๋งค์ถ",
|
| 89 |
+
"์์ด์ต",
|
| 90 |
+
"์ค์ ",
|
| 91 |
+
"ํ๊ธํ๋ฆ",
|
| 92 |
+
"๋ถ์ฑ",
|
| 93 |
+
"์์ฐ",
|
| 94 |
+
"์์ต์ฑ",
|
| 95 |
+
"๊ฑด์ ์ฑ",
|
| 96 |
+
"์ฑ์ฅ์ฑ",
|
| 97 |
+
"์ด์ต๋ฅ ",
|
| 98 |
+
"๋ง์ง",
|
| 99 |
+
"revenue",
|
| 100 |
+
"profit",
|
| 101 |
+
"margin",
|
| 102 |
+
"cash flow",
|
| 103 |
+
"cashflow",
|
| 104 |
+
"debt",
|
| 105 |
+
"asset",
|
| 106 |
+
}
|
| 107 |
+
)
|
| 108 |
+
_ROUTE_REPORT_FINANCE_HINTS = frozenset(
|
| 109 |
+
{
|
| 110 |
+
"์ง์ ๊ฐ๋ฅ",
|
| 111 |
+
"์ง์๊ฐ๋ฅ",
|
| 112 |
+
"์ง์์ฑ",
|
| 113 |
+
"ํ๊ธํ๋ฆ",
|
| 114 |
+
"ํ๊ธ",
|
| 115 |
+
"์ค์ ",
|
| 116 |
+
"์์
์ด์ต",
|
| 117 |
+
"์์ด์ต",
|
| 118 |
+
"์ปค๋ฒ",
|
| 119 |
+
"ํ๋จ",
|
| 120 |
+
"ํ๊ฐ",
|
| 121 |
+
"๊ฐ๋ฅํ์ง",
|
| 122 |
+
}
|
| 123 |
+
)
|
| 124 |
+
_ROUTE_DISTRESS_KEYWORDS = frozenset(
|
| 125 |
+
{
|
| 126 |
+
"๋ถ์ค",
|
| 127 |
+
"๋ถ์ค ์งํ",
|
| 128 |
+
"์๊ธฐ ์งํ",
|
| 129 |
+
"์ฌ๋ฌด ์๊ธฐ",
|
| 130 |
+
"์ ๋์ฑ ์๊ธฐ",
|
| 131 |
+
"์๊ธ ์๋ฐ",
|
| 132 |
+
"์ํ ๋ถ๋ด",
|
| 133 |
+
"์ด์๋ณด์",
|
| 134 |
+
"์กด์ ๊ฐ๋ฅ",
|
| 135 |
+
"going concern",
|
| 136 |
+
"distress",
|
| 137 |
+
}
|
| 138 |
+
)
|
| 139 |
+
_SUMMARY_REQUEST_KEYWORDS = frozenset({"์ข
ํฉ", "์ ๋ฐ", "์ ์ฒด", "์์ฝ", "๊ฐ๊ด", "ํ๋์"})
|
| 140 |
+
_QUARTERLY_HINTS = frozenset(
|
| 141 |
+
{
|
| 142 |
+
"๋ถ๊ธฐ",
|
| 143 |
+
"๋ถ๊ธฐ๋ณ",
|
| 144 |
+
"quarterly",
|
| 145 |
+
"quarter",
|
| 146 |
+
"Q1",
|
| 147 |
+
"Q2",
|
| 148 |
+
"Q3",
|
| 149 |
+
"Q4",
|
| 150 |
+
"1๋ถ๊ธฐ",
|
| 151 |
+
"2๋ถ๊ธฐ",
|
| 152 |
+
"3๋ถ๊ธฐ",
|
| 153 |
+
"4๋ถ๊ธฐ",
|
| 154 |
+
"๋ฐ๊ธฐ",
|
| 155 |
+
"๋ฐ๊ธฐ๋ณ",
|
| 156 |
+
"QoQ",
|
| 157 |
+
"์ ๋ถ๊ธฐ",
|
| 158 |
+
}
|
| 159 |
+
)
|
| 160 |
+
|
| 161 |
+
|
| 162 |
+
def _detectGranularity(question: str) -> str:
|
| 163 |
+
"""์ง๋ฌธ์์ ์๊ฐ ๋จ์ ๊ฐ์ง: 'quarterly' | 'annual'."""
|
| 164 |
+
if any(k in question for k in _QUARTERLY_HINTS):
|
| 165 |
+
return "quarterly"
|
| 166 |
+
return "annual"
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
_SECTIONS_TYPE_DEFAULTS: dict[str, list[str]] = {
|
| 170 |
+
"์ฌ์
": ["businessOverview", "productService", "salesOrder"],
|
| 171 |
+
"๋ฆฌ์คํฌ": ["riskDerivative", "contingentLiability", "internalControl"],
|
| 172 |
+
"๊ณต์": ["disclosureChanges", "subsequentEvents", "otherReference"],
|
| 173 |
+
"์ง๋ฐฐ๊ตฌ์กฐ": ["governanceOverview", "boardOfDirectors", "holderOverview"],
|
| 174 |
+
}
|
| 175 |
+
_SECTIONS_KEYWORD_TOPICS: dict[str, list[str]] = {
|
| 176 |
+
"๊ด๊ณ์ฌ": ["affiliateGroupDetail", "subsidiaryDetail", "investedCompany"],
|
| 177 |
+
"์ง๋ฐฐ๊ตฌ์กฐ": ["governanceOverview", "boardOfDirectors", "holderOverview"],
|
| 178 |
+
"๋ฌด์จ ์ฌ์
": ["businessOverview", "productService"],
|
| 179 |
+
"๋ญํ๋": ["businessOverview", "productService"],
|
| 180 |
+
"์ด๋ค ํ์ฌ": ["businessOverview", "companyHistory"],
|
| 181 |
+
"์ต๊ทผ ๊ณต์": ["disclosureChanges", "subsequentEvents"],
|
| 182 |
+
"๋ณํ": ["disclosureChanges", "businessStatus"],
|
| 183 |
+
"ESG": ["governanceOverview", "boardOfDirectors"],
|
| 184 |
+
"ํ๊ฒฝ": ["businessOverview"],
|
| 185 |
+
"๊ณต๊ธ๋ง": ["segments", "rawMaterial"],
|
| 186 |
+
"๊ณต๊ธ์ฌ": ["segments", "rawMaterial"],
|
| 187 |
+
"๋ณํ ๊ฐ์ง": ["disclosureChanges", "businessStatus"],
|
| 188 |
+
}
|
| 189 |
+
_FINANCIAL_ONLY = {"BS", "IS", "CF", "fsSummary", "ratios"}
|
| 190 |
+
_SECTIONS_ROUTE_EXCLUDE_TOPICS = {
|
| 191 |
+
"fsSummary",
|
| 192 |
+
"financialStatements",
|
| 193 |
+
"financialNotes",
|
| 194 |
+
"consolidatedStatements",
|
| 195 |
+
"consolidatedNotes",
|
| 196 |
+
"dividend",
|
| 197 |
+
"employee",
|
| 198 |
+
"majorHolder",
|
| 199 |
+
"audit",
|
| 200 |
+
}
|
| 201 |
+
_FINANCE_STATEMENT_MODULES = frozenset({"BS", "IS", "CF", "CIS", "SCE"})
|
| 202 |
+
_FINANCE_CONTEXT_MODULES = _FINANCE_STATEMENT_MODULES | {"ratios"}
|
| 203 |
+
_BALANCE_SHEET_HINTS = frozenset({"๋ถ์ฑ", "์์ฐ", "์ ๋", "์ฐจ์
", "์๋ณธ", "๋ ๋ฒ๋ฆฌ์ง", "๊ฑด์ ์ฑ", "์์ "})
|
| 204 |
+
_CASHFLOW_HINTS = frozenset({"ํ๊ธํ๋ฆ", "ํ๊ธ", "fcf", "์๊ธ", "์ปค๋ฒ", "๋ฐฐ๋น์ง๊ธ", "์ง์ ๊ฐ๋ฅ", "์ง์๊ฐ๋ฅ"})
|
| 205 |
+
_INCOME_STATEMENT_HINTS = frozenset(
|
| 206 |
+
{"๋งค์ถ", "์์
์ด์ต", "์์ด์ต", "์์ต", "๋ง์ง", "์ด์ต๋ฅ ", "์ค์ ", "์๊ฐ", "๋น์ฉ", "ํ๊ด๋น"}
|
| 207 |
+
)
|
| 208 |
+
_RATIO_HINTS = frozenset({"๋น์จ", "๋ง์ง", "์ด์ต๋ฅ ", "์์ต์ฑ", "๊ฑด์ ์ฑ", "์ฑ์ฅ์ฑ", "์์ ์ฑ", "์ง์ ๊ฐ๋ฅ", "์ง์๊ฐ๋ฅ"})
|
| 209 |
+
_DIRECT_HINT_MAP: dict[str, list[str]] = {
|
| 210 |
+
"์ฑ๊ฒฉ๋ณ ๋น์ฉ": ["costByNature"],
|
| 211 |
+
"๋น์ฉ์ ์ฑ๊ฒฉ": ["costByNature"],
|
| 212 |
+
"์ธ๊ฑด๋น": ["costByNature"],
|
| 213 |
+
"๊ฐ๊ฐ์๊ฐ": ["costByNature"],
|
| 214 |
+
"๊ด๊ณ ์ ์ ๋น": ["costByNature"],
|
| 215 |
+
"ํ๋งค์ด์ง๋น": ["costByNature"],
|
| 216 |
+
"์ง๊ธ์์๋ฃ": ["costByNature"],
|
| 217 |
+
"์ด๋ฐ๋น": ["costByNature"],
|
| 218 |
+
"๋ฌผ๋ฅ๋น": ["costByNature"],
|
| 219 |
+
"์ฐ๊ตฌ๊ฐ๋ฐ": ["rnd"],
|
| 220 |
+
"r&d": ["rnd"],
|
| 221 |
+
"์ธ๊ทธ๋จผํธ": ["segments"],
|
| 222 |
+
"๋ถ๋ฌธ์ ๋ณด": ["segments"],
|
| 223 |
+
"์ฌ์
๋ถ๋ฌธ": ["segments"],
|
| 224 |
+
"๋ถ๋ฌธ๋ณ": ["segments"],
|
| 225 |
+
"์ ํ๋ณ": ["productService"],
|
| 226 |
+
"์๋น์ค๋ณ": ["productService"],
|
| 227 |
+
}
|
| 228 |
+
_CANDIDATE_ALIASES = {
|
| 229 |
+
"segment": "segments",
|
| 230 |
+
"operationalAsset": "tangibleAsset",
|
| 231 |
+
}
|
| 232 |
+
_MARGIN_DRIVER_MARGIN_HINTS = frozenset({"์์
์ด์ต๋ฅ ", "๋ง์ง", "์ด์ต๋ฅ ", "margin"})
|
| 233 |
+
_MARGIN_DRIVER_COST_HINTS = frozenset({"๋น์ฉ ๊ตฌ์กฐ", "์๊ฐ ๊ตฌ์กฐ", "๋น์ฉ", "์๊ฐ", "ํ๊ด๋น", "๋งค์ถ์๊ฐ"})
|
| 234 |
+
_MARGIN_DRIVER_BUSINESS_HINTS = frozenset({"์ฌ์
๋ณํ", "์ฌ์
๋ณํ", "์ฌ์
๊ตฌ์กฐ", "์ฌ์
๊ตฌ์กฐ"})
|
| 235 |
+
_RECENT_DISCLOSURE_BUSINESS_HINTS = frozenset({"์ฌ์
๋ณํ", "์ฌ์
๋ณํ", "์ฌ์
๊ตฌ์กฐ", "์ฌ์
๊ตฌ์กฐ"})
|
| 236 |
+
_PERIOD_COLUMN_RE = re.compile(r"^\d{4}(?:Q[1-4])?$")
|
| 237 |
+
|
| 238 |
+
|
| 239 |
+
def _section_key_to_module_name(key: str) -> str:
|
| 240 |
+
if key.startswith("report_"):
|
| 241 |
+
return key.removeprefix("report_")
|
| 242 |
+
if key.startswith("module_"):
|
| 243 |
+
return key.removeprefix("module_")
|
| 244 |
+
if key.startswith("section_"):
|
| 245 |
+
return key.removeprefix("section_")
|
| 246 |
+
return key
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
def _module_name_to_section_keys(name: str) -> list[str]:
|
| 250 |
+
return [
|
| 251 |
+
name,
|
| 252 |
+
f"report_{name}",
|
| 253 |
+
f"module_{name}",
|
| 254 |
+
f"section_{name}",
|
| 255 |
+
]
|
| 256 |
+
|
| 257 |
+
|
| 258 |
+
def _build_module_section(name: str, data: Any, *, compact: bool, max_rows: int | None = None) -> str | None:
|
| 259 |
+
meta = MODULE_META.get(name)
|
| 260 |
+
label = meta.label if meta else name
|
| 261 |
+
max_rows_value = max_rows or (8 if compact else 15)
|
| 262 |
+
|
| 263 |
+
if isinstance(data, pl.DataFrame):
|
| 264 |
+
if data.is_empty():
|
| 265 |
+
return None
|
| 266 |
+
md = df_to_markdown(data, max_rows=max_rows_value, meta=meta, compact=True)
|
| 267 |
+
return f"\n## {label}\n{md}"
|
| 268 |
+
|
| 269 |
+
if isinstance(data, dict):
|
| 270 |
+
items = list(data.items())[:max_rows_value]
|
| 271 |
+
lines = [f"\n## {label}"]
|
| 272 |
+
lines.extend(f"- {k}: {v}" for k, v in items)
|
| 273 |
+
return "\n".join(lines)
|
| 274 |
+
|
| 275 |
+
if isinstance(data, list):
|
| 276 |
+
max_items = min(meta.maxRows if meta else 10, 5 if compact else 10)
|
| 277 |
+
lines = [f"\n## {label}"]
|
| 278 |
+
for item in data[:max_items]:
|
| 279 |
+
if hasattr(item, "title") and hasattr(item, "chars"):
|
| 280 |
+
lines.append(f"- **{item.title}** ({item.chars}์)")
|
| 281 |
+
else:
|
| 282 |
+
lines.append(f"- {item}")
|
| 283 |
+
if len(data) > max_items:
|
| 284 |
+
lines.append(f"(... ์์ {max_items}๊ฑด, ์ ์ฒด {len(data)}๊ฑด)")
|
| 285 |
+
return "\n".join(lines)
|
| 286 |
+
|
| 287 |
+
text = str(data).strip()
|
| 288 |
+
if not text:
|
| 289 |
+
return None
|
| 290 |
+
max_text = 500 if compact else 1000
|
| 291 |
+
return f"\n## {label}\n{text[:max_text]}"
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
def _resolve_context_route(
|
| 295 |
+
question: str,
|
| 296 |
+
*,
|
| 297 |
+
include: list[str] | None,
|
| 298 |
+
q_types: list[str],
|
| 299 |
+
) -> str:
|
| 300 |
+
if include:
|
| 301 |
+
return "hybrid"
|
| 302 |
+
|
| 303 |
+
if _detectGranularity(question) == "quarterly":
|
| 304 |
+
return "hybrid"
|
| 305 |
+
|
| 306 |
+
if _has_margin_driver_pattern(question):
|
| 307 |
+
return "hybrid"
|
| 308 |
+
|
| 309 |
+
if _has_distress_pattern(question):
|
| 310 |
+
return "finance"
|
| 311 |
+
|
| 312 |
+
if _has_recent_disclosure_business_pattern(question):
|
| 313 |
+
return "sections"
|
| 314 |
+
|
| 315 |
+
question_lower = question.lower()
|
| 316 |
+
q_set = set(q_types)
|
| 317 |
+
has_report = any(keyword in question for keyword in _ROUTE_REPORT_KEYWORDS)
|
| 318 |
+
has_sections = any(keyword in question for keyword in _ROUTE_SECTIONS_KEYWORDS) or bool(
|
| 319 |
+
q_set & _ROUTE_SECTIONS_TYPES
|
| 320 |
+
)
|
| 321 |
+
has_finance_keyword = any(keyword in question_lower for keyword in _ROUTE_FINANCE_KEYWORDS)
|
| 322 |
+
has_finance = has_finance_keyword or bool(q_set & _ROUTE_FINANCE_TYPES)
|
| 323 |
+
has_report_finance_hint = any(keyword in question for keyword in _ROUTE_REPORT_FINANCE_HINTS)
|
| 324 |
+
|
| 325 |
+
if has_report and (has_finance_keyword or has_sections or has_report_finance_hint):
|
| 326 |
+
return "hybrid"
|
| 327 |
+
|
| 328 |
+
for keyword in _ROUTE_REPORT_KEYWORDS:
|
| 329 |
+
if keyword in question:
|
| 330 |
+
return "report"
|
| 331 |
+
|
| 332 |
+
if has_sections:
|
| 333 |
+
return "sections"
|
| 334 |
+
|
| 335 |
+
if q_set and q_set.issubset(_ROUTE_FINANCE_TYPES):
|
| 336 |
+
return "finance"
|
| 337 |
+
|
| 338 |
+
if has_finance:
|
| 339 |
+
return "finance"
|
| 340 |
+
|
| 341 |
+
if q_set and len(q_set) > 1:
|
| 342 |
+
return "hybrid"
|
| 343 |
+
|
| 344 |
+
if q_set & {"์ข
ํฉ"}:
|
| 345 |
+
return "hybrid"
|
| 346 |
+
|
| 347 |
+
if any(keyword in question for keyword in _ROUTE_HYBRID_KEYWORDS):
|
| 348 |
+
return "hybrid"
|
| 349 |
+
|
| 350 |
+
return "finance" if q_set else "hybrid"
|
| 351 |
+
|
| 352 |
+
|
| 353 |
+
def _append_unique(items: list[str], value: str | None) -> None:
|
| 354 |
+
if value and value not in items:
|
| 355 |
+
items.append(value)
|
| 356 |
+
|
| 357 |
+
|
| 358 |
+
def _normalize_candidate_module(name: str) -> str:
|
| 359 |
+
return _CANDIDATE_ALIASES.get(name, name)
|
| 360 |
+
|
| 361 |
+
|
| 362 |
+
def _question_has_any(question: str, keywords: set[str] | frozenset[str]) -> bool:
|
| 363 |
+
lowered = question.lower()
|
| 364 |
+
return any(keyword.lower() in lowered for keyword in keywords)
|
| 365 |
+
|
| 366 |
+
|
| 367 |
+
def _has_distress_pattern(question: str) -> bool:
|
| 368 |
+
return _question_has_any(question, _ROUTE_DISTRESS_KEYWORDS)
|
| 369 |
+
|
| 370 |
+
|
| 371 |
+
def _has_margin_driver_pattern(question: str) -> bool:
|
| 372 |
+
return (
|
| 373 |
+
_question_has_any(question, _MARGIN_DRIVER_MARGIN_HINTS)
|
| 374 |
+
and _question_has_any(question, _MARGIN_DRIVER_COST_HINTS)
|
| 375 |
+
and _question_has_any(question, _MARGIN_DRIVER_BUSINESS_HINTS)
|
| 376 |
+
)
|
| 377 |
+
|
| 378 |
+
|
| 379 |
+
def _has_recent_disclosure_business_pattern(question: str) -> bool:
|
| 380 |
+
lowered = question.lower()
|
| 381 |
+
return "์ต๊ทผ ๊ณต์" in lowered and _question_has_any(question, _RECENT_DISCLOSURE_BUSINESS_HINTS)
|
| 382 |
+
|
| 383 |
+
|
| 384 |
+
def _resolve_direct_hint_modules(question: str) -> list[str]:
|
| 385 |
+
selected: list[str] = []
|
| 386 |
+
lowered = question.lower()
|
| 387 |
+
for keyword, modules in _DIRECT_HINT_MAP.items():
|
| 388 |
+
if keyword.lower() in lowered:
|
| 389 |
+
for module_name in modules:
|
| 390 |
+
_append_unique(selected, _normalize_candidate_module(module_name))
|
| 391 |
+
return selected
|
| 392 |
+
|
| 393 |
+
|
| 394 |
+
def _apply_question_specific_boosts(question: str, selected: list[str]) -> None:
|
| 395 |
+
if _has_distress_pattern(question):
|
| 396 |
+
for module_name in ("BS", "IS", "CF", "ratios"):
|
| 397 |
+
_append_unique(selected, module_name)
|
| 398 |
+
|
| 399 |
+
if _has_margin_driver_pattern(question):
|
| 400 |
+
for module_name in ("IS", "costByNature", "businessOverview", "productService"):
|
| 401 |
+
_append_unique(selected, module_name)
|
| 402 |
+
|
| 403 |
+
if _has_recent_disclosure_business_pattern(question):
|
| 404 |
+
for module_name in ("businessOverview", "productService"):
|
| 405 |
+
_append_unique(selected, module_name)
|
| 406 |
+
|
| 407 |
+
|
| 408 |
+
def _resolve_candidate_modules(
|
| 409 |
+
question: str,
|
| 410 |
+
*,
|
| 411 |
+
include: list[str] | None = None,
|
| 412 |
+
exclude: list[str] | None = None,
|
| 413 |
+
) -> list[str]:
|
| 414 |
+
selected: list[str] = []
|
| 415 |
+
|
| 416 |
+
if include:
|
| 417 |
+
for name in include:
|
| 418 |
+
_append_unique(selected, _normalize_candidate_module(name))
|
| 419 |
+
else:
|
| 420 |
+
for module_name in _resolve_direct_hint_modules(question):
|
| 421 |
+
_append_unique(selected, module_name)
|
| 422 |
+
|
| 423 |
+
for name in _resolve_tables(question, None, exclude):
|
| 424 |
+
_append_unique(selected, _normalize_candidate_module(name))
|
| 425 |
+
|
| 426 |
+
_apply_question_specific_boosts(question, selected)
|
| 427 |
+
|
| 428 |
+
if exclude:
|
| 429 |
+
excluded = {_normalize_candidate_module(name) for name in exclude}
|
| 430 |
+
selected = [name for name in selected if name not in excluded]
|
| 431 |
+
|
| 432 |
+
specific_modules = set(selected) - (_FINANCE_CONTEXT_MODULES | {"fsSummary"})
|
| 433 |
+
if specific_modules and not _question_has_any(question, _SUMMARY_REQUEST_KEYWORDS):
|
| 434 |
+
selected = [name for name in selected if name != "fsSummary"]
|
| 435 |
+
|
| 436 |
+
return selected
|
| 437 |
+
|
| 438 |
+
|
| 439 |
+
def _available_sections_topics(company: Any) -> set[str]:
|
| 440 |
+
docs = getattr(company, "docs", None)
|
| 441 |
+
sections = getattr(docs, "sections", None)
|
| 442 |
+
if sections is None:
|
| 443 |
+
return set()
|
| 444 |
+
|
| 445 |
+
manifest = sections.outline() if hasattr(sections, "outline") else None
|
| 446 |
+
if isinstance(manifest, pl.DataFrame) and "topic" in manifest.columns:
|
| 447 |
+
return {topic for topic in manifest["topic"].drop_nulls().to_list() if isinstance(topic, str) and topic}
|
| 448 |
+
|
| 449 |
+
if hasattr(sections, "topics"):
|
| 450 |
+
try:
|
| 451 |
+
return {topic for topic in sections.topics() if isinstance(topic, str) and topic}
|
| 452 |
+
except _CONTEXT_ERRORS:
|
| 453 |
+
return set()
|
| 454 |
+
return set()
|
| 455 |
+
|
| 456 |
+
|
| 457 |
+
def _available_report_modules(company: Any) -> set[str]:
|
| 458 |
+
report = getattr(company, "report", None)
|
| 459 |
+
if report is None:
|
| 460 |
+
return set()
|
| 461 |
+
|
| 462 |
+
for attr_name in ("availableApiTypes", "apiTypes"):
|
| 463 |
+
try:
|
| 464 |
+
values = getattr(report, attr_name, None)
|
| 465 |
+
except _CONTEXT_ERRORS:
|
| 466 |
+
values = None
|
| 467 |
+
if isinstance(values, list):
|
| 468 |
+
return {str(value) for value in values if isinstance(value, str) and value}
|
| 469 |
+
return set()
|
| 470 |
+
|
| 471 |
+
|
| 472 |
+
def _available_notes_modules(company: Any) -> set[str]:
|
| 473 |
+
notes = getattr(company, "notes", None)
|
| 474 |
+
if notes is None:
|
| 475 |
+
docs = getattr(company, "docs", None)
|
| 476 |
+
notes = getattr(docs, "notes", None) if docs is not None else None
|
| 477 |
+
if notes is None or not hasattr(notes, "keys"):
|
| 478 |
+
return set()
|
| 479 |
+
|
| 480 |
+
try:
|
| 481 |
+
return {str(value) for value in notes.keys() if isinstance(value, str) and value}
|
| 482 |
+
except _CONTEXT_ERRORS:
|
| 483 |
+
return set()
|
| 484 |
+
|
| 485 |
+
|
| 486 |
+
def _resolve_candidate_plan(
|
| 487 |
+
company: Any,
|
| 488 |
+
question: str,
|
| 489 |
+
*,
|
| 490 |
+
route: str,
|
| 491 |
+
include: list[str] | None = None,
|
| 492 |
+
exclude: list[str] | None = None,
|
| 493 |
+
) -> dict[str, list[str]]:
|
| 494 |
+
requested = _resolve_candidate_modules(question, include=include, exclude=exclude)
|
| 495 |
+
sections_set = _available_sections_topics(company) if route in {"sections", "hybrid"} else set()
|
| 496 |
+
report_set = _available_report_modules(company) if route in {"report", "hybrid"} else set()
|
| 497 |
+
notes_set = _available_notes_modules(company) if route == "hybrid" else set()
|
| 498 |
+
explicit_direct = set(_resolve_direct_hint_modules(question))
|
| 499 |
+
boosted_direct: list[str] = []
|
| 500 |
+
_apply_question_specific_boosts(question, boosted_direct)
|
| 501 |
+
explicit_direct.update(name for name in boosted_direct if name not in _FINANCE_CONTEXT_MODULES)
|
| 502 |
+
if include:
|
| 503 |
+
explicit_direct.update(_normalize_candidate_module(name) for name in include)
|
| 504 |
+
|
| 505 |
+
sections: list[str] = []
|
| 506 |
+
report: list[str] = []
|
| 507 |
+
finance: list[str] = []
|
| 508 |
+
direct: list[str] = []
|
| 509 |
+
verified: list[str] = []
|
| 510 |
+
|
| 511 |
+
for name in requested:
|
| 512 |
+
normalized = _normalize_candidate_module(name)
|
| 513 |
+
if normalized in _FINANCE_CONTEXT_MODULES:
|
| 514 |
+
if route in {"finance", "hybrid"}:
|
| 515 |
+
_append_unique(finance, normalized)
|
| 516 |
+
_append_unique(verified, normalized)
|
| 517 |
+
continue
|
| 518 |
+
if normalized in sections_set and normalized not in _SECTIONS_ROUTE_EXCLUDE_TOPICS:
|
| 519 |
+
_append_unique(sections, normalized)
|
| 520 |
+
_append_unique(verified, normalized)
|
| 521 |
+
continue
|
| 522 |
+
if normalized in report_set:
|
| 523 |
+
_append_unique(report, normalized)
|
| 524 |
+
_append_unique(verified, normalized)
|
| 525 |
+
continue
|
| 526 |
+
if normalized in notes_set and normalized in explicit_direct:
|
| 527 |
+
_append_unique(direct, normalized)
|
| 528 |
+
_append_unique(verified, normalized)
|
| 529 |
+
continue
|
| 530 |
+
|
| 531 |
+
if normalized in explicit_direct:
|
| 532 |
+
data = _resolve_module_data(company, normalized)
|
| 533 |
+
if data is not None:
|
| 534 |
+
_append_unique(direct, normalized)
|
| 535 |
+
_append_unique(verified, normalized)
|
| 536 |
+
|
| 537 |
+
return {
|
| 538 |
+
"requested": requested,
|
| 539 |
+
"sections": sections,
|
| 540 |
+
"report": report,
|
| 541 |
+
"finance": finance,
|
| 542 |
+
"direct": direct,
|
| 543 |
+
"verified": verified,
|
| 544 |
+
}
|
| 545 |
+
|
| 546 |
+
|
| 547 |
+
def _resolve_finance_modules_for_question(
|
| 548 |
+
question: str,
|
| 549 |
+
*,
|
| 550 |
+
q_types: list[str],
|
| 551 |
+
route: str,
|
| 552 |
+
candidate_plan: dict[str, list[str]],
|
| 553 |
+
) -> list[str]:
|
| 554 |
+
selected: list[str] = []
|
| 555 |
+
finance_candidates = [name for name in candidate_plan.get("finance", []) if name in _FINANCE_STATEMENT_MODULES]
|
| 556 |
+
|
| 557 |
+
if _has_margin_driver_pattern(question):
|
| 558 |
+
_append_unique(selected, "IS")
|
| 559 |
+
|
| 560 |
+
if route == "finance":
|
| 561 |
+
if _question_has_any(question, _INCOME_STATEMENT_HINTS):
|
| 562 |
+
_append_unique(selected, "IS")
|
| 563 |
+
if _question_has_any(question, _BALANCE_SHEET_HINTS):
|
| 564 |
+
_append_unique(selected, "BS")
|
| 565 |
+
if _question_has_any(question, _CASHFLOW_HINTS):
|
| 566 |
+
_append_unique(selected, "CF")
|
| 567 |
+
if not selected:
|
| 568 |
+
selected.extend(["IS", "BS", "CF"])
|
| 569 |
+
elif route == "hybrid":
|
| 570 |
+
has_finance_signal = bool(finance_candidates) and (
|
| 571 |
+
_question_has_any(question, _BALANCE_SHEET_HINTS | _CASHFLOW_HINTS | _RATIO_HINTS)
|
| 572 |
+
or bool(set(q_types) & _ROUTE_FINANCE_TYPES)
|
| 573 |
+
or any(name in candidate_plan.get("report", []) for name in ("dividend", "shareCapital"))
|
| 574 |
+
)
|
| 575 |
+
if not has_finance_signal:
|
| 576 |
+
return []
|
| 577 |
+
|
| 578 |
+
for module_name in finance_candidates:
|
| 579 |
+
_append_unique(selected, module_name)
|
| 580 |
+
|
| 581 |
+
if not selected:
|
| 582 |
+
if _question_has_any(question, _CASHFLOW_HINTS):
|
| 583 |
+
selected.extend(["IS", "CF"])
|
| 584 |
+
elif _question_has_any(question, _BALANCE_SHEET_HINTS):
|
| 585 |
+
selected.extend(["IS", "BS"])
|
| 586 |
+
else:
|
| 587 |
+
selected.append("IS")
|
| 588 |
+
|
| 589 |
+
if route == "finance" or _question_has_any(question, _RATIO_HINTS) or bool(set(q_types) & _ROUTE_FINANCE_TYPES):
|
| 590 |
+
_append_unique(selected, "ratios")
|
| 591 |
+
elif route == "hybrid" and {"dividend", "shareCapital"} & set(candidate_plan.get("report", [])):
|
| 592 |
+
_append_unique(selected, "ratios")
|
| 593 |
+
|
| 594 |
+
return selected
|
| 595 |
+
|
| 596 |
+
|
| 597 |
+
def _build_direct_module_context(
|
| 598 |
+
company: Any,
|
| 599 |
+
modules: list[str],
|
| 600 |
+
*,
|
| 601 |
+
compact: bool,
|
| 602 |
+
question: str,
|
| 603 |
+
) -> dict[str, str]:
|
| 604 |
+
result: dict[str, str] = {}
|
| 605 |
+
for name in modules:
|
| 606 |
+
try:
|
| 607 |
+
data = _resolve_module_data(company, name)
|
| 608 |
+
except _CONTEXT_ERRORS:
|
| 609 |
+
data = None
|
| 610 |
+
if data is None:
|
| 611 |
+
continue
|
| 612 |
+
if isinstance(data, pl.DataFrame):
|
| 613 |
+
data = _trim_period_columns(data, question, compact=compact)
|
| 614 |
+
section = _build_module_section(name, data, compact=compact)
|
| 615 |
+
if section:
|
| 616 |
+
result[name] = section
|
| 617 |
+
return result
|
| 618 |
+
|
| 619 |
+
|
| 620 |
+
def _trim_period_columns(data: pl.DataFrame, question: str, *, compact: bool) -> pl.DataFrame:
|
| 621 |
+
if data.is_empty():
|
| 622 |
+
return data
|
| 623 |
+
|
| 624 |
+
period_cols = [column for column in data.columns if isinstance(column, str) and _PERIOD_COLUMN_RE.fullmatch(column)]
|
| 625 |
+
if len(period_cols) <= 1:
|
| 626 |
+
return data
|
| 627 |
+
|
| 628 |
+
def sort_key(value: str) -> tuple[int, int]:
|
| 629 |
+
if "Q" in value:
|
| 630 |
+
year, quarter = value.split("Q", 1)
|
| 631 |
+
return int(year), int(quarter)
|
| 632 |
+
return int(value), 9
|
| 633 |
+
|
| 634 |
+
ordered_periods = sorted(period_cols, key=sort_key)
|
| 635 |
+
keep_periods = _detect_year_hint(question)
|
| 636 |
+
if compact:
|
| 637 |
+
keep_periods = min(keep_periods, 5)
|
| 638 |
+
else:
|
| 639 |
+
keep_periods = min(keep_periods, 8)
|
| 640 |
+
if len(ordered_periods) <= keep_periods:
|
| 641 |
+
return data
|
| 642 |
+
|
| 643 |
+
selected_periods = ordered_periods[-keep_periods:]
|
| 644 |
+
base_columns = [column for column in data.columns if column not in period_cols]
|
| 645 |
+
return data.select(base_columns + selected_periods)
|
| 646 |
+
|
| 647 |
+
|
| 648 |
+
def _build_response_contract(
|
| 649 |
+
question: str,
|
| 650 |
+
*,
|
| 651 |
+
included_modules: list[str],
|
| 652 |
+
route: str,
|
| 653 |
+
) -> str | None:
|
| 654 |
+
lines = ["## ์๋ต ๊ณ์ฝ", "- ์๋ ๋ชจ๋์ ์ด๋ฏธ ๋ก์ปฌ dartlab ๋ฐ์ดํฐ์์ ํ์ธ๋์ด ํฌํจ๋์์ต๋๋ค."]
|
| 655 |
+
lines.append(f"- ํฌํจ ๋ชจ๋: {', '.join(included_modules)}")
|
| 656 |
+
lines.append("- ํฌํจ๋ ๋ชจ๋์ ๋ณด๊ณ ๋ '๋ฐ์ดํฐ๊ฐ ์๋ค'๊ณ ๋งํ์ง ๋ง์ธ์.")
|
| 657 |
+
lines.append("- ํต์ฌ ๊ฒฐ๋ก 1~2๋ฌธ์ฅ์ ๋จผ์ ์ ์ํ๊ณ , ๋ฐ๋ก ๊ทผ๊ฑฐ ํ๋ ๊ทผ๊ฑฐ bullet์ ๋ถ์ด์ธ์.")
|
| 658 |
+
lines.append(
|
| 659 |
+
"- `explore()` ๊ฐ์ ๋๊ตฌ ํธ์ถ ๊ณํ์ด๋ ๋ด๋ถ ์ ์ฐจ ์ค๋ช
์ ๋ต๋ณ ๋ณธ๋ฌธ์ ์ฐ์ง ๋ง๊ณ ๋ฐ๋ก ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ๋งํ์ธ์."
|
| 660 |
+
)
|
| 661 |
+
lines.append(
|
| 662 |
+
"- ๋ต๋ณ ๋ณธ๋ฌธ์์๋ `IS/BS/CF/ratios/TTM/topic/period/source` ๊ฐ์ ๋ด๋ถ ์ฝ์ด๋ ํ๋๋ช
์ ๊ทธ๋๋ก ์ฐ์ง ๋ง๊ณ "
|
| 663 |
+
"`์์ต๊ณ์ฐ์/์ฌ๋ฌด์ํํ/ํ๊ธํ๋ฆํ/์ฌ๋ฌด๋น์จ/์ต๊ทผ 4๋ถ๊ธฐ ํฉ์ฐ/ํญ๋ชฉ/์์ /์ถ์ฒ`์ฒ๋ผ ์ฌ์ฉ์ ์ธ์ด๋ก ๋ฐ๊พธ์ธ์."
|
| 664 |
+
)
|
| 665 |
+
lines.append(
|
| 666 |
+
"- `costByNature`, `businessOverview`, `productService` ๊ฐ์ ๋ด๋ถ ๋ชจ๋๋ช
๋ ๊ฐ๊ฐ "
|
| 667 |
+
"`์ฑ๊ฒฉ๋ณ ๋น์ฉ ๋ถ๋ฅ`, `์ฌ์
์ ๊ฐ์`, `์ ํยท์๋น์ค`์ฒ๋ผ ๋ฐ๊ฟ ์ฐ์ธ์."
|
| 668 |
+
)
|
| 669 |
+
|
| 670 |
+
module_set = set(included_modules)
|
| 671 |
+
if "costByNature" in module_set:
|
| 672 |
+
lines.append("- `costByNature`๊ฐ ์์ผ๋ฉด ์์ ๋น์ฉ ํญ๋ชฉ 3~5๊ฐ์ ์ต๊ทผ ๊ธฐ๊ฐ ๋ณํ ๋ฐฉํฅ์ ๋จผ์ ์์ฝํ์ธ์.")
|
| 673 |
+
lines.append("- ๊ธฐ๊ฐ์ด ๋ช
์๋์ง ์์๋ ์ต์ ์์ ๊ณผ ์ต๊ทผ ์ถ์ธ๋ฅผ ๋จผ์ ๋ตํ๊ณ , ์ฐ๋ ๊ธฐ์ค์ ๋ค์ ๋ฌป์ง ๋ง์ธ์.")
|
| 674 |
+
if "dividend" in module_set:
|
| 675 |
+
lines.append("- `dividend`๊ฐ ์์ผ๋ฉด DPSยท๋ฐฐ๋น์์ต๋ฅ ยท๋ฐฐ๋น์ฑํฅ์ ๋จผ์ ์์ฝํ์ธ์.")
|
| 676 |
+
lines.append(
|
| 677 |
+
"- `dividend`๊ฐ ์๋๋ฐ๋ ๋ฐฐ๋น ๋ฐ์ดํฐ๊ฐ ์๋ค๊ณ ๋งํ์ง ๋ง์ธ์. ์ฒซ ๋ฌธ์ฅ์ด๋ ์ฒซ ํ์์ DPS์ ๋ฐฐ๋น์์ต๋ฅ ์ ์ง์ ์ธ์ฉํ์ธ์."
|
| 678 |
+
)
|
| 679 |
+
if {"dividend", "IS", "CF"} <= module_set or {"dividend", "CF"} <= module_set:
|
| 680 |
+
lines.append("- `dividend`์ `IS/CF`๊ฐ ๊ฐ์ด ์์ผ๋ฉด ๋ฐฐ๋น์ ์ด์ต/ํ๊ธํ๋ฆ ์ปค๋ฒ ์ฌ๋ถ๋ฅผ ํ ์ค๋ก ๋ช
์ํ์ธ์.")
|
| 681 |
+
if _has_distress_pattern(question):
|
| 682 |
+
lines.append(
|
| 683 |
+
"- `๋ถ์ค ์งํ` ์ง๋ฌธ์ด๋ฉด ๊ฑด์ ์ฑ ๊ฒฐ๋ก ์ ๋จผ์ ๋งํ๊ณ , ์์ต์ฑยทํ๊ธํ๋ฆยท์ฐจ์
๋ถ๋ด ์์ผ๋ก ์งง๊ฒ ์ ๋ฆฌํ์ธ์."
|
| 684 |
+
)
|
| 685 |
+
if route == "sections" or any(keyword in question for keyword in ("๊ทผ๊ฑฐ", "์", "์ต๊ทผ ๊ณต์ ๊ธฐ์ค", "์ถ์ฒ")):
|
| 686 |
+
lines.append("- ๊ทผ๊ฑฐ ์ง๋ฌธ์ด๋ฉด `topic`, `period`, `source`๋ฅผ ์ต์ 2๊ฐ ๋ช
์ํ์ธ์.")
|
| 687 |
+
lines.append(
|
| 688 |
+
"- `period`์ `source`๋ outline ํ์ ๋์จ ์ค์ ๊ฐ์ ์ฐ์ธ์. '์ต๊ทผ ๊ณต์ ๊ธฐ์ค' ๊ฐ์ ํฌ๊ด ํํ์ผ๋ก ๋ญ๊ฐ์ง ๋ง์ธ์."
|
| 689 |
+
)
|
| 690 |
+
lines.append("- ๋ณธ๋ฌธ์์๋ `topic/period/source` ๋์ `ํญ๋ชฉ/์์ /์ถ์ฒ`์ฒ๋ผ ์์ฐ์ด๋ฅผ ์ฐ์ธ์.")
|
| 691 |
+
hasQuarterly = any(m.endswith("_quarterly") for m in module_set)
|
| 692 |
+
if hasQuarterly:
|
| 693 |
+
lines.append("- **๋ถ๊ธฐ๋ณ ๋ฐ์ดํฐ๊ฐ ํฌํจ๋์์ต๋๋ค. '๋ถ๊ธฐ ๋ฐ์ดํฐ๊ฐ ์๋ค'๊ณ ์ ๋ ๋งํ์ง ๋ง์ธ์.**")
|
| 694 |
+
lines.append("- ๋ถ๊ธฐ๋ณ ์ถ์ด๋ฅผ ํ
์ด๋ธ๋ก ์ ๋ฆฌํ๊ณ , ์ ๋ถ๊ธฐ ๋๋น(QoQ)์ ์ ๋
๋๊ธฐ ๋๋น(YoY) ๋ณํ๋ฅผ ํจ๊ป ๋ณด์ฌ์ฃผ์ธ์.")
|
| 695 |
+
lines.append(
|
| 696 |
+
"- `IS_quarterly`, `CF_quarterly` ๊ฐ์ ๋ด๋ถ๋ช
๋์ `๋ถ๊ธฐ๋ณ ์์ต๊ณ์ฐ์`, `๋ถ๊ธฐ๋ณ ํ๊ธํ๋ฆํ`๋ก ์ฐ์ธ์."
|
| 697 |
+
)
|
| 698 |
+
|
| 699 |
+
# โโ ๋๊ตฌ ์ถ์ฒ ํํธ โโ
|
| 700 |
+
hasFinancial = {"IS", "BS"} <= module_set or {"IS", "CF"} <= module_set
|
| 701 |
+
if hasFinancial:
|
| 702 |
+
lines.append(
|
| 703 |
+
"- **์ถ๊ฐ ๋ถ์ ์ถ์ฒ**: `finance(action='ratios')`๋ก ์ฌ๋ฌด๋น์จ ํ์ธ, "
|
| 704 |
+
"`explore(action='search', keyword='...')`๋ก ๋ณํ ์์ธ ํ์
."
|
| 705 |
+
)
|
| 706 |
+
elif not module_set & {"IS", "BS", "CF", "ratios"}:
|
| 707 |
+
lines.append(
|
| 708 |
+
"- **์ฌ๋ฌด ๋ฐ์ดํฐ ๋ฏธํฌํจ**: `finance(action='modules')`๋ก ์ฌ์ฉ ๊ฐ๋ฅ ๋ชจ๋ ํ์ธ, "
|
| 709 |
+
"`explore(action='topics')`๋ก topic ๋ชฉ๋ก ํ์ธ ์ถ์ฒ."
|
| 710 |
+
)
|
| 711 |
+
return "\n".join(lines)
|
| 712 |
+
|
| 713 |
+
|
| 714 |
+
def _build_clarification_context(
|
| 715 |
+
company: Any,
|
| 716 |
+
question: str,
|
| 717 |
+
*,
|
| 718 |
+
candidate_plan: dict[str, list[str]],
|
| 719 |
+
) -> str | None:
|
| 720 |
+
if _has_margin_driver_pattern(question):
|
| 721 |
+
return None
|
| 722 |
+
|
| 723 |
+
lowered = question.lower()
|
| 724 |
+
module_set = set(candidate_plan.get("verified", []))
|
| 725 |
+
has_cost_by_nature = "costByNature" in module_set
|
| 726 |
+
if not has_cost_by_nature and "costByNature" in set(candidate_plan.get("requested", [])):
|
| 727 |
+
try:
|
| 728 |
+
has_cost_by_nature = _resolve_module_data(company, "costByNature") is not None
|
| 729 |
+
except _CONTEXT_ERRORS:
|
| 730 |
+
has_cost_by_nature = False
|
| 731 |
+
has_is = "IS" in module_set or "IS" in set(candidate_plan.get("requested", []))
|
| 732 |
+
if not has_cost_by_nature or not has_is:
|
| 733 |
+
return None
|
| 734 |
+
if "๋น์ฉ" not in lowered:
|
| 735 |
+
return None
|
| 736 |
+
if any(keyword in lowered for keyword in ("์ฑ๊ฒฉ", "์ธ๊ฑด๋น", "๊ฐ๊ฐ์๊ฐ", "๊ด๊ณ ์ ์ ", "ํ๊ด", "๋งค์ถ์๊ฐ")):
|
| 737 |
+
return None
|
| 738 |
+
|
| 739 |
+
return (
|
| 740 |
+
"## Clarification Needed\n"
|
| 741 |
+
"- ํ์ฌ ๋ก์ปฌ์์ ๋ ํด์์ด ๋ชจ๋ ๊ฐ๋ฅํฉ๋๋ค.\n"
|
| 742 |
+
"- `costByNature`: ์ธ๊ฑด๋นยท๊ฐ๊ฐ์๊ฐ๋น ๊ฐ์ ์ฑ๊ฒฉ๋ณ ๋น์ฉ ๋ถ๋ฅ\n"
|
| 743 |
+
"- `IS`: ๋งค์ถ์๊ฐยทํ๊ด๋น ๊ฐ์ ๊ธฐ๋ฅ๋ณ ๋น์ฉ ์ด์ก\n"
|
| 744 |
+
"- ์ฌ์ฉ์์ ์๋๊ฐ ๋ ์ค ์ด๋ ์ชฝ์ธ์ง ๊ฒฐ๋ก ์ ๋ฐ๊พธ๋ฏ๋ก, ๋จผ์ ํ ๋ฌธ์ฅ์ผ๋ก ์ด๋ ๊ด์ ์ ์ํ๋์ง ํ์ธํ์ธ์.\n"
|
| 745 |
+
"- ํ์ธ ์ง๋ฌธ์ ํ ๋ฌธ์ฅ๋ง ํ์ธ์. ๊ฐ์ ๋ฌธ์ฅ์ ๋ฐ๋ณตํ์ง ๋ง์ธ์."
|
| 746 |
+
)
|
| 747 |
+
|
| 748 |
+
|
| 749 |
+
def _resolve_report_modules_for_question(
|
| 750 |
+
question: str,
|
| 751 |
+
*,
|
| 752 |
+
include: list[str] | None = None,
|
| 753 |
+
exclude: list[str] | None = None,
|
| 754 |
+
) -> list[str]:
|
| 755 |
+
modules: list[str] = []
|
| 756 |
+
|
| 757 |
+
for keyword, name in _ROUTE_REPORT_KEYWORDS.items():
|
| 758 |
+
if keyword in question and name not in modules:
|
| 759 |
+
modules.append(name)
|
| 760 |
+
|
| 761 |
+
if include:
|
| 762 |
+
for name in include:
|
| 763 |
+
if (
|
| 764 |
+
name in {"dividend", "employee", "majorHolder", "executive", "audit", "treasuryStock"}
|
| 765 |
+
and name not in modules
|
| 766 |
+
):
|
| 767 |
+
modules.append(name)
|
| 768 |
+
|
| 769 |
+
if exclude:
|
| 770 |
+
modules = [name for name in modules if name not in exclude]
|
| 771 |
+
|
| 772 |
+
return modules
|
| 773 |
+
|
| 774 |
+
|
| 775 |
+
def _resolve_sections_topics(
|
| 776 |
+
company: Any,
|
| 777 |
+
question: str,
|
| 778 |
+
*,
|
| 779 |
+
q_types: list[str],
|
| 780 |
+
candidates: list[str] | None = None,
|
| 781 |
+
include: list[str] | None = None,
|
| 782 |
+
exclude: list[str] | None = None,
|
| 783 |
+
limit: int = 2,
|
| 784 |
+
) -> list[str]:
|
| 785 |
+
docs = getattr(company, "docs", None)
|
| 786 |
+
sections = getattr(docs, "sections", None)
|
| 787 |
+
if sections is None:
|
| 788 |
+
return []
|
| 789 |
+
|
| 790 |
+
manifest = sections.outline() if hasattr(sections, "outline") else None
|
| 791 |
+
available = (
|
| 792 |
+
manifest["topic"].drop_nulls().to_list()
|
| 793 |
+
if isinstance(manifest, pl.DataFrame) and "topic" in manifest.columns
|
| 794 |
+
else sections.topics()
|
| 795 |
+
if hasattr(sections, "topics")
|
| 796 |
+
else []
|
| 797 |
+
)
|
| 798 |
+
availableTopics = [topic for topic in available if isinstance(topic, str) and topic]
|
| 799 |
+
availableSet = set(availableTopics)
|
| 800 |
+
if not availableSet:
|
| 801 |
+
return []
|
| 802 |
+
|
| 803 |
+
selected: list[str] = []
|
| 804 |
+
isQuarterly = _detectGranularity(question) == "quarterly"
|
| 805 |
+
|
| 806 |
+
def append(topic: str) -> None:
|
| 807 |
+
if topic in _SECTIONS_ROUTE_EXCLUDE_TOPICS:
|
| 808 |
+
if not (isQuarterly and topic == "fsSummary"):
|
| 809 |
+
return
|
| 810 |
+
if topic in availableSet and topic not in selected:
|
| 811 |
+
selected.append(topic)
|
| 812 |
+
|
| 813 |
+
if isQuarterly:
|
| 814 |
+
append("fsSummary")
|
| 815 |
+
|
| 816 |
+
if include:
|
| 817 |
+
for name in include:
|
| 818 |
+
append(name)
|
| 819 |
+
|
| 820 |
+
if _has_recent_disclosure_business_pattern(question):
|
| 821 |
+
append("disclosureChanges")
|
| 822 |
+
append("businessOverview")
|
| 823 |
+
|
| 824 |
+
candidate_source = _resolve_tables(question, None, exclude) if candidates is None else candidates
|
| 825 |
+
for name in candidate_source:
|
| 826 |
+
append(name)
|
| 827 |
+
|
| 828 |
+
for q_type in q_types:
|
| 829 |
+
for topic in _SECTIONS_TYPE_DEFAULTS.get(q_type, []):
|
| 830 |
+
append(topic)
|
| 831 |
+
|
| 832 |
+
for keyword, topics in _SECTIONS_KEYWORD_TOPICS.items():
|
| 833 |
+
if keyword in question:
|
| 834 |
+
for topic in topics:
|
| 835 |
+
append(topic)
|
| 836 |
+
|
| 837 |
+
if candidates is None and not selected and availableTopics:
|
| 838 |
+
selected.append(availableTopics[0])
|
| 839 |
+
|
| 840 |
+
return selected[:limit]
|
| 841 |
+
|
| 842 |
+
|
| 843 |
+
def _build_sections_context(
|
| 844 |
+
company: Any,
|
| 845 |
+
topics: list[str],
|
| 846 |
+
*,
|
| 847 |
+
compact: bool,
|
| 848 |
+
) -> dict[str, str]:
|
| 849 |
+
docs = getattr(company, "docs", None)
|
| 850 |
+
sections = getattr(docs, "sections", None)
|
| 851 |
+
if sections is None:
|
| 852 |
+
return {}
|
| 853 |
+
|
| 854 |
+
try:
|
| 855 |
+
context_slices = getattr(docs, "contextSlices", None) if docs is not None else None
|
| 856 |
+
except _CONTEXT_ERRORS:
|
| 857 |
+
context_slices = None
|
| 858 |
+
|
| 859 |
+
result: dict[str, str] = {}
|
| 860 |
+
for topic in topics:
|
| 861 |
+
outline = sections.outline(topic) if hasattr(sections, "outline") else None
|
| 862 |
+
if outline is None or not isinstance(outline, pl.DataFrame) or outline.is_empty():
|
| 863 |
+
continue
|
| 864 |
+
|
| 865 |
+
label_fn = getattr(company, "_topicLabel", None)
|
| 866 |
+
label = label_fn(topic) if callable(label_fn) else topic
|
| 867 |
+
lines = [f"\n## {label}"]
|
| 868 |
+
lines.append(df_to_markdown(outline.head(6 if compact else 10), max_rows=6 if compact else 10, compact=True))
|
| 869 |
+
|
| 870 |
+
topic_slices = _select_section_slices(context_slices, topic)
|
| 871 |
+
if isinstance(topic_slices, pl.DataFrame) and not topic_slices.is_empty():
|
| 872 |
+
lines.append("\n### ํต์ฌ ๊ทผ๊ฑฐ")
|
| 873 |
+
for row in topic_slices.head(2 if compact else 4).iter_rows(named=True):
|
| 874 |
+
period = row.get("period", "-")
|
| 875 |
+
source_topic = row.get("sourceTopic") or row.get("topic") or topic
|
| 876 |
+
block_type = "ํ" if row.get("isTable") or row.get("blockType") == "table" else "๋ฌธ์ฅ"
|
| 877 |
+
slice_text = _truncate_section_slice(str(row.get("sliceText") or ""), compact=compact)
|
| 878 |
+
if not slice_text:
|
| 879 |
+
continue
|
| 880 |
+
lines.append(f"#### ์์ : {period} | ์ถ์ฒ: {source_topic} | ์ ํ: {block_type}")
|
| 881 |
+
lines.append(slice_text)
|
| 882 |
+
|
| 883 |
+
if compact:
|
| 884 |
+
if ("preview" in outline.columns) and not (
|
| 885 |
+
isinstance(topic_slices, pl.DataFrame) and not topic_slices.is_empty()
|
| 886 |
+
):
|
| 887 |
+
preview_lines: list[str] = []
|
| 888 |
+
for row in outline.head(2).iter_rows(named=True):
|
| 889 |
+
preview = row.get("preview")
|
| 890 |
+
if not isinstance(preview, str) or not preview.strip():
|
| 891 |
+
continue
|
| 892 |
+
period = row.get("period", "-")
|
| 893 |
+
title = row.get("title", "-")
|
| 894 |
+
preview_lines.append(
|
| 895 |
+
f"- period: {period} | source: docs | title: {title} | preview: {preview.strip()}"
|
| 896 |
+
)
|
| 897 |
+
if preview_lines:
|
| 898 |
+
lines.append("\n### ํต์ฌ preview")
|
| 899 |
+
lines.extend(preview_lines)
|
| 900 |
+
result[f"section_{topic}"] = "\n".join(lines)
|
| 901 |
+
continue
|
| 902 |
+
|
| 903 |
+
try:
|
| 904 |
+
raw_sections = sections.raw if hasattr(sections, "raw") else None
|
| 905 |
+
except _CONTEXT_ERRORS:
|
| 906 |
+
raw_sections = None
|
| 907 |
+
|
| 908 |
+
topic_rows = (
|
| 909 |
+
raw_sections.filter(pl.col("topic") == topic)
|
| 910 |
+
if isinstance(raw_sections, pl.DataFrame) and "topic" in raw_sections.columns
|
| 911 |
+
else None
|
| 912 |
+
)
|
| 913 |
+
|
| 914 |
+
block_builder = getattr(company, "_buildBlockIndex", None)
|
| 915 |
+
block_index = (
|
| 916 |
+
block_builder(topic_rows) if callable(block_builder) and isinstance(topic_rows, pl.DataFrame) else None
|
| 917 |
+
)
|
| 918 |
+
|
| 919 |
+
if isinstance(block_index, pl.DataFrame) and not block_index.is_empty():
|
| 920 |
+
lines.append("\n### block index")
|
| 921 |
+
lines.append(
|
| 922 |
+
df_to_markdown(block_index.head(4 if compact else 6), max_rows=4 if compact else 6, compact=True)
|
| 923 |
+
)
|
| 924 |
+
|
| 925 |
+
block_col = (
|
| 926 |
+
"block"
|
| 927 |
+
if "block" in block_index.columns
|
| 928 |
+
else "blockOrder"
|
| 929 |
+
if "blockOrder" in block_index.columns
|
| 930 |
+
else None
|
| 931 |
+
)
|
| 932 |
+
type_col = (
|
| 933 |
+
"type" if "type" in block_index.columns else "blockType" if "blockType" in block_index.columns else None
|
| 934 |
+
)
|
| 935 |
+
sample_block = None
|
| 936 |
+
if block_col:
|
| 937 |
+
for row in block_index.iter_rows(named=True):
|
| 938 |
+
block_no = row.get(block_col)
|
| 939 |
+
block_type = row.get(type_col)
|
| 940 |
+
if isinstance(block_no, int) and block_type in {"text", "table"}:
|
| 941 |
+
sample_block = block_no
|
| 942 |
+
break
|
| 943 |
+
if sample_block is not None:
|
| 944 |
+
show_section_block = getattr(company, "_showSectionBlock", None)
|
| 945 |
+
block_data = (
|
| 946 |
+
show_section_block(topic_rows, block=sample_block)
|
| 947 |
+
if callable(show_section_block) and isinstance(topic_rows, pl.DataFrame)
|
| 948 |
+
else None
|
| 949 |
+
)
|
| 950 |
+
section = _build_module_section(topic, block_data, compact=compact, max_rows=4 if compact else 6)
|
| 951 |
+
if section:
|
| 952 |
+
lines.append("\n### ๋ํ block")
|
| 953 |
+
lines.append(section.replace(f"\n## {label}", "", 1).strip())
|
| 954 |
+
|
| 955 |
+
result[f"section_{topic}"] = "\n".join(lines)
|
| 956 |
+
|
| 957 |
+
return result
|
| 958 |
+
|
| 959 |
+
|
| 960 |
+
def _select_section_slices(context_slices: Any, topic: str) -> pl.DataFrame | None:
|
| 961 |
+
if not isinstance(context_slices, pl.DataFrame) or context_slices.is_empty():
|
| 962 |
+
return None
|
| 963 |
+
|
| 964 |
+
required_columns = {"topic", "periodOrder", "sliceText"}
|
| 965 |
+
if not required_columns <= set(context_slices.columns):
|
| 966 |
+
return None
|
| 967 |
+
|
| 968 |
+
detail_col = pl.col("detailTopic") if "detailTopic" in context_slices.columns else pl.lit(None)
|
| 969 |
+
semantic_col = pl.col("semanticTopic") if "semanticTopic" in context_slices.columns else pl.lit(None)
|
| 970 |
+
block_priority_col = pl.col("blockPriority") if "blockPriority" in context_slices.columns else pl.lit(0)
|
| 971 |
+
slice_idx_col = pl.col("sliceIdx") if "sliceIdx" in context_slices.columns else pl.lit(0)
|
| 972 |
+
|
| 973 |
+
matched = context_slices.filter((pl.col("topic") == topic) | (detail_col == topic) | (semantic_col == topic))
|
| 974 |
+
if matched.is_empty():
|
| 975 |
+
return None
|
| 976 |
+
|
| 977 |
+
return matched.with_columns(
|
| 978 |
+
pl.when(detail_col == topic)
|
| 979 |
+
.then(3)
|
| 980 |
+
.when(semantic_col == topic)
|
| 981 |
+
.then(2)
|
| 982 |
+
.when(pl.col("topic") == topic)
|
| 983 |
+
.then(1)
|
| 984 |
+
.otherwise(0)
|
| 985 |
+
.alias("matchPriority")
|
| 986 |
+
).sort(
|
| 987 |
+
["periodOrder", "matchPriority", "blockPriority", "sliceIdx"],
|
| 988 |
+
descending=[True, True, True, False],
|
| 989 |
+
)
|
| 990 |
+
|
| 991 |
+
|
| 992 |
+
def _truncate_section_slice(text: str, *, compact: bool) -> str:
|
| 993 |
+
stripped = text.strip()
|
| 994 |
+
if not stripped:
|
| 995 |
+
return ""
|
| 996 |
+
max_chars = 500 if compact else 1200
|
| 997 |
+
if len(stripped) <= max_chars:
|
| 998 |
+
return stripped
|
| 999 |
+
return stripped[:max_chars].rstrip() + " ..."
|
| 1000 |
+
|
| 1001 |
+
|
| 1002 |
+
def build_context_by_module(
|
| 1003 |
+
company: Any,
|
| 1004 |
+
question: str,
|
| 1005 |
+
include: list[str] | None = None,
|
| 1006 |
+
exclude: list[str] | None = None,
|
| 1007 |
+
compact: bool = False,
|
| 1008 |
+
) -> tuple[dict[str, str], list[str], str]:
|
| 1009 |
+
"""financeEngine ์ฐ์ compact ์ปจํ
์คํธ ๋น๋ (๋ชจ๋๋ณ ๋ถ๋ฆฌ).
|
| 1010 |
+
|
| 1011 |
+
1์ฐจ: financeEngine annual + ratios (๋น ๋ฅด๊ณ ์ ๊ทํ๋ ์์น)
|
| 1012 |
+
2์ฐจ: docsParser ์ ์ฑ ๋ฐ์ดํฐ (๋ฐฐ๋น, ๊ฐ์ฌ, ์์ ๋ฑ โ ์ง๋ฌธ์ ๋ง๋ ๊ฒ๋ง)
|
| 1013 |
+
|
| 1014 |
+
Args:
|
| 1015 |
+
compact: True๋ฉด ์ํ ๋ชจ๋ธ์ฉ์ผ๋ก ์ฐ๋/ํ์ ์ ํ (Ollama).
|
| 1016 |
+
|
| 1017 |
+
Returns:
|
| 1018 |
+
(modules_dict, included_list, header_text)
|
| 1019 |
+
- modules_dict: {"IS": "## ์์ต๊ณ์ฐ์\n...", "BS": "...", ...}
|
| 1020 |
+
- included_list: ["IS", "BS", "CF", "ratios", ...]
|
| 1021 |
+
- header_text: ๊ธฐ์
๋ช
+ ๋ฐ์ดํฐ ๊ธฐ์ค ๋ผ์ธ
|
| 1022 |
+
"""
|
| 1023 |
+
from dartlab import config
|
| 1024 |
+
|
| 1025 |
+
orig_verbose = config.verbose
|
| 1026 |
+
config.verbose = False
|
| 1027 |
+
try:
|
| 1028 |
+
return _build_compact_context_modules_inner(company, question, include, exclude, compact, orig_verbose)
|
| 1029 |
+
finally:
|
| 1030 |
+
config.verbose = orig_verbose
|
| 1031 |
+
|
| 1032 |
+
|
| 1033 |
+
def _build_compact_context_modules_inner(
|
| 1034 |
+
company: Any,
|
| 1035 |
+
question: str,
|
| 1036 |
+
include: list[str] | None,
|
| 1037 |
+
exclude: list[str] | None,
|
| 1038 |
+
compact: bool,
|
| 1039 |
+
orig_verbose: bool,
|
| 1040 |
+
) -> tuple[dict[str, str], list[str], str]:
|
| 1041 |
+
n_years = _detect_year_hint(question)
|
| 1042 |
+
if compact:
|
| 1043 |
+
n_years = min(n_years, 4)
|
| 1044 |
+
modules_dict: dict[str, str] = {}
|
| 1045 |
+
included: list[str] = []
|
| 1046 |
+
|
| 1047 |
+
header_parts = [f"# {company.corpName} ({company.stockCode})"]
|
| 1048 |
+
|
| 1049 |
+
try:
|
| 1050 |
+
detail = getattr(company, "companyOverviewDetail", None)
|
| 1051 |
+
if detail and isinstance(detail, dict):
|
| 1052 |
+
info_parts = []
|
| 1053 |
+
if detail.get("ceo"):
|
| 1054 |
+
info_parts.append(f"๋ํ: {detail['ceo']}")
|
| 1055 |
+
if detail.get("mainBusiness"):
|
| 1056 |
+
info_parts.append(f"์ฃผ์์ฌ์
: {detail['mainBusiness']}")
|
| 1057 |
+
if info_parts:
|
| 1058 |
+
header_parts.append("> " + " | ".join(info_parts))
|
| 1059 |
+
except _CONTEXT_ERRORS:
|
| 1060 |
+
pass
|
| 1061 |
+
|
| 1062 |
+
from dartlab.ai.conversation.prompts import _classify_question_multi
|
| 1063 |
+
|
| 1064 |
+
q_types = _classify_question_multi(question, max_types=2)
|
| 1065 |
+
route = _resolve_context_route(question, include=include, q_types=q_types)
|
| 1066 |
+
report_modules = _resolve_report_modules_for_question(question, include=include, exclude=exclude)
|
| 1067 |
+
candidate_plan = _resolve_candidate_plan(company, question, route=route, include=include, exclude=exclude)
|
| 1068 |
+
selected_finance_modules = _resolve_finance_modules_for_question(
|
| 1069 |
+
question,
|
| 1070 |
+
q_types=q_types,
|
| 1071 |
+
route=route,
|
| 1072 |
+
candidate_plan=candidate_plan,
|
| 1073 |
+
)
|
| 1074 |
+
|
| 1075 |
+
acct_filters: dict[str, set[str]] = {}
|
| 1076 |
+
if compact:
|
| 1077 |
+
for qt in q_types:
|
| 1078 |
+
for sj, ids in _QUESTION_ACCOUNT_FILTER.get(qt, {}).items():
|
| 1079 |
+
acct_filters.setdefault(sj, set()).update(ids)
|
| 1080 |
+
|
| 1081 |
+
statement_modules = [name for name in selected_finance_modules if name in _FINANCE_STATEMENT_MODULES]
|
| 1082 |
+
if statement_modules:
|
| 1083 |
+
annual = getattr(company, "annual", None)
|
| 1084 |
+
if annual is not None:
|
| 1085 |
+
series, years = annual
|
| 1086 |
+
quarter_counts = _get_quarter_counts(company)
|
| 1087 |
+
if years:
|
| 1088 |
+
yr_min = years[max(0, len(years) - n_years)]
|
| 1089 |
+
yr_max = years[-1]
|
| 1090 |
+
header = f"\n**๋ฐ์ดํฐ ๊ธฐ์ค: {yr_min}~{yr_max}๋
** (๊ฐ์ฅ ์ต๊ทผ: {yr_max}๋
, ๊ธ์ก: ์ต/์กฐ์)\n"
|
| 1091 |
+
|
| 1092 |
+
partial = [y for y in years[-n_years:] if quarter_counts.get(y, 4) < 4]
|
| 1093 |
+
if partial:
|
| 1094 |
+
notes = ", ".join(f"{y}๋
=Q1~Q{quarter_counts[y]}" for y in partial)
|
| 1095 |
+
header += (
|
| 1096 |
+
f"โ ๏ธ **๋ถ๋ถ ์ฐ๋ ์ฃผ์**: {notes} (ํด๋น ์ฐ๋๋ ๋ถ๊ธฐ ๋์ ์ด๋ฏ๋ก ์ ๋
์ฐ๊ฐ๊ณผ ์ง์ ๋น๊ต ๋ถ๊ฐ)\n"
|
| 1097 |
+
)
|
| 1098 |
+
|
| 1099 |
+
header_parts.append(header)
|
| 1100 |
+
|
| 1101 |
+
for sj in statement_modules:
|
| 1102 |
+
af = acct_filters.get(sj) if acct_filters and sj in {"IS", "BS", "CF"} else None
|
| 1103 |
+
section = _build_finance_engine_section(
|
| 1104 |
+
series,
|
| 1105 |
+
years,
|
| 1106 |
+
sj,
|
| 1107 |
+
n_years,
|
| 1108 |
+
af,
|
| 1109 |
+
quarter_counts=quarter_counts,
|
| 1110 |
+
)
|
| 1111 |
+
if section:
|
| 1112 |
+
modules_dict[sj] = section
|
| 1113 |
+
included.append(sj)
|
| 1114 |
+
|
| 1115 |
+
if _detectGranularity(question) == "quarterly" and statement_modules:
|
| 1116 |
+
ts = getattr(company, "timeseries", None)
|
| 1117 |
+
if ts is not None:
|
| 1118 |
+
tsSeries, tsPeriods = ts
|
| 1119 |
+
for sj in statement_modules:
|
| 1120 |
+
if sj in {"IS", "CF"}:
|
| 1121 |
+
af = acct_filters.get(sj) if acct_filters else None
|
| 1122 |
+
qSection = _buildQuarterlySection(
|
| 1123 |
+
tsSeries,
|
| 1124 |
+
tsPeriods,
|
| 1125 |
+
sj,
|
| 1126 |
+
nQuarters=8,
|
| 1127 |
+
accountFilter=af,
|
| 1128 |
+
)
|
| 1129 |
+
if qSection:
|
| 1130 |
+
qKey = f"{sj}_quarterly"
|
| 1131 |
+
modules_dict[qKey] = qSection
|
| 1132 |
+
included.append(qKey)
|
| 1133 |
+
|
| 1134 |
+
if "ratios" in selected_finance_modules:
|
| 1135 |
+
ratios_section = _build_ratios_section(company, compact=compact, q_types=q_types or None)
|
| 1136 |
+
if ratios_section:
|
| 1137 |
+
modules_dict["ratios"] = ratios_section
|
| 1138 |
+
if "ratios" not in included:
|
| 1139 |
+
included.append("ratios")
|
| 1140 |
+
|
| 1141 |
+
requested_report_modules = report_modules or candidate_plan.get("report", [])
|
| 1142 |
+
if route == "report":
|
| 1143 |
+
requested_report_modules = requested_report_modules or [
|
| 1144 |
+
"dividend",
|
| 1145 |
+
"employee",
|
| 1146 |
+
"majorHolder",
|
| 1147 |
+
"executive",
|
| 1148 |
+
"audit",
|
| 1149 |
+
]
|
| 1150 |
+
report_sections = _build_report_sections(
|
| 1151 |
+
company,
|
| 1152 |
+
compact=compact,
|
| 1153 |
+
q_types=q_types,
|
| 1154 |
+
tier="focused" if compact else "full",
|
| 1155 |
+
report_names=requested_report_modules,
|
| 1156 |
+
)
|
| 1157 |
+
for key, section in report_sections.items():
|
| 1158 |
+
modules_dict[key] = section
|
| 1159 |
+
included_name = _section_key_to_module_name(key)
|
| 1160 |
+
if included_name not in included:
|
| 1161 |
+
included.append(included_name)
|
| 1162 |
+
|
| 1163 |
+
if route == "hybrid" and requested_report_modules:
|
| 1164 |
+
report_sections = _build_report_sections(
|
| 1165 |
+
company,
|
| 1166 |
+
compact=compact,
|
| 1167 |
+
q_types=q_types,
|
| 1168 |
+
tier="focused" if compact else "full",
|
| 1169 |
+
report_names=requested_report_modules,
|
| 1170 |
+
)
|
| 1171 |
+
for key, section in report_sections.items():
|
| 1172 |
+
modules_dict[key] = section
|
| 1173 |
+
included_name = _section_key_to_module_name(key)
|
| 1174 |
+
if included_name not in included:
|
| 1175 |
+
included.append(included_name)
|
| 1176 |
+
|
| 1177 |
+
if route in {"sections", "hybrid"}:
|
| 1178 |
+
topics = _resolve_sections_topics(
|
| 1179 |
+
company,
|
| 1180 |
+
question,
|
| 1181 |
+
q_types=q_types,
|
| 1182 |
+
candidates=candidate_plan.get("sections"),
|
| 1183 |
+
include=include,
|
| 1184 |
+
exclude=exclude,
|
| 1185 |
+
limit=1 if route == "hybrid" else 2,
|
| 1186 |
+
)
|
| 1187 |
+
sections_context = _build_sections_context(company, topics, compact=compact)
|
| 1188 |
+
for key, section in sections_context.items():
|
| 1189 |
+
modules_dict[key] = section
|
| 1190 |
+
included_name = _section_key_to_module_name(key)
|
| 1191 |
+
if included_name not in included:
|
| 1192 |
+
included.append(included_name)
|
| 1193 |
+
|
| 1194 |
+
if route == "finance":
|
| 1195 |
+
_financeSectionsTopics = ["businessStatus", "businessOverview"]
|
| 1196 |
+
availableTopicSet = _topic_name_set(company)
|
| 1197 |
+
lightTopics = [t for t in _financeSectionsTopics if t in availableTopicSet]
|
| 1198 |
+
if lightTopics:
|
| 1199 |
+
lightContext = _build_sections_context(company, lightTopics[:1], compact=True)
|
| 1200 |
+
for key, section in lightContext.items():
|
| 1201 |
+
modules_dict[key] = section
|
| 1202 |
+
included_name = _section_key_to_module_name(key)
|
| 1203 |
+
if included_name not in included:
|
| 1204 |
+
included.append(included_name)
|
| 1205 |
+
|
| 1206 |
+
direct_sections = _build_direct_module_context(
|
| 1207 |
+
company,
|
| 1208 |
+
candidate_plan.get("direct", []),
|
| 1209 |
+
compact=compact,
|
| 1210 |
+
question=question,
|
| 1211 |
+
)
|
| 1212 |
+
for key, section in direct_sections.items():
|
| 1213 |
+
modules_dict[key] = section
|
| 1214 |
+
if key not in included:
|
| 1215 |
+
included.append(key)
|
| 1216 |
+
|
| 1217 |
+
response_contract = _build_response_contract(question, included_modules=included, route=route)
|
| 1218 |
+
if response_contract:
|
| 1219 |
+
modules_dict["_response_contract"] = response_contract
|
| 1220 |
+
|
| 1221 |
+
clarification_context = _build_clarification_context(company, question, candidate_plan=candidate_plan)
|
| 1222 |
+
if clarification_context:
|
| 1223 |
+
modules_dict["_clarify"] = clarification_context
|
| 1224 |
+
|
| 1225 |
+
if not modules_dict:
|
| 1226 |
+
text, inc = build_context(company, question, include, exclude, compact=True)
|
| 1227 |
+
return {"_full": text}, inc, ""
|
| 1228 |
+
|
| 1229 |
+
deduped_included: list[str] = []
|
| 1230 |
+
for name in included:
|
| 1231 |
+
if name not in deduped_included:
|
| 1232 |
+
deduped_included.append(name)
|
| 1233 |
+
|
| 1234 |
+
return modules_dict, deduped_included, "\n".join(header_parts)
|
| 1235 |
+
|
| 1236 |
+
|
| 1237 |
+
def build_compact_context(
|
| 1238 |
+
company: Any,
|
| 1239 |
+
question: str,
|
| 1240 |
+
include: list[str] | None = None,
|
| 1241 |
+
exclude: list[str] | None = None,
|
| 1242 |
+
) -> tuple[str, list[str]]:
|
| 1243 |
+
"""financeEngine ์ฐ์ compact ์ปจํ
์คํธ ๋น๋ (ํ์ํธํ).
|
| 1244 |
+
|
| 1245 |
+
build_context_by_module ๊ฒฐ๊ณผ๋ฅผ ๋จ์ผ ๋ฌธ์์ด๋ก ํฉ์ณ ๋ฐํํ๋ค.
|
| 1246 |
+
"""
|
| 1247 |
+
modules_dict, included, header = build_context_by_module(
|
| 1248 |
+
company,
|
| 1249 |
+
question,
|
| 1250 |
+
include,
|
| 1251 |
+
exclude,
|
| 1252 |
+
compact=True,
|
| 1253 |
+
)
|
| 1254 |
+
if "_full" in modules_dict:
|
| 1255 |
+
return modules_dict["_full"], included
|
| 1256 |
+
|
| 1257 |
+
parts = [header] if header else []
|
| 1258 |
+
for name in included:
|
| 1259 |
+
for key in _module_name_to_section_keys(name):
|
| 1260 |
+
if key in modules_dict:
|
| 1261 |
+
parts.append(modules_dict[key])
|
| 1262 |
+
break
|
| 1263 |
+
return "\n".join(parts), included
|
| 1264 |
+
|
| 1265 |
+
|
| 1266 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 1267 |
+
# ์ง๋ฌธ ํค์๋ โ ์๋ ํฌํจ ๋ฐ์ดํฐ ๋งคํ
|
| 1268 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 1269 |
+
|
| 1270 |
+
from dartlab.core.registry import buildKeywordMap
|
| 1271 |
+
|
| 1272 |
+
# registry aiKeywords ์๋ ์ญ์ธ๋ฑ์ค (~55 ๋ชจ๋ ํค์๋)
|
| 1273 |
+
_KEYWORD_MAP = buildKeywordMap()
|
| 1274 |
+
|
| 1275 |
+
# ์ฌ๋ฌด์ ํ ์ง์ ๋งคํ (registry ๋ฒ์ ๋ฐ โ BS/IS/CF ๋ฑ ์ฌ๋ฌด ์ฝ๋)
|
| 1276 |
+
_FINANCIAL_MAP: dict[str, list[str]] = {
|
| 1277 |
+
"์ฌ๋ฌด": ["BS", "IS", "CF", "fsSummary", "costByNature"],
|
| 1278 |
+
"๊ฑด์ ์ฑ": ["BS", "audit", "contingentLiability", "internalControl", "bond"],
|
| 1279 |
+
"์์ต": ["IS", "segments", "productService", "costByNature"],
|
| 1280 |
+
"์ค์ ": ["IS", "segments", "fsSummary", "productService", "salesOrder"],
|
| 1281 |
+
"๋งค์ถ": ["IS", "segments", "productService", "salesOrder"],
|
| 1282 |
+
"์์
์ด์ต": ["IS", "fsSummary", "segments"],
|
| 1283 |
+
"์์ด์ต": ["IS", "fsSummary"],
|
| 1284 |
+
"ํ๊ธ": ["CF", "BS"],
|
| 1285 |
+
"์์ฐ": ["BS", "tangibleAsset", "investmentInOther"],
|
| 1286 |
+
"์ฑ์ฅ": ["IS", "CF", "productService", "salesOrder", "rnd"],
|
| 1287 |
+
"์๊ฐ": ["costByNature", "IS"],
|
| 1288 |
+
"๋น์ฉ": ["costByNature", "IS"],
|
| 1289 |
+
"๋ฐฐ๋น": ["dividend", "IS", "shareCapital"],
|
| 1290 |
+
"์๋ณธ": ["BS", "capitalChange", "shareCapital", "fundraising"],
|
| 1291 |
+
"ํฌ์": ["CF", "rnd", "subsidiary", "investmentInOther", "tangibleAsset"],
|
| 1292 |
+
"๋ถ์ฑ": ["BS", "bond", "contingentLiability", "capitalChange"],
|
| 1293 |
+
"๋ฆฌ์คํฌ": ["contingentLiability", "sanction", "riskDerivative", "audit", "internalControl"],
|
| 1294 |
+
"์ง๋ฐฐ": ["majorHolder", "executive", "boardOfDirectors", "holderOverview"],
|
| 1295 |
+
}
|
| 1296 |
+
|
| 1297 |
+
# ๋ณตํฉ ๋ถ์ (์ฌ๋ฌ ์ฌ๋ฌด์ ํ ์กฐํฉ)
|
| 1298 |
+
_COMPOSITE_MAP: dict[str, list[str]] = {
|
| 1299 |
+
"ROE": ["IS", "BS", "fsSummary"],
|
| 1300 |
+
"ROA": ["IS", "BS", "fsSummary"],
|
| 1301 |
+
"PER": ["IS", "fsSummary", "dividend"],
|
| 1302 |
+
"PBR": ["BS", "fsSummary"],
|
| 1303 |
+
"EPS": ["IS", "fsSummary", "dividend"],
|
| 1304 |
+
"EBITDA": ["IS", "CF", "fsSummary"],
|
| 1305 |
+
"ESG": ["employee", "boardOfDirectors", "sanction", "internalControl"],
|
| 1306 |
+
"๊ฑฐ๋ฒ๋์ค": ["majorHolder", "executive", "boardOfDirectors", "audit"],
|
| 1307 |
+
"์ง๋ฐฐ๊ตฌ์กฐ": ["majorHolder", "executive", "boardOfDirectors", "audit"],
|
| 1308 |
+
"์ธ๋ ฅํํฉ": ["employee", "executivePay"],
|
| 1309 |
+
"์ฃผ์ฃผํ์": ["dividend", "shareCapital", "capitalChange"],
|
| 1310 |
+
"๋ถ์ฑ์ํ": ["BS", "bond", "contingentLiability"],
|
| 1311 |
+
"๋ถ์ฑ๊ตฌ์กฐ": ["BS", "bond", "contingentLiability"],
|
| 1312 |
+
"์ข
ํฉ์ง๋จ": ["BS", "IS", "CF", "fsSummary", "dividend", "majorHolder", "audit", "employee"],
|
| 1313 |
+
"์ค์บ": ["BS", "IS", "dividend", "majorHolder", "audit", "employee"],
|
| 1314 |
+
"์ ๋ฐ": ["BS", "IS", "CF", "fsSummary", "audit", "majorHolder"],
|
| 1315 |
+
"์ข
ํฉ": ["BS", "IS", "CF", "fsSummary", "audit", "majorHolder"],
|
| 1316 |
+
# ์๋ฌธ
|
| 1317 |
+
"revenue": ["IS", "segments", "productService"],
|
| 1318 |
+
"profit": ["IS", "fsSummary"],
|
| 1319 |
+
"debt": ["BS", "bond", "contingentLiability"],
|
| 1320 |
+
"cash flow": ["CF"],
|
| 1321 |
+
"cashflow": ["CF"],
|
| 1322 |
+
"dividend": ["dividend", "IS", "shareCapital"],
|
| 1323 |
+
"growth": ["IS", "CF", "productService", "rnd"],
|
| 1324 |
+
"risk": ["contingentLiability", "sanction", "riskDerivative", "audit"],
|
| 1325 |
+
"audit": ["audit", "auditSystem", "internalControl"],
|
| 1326 |
+
"governance": ["majorHolder", "executive", "boardOfDirectors"],
|
| 1327 |
+
"employee": ["employee", "executivePay"],
|
| 1328 |
+
"subsidiary": ["subsidiary", "affiliateGroup", "investmentInOther"],
|
| 1329 |
+
"capex": ["CF", "tangibleAsset"],
|
| 1330 |
+
"operating": ["IS", "fsSummary", "segments"],
|
| 1331 |
+
}
|
| 1332 |
+
|
| 1333 |
+
# ์์ฐ์ด ์ง๋ฌธ ํจํด
|
| 1334 |
+
_NATURAL_LANG_MAP: dict[str, list[str]] = {
|
| 1335 |
+
"๋": ["BS", "CF"],
|
| 1336 |
+
"๋ฒ": ["IS", "fsSummary"],
|
| 1337 |
+
"์": ["IS", "fsSummary", "segments"],
|
| 1338 |
+
"์ํ": ["contingentLiability", "sanction", "riskDerivative", "audit", "internalControl"],
|
| 1339 |
+
"์์ ": ["BS", "audit", "contingentLiability", "internalControl"],
|
| 1340 |
+
"๊ฑด๊ฐ": ["BS", "IS", "CF", "audit"],
|
| 1341 |
+
"์ ๋ง": ["IS", "CF", "rnd", "segments", "mdna"],
|
| 1342 |
+
"๋น๊ต": ["IS", "BS", "CF", "fsSummary"],
|
| 1343 |
+
"์ถ์ธ": ["IS", "BS", "CF", "fsSummary"],
|
| 1344 |
+
"ํธ๋ ๋": ["IS", "BS", "CF", "fsSummary"],
|
| 1345 |
+
"๋ถ์": ["BS", "IS", "CF", "fsSummary"],
|
| 1346 |
+
"์ด๋ค ํ์ฌ": ["companyOverviewDetail", "companyOverview", "business", "companyHistory"],
|
| 1347 |
+
"๋ฌด์จ ์ฌ์
": ["business", "productService", "segments", "companyOverviewDetail"],
|
| 1348 |
+
"๋ญํ๋": ["business", "productService", "segments", "companyOverviewDetail"],
|
| 1349 |
+
"์ด๋ค ์ฌ์
": ["business", "productService", "segments", "companyOverviewDetail"],
|
| 1350 |
+
}
|
| 1351 |
+
|
| 1352 |
+
# ๋ณํฉ: registry ํค์๋ โ ์ฌ๋ฌด์ ํ โ ๋ณตํฉ โ ์์ฐ์ด (ํ์์๊ฐ ์ค๋ฒ๋ผ์ด๋)
|
| 1353 |
+
_TOPIC_MAP: dict[str, list[str]] = {**_KEYWORD_MAP, **_FINANCIAL_MAP, **_COMPOSITE_MAP, **_NATURAL_LANG_MAP}
|
| 1354 |
+
|
| 1355 |
+
# ํญ์ ํฌํจ๋๋ ๊ธฐ๋ณธ ์ปจํ
์คํธ
|
| 1356 |
+
_BASE_CONTEXT = ["fsSummary"]
|
| 1357 |
+
|
| 1358 |
+
|
| 1359 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 1360 |
+
# ํ ํฝ ๋งคํ
|
| 1361 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 1362 |
+
|
| 1363 |
+
|
| 1364 |
+
def _resolve_tables(question: str, include: list[str] | None, exclude: list[str] | None) -> list[str]:
|
| 1365 |
+
"""์ง๋ฌธ๊ณผ include/exclude๋ก ํฌํจํ ํ
์ด๋ธ ๋ชฉ๋ก ๊ฒฐ์ .
|
| 1366 |
+
|
| 1367 |
+
๊ฐ์ : ๋์๋ฌธ์ ๋ฌด์, ๋ถ๋ถ๋งค์นญ, ๋ณตํฉ ํค์๋ ์ง์.
|
| 1368 |
+
"""
|
| 1369 |
+
tables: list[str] = list(_BASE_CONTEXT)
|
| 1370 |
+
|
| 1371 |
+
if include:
|
| 1372 |
+
tables.extend(include)
|
| 1373 |
+
else:
|
| 1374 |
+
q_lower = question.lower()
|
| 1375 |
+
matched_count = 0
|
| 1376 |
+
|
| 1377 |
+
for keyword, table_names in _TOPIC_MAP.items():
|
| 1378 |
+
# ๋์๋ฌธ์ ๋ฌด์ ๋งค์นญ
|
| 1379 |
+
if keyword.lower() in q_lower:
|
| 1380 |
+
matched_count += 1
|
| 1381 |
+
for t in table_names:
|
| 1382 |
+
if t not in tables:
|
| 1383 |
+
tables.append(t)
|
| 1384 |
+
|
| 1385 |
+
# ๋งคํ ์ ๋์ผ๋ฉด ๊ธฐ๋ณธ ์ฌ๋ฌด์ ํ ํฌํจ
|
| 1386 |
+
if matched_count == 0:
|
| 1387 |
+
tables.extend(["BS", "IS", "CF"])
|
| 1388 |
+
|
| 1389 |
+
# ๋๋ฌด ๋ง์ ๋ชจ๋์ด ๋งค์นญ๋๋ฉด ์์ ์ฐ์ ์์๋ง (ํ ํฐ ์ ์ฝ)
|
| 1390 |
+
# ํต์ฌ ๋ชจ๋(BS/IS/CF/fsSummary)์ ํญ์ ์ ์ง
|
| 1391 |
+
_CORE = {"fsSummary", "BS", "IS", "CF"}
|
| 1392 |
+
if len(tables) > 12:
|
| 1393 |
+
core = [t for t in tables if t in _CORE]
|
| 1394 |
+
non_core = [t for t in tables if t not in _CORE]
|
| 1395 |
+
tables = core + non_core[:8]
|
| 1396 |
+
|
| 1397 |
+
if exclude:
|
| 1398 |
+
tables = [t for t in tables if t not in exclude]
|
| 1399 |
+
|
| 1400 |
+
return tables
|
| 1401 |
+
|
| 1402 |
+
|
| 1403 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 1404 |
+
# ์ปจํ
์คํธ ์กฐ๋ฆฝ
|
| 1405 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 1406 |
+
|
| 1407 |
+
|
| 1408 |
+
def build_context(
|
| 1409 |
+
company: Any,
|
| 1410 |
+
question: str,
|
| 1411 |
+
include: list[str] | None = None,
|
| 1412 |
+
exclude: list[str] | None = None,
|
| 1413 |
+
max_rows: int = 30,
|
| 1414 |
+
compact: bool = False,
|
| 1415 |
+
) -> tuple[str, list[str]]:
|
| 1416 |
+
"""์ง๋ฌธ๊ณผ Company ์ธ์คํด์ค๋ก๋ถํฐ LLM context ํ
์คํธ ์กฐ๋ฆฝ.
|
| 1417 |
+
|
| 1418 |
+
Args:
|
| 1419 |
+
compact: True๋ฉด ํต์ฌ ๊ณ์ ๋ง, ์ต/์กฐ ๋จ์, ๊ฐ๊ฒฐ ํฌ๋งท (์ํ ๋ชจ๋ธ์ฉ).
|
| 1420 |
+
|
| 1421 |
+
Returns:
|
| 1422 |
+
(context_text, included_table_names)
|
| 1423 |
+
"""
|
| 1424 |
+
from dartlab.ai.context.formatting import _KEY_ACCOUNTS_MAP
|
| 1425 |
+
|
| 1426 |
+
tables_to_include = _resolve_tables(question, include, exclude)
|
| 1427 |
+
|
| 1428 |
+
# fsSummary ์ค๋ณต ์ ๊ฑฐ: BS+IS ๋ ๋ค ์์ผ๋ฉด fsSummary ์คํต
|
| 1429 |
+
if compact and "fsSummary" in tables_to_include:
|
| 1430 |
+
has_bs = "BS" in tables_to_include
|
| 1431 |
+
has_is = "IS" in tables_to_include
|
| 1432 |
+
if has_bs and has_is:
|
| 1433 |
+
tables_to_include = [t for t in tables_to_include if t != "fsSummary"]
|
| 1434 |
+
|
| 1435 |
+
from dartlab import config
|
| 1436 |
+
|
| 1437 |
+
orig_verbose = config.verbose
|
| 1438 |
+
config.verbose = False
|
| 1439 |
+
|
| 1440 |
+
sections = []
|
| 1441 |
+
included = []
|
| 1442 |
+
|
| 1443 |
+
sections.append(f"# {company.corpName} ({company.stockCode})")
|
| 1444 |
+
|
| 1445 |
+
try:
|
| 1446 |
+
detail = getattr(company, "companyOverviewDetail", None)
|
| 1447 |
+
if detail and isinstance(detail, dict):
|
| 1448 |
+
info_parts = []
|
| 1449 |
+
if detail.get("ceo"):
|
| 1450 |
+
info_parts.append(f"๋ํ: {detail['ceo']}")
|
| 1451 |
+
if detail.get("mainBusiness"):
|
| 1452 |
+
info_parts.append(f"์ฃผ์์ฌ์
: {detail['mainBusiness']}")
|
| 1453 |
+
if detail.get("foundedDate"):
|
| 1454 |
+
info_parts.append(f"์ค๋ฆฝ: {detail['foundedDate']}")
|
| 1455 |
+
if info_parts:
|
| 1456 |
+
sections.append("> " + " | ".join(info_parts))
|
| 1457 |
+
except _CONTEXT_ERRORS:
|
| 1458 |
+
pass
|
| 1459 |
+
|
| 1460 |
+
year_range = detect_year_range(company, tables_to_include)
|
| 1461 |
+
if year_range:
|
| 1462 |
+
sections.append(
|
| 1463 |
+
f"\n**๋ฐ์ดํฐ ๊ธฐ์ค: {year_range['min_year']}~{year_range['max_year']}๋
** (๊ฐ์ฅ ์ต๊ทผ: {year_range['max_year']}๋
)"
|
| 1464 |
+
)
|
| 1465 |
+
if not compact:
|
| 1466 |
+
sections.append("์ดํ ๋ฐ์ดํฐ๋ ํฌํจ๋์ด ์์ง ์์ต๋๋ค.\n")
|
| 1467 |
+
|
| 1468 |
+
if compact:
|
| 1469 |
+
sections.append("\n๊ธ์ก: ์ต/์กฐ์ ํ์ (์๋ณธ ๋ฐฑ๋ง์)\n")
|
| 1470 |
+
else:
|
| 1471 |
+
sections.append("")
|
| 1472 |
+
sections.append("๋ชจ๋ ๊ธ์ก์ ๋ณ๋ ํ๊ธฐ ์์ผ๋ฉด ๋ฐฑ๋ง์(millions KRW) ๋จ์์
๋๋ค.")
|
| 1473 |
+
sections.append("")
|
| 1474 |
+
|
| 1475 |
+
for name in tables_to_include:
|
| 1476 |
+
try:
|
| 1477 |
+
data = getattr(company, name, None)
|
| 1478 |
+
if data is None:
|
| 1479 |
+
continue
|
| 1480 |
+
|
| 1481 |
+
if callable(data) and not isinstance(data, type):
|
| 1482 |
+
try:
|
| 1483 |
+
result = data()
|
| 1484 |
+
if hasattr(result, "FS") and isinstance(getattr(result, "FS", None), pl.DataFrame):
|
| 1485 |
+
data = result.FS
|
| 1486 |
+
elif isinstance(result, pl.DataFrame):
|
| 1487 |
+
data = result
|
| 1488 |
+
else:
|
| 1489 |
+
data = result
|
| 1490 |
+
except _CONTEXT_ERRORS:
|
| 1491 |
+
continue
|
| 1492 |
+
|
| 1493 |
+
meta = MODULE_META.get(name)
|
| 1494 |
+
label = meta.label if meta else name
|
| 1495 |
+
desc = meta.description if meta else ""
|
| 1496 |
+
|
| 1497 |
+
section_parts = [f"\n## {label}"]
|
| 1498 |
+
if not compact and desc:
|
| 1499 |
+
section_parts.append(desc)
|
| 1500 |
+
|
| 1501 |
+
if isinstance(data, pl.DataFrame):
|
| 1502 |
+
display_df = data
|
| 1503 |
+
if compact and name in _KEY_ACCOUNTS_MAP:
|
| 1504 |
+
display_df = _filter_key_accounts(data, name)
|
| 1505 |
+
|
| 1506 |
+
md = df_to_markdown(display_df, max_rows=max_rows, meta=meta, compact=compact)
|
| 1507 |
+
section_parts.append(md)
|
| 1508 |
+
|
| 1509 |
+
derived = _compute_derived_metrics(name, data, company)
|
| 1510 |
+
if derived:
|
| 1511 |
+
section_parts.append(derived)
|
| 1512 |
+
|
| 1513 |
+
elif isinstance(data, dict):
|
| 1514 |
+
dict_lines = []
|
| 1515 |
+
for k, v in data.items():
|
| 1516 |
+
dict_lines.append(f"- {k}: {v}")
|
| 1517 |
+
section_parts.append("\n".join(dict_lines))
|
| 1518 |
+
|
| 1519 |
+
elif isinstance(data, list):
|
| 1520 |
+
effective_max = meta.maxRows if meta else 20
|
| 1521 |
+
if compact:
|
| 1522 |
+
effective_max = min(effective_max, 10)
|
| 1523 |
+
list_lines = []
|
| 1524 |
+
for item in data[:effective_max]:
|
| 1525 |
+
if hasattr(item, "title") and hasattr(item, "chars"):
|
| 1526 |
+
list_lines.append(f"- **{item.title}** ({item.chars}์)")
|
| 1527 |
+
else:
|
| 1528 |
+
list_lines.append(f"- {item}")
|
| 1529 |
+
if len(data) > effective_max:
|
| 1530 |
+
list_lines.append(f"(... ์์ {effective_max}๊ฑด, ์ ์ฒด {len(data)}๊ฑด)")
|
| 1531 |
+
section_parts.append("\n".join(list_lines))
|
| 1532 |
+
|
| 1533 |
+
else:
|
| 1534 |
+
max_text = 1000 if compact else 2000
|
| 1535 |
+
section_parts.append(str(data)[:max_text])
|
| 1536 |
+
|
| 1537 |
+
if not compact and meta and meta.analysisHints:
|
| 1538 |
+
hints = " | ".join(meta.analysisHints)
|
| 1539 |
+
section_parts.append(f"> ๋ถ์ ํฌ์ธํธ: {hints}")
|
| 1540 |
+
|
| 1541 |
+
sections.append("\n".join(section_parts))
|
| 1542 |
+
included.append(name)
|
| 1543 |
+
|
| 1544 |
+
except _CONTEXT_ERRORS:
|
| 1545 |
+
continue
|
| 1546 |
+
|
| 1547 |
+
from dartlab.ai.conversation.prompts import _classify_question_multi
|
| 1548 |
+
|
| 1549 |
+
_q_types = _classify_question_multi(question, max_types=2) if question else []
|
| 1550 |
+
report_sections = _build_report_sections(company, q_types=_q_types)
|
| 1551 |
+
for key, section in report_sections.items():
|
| 1552 |
+
sections.append(section)
|
| 1553 |
+
included.append(key)
|
| 1554 |
+
|
| 1555 |
+
if not compact:
|
| 1556 |
+
available_modules = scan_available_modules(company)
|
| 1557 |
+
available_names = {m["name"] for m in available_modules}
|
| 1558 |
+
not_included = available_names - set(included)
|
| 1559 |
+
if not_included:
|
| 1560 |
+
available_list = []
|
| 1561 |
+
for m in available_modules:
|
| 1562 |
+
if m["name"] in not_included:
|
| 1563 |
+
info = f"`{m['name']}` ({m['label']}"
|
| 1564 |
+
if m.get("rows"):
|
| 1565 |
+
info += f", {m['rows']}ํ"
|
| 1566 |
+
info += ")"
|
| 1567 |
+
available_list.append(info)
|
| 1568 |
+
if available_list:
|
| 1569 |
+
sections.append(
|
| 1570 |
+
"\n---\n### ์ถ๊ฐ ์กฐํ ๊ฐ๋ฅํ ๋ฐ์ดํฐ\n"
|
| 1571 |
+
"์๋ ๋ฐ์ดํฐ๋ ํ์ฌ ํฌํจ๋์ง ์์์ง๋ง `finance(action='data', module=...)` ๋๊ตฌ๋ก ์กฐํํ ์ ์์ต๋๋ค:\n"
|
| 1572 |
+
+ ", ".join(available_list[:15])
|
| 1573 |
+
)
|
| 1574 |
+
|
| 1575 |
+
# โ๏ฟฝ๏ฟฝ๏ฟฝ ์ ๋ณด ๋ฐฐ์น ์ต์ ํ: ํต์ฌ ์์น๋ฅผ context ๋์ ๋ฐ๋ณต (Lost-in-the-Middle ๋์) โโ
|
| 1576 |
+
key_facts = _build_key_facts_recap(company, included)
|
| 1577 |
+
if key_facts:
|
| 1578 |
+
sections.append(key_facts)
|
| 1579 |
+
|
| 1580 |
+
config.verbose = orig_verbose
|
| 1581 |
+
|
| 1582 |
+
return "\n".join(sections), included
|
| 1583 |
+
|
| 1584 |
+
|
| 1585 |
+
def _build_key_facts_recap(company: Any, included: list[str]) -> str | None:
|
| 1586 |
+
"""context ๋์ ํต์ฌ ์์น๋ฅผ ๊ฐ๊ฒฐํ๊ฒ ๋ฐ๋ณต โ Lost-in-the-Middle ๋ฌธ์ ๋์."""
|
| 1587 |
+
lines: list[str] = []
|
| 1588 |
+
|
| 1589 |
+
ratios = get_headline_ratios(company)
|
| 1590 |
+
if ratios is not None and hasattr(ratios, "roe"):
|
| 1591 |
+
facts = []
|
| 1592 |
+
if ratios.roe is not None:
|
| 1593 |
+
facts.append(f"ROE {ratios.roe:.1f}%")
|
| 1594 |
+
if ratios.operatingMargin is not None:
|
| 1595 |
+
facts.append(f"์์
์ด์ต๋ฅ {ratios.operatingMargin:.1f}%")
|
| 1596 |
+
if ratios.debtRatio is not None:
|
| 1597 |
+
facts.append(f"๋ถ์ฑ๋น์จ {ratios.debtRatio:.1f}%")
|
| 1598 |
+
if ratios.currentRatio is not None:
|
| 1599 |
+
facts.append(f"์ ๋๋น์จ {ratios.currentRatio:.1f}%")
|
| 1600 |
+
if ratios.fcf is not None:
|
| 1601 |
+
facts.append(f"FCF {_format_won(ratios.fcf)}")
|
| 1602 |
+
if facts:
|
| 1603 |
+
lines.append("---")
|
| 1604 |
+
lines.append(f"**[ํต์ฌ ์งํ ์์ฝ] {' | '.join(facts)}**")
|
| 1605 |
+
|
| 1606 |
+
# insight ๋ฑ๊ธ ์์ฝ (์์ผ๋ฉด)
|
| 1607 |
+
try:
|
| 1608 |
+
from dartlab.analysis.financial.insight import analyze
|
| 1609 |
+
|
| 1610 |
+
stockCode = getattr(company, "stockCode", None)
|
| 1611 |
+
if stockCode:
|
| 1612 |
+
result = analyze(stockCode, company=company)
|
| 1613 |
+
if result is not None:
|
| 1614 |
+
grades = result.grades()
|
| 1615 |
+
grade_parts = [f"{k}={v}" for k, v in grades.items() if v != "N"]
|
| 1616 |
+
if grade_parts:
|
| 1617 |
+
lines.append(f"**[์ธ์ฌ์ดํธ ๋ฑ๊ธ] {result.profile} โ {', '.join(grade_parts[:5])}**")
|
| 1618 |
+
except (ImportError, AttributeError, KeyError, OSError, RuntimeError, TypeError, ValueError):
|
| 1619 |
+
pass
|
| 1620 |
+
|
| 1621 |
+
if not lines:
|
| 1622 |
+
return None
|
| 1623 |
+
return "\n".join(lines)
|
| 1624 |
+
|
| 1625 |
+
|
| 1626 |
+
def _build_change_summary(company: Any, max_topics: int = 5) -> str | None:
|
| 1627 |
+
"""๊ธฐ๊ฐ๊ฐ ๋ณํ๊ฐ ํฐ topic top-N์ ์๋ ์์ฝํ์ฌ AI ์ปจํ
์คํธ์ ์ ๊ณต."""
|
| 1628 |
+
try:
|
| 1629 |
+
diff_df = company.diff()
|
| 1630 |
+
except _CONTEXT_ERRORS:
|
| 1631 |
+
return None
|
| 1632 |
+
|
| 1633 |
+
if diff_df is None or (isinstance(diff_df, pl.DataFrame) and diff_df.is_empty()):
|
| 1634 |
+
return None
|
| 1635 |
+
|
| 1636 |
+
if not isinstance(diff_df, pl.DataFrame):
|
| 1637 |
+
return None
|
| 1638 |
+
|
| 1639 |
+
# changeRate > 0 ์ธ topic๋ง ํํฐ, ์์ N๊ฐ
|
| 1640 |
+
if "changeRate" not in diff_df.columns or "topic" not in diff_df.columns:
|
| 1641 |
+
return None
|
| 1642 |
+
|
| 1643 |
+
changed = diff_df.filter(pl.col("changeRate") > 0).sort("changeRate", descending=True)
|
| 1644 |
+
if changed.is_empty():
|
| 1645 |
+
return None
|
| 1646 |
+
|
| 1647 |
+
top = changed.head(max_topics)
|
| 1648 |
+
lines = [
|
| 1649 |
+
"\n## ์ฃผ์ ๋ณํ (์ต๊ทผ ๊ณต์ vs ์ง์ )",
|
| 1650 |
+
"| topic | ๋ณํ์จ | ๊ธฐ๊ฐ์ |",
|
| 1651 |
+
"| --- | --- | --- |",
|
| 1652 |
+
]
|
| 1653 |
+
for row in top.iter_rows(named=True):
|
| 1654 |
+
rate_pct = round(row["changeRate"] * 100, 1)
|
| 1655 |
+
periods = row.get("periods", "")
|
| 1656 |
+
lines.append(f"| `{row['topic']}` | {rate_pct}% | {periods} |")
|
| 1657 |
+
|
| 1658 |
+
lines.append("")
|
| 1659 |
+
lines.append(
|
| 1660 |
+
"๊น์ด ๋ถ์์ด ํ์ํ๋ฉด `explore(action='show', topic=topic)`์ผ๋ก ์๋ฌธ์, `explore(action='diff', topic=topic)`์ผ๋ก ์์ธ ๋ณํ๋ฅผ ํ์ธํ์ธ์."
|
| 1661 |
+
)
|
| 1662 |
+
return "\n".join(lines)
|
| 1663 |
+
|
| 1664 |
+
|
| 1665 |
+
def _build_topics_section(company: Any, compact: bool = False) -> str | None:
|
| 1666 |
+
"""Company์ topics ๋ชฉ๋ก์ LLM์ด ์ฌ์ฉํ ์ ์๋ ๋งํฌ๋ค์ด์ผ๋ก ๋ณํ.
|
| 1667 |
+
|
| 1668 |
+
dartlab์ topic์ด ์ถ๊ฐ๋๋ฉด ์๋์ผ๋ก LLM ์ปจํ
์คํธ์ ํฌํจ๋๋ค.
|
| 1669 |
+
|
| 1670 |
+
Args:
|
| 1671 |
+
compact: True๋ฉด ์์ 10๊ฐ + ์ด ๊ฐ์ ์์ฝ (93% ํ ํฐ ์ ๊ฐ)
|
| 1672 |
+
"""
|
| 1673 |
+
topics = getattr(company, "topics", None)
|
| 1674 |
+
if topics is None:
|
| 1675 |
+
return None
|
| 1676 |
+
if isinstance(topics, pl.DataFrame):
|
| 1677 |
+
if "topic" not in topics.columns:
|
| 1678 |
+
return None
|
| 1679 |
+
topic_list = [topic for topic in topics["topic"].drop_nulls().to_list() if isinstance(topic, str) and topic]
|
| 1680 |
+
elif isinstance(topics, pl.Series):
|
| 1681 |
+
topic_list = [topic for topic in topics.drop_nulls().to_list() if isinstance(topic, str) and topic]
|
| 1682 |
+
elif isinstance(topics, list):
|
| 1683 |
+
topic_list = [topic for topic in topics if isinstance(topic, str) and topic]
|
| 1684 |
+
else:
|
| 1685 |
+
try:
|
| 1686 |
+
topic_list = [topic for topic in list(topics) if isinstance(topic, str) and topic]
|
| 1687 |
+
except TypeError:
|
| 1688 |
+
return None
|
| 1689 |
+
if not topic_list:
|
| 1690 |
+
return None
|
| 1691 |
+
|
| 1692 |
+
if compact:
|
| 1693 |
+
top10 = topic_list[:10]
|
| 1694 |
+
return (
|
| 1695 |
+
f"\n## ๊ณต์ topic ({len(topic_list)}๊ฐ)\n"
|
| 1696 |
+
f"์ฃผ์: {', '.join(top10)}\n"
|
| 1697 |
+
f"์ ์ฒด ๋ชฉ๋ก์ `explore(action='topics')` ๋๊ตฌ๋ก ์กฐํํ์ธ์."
|
| 1698 |
+
)
|
| 1699 |
+
|
| 1700 |
+
lines = [
|
| 1701 |
+
"\n## ์กฐํ ๊ฐ๋ฅํ ๊ณต์ topic ๋ชฉ๋ก",
|
| 1702 |
+
"`explore(action='show', topic=...)` ๋๊ตฌ์ ์๋ topic์ ๋ฃ์ผ๋ฉด ์์ธ ๋ฐ์ดํฐ๋ฅผ ์กฐํํ ์ ์์ต๋๋ค.",
|
| 1703 |
+
"",
|
| 1704 |
+
]
|
| 1705 |
+
|
| 1706 |
+
# index๊ฐ ์์ผ๋ฉด label ์ ๋ณด ํฌํจ
|
| 1707 |
+
index_df = getattr(company, "index", None)
|
| 1708 |
+
if isinstance(index_df, pl.DataFrame) and index_df.height > 0:
|
| 1709 |
+
label_col = "label" if "label" in index_df.columns else None
|
| 1710 |
+
source_col = "source" if "source" in index_df.columns else None
|
| 1711 |
+
for row in index_df.head(60).iter_rows(named=True):
|
| 1712 |
+
topic = row.get("topic", "")
|
| 1713 |
+
label = row.get(label_col, topic) if label_col else topic
|
| 1714 |
+
source = row.get(source_col, "") if source_col else ""
|
| 1715 |
+
lines.append(f"- `{topic}` ({label}) [{source}]")
|
| 1716 |
+
else:
|
| 1717 |
+
for t in topic_list[:60]:
|
| 1718 |
+
lines.append(f"- `{t}`")
|
| 1719 |
+
|
| 1720 |
+
return "\n".join(lines)
|
| 1721 |
+
|
| 1722 |
+
|
| 1723 |
+
def _build_insights_section(company: Any) -> str | None:
|
| 1724 |
+
"""Company์ 7์์ญ ์ธ์ฌ์ดํธ ๋ฑ๊ธ์ ์ปจํ
์คํธ์ ์๋ ํฌํจ."""
|
| 1725 |
+
stockCode = getattr(company, "stockCode", None)
|
| 1726 |
+
if not stockCode:
|
| 1727 |
+
return None
|
| 1728 |
+
|
| 1729 |
+
try:
|
| 1730 |
+
from dartlab.analysis.financial.insight.pipeline import analyze
|
| 1731 |
+
|
| 1732 |
+
result = analyze(stockCode, company=company)
|
| 1733 |
+
except (ImportError, AttributeError, FileNotFoundError, OSError, RuntimeError, TypeError, ValueError):
|
| 1734 |
+
return None
|
| 1735 |
+
if result is None:
|
| 1736 |
+
return None
|
| 1737 |
+
|
| 1738 |
+
area_labels = {
|
| 1739 |
+
"performance": "์ค์ ",
|
| 1740 |
+
"profitability": "์์ต์ฑ",
|
| 1741 |
+
"health": "๊ฑด์ ์ฑ",
|
| 1742 |
+
"cashflow": "ํ๊ธํ๋ฆ",
|
| 1743 |
+
"governance": "์ง๋ฐฐ๊ตฌ์กฐ",
|
| 1744 |
+
"risk": "๋ฆฌ์คํฌ",
|
| 1745 |
+
"opportunity": "๊ธฐํ",
|
| 1746 |
+
}
|
| 1747 |
+
|
| 1748 |
+
lines = [
|
| 1749 |
+
"\n## ์ธ์ฌ์ดํธ ๋ฑ๊ธ (์๋ ๋ถ์)",
|
| 1750 |
+
f"ํ๋กํ์ผ: **{result.profile}**",
|
| 1751 |
+
"",
|
| 1752 |
+
"| ์์ญ | ๋ฑ๊ธ | ์์ฝ |",
|
| 1753 |
+
"| --- | --- | --- |",
|
| 1754 |
+
]
|
| 1755 |
+
for key, label in area_labels.items():
|
| 1756 |
+
ir = getattr(result, key, None)
|
| 1757 |
+
grade = result.grades().get(key, "N")
|
| 1758 |
+
summary = ir.summary if ir else "-"
|
| 1759 |
+
lines.append(f"| {label} | {grade} | {summary} |")
|
| 1760 |
+
|
| 1761 |
+
if result.anomalies:
|
| 1762 |
+
lines.append("")
|
| 1763 |
+
lines.append("### ์ด์์น ๊ฒฝ๊ณ ")
|
| 1764 |
+
for a in result.anomalies[:5]:
|
| 1765 |
+
lines.append(f"- [{a.severity}] {a.text}")
|
| 1766 |
+
|
| 1767 |
+
if result.summary:
|
| 1768 |
+
lines.append(f"\n{result.summary}")
|
| 1769 |
+
|
| 1770 |
+
return "\n".join(lines)
|
| 1771 |
+
|
| 1772 |
+
|
| 1773 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 1774 |
+
# Tiered Context Pipeline
|
| 1775 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 1776 |
+
|
| 1777 |
+
# skeleton tier์์ ์ฌ์ฉํ ํต์ฌ ratios ํค
|
| 1778 |
+
_SKELETON_RATIO_KEYS = ("roe", "debtRatio", "currentRatio", "operatingMargin", "fcf", "revenueGrowth3Y")
|
| 1779 |
+
|
| 1780 |
+
# skeleton tier์์ ์ฌ์ฉํ ํต์ฌ ๊ณ์ (๋งค์ถ/์์
์ด์ต/์ด์์ฐ)
|
| 1781 |
+
_SKELETON_ACCOUNTS_KR: dict[str, list[tuple[str, str]]] = {
|
| 1782 |
+
"IS": [("sales", "๋งค์ถ์ก"), ("operating_profit", "์์
์ด์ต")],
|
| 1783 |
+
"BS": [("total_assets", "์์ฐ์ด๊ณ")],
|
| 1784 |
+
}
|
| 1785 |
+
_SKELETON_ACCOUNTS_EN: dict[str, list[tuple[str, str]]] = {
|
| 1786 |
+
"IS": [("sales", "Revenue"), ("operating_profit", "Operating Income")],
|
| 1787 |
+
"BS": [("total_assets", "Total Assets")],
|
| 1788 |
+
}
|
| 1789 |
+
|
| 1790 |
+
|
| 1791 |
+
def build_context_skeleton(company: Any) -> tuple[str, list[str]]:
|
| 1792 |
+
"""skeleton tier: ~500 ํ ํฐ. tool calling provider์ฉ ์ต์ ์ปจํ
์คํธ.
|
| 1793 |
+
|
| 1794 |
+
ํต์ฌ ๋น์จ 6๊ฐ + ๋งค์ถ/์์
์ด์ต/์ด์์ฐ 3๊ณ์ + insight ๋ฑ๊ธ 1์ค.
|
| 1795 |
+
์์ธ ๋ฐ์ดํฐ๋ ๋๊ตฌ๋ก ์กฐํํ๋๋ก ์๋ด.
|
| 1796 |
+
EDGAR(US) / DART(KR) ์๋ ๊ฐ์ง.
|
| 1797 |
+
"""
|
| 1798 |
+
market = getattr(company, "market", "KR")
|
| 1799 |
+
is_us = market == "US"
|
| 1800 |
+
fmt_val = _format_usd if is_us else _format_won
|
| 1801 |
+
skel_accounts = _SKELETON_ACCOUNTS_EN if is_us else _SKELETON_ACCOUNTS_KR
|
| 1802 |
+
unit_label = "USD" if is_us else "์ต/์กฐ์"
|
| 1803 |
+
|
| 1804 |
+
parts = [f"# {company.corpName} ({company.stockCode})"]
|
| 1805 |
+
if is_us:
|
| 1806 |
+
parts[0] += " | Market: US (SEC EDGAR) | Currency: USD"
|
| 1807 |
+
parts.append("โ ๏ธ ์๋๋ ์ฐธ๊ณ ์ฉ ์์ฝ์
๋๋ค. ์ง๋ฌธ์ ๋ตํ๋ ค๋ฉด ๋ฐ๋์ ๋๊ตฌ(explore/finance)๋ก ์์ธ ๋ฐ์ดํฐ๋ฅผ ์กฐํํ์ธ์.")
|
| 1808 |
+
included = []
|
| 1809 |
+
|
| 1810 |
+
# ํต์ฌ ๊ณ์ 3๊ฐ (์ต๊ทผ 3๋
)
|
| 1811 |
+
annual = getattr(company, "annual", None)
|
| 1812 |
+
if annual is not None:
|
| 1813 |
+
series, years = annual
|
| 1814 |
+
quarter_counts = _get_quarter_counts(company)
|
| 1815 |
+
if years:
|
| 1816 |
+
display_years = years[-3:]
|
| 1817 |
+
display_labeled = []
|
| 1818 |
+
for y in display_years:
|
| 1819 |
+
qc = quarter_counts.get(y, 4)
|
| 1820 |
+
if qc < 4:
|
| 1821 |
+
display_labeled.append(f"{y}(~Q{qc})")
|
| 1822 |
+
else:
|
| 1823 |
+
display_labeled.append(y)
|
| 1824 |
+
display_reversed = list(reversed(display_labeled))
|
| 1825 |
+
year_offset = len(years) - 3
|
| 1826 |
+
|
| 1827 |
+
col_header = "Account" if is_us else "๊ณ์ "
|
| 1828 |
+
header = f"| {col_header} | " + " | ".join(display_reversed) + " |"
|
| 1829 |
+
sep = "| --- | " + " | ".join(["---"] * len(display_reversed)) + " |"
|
| 1830 |
+
rows = []
|
| 1831 |
+
for sj, accts in skel_accounts.items():
|
| 1832 |
+
sj_data = series.get(sj, {})
|
| 1833 |
+
for snake_id, label in accts:
|
| 1834 |
+
vals = sj_data.get(snake_id)
|
| 1835 |
+
if not vals:
|
| 1836 |
+
continue
|
| 1837 |
+
sliced = vals[max(0, year_offset) :]
|
| 1838 |
+
cells = [fmt_val(v) if v is not None else "-" for v in reversed(sliced)]
|
| 1839 |
+
rows.append(f"| {label} | " + " | ".join(cells) + " |")
|
| 1840 |
+
|
| 1841 |
+
if rows:
|
| 1842 |
+
partial = [y for y in display_years if quarter_counts.get(y, 4) < 4]
|
| 1843 |
+
partial_note = ""
|
| 1844 |
+
if partial:
|
| 1845 |
+
notes = ", ".join(f"{y}=Q1~Q{quarter_counts[y]}" for y in partial)
|
| 1846 |
+
partial_note = f"\nโ ๏ธ {'Partial year' if is_us else '๋ถ๋ถ ์ฐ๋'}: {notes}"
|
| 1847 |
+
section_title = f"Key Financials ({unit_label})" if is_us else f"ํต์ฌ ์์น ({unit_label})"
|
| 1848 |
+
parts.extend(["", f"## {section_title}{partial_note}", header, sep, *rows])
|
| 1849 |
+
included.extend(["IS", "BS"])
|
| 1850 |
+
|
| 1851 |
+
# ํต์ฌ ๋น์จ 6๊ฐ
|
| 1852 |
+
ratios = get_headline_ratios(company)
|
| 1853 |
+
if ratios is not None and hasattr(ratios, "roe"):
|
| 1854 |
+
ratio_lines = []
|
| 1855 |
+
for key in _SKELETON_RATIO_KEYS:
|
| 1856 |
+
val = getattr(ratios, key, None)
|
| 1857 |
+
if val is None:
|
| 1858 |
+
continue
|
| 1859 |
+
label_map_kr = {
|
| 1860 |
+
"roe": "ROE",
|
| 1861 |
+
"debtRatio": "๋ถ์ฑ๋น์จ",
|
| 1862 |
+
"currentRatio": "์ ๋๋น์จ",
|
| 1863 |
+
"operatingMargin": "์์
์ด์ต๋ฅ ",
|
| 1864 |
+
"fcf": "FCF",
|
| 1865 |
+
"revenueGrowth3Y": "๋งค์ถ3Y CAGR",
|
| 1866 |
+
}
|
| 1867 |
+
label_map_en = {
|
| 1868 |
+
"roe": "ROE",
|
| 1869 |
+
"debtRatio": "Debt Ratio",
|
| 1870 |
+
"currentRatio": "Current Ratio",
|
| 1871 |
+
"operatingMargin": "Op. Margin",
|
| 1872 |
+
"fcf": "FCF",
|
| 1873 |
+
"revenueGrowth3Y": "Rev. 3Y CAGR",
|
| 1874 |
+
}
|
| 1875 |
+
label = (label_map_en if is_us else label_map_kr).get(key, key)
|
| 1876 |
+
if key == "fcf":
|
| 1877 |
+
ratio_lines.append(f"- {label}: {fmt_val(val)}")
|
| 1878 |
+
else:
|
| 1879 |
+
ratio_lines.append(f"- {label}: {val:.1f}%")
|
| 1880 |
+
if ratio_lines:
|
| 1881 |
+
section_title = "Key Ratios" if is_us else "ํต์ฌ ๋น์จ"
|
| 1882 |
+
parts.extend(["", f"## {section_title}", *ratio_lines])
|
| 1883 |
+
included.append("ratios")
|
| 1884 |
+
|
| 1885 |
+
# ๋ถ์ ๊ฐ์ด๋
|
| 1886 |
+
if is_us:
|
| 1887 |
+
parts.extend(
|
| 1888 |
+
[
|
| 1889 |
+
"",
|
| 1890 |
+
"## DartLab Analysis Guide",
|
| 1891 |
+
"All filing data is structured as **sections** (topic ร period horizontalization).",
|
| 1892 |
+
"- `explore(action='topics')` โ full topic list | `explore(action='show', topic=...)` โ block index โ data",
|
| 1893 |
+
"- `explore(action='search', keyword=...)` โ original filing text for citations",
|
| 1894 |
+
"- `explore(action='diff', topic=...)` โ period-over-period changes | `explore(action='trace', topic=...)` โ source provenance",
|
| 1895 |
+
"- `finance(action='data', module='BS/IS/CF')` โ financials | `finance(action='ratios')` โ ratios",
|
| 1896 |
+
"- `analyze(action='insight')` โ 7-area grades | `explore(action='coverage')` โ data availability",
|
| 1897 |
+
"",
|
| 1898 |
+
"**Note**: This is a US company (SEC EDGAR). No `report` namespace โ all narrative data via sections.",
|
| 1899 |
+
"**Procedure**: Understand question โ explore topics โ retrieve data โ cross-verify โ synthesize answer",
|
| 1900 |
+
]
|
| 1901 |
+
)
|
| 1902 |
+
else:
|
| 1903 |
+
parts.extend(
|
| 1904 |
+
[
|
| 1905 |
+
"",
|
| 1906 |
+
"## DartLab ๋ถ์ ๊ฐ์ด๋",
|
| 1907 |
+
"์ด ๊ธฐ์
์ ๋ชจ๋ ๊ณต์ ๋ฐ์ดํฐ๋ **sections** (topic ร ๊ธฐ๊ฐ ์ํํ)์ผ๋ก ๊ตฌ์กฐํ๋์ด ์์ต๋๋ค.",
|
| 1908 |
+
"- `explore(action='topics')` โ ์ ์ฒด topic ๋ชฉ๋ก (ํ๊ท 120+๊ฐ)",
|
| 1909 |
+
"- `explore(action='show', topic=...)` โ ๋ธ๋ก ๋ชฉ์ฐจ โ ์ค์ ๋ฐ์ดํฐ",
|
| 1910 |
+
"- `explore(action='search', keyword=...)` โ ์๋ฌธ ์ฆ๊ฑฐ ๊ฒ์ (์ธ์ฉ์ฉ)",
|
| 1911 |
+
"- `explore(action='diff', topic=...)` โ ๊ธฐ๊ฐ๊ฐ ๋ณํ | `explore(action='trace', topic=...)` โ ์ถ์ฒ ์ถ์ ",
|
| 1912 |
+
"- `finance(action='data', module='BS/IS/CF')` โ ์ฌ๋ฌด์ ํ | `finance(action='ratios')` โ ์ฌ๋ฌด๋น์จ",
|
| 1913 |
+
"- `analyze(action='insight')` โ 7์์ญ ์ข
ํฉ ๋ฑ๊ธ | `explore(action='report', apiType=...)` โ ์ ๊ธฐ๋ณด๊ณ ์",
|
| 1914 |
+
"",
|
| 1915 |
+
"**๋ถ์ ์ ์ฐจ**: ์ง๋ฌธ ์ดํด โ ๊ด๋ จ topic ํ์ โ ์๋ฌธ ๋ฐ์ดํฐ ์กฐํ โ ๊ต์ฐจ ๊ฒ์ฆ โ ์ข
ํฉ ๋ต๋ณ",
|
| 1916 |
+
"**ํต์ฌ**: '๋ฐ์ดํฐ ์์'์ผ๋ก ๋ตํ๊ธฐ ์ ์ ๋ฐ๋์ ๋๊ตฌ๋ก ํ์ธ. sections์ ๊ฑฐ์ ๋ชจ๋ ๊ณต์ ๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค.",
|
| 1917 |
+
]
|
| 1918 |
+
)
|
| 1919 |
+
|
| 1920 |
+
return "\n".join(parts), included
|
| 1921 |
+
|
| 1922 |
+
|
| 1923 |
+
def build_context_focused(
|
| 1924 |
+
company: Any,
|
| 1925 |
+
question: str,
|
| 1926 |
+
include: list[str] | None = None,
|
| 1927 |
+
exclude: list[str] | None = None,
|
| 1928 |
+
) -> tuple[dict[str, str], list[str], str]:
|
| 1929 |
+
"""focused tier: ~2,000 ํ ํฐ. tool calling ๋ฏธ์ง์ provider์ฉ.
|
| 1930 |
+
|
| 1931 |
+
skeleton + ์ง๋ฌธ ์ ํ๋ณ ๊ด๋ จ ๋ชจ๋๋ง ํฌํจ (compact ํ์).
|
| 1932 |
+
"""
|
| 1933 |
+
return build_context_by_module(company, question, include, exclude, compact=True)
|
| 1934 |
+
|
| 1935 |
+
|
| 1936 |
+
ContextTier = str # "skeleton" | "focused" | "full"
|
| 1937 |
+
|
| 1938 |
+
|
| 1939 |
+
def build_context_tiered(
|
| 1940 |
+
company: Any,
|
| 1941 |
+
question: str,
|
| 1942 |
+
tier: ContextTier,
|
| 1943 |
+
include: list[str] | None = None,
|
| 1944 |
+
exclude: list[str] | None = None,
|
| 1945 |
+
) -> tuple[dict[str, str], list[str], str]:
|
| 1946 |
+
"""tier๋ณ context ๋น๋. streaming.py์์ ํธ์ถ.
|
| 1947 |
+
|
| 1948 |
+
Args:
|
| 1949 |
+
tier: "skeleton" | "focused" | "full"
|
| 1950 |
+
|
| 1951 |
+
Returns:
|
| 1952 |
+
(modules_dict, included_list, header_text)
|
| 1953 |
+
"""
|
| 1954 |
+
if tier == "skeleton":
|
| 1955 |
+
text, included = build_context_skeleton(company)
|
| 1956 |
+
return {"_skeleton": text}, included, ""
|
| 1957 |
+
elif tier == "focused":
|
| 1958 |
+
return build_context_focused(company, question, include, exclude)
|
| 1959 |
+
else:
|
| 1960 |
+
return build_context_by_module(company, question, include, exclude, compact=False)
|
src/dartlab/ai/context/company_adapter.py
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Facade adapter helpers for AI runtime.
|
| 2 |
+
|
| 3 |
+
AI layer๋ `dartlab.Company` facade์ ์์ง ๋ด๋ถ ๊ตฌํ ์ฐจ์ด๋ฅผ ์ง์ ์์ง ์๋๋ค.
|
| 4 |
+
์ด ๋ชจ๋์์ headline ratios / ratio series ๊ฐ์ surface ์ฐจ์ด๋ฅผ ํก์ํ๋ค.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
from types import SimpleNamespace
|
| 10 |
+
from typing import Any
|
| 11 |
+
|
| 12 |
+
_ADAPTER_ERRORS = (
|
| 13 |
+
AttributeError,
|
| 14 |
+
KeyError,
|
| 15 |
+
OSError,
|
| 16 |
+
RuntimeError,
|
| 17 |
+
TypeError,
|
| 18 |
+
ValueError,
|
| 19 |
+
)
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
class _RatioProxy:
|
| 23 |
+
"""๋๋ฝ ์์ฑ์ None์ผ๋ก ํก์ํ๋ lightweight ratio adapter."""
|
| 24 |
+
|
| 25 |
+
def __init__(self, inner: Any):
|
| 26 |
+
self._inner = inner
|
| 27 |
+
|
| 28 |
+
def __getattr__(self, name: str) -> Any:
|
| 29 |
+
return getattr(self._inner, name, None)
|
| 30 |
+
|
| 31 |
+
|
| 32 |
+
def get_headline_ratios(company: Any) -> Any | None:
|
| 33 |
+
"""Return RatioResult-like object regardless of facade surface."""
|
| 34 |
+
# ๋ด๋ถ์ฉ _getRatiosInternal ์ฐ์ (deprecation warning ์์)
|
| 35 |
+
internal = getattr(company, "_getRatiosInternal", None)
|
| 36 |
+
getter = internal if callable(internal) else getattr(company, "getRatios", None)
|
| 37 |
+
if callable(getter):
|
| 38 |
+
try:
|
| 39 |
+
result = getter()
|
| 40 |
+
if result is not None and hasattr(result, "roe"):
|
| 41 |
+
return _RatioProxy(result)
|
| 42 |
+
except _ADAPTER_ERRORS:
|
| 43 |
+
pass
|
| 44 |
+
|
| 45 |
+
finance = getattr(company, "finance", None)
|
| 46 |
+
finance_getter = getattr(finance, "getRatios", None)
|
| 47 |
+
if callable(finance_getter):
|
| 48 |
+
try:
|
| 49 |
+
result = finance_getter()
|
| 50 |
+
if result is not None and hasattr(result, "roe"):
|
| 51 |
+
return _RatioProxy(result)
|
| 52 |
+
except _ADAPTER_ERRORS:
|
| 53 |
+
pass
|
| 54 |
+
|
| 55 |
+
for candidate in (
|
| 56 |
+
getattr(company, "ratios", None),
|
| 57 |
+
getattr(finance, "ratios", None),
|
| 58 |
+
):
|
| 59 |
+
if candidate is not None and hasattr(candidate, "roe"):
|
| 60 |
+
return _RatioProxy(candidate)
|
| 61 |
+
|
| 62 |
+
return None
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
def get_ratio_series(company: Any) -> Any | None:
|
| 66 |
+
"""Return attribute-style ratio series regardless of tuple/object surface."""
|
| 67 |
+
for candidate in (
|
| 68 |
+
getattr(company, "ratioSeries", None),
|
| 69 |
+
getattr(getattr(company, "finance", None), "ratioSeries", None),
|
| 70 |
+
):
|
| 71 |
+
if candidate is None:
|
| 72 |
+
continue
|
| 73 |
+
if hasattr(candidate, "roe"):
|
| 74 |
+
return candidate
|
| 75 |
+
if isinstance(candidate, tuple) and len(candidate) == 2:
|
| 76 |
+
series, periods = candidate
|
| 77 |
+
if not isinstance(series, dict):
|
| 78 |
+
continue
|
| 79 |
+
ratio_series = series.get("RATIO", {})
|
| 80 |
+
if not isinstance(ratio_series, dict) or not ratio_series:
|
| 81 |
+
continue
|
| 82 |
+
adapted = SimpleNamespace(periods=periods)
|
| 83 |
+
for key, values in ratio_series.items():
|
| 84 |
+
setattr(adapted, key, values)
|
| 85 |
+
return adapted
|
| 86 |
+
return None
|
src/dartlab/ai/context/dartOpenapi.py
ADDED
|
@@ -0,0 +1,485 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""OpenDART ๊ณต์๋ชฉ๋ก retrieval helper.
|
| 2 |
+
|
| 3 |
+
ํ์ฌ ๋ฏธ์ ํ ์ง๋ฌธ์์๋ ์ต๊ทผ ๊ณต์๋ชฉ๋ก/์์ฃผ๊ณต์/๊ณ์ฝ๊ณต์๋ฅผ
|
| 4 |
+
deterministic prefetch๋ก ํ์ํด AI ์ปจํ
์คํธ๋ก ์ฃผ์
ํ๋ค.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import re
|
| 10 |
+
from dataclasses import dataclass
|
| 11 |
+
from datetime import date, timedelta
|
| 12 |
+
from html import unescape
|
| 13 |
+
from typing import Any
|
| 14 |
+
|
| 15 |
+
import polars as pl
|
| 16 |
+
|
| 17 |
+
from dartlab.ai.context.formatting import df_to_markdown
|
| 18 |
+
from dartlab.core.capabilities import UiAction
|
| 19 |
+
from dartlab.providers.dart.openapi.dartKey import hasDartApiKey
|
| 20 |
+
|
| 21 |
+
_FILING_TERMS = (
|
| 22 |
+
"๊ณต์",
|
| 23 |
+
"์ ์๊ณต์",
|
| 24 |
+
"๊ณต์๋ชฉ๋ก",
|
| 25 |
+
"๊ณต์ ๋ฆฌ์คํธ",
|
| 26 |
+
"์์ฃผ๊ณต์",
|
| 27 |
+
"๊ณ์ฝ๊ณต์",
|
| 28 |
+
"๋จ์ผํ๋งค๊ณต๊ธ๊ณ์ฝ",
|
| 29 |
+
"๊ณต๊ธ๊ณ์ฝ",
|
| 30 |
+
"ํ๋งค๊ณต๊ธ๊ณ์ฝ",
|
| 31 |
+
"์์ฃผ",
|
| 32 |
+
)
|
| 33 |
+
_REQUEST_TERMS = (
|
| 34 |
+
"์๋ ค",
|
| 35 |
+
"๋ณด์ฌ",
|
| 36 |
+
"์ฐพ์",
|
| 37 |
+
"์ ๋ฆฌ",
|
| 38 |
+
"์์ฝ",
|
| 39 |
+
"๋ถ์",
|
| 40 |
+
"๊ณจ๋ผ",
|
| 41 |
+
"์ถ์ฒ",
|
| 42 |
+
"๋ฌด์จ",
|
| 43 |
+
"๋ญ ์์",
|
| 44 |
+
"๋ฆฌ์คํธ",
|
| 45 |
+
"๋ชฉ๋ก",
|
| 46 |
+
)
|
| 47 |
+
_DETAIL_TERMS = (
|
| 48 |
+
"์์ฝ",
|
| 49 |
+
"๋ถ์",
|
| 50 |
+
"ํต์ฌ",
|
| 51 |
+
"์ค์",
|
| 52 |
+
"์ฝ์",
|
| 53 |
+
"๋ฆฌ์คํฌ",
|
| 54 |
+
"๋ด์ฉ",
|
| 55 |
+
"๋ฌด์จ ๋ด์ฉ",
|
| 56 |
+
"๊ผญ",
|
| 57 |
+
)
|
| 58 |
+
_READ_TERMS = (
|
| 59 |
+
"์ฝ์ด",
|
| 60 |
+
"๋ณธ๋ฌธ",
|
| 61 |
+
"์๋ฌธ",
|
| 62 |
+
"์ ๋ฌธ",
|
| 63 |
+
"์์ธํ ๋ณด์ฌ",
|
| 64 |
+
"๋ด์ฉ ๋ณด์ฌ",
|
| 65 |
+
)
|
| 66 |
+
_ANALYSIS_ONLY_TERMS = (
|
| 67 |
+
"๊ทผ๊ฑฐ",
|
| 68 |
+
"์",
|
| 69 |
+
"์ง์ ๊ฐ๋ฅ",
|
| 70 |
+
"์ง์๊ฐ๋ฅ",
|
| 71 |
+
"ํ๋จ",
|
| 72 |
+
"ํ๊ฐ",
|
| 73 |
+
"ํด์",
|
| 74 |
+
"์ฌ์
๊ตฌ์กฐ",
|
| 75 |
+
"๊ตฌ์กฐ",
|
| 76 |
+
"์ํฅ",
|
| 77 |
+
"๋ณํ",
|
| 78 |
+
)
|
| 79 |
+
_ORDER_KEYWORDS = (
|
| 80 |
+
"๋จ์ผํ๋งค๊ณต๊ธ๊ณ์ฝ",
|
| 81 |
+
"ํ๋งค๊ณต๊ธ๊ณ์ฝ",
|
| 82 |
+
"๊ณต๊ธ๊ณ์ฝ",
|
| 83 |
+
"์์ฃผ",
|
| 84 |
+
)
|
| 85 |
+
_DISCLOSURE_TYPE_HINTS = {
|
| 86 |
+
"์ ๊ธฐ๊ณต์": "A",
|
| 87 |
+
"์ฃผ์์ฌํญ": "B",
|
| 88 |
+
"์ฃผ์์ฌํญ๋ณด๊ณ ": "B",
|
| 89 |
+
"๋ฐํ๊ณต์": "C",
|
| 90 |
+
"์ง๋ถ๊ณต์": "D",
|
| 91 |
+
"๊ธฐํ๊ณต์": "E",
|
| 92 |
+
"์ธ๋ถ๊ฐ์ฌ": "F",
|
| 93 |
+
"ํ๋๊ณต์": "G",
|
| 94 |
+
"์์ฐ์ ๋ํ": "H",
|
| 95 |
+
"๊ฑฐ๋์๊ณต์": "I",
|
| 96 |
+
"๊ณต์ ์๊ณต์": "J",
|
| 97 |
+
}
|
| 98 |
+
_MARKET_HINTS = {
|
| 99 |
+
"์ฝ์คํผ": "Y",
|
| 100 |
+
"์ ๊ฐ์ฆ๊ถ": "Y",
|
| 101 |
+
"์ฝ์ค๋ฅ": "K",
|
| 102 |
+
"์ฝ๋ฅ์ค": "N",
|
| 103 |
+
}
|
| 104 |
+
_DEFAULT_LIMIT = 20
|
| 105 |
+
_DEFAULT_DAYS = 7
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
@dataclass(frozen=True)
|
| 109 |
+
class DartFilingIntent:
|
| 110 |
+
matched: bool = False
|
| 111 |
+
corp: str | None = None
|
| 112 |
+
start: str = ""
|
| 113 |
+
end: str = ""
|
| 114 |
+
disclosureType: str | None = None
|
| 115 |
+
market: str | None = None
|
| 116 |
+
finalOnly: bool = False
|
| 117 |
+
limit: int = _DEFAULT_LIMIT
|
| 118 |
+
titleKeywords: tuple[str, ...] = ()
|
| 119 |
+
includeText: bool = False
|
| 120 |
+
textLimit: int = 0
|
| 121 |
+
|
| 122 |
+
|
| 123 |
+
@dataclass(frozen=True)
|
| 124 |
+
class DartFilingPrefetch:
|
| 125 |
+
matched: bool
|
| 126 |
+
needsKey: bool = False
|
| 127 |
+
message: str = ""
|
| 128 |
+
contextText: str = ""
|
| 129 |
+
uiAction: dict[str, Any] | None = None
|
| 130 |
+
filings: pl.DataFrame | None = None
|
| 131 |
+
intent: DartFilingIntent | None = None
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
def buildMissingDartKeyMessage() -> str:
|
| 135 |
+
return (
|
| 136 |
+
"OpenDART API ํค๊ฐ ํ์ํฉ๋๋ค.\n"
|
| 137 |
+
"- ์ด ์ง๋ฌธ์ ์ค์๊ฐ ๊ณต์๋ชฉ๋ก ์กฐํ๊ฐ ํ์ํฉ๋๋ค.\n"
|
| 138 |
+
"- ์ค์ ์์ `OpenDART API ํค`๋ฅผ ์ ์ฅํ๋ฉด ์ต๊ทผ ๊ณต์, ์์ฃผ๊ณต์, ๊ณ์ฝ๊ณต์๋ฅผ ๋ฐ๋ก ๊ฒ์ํ ์ ์์ต๋๋ค.\n"
|
| 139 |
+
"- ํค๋ ํ๋ก์ ํธ ๋ฃจํธ `.env`์ `DART_API_KEY`๋ก ์ ์ฅ๋ฉ๋๋ค."
|
| 140 |
+
)
|
| 141 |
+
|
| 142 |
+
|
| 143 |
+
def buildMissingDartKeyUiAction() -> dict[str, Any]:
|
| 144 |
+
return UiAction.update(
|
| 145 |
+
"settings",
|
| 146 |
+
{
|
| 147 |
+
"open": True,
|
| 148 |
+
"section": "openDart",
|
| 149 |
+
"message": "OpenDART API ํค๋ฅผ ์ค์ ํ๋ฉด ์ต๊ทผ ๊ณต์๋ชฉ๋ก์ ๋ฐ๋ก ๊ฒ์ํ ์ ์์ต๋๋ค.",
|
| 150 |
+
},
|
| 151 |
+
).to_payload()
|
| 152 |
+
|
| 153 |
+
|
| 154 |
+
def isDartFilingQuestion(question: str) -> bool:
|
| 155 |
+
q = (question or "").strip()
|
| 156 |
+
if not q:
|
| 157 |
+
return False
|
| 158 |
+
normalized = q.replace(" ", "")
|
| 159 |
+
if any(term in normalized for term in ("openapi", "opendart", "dartapi")) and not any(
|
| 160 |
+
term in q for term in _FILING_TERMS
|
| 161 |
+
):
|
| 162 |
+
return False
|
| 163 |
+
has_filing_term = any(term in q for term in _FILING_TERMS)
|
| 164 |
+
has_request_term = any(term in q for term in _REQUEST_TERMS)
|
| 165 |
+
has_time_term = any(term in q for term in ("์ต๊ทผ", "์ค๋", "์ด์ ", "์ด๋ฒ ์ฃผ", "์ง๋ ์ฃผ", "์ด๋ฒ ๋ฌ", "๋ฉฐ์น ", "๋ช์ผ"))
|
| 166 |
+
has_read_term = any(term in q for term in _READ_TERMS)
|
| 167 |
+
has_analysis_only_term = any(term in q for term in _ANALYSIS_ONLY_TERMS)
|
| 168 |
+
|
| 169 |
+
if (
|
| 170 |
+
has_analysis_only_term
|
| 171 |
+
and not has_read_term
|
| 172 |
+
and not any(term in q for term in ("๋ชฉ๋ก", "๋ฆฌ์คํธ", "๋ญ ์์", "๋ฌด์จ ๊ณต์"))
|
| 173 |
+
):
|
| 174 |
+
return False
|
| 175 |
+
|
| 176 |
+
return has_filing_term and (has_request_term or has_time_term or has_read_term or "?" not in q)
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def detectDartFilingIntent(question: str, company: Any | None = None) -> DartFilingIntent:
|
| 180 |
+
if not isDartFilingQuestion(question):
|
| 181 |
+
return DartFilingIntent()
|
| 182 |
+
|
| 183 |
+
today = date.today()
|
| 184 |
+
start_date, end_date = _resolve_date_window(question, today)
|
| 185 |
+
title_keywords = _resolve_title_keywords(question)
|
| 186 |
+
include_text = any(term in question for term in _DETAIL_TERMS) or any(term in question for term in _READ_TERMS)
|
| 187 |
+
limit = _resolve_limit(question)
|
| 188 |
+
corp = None
|
| 189 |
+
if company is not None:
|
| 190 |
+
corp = getattr(company, "stockCode", None) or getattr(company, "corpName", None)
|
| 191 |
+
|
| 192 |
+
disclosure_type = None
|
| 193 |
+
for hint, code in _DISCLOSURE_TYPE_HINTS.items():
|
| 194 |
+
if hint in question:
|
| 195 |
+
disclosure_type = code
|
| 196 |
+
break
|
| 197 |
+
|
| 198 |
+
market = None
|
| 199 |
+
for hint, code in _MARKET_HINTS.items():
|
| 200 |
+
if hint in question:
|
| 201 |
+
market = code
|
| 202 |
+
break
|
| 203 |
+
|
| 204 |
+
final_only = any(term in question for term in ("์ต์ข
", "์ ์ ์ ์ธ", "์ ์ ์๋", "์ ์ ์๋"))
|
| 205 |
+
text_limit = 3 if include_text and limit <= 5 else (2 if include_text else 0)
|
| 206 |
+
|
| 207 |
+
return DartFilingIntent(
|
| 208 |
+
matched=True,
|
| 209 |
+
corp=corp,
|
| 210 |
+
start=start_date.strftime("%Y%m%d"),
|
| 211 |
+
end=end_date.strftime("%Y%m%d"),
|
| 212 |
+
disclosureType=disclosure_type,
|
| 213 |
+
market=market,
|
| 214 |
+
finalOnly=final_only,
|
| 215 |
+
limit=limit,
|
| 216 |
+
titleKeywords=title_keywords,
|
| 217 |
+
includeText=include_text,
|
| 218 |
+
textLimit=text_limit,
|
| 219 |
+
)
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
def searchDartFilings(
|
| 223 |
+
*,
|
| 224 |
+
corp: str | None = None,
|
| 225 |
+
start: str | None = None,
|
| 226 |
+
end: str | None = None,
|
| 227 |
+
days: int | None = None,
|
| 228 |
+
weeks: int | None = None,
|
| 229 |
+
disclosureType: str | None = None,
|
| 230 |
+
market: str | None = None,
|
| 231 |
+
finalOnly: bool = False,
|
| 232 |
+
titleKeywords: list[str] | tuple[str, ...] | None = None,
|
| 233 |
+
limit: int = _DEFAULT_LIMIT,
|
| 234 |
+
) -> pl.DataFrame:
|
| 235 |
+
from dartlab import OpenDart
|
| 236 |
+
|
| 237 |
+
if not hasDartApiKey():
|
| 238 |
+
raise ValueError(buildMissingDartKeyMessage())
|
| 239 |
+
|
| 240 |
+
resolved_start, resolved_end = _coerce_search_window(start, end, days=days, weeks=weeks)
|
| 241 |
+
dart = OpenDart()
|
| 242 |
+
filings = dart.filings(
|
| 243 |
+
corp=corp,
|
| 244 |
+
start=resolved_start,
|
| 245 |
+
end=resolved_end,
|
| 246 |
+
type=disclosureType,
|
| 247 |
+
final=finalOnly,
|
| 248 |
+
market=market,
|
| 249 |
+
)
|
| 250 |
+
if filings is None or filings.height == 0:
|
| 251 |
+
return pl.DataFrame()
|
| 252 |
+
|
| 253 |
+
df = filings
|
| 254 |
+
if titleKeywords and "report_nm" in df.columns:
|
| 255 |
+
mask = pl.lit(False)
|
| 256 |
+
for keyword in titleKeywords:
|
| 257 |
+
mask = mask | pl.col("report_nm").str.contains(keyword, literal=True)
|
| 258 |
+
df = df.filter(mask)
|
| 259 |
+
|
| 260 |
+
if df.height == 0:
|
| 261 |
+
return pl.DataFrame()
|
| 262 |
+
|
| 263 |
+
sort_cols = [col for col in ("rcept_dt", "rcept_no") if col in df.columns]
|
| 264 |
+
if sort_cols:
|
| 265 |
+
descending = [True] * len(sort_cols)
|
| 266 |
+
df = df.sort(sort_cols, descending=descending)
|
| 267 |
+
|
| 268 |
+
return df.head(max(1, min(limit, 100)))
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
def getDartFilingText(rceptNo: str, maxChars: int = 4000) -> str:
|
| 272 |
+
from dartlab import OpenDart
|
| 273 |
+
|
| 274 |
+
if not rceptNo:
|
| 275 |
+
raise ValueError("rcept_no๊ฐ ํ์ํฉ๋๋ค.")
|
| 276 |
+
if not hasDartApiKey():
|
| 277 |
+
raise ValueError(buildMissingDartKeyMessage())
|
| 278 |
+
|
| 279 |
+
raw_text = OpenDart().documentText(rceptNo)
|
| 280 |
+
return cleanDartFilingText(raw_text, maxChars=maxChars)
|
| 281 |
+
|
| 282 |
+
|
| 283 |
+
def buildDartFilingPrefetch(question: str, company: Any | None = None) -> DartFilingPrefetch:
|
| 284 |
+
intent = detectDartFilingIntent(question, company=company)
|
| 285 |
+
if not intent.matched:
|
| 286 |
+
return DartFilingPrefetch(matched=False)
|
| 287 |
+
if not hasDartApiKey():
|
| 288 |
+
return DartFilingPrefetch(
|
| 289 |
+
matched=True,
|
| 290 |
+
needsKey=True,
|
| 291 |
+
message=buildMissingDartKeyMessage(),
|
| 292 |
+
uiAction=buildMissingDartKeyUiAction(),
|
| 293 |
+
intent=intent,
|
| 294 |
+
)
|
| 295 |
+
|
| 296 |
+
filings = searchDartFilings(
|
| 297 |
+
corp=intent.corp,
|
| 298 |
+
start=intent.start,
|
| 299 |
+
end=intent.end,
|
| 300 |
+
disclosureType=intent.disclosureType,
|
| 301 |
+
market=intent.market,
|
| 302 |
+
finalOnly=intent.finalOnly,
|
| 303 |
+
titleKeywords=intent.titleKeywords,
|
| 304 |
+
limit=intent.limit,
|
| 305 |
+
)
|
| 306 |
+
context_text = formatDartFilingContext(filings, intent, question=question)
|
| 307 |
+
if intent.includeText and filings.height > 0 and "rcept_no" in filings.columns:
|
| 308 |
+
detail_blocks = []
|
| 309 |
+
for rcept_no in filings["rcept_no"].head(intent.textLimit).to_list():
|
| 310 |
+
try:
|
| 311 |
+
excerpt = getDartFilingText(str(rcept_no), maxChars=1800)
|
| 312 |
+
except (OSError, RuntimeError, ValueError):
|
| 313 |
+
continue
|
| 314 |
+
detail_blocks.append(f"### ์ ์๋ฒํธ {rcept_no} ์๋ฌธ ๋ฐ์ท\n{excerpt}")
|
| 315 |
+
if detail_blocks:
|
| 316 |
+
context_text = "\n\n".join([context_text, *detail_blocks]) if context_text else "\n\n".join(detail_blocks)
|
| 317 |
+
|
| 318 |
+
return DartFilingPrefetch(
|
| 319 |
+
matched=True,
|
| 320 |
+
needsKey=False,
|
| 321 |
+
contextText=context_text,
|
| 322 |
+
filings=filings,
|
| 323 |
+
intent=intent,
|
| 324 |
+
)
|
| 325 |
+
|
| 326 |
+
|
| 327 |
+
def formatDartFilingContext(
|
| 328 |
+
filings: pl.DataFrame,
|
| 329 |
+
intent: DartFilingIntent,
|
| 330 |
+
*,
|
| 331 |
+
question: str = "",
|
| 332 |
+
) -> str:
|
| 333 |
+
if intent.start or intent.end:
|
| 334 |
+
window_label = f"{_format_date(intent.start or intent.end)} ~ {_format_date(intent.end or intent.start)}"
|
| 335 |
+
else:
|
| 336 |
+
window_label = "์๋ ๊ธฐ๋ณธ ๋ฒ์"
|
| 337 |
+
lines = ["## OpenDART ๊ณต์๋ชฉ๋ก ๊ฒ์ ๊ฒฐ๊ณผ", f"- ๊ธฐ๊ฐ: {window_label}"]
|
| 338 |
+
if intent.corp:
|
| 339 |
+
lines.append(f"- ํ์ฌ ํํฐ: {intent.corp}")
|
| 340 |
+
else:
|
| 341 |
+
lines.append("- ํ์ฌ ํํฐ: ์ ์ฒด ์์ฅ")
|
| 342 |
+
if intent.market:
|
| 343 |
+
lines.append(f"- ์์ฅ ํํฐ: {intent.market}")
|
| 344 |
+
if intent.disclosureType:
|
| 345 |
+
lines.append(f"- ๊ณต์์ ํ: {intent.disclosureType}")
|
| 346 |
+
if intent.finalOnly:
|
| 347 |
+
lines.append("- ์ต์ข
๋ณด๊ณ ์๋ง ํฌํจ")
|
| 348 |
+
if intent.titleKeywords:
|
| 349 |
+
lines.append(f"- ์ ๋ชฉ ํค์๋: {', '.join(intent.titleKeywords)}")
|
| 350 |
+
if question:
|
| 351 |
+
lines.append(f"- ์ฌ์ฉ์ ์ง๋ฌธ: {question}")
|
| 352 |
+
|
| 353 |
+
if filings is None or filings.height == 0:
|
| 354 |
+
lines.append("")
|
| 355 |
+
lines.append("ํด๋น ์กฐ๊ฑด์ ๋ง๋ ๊ณต์๊ฐ ์์ต๋๋ค.")
|
| 356 |
+
return "\n".join(lines)
|
| 357 |
+
|
| 358 |
+
display_df = _build_display_df(filings)
|
| 359 |
+
lines.extend(["", df_to_markdown(display_df, max_rows=min(intent.limit, 20), compact=False)])
|
| 360 |
+
return "\n".join(lines)
|
| 361 |
+
|
| 362 |
+
|
| 363 |
+
def cleanDartFilingText(text: str, *, maxChars: int = 4000) -> str:
|
| 364 |
+
normalized = unescape(text or "")
|
| 365 |
+
normalized = re.sub(r"<[^>]+>", " ", normalized)
|
| 366 |
+
normalized = re.sub(r"\s+", " ", normalized).strip()
|
| 367 |
+
if len(normalized) <= maxChars:
|
| 368 |
+
return normalized
|
| 369 |
+
return normalized[:maxChars].rstrip() + " ... (truncated)"
|
| 370 |
+
|
| 371 |
+
|
| 372 |
+
def _build_display_df(df: pl.DataFrame) -> pl.DataFrame:
|
| 373 |
+
display = df
|
| 374 |
+
if "rcept_dt" in display.columns:
|
| 375 |
+
display = display.with_columns(
|
| 376 |
+
pl.col("rcept_dt").cast(pl.Utf8).map_elements(_format_date, return_dtype=pl.Utf8).alias("rcept_dt")
|
| 377 |
+
)
|
| 378 |
+
|
| 379 |
+
preferred_cols = [
|
| 380 |
+
col
|
| 381 |
+
for col in ("rcept_dt", "corp_name", "stock_code", "corp_cls", "report_nm", "rcept_no")
|
| 382 |
+
if col in display.columns
|
| 383 |
+
]
|
| 384 |
+
if preferred_cols:
|
| 385 |
+
display = display.select(preferred_cols)
|
| 386 |
+
|
| 387 |
+
rename_map = {
|
| 388 |
+
"rcept_dt": "์ ์์ผ",
|
| 389 |
+
"corp_name": "ํ์ฌ",
|
| 390 |
+
"stock_code": "์ข
๋ชฉ์ฝ๋",
|
| 391 |
+
"corp_cls": "์์ฅ",
|
| 392 |
+
"report_nm": "๊ณต์๋ช
",
|
| 393 |
+
"rcept_no": "์ ์๋ฒํธ",
|
| 394 |
+
}
|
| 395 |
+
actual_map = {src: dst for src, dst in rename_map.items() if src in display.columns}
|
| 396 |
+
return display.rename(actual_map)
|
| 397 |
+
|
| 398 |
+
|
| 399 |
+
def _resolve_title_keywords(question: str) -> tuple[str, ...]:
|
| 400 |
+
if any(term in question for term in _ORDER_KEYWORDS) or "๊ณ์ฝ๊ณต์" in question:
|
| 401 |
+
return _ORDER_KEYWORDS
|
| 402 |
+
explicit = []
|
| 403 |
+
for phrase in ("๊ฐ์ฌ๋ณด๊ณ ์", "ํฉ๋ณ", "์ ์์ฆ์", "๋ฌด์์ฆ์", "๋ฐฐ๋น", "์๊ธฐ์ฃผ์", "์ต๋์ฃผ์ฃผ"):
|
| 404 |
+
if phrase in question:
|
| 405 |
+
explicit.append(phrase)
|
| 406 |
+
return tuple(explicit)
|
| 407 |
+
|
| 408 |
+
|
| 409 |
+
def _resolve_limit(question: str) -> int:
|
| 410 |
+
match = re.search(r"(\d+)\s*๊ฑด", question)
|
| 411 |
+
if match:
|
| 412 |
+
return max(1, min(int(match.group(1)), 50))
|
| 413 |
+
if "์ซ" in question or "์ ๋ถ" in question or "์ ์ฒด" in question:
|
| 414 |
+
return 30
|
| 415 |
+
return _DEFAULT_LIMIT
|
| 416 |
+
|
| 417 |
+
|
| 418 |
+
def _resolve_date_window(question: str, today: date) -> tuple[date, date]:
|
| 419 |
+
q = question.replace(" ", "")
|
| 420 |
+
if "์ค๋" in question:
|
| 421 |
+
return today, today
|
| 422 |
+
if "์ด์ " in question:
|
| 423 |
+
target = today - timedelta(days=1)
|
| 424 |
+
return target, target
|
| 425 |
+
if "์ด๋ฒ์ฃผ" in q:
|
| 426 |
+
start = today - timedelta(days=today.weekday())
|
| 427 |
+
return start, today
|
| 428 |
+
if "์ง๋์ฃผ" in q:
|
| 429 |
+
end = today - timedelta(days=today.weekday() + 1)
|
| 430 |
+
start = end - timedelta(days=6)
|
| 431 |
+
return start, end
|
| 432 |
+
if "์ด๋ฒ๋ฌ" in q:
|
| 433 |
+
start = today.replace(day=1)
|
| 434 |
+
return start, today
|
| 435 |
+
|
| 436 |
+
recent_match = re.search(r"์ต๊ทผ\s*(\d+)\s*(์ผ|์ฃผ|๊ฐ์|๋ฌ)", question)
|
| 437 |
+
if recent_match:
|
| 438 |
+
amount = int(recent_match.group(1))
|
| 439 |
+
unit = recent_match.group(2)
|
| 440 |
+
if unit == "์ผ":
|
| 441 |
+
return today - timedelta(days=max(amount - 1, 0)), today
|
| 442 |
+
if unit == "์ฃผ":
|
| 443 |
+
return today - timedelta(days=max(amount * 7 - 1, 0)), today
|
| 444 |
+
if unit in {"๊ฐ์", "๋ฌ"}:
|
| 445 |
+
return today - timedelta(days=max(amount * 30 - 1, 0)), today
|
| 446 |
+
|
| 447 |
+
if "์ต๊ทผ ๋ช์ผ" in q or "์ต๊ทผ๋ช์ผ" in q or "์ต๊ทผ ๋ฉฐ์น " in question or "์ต๊ทผ๋ฉฐ์น " in q:
|
| 448 |
+
return today - timedelta(days=_DEFAULT_DAYS - 1), today
|
| 449 |
+
if "์ต๊ทผ ๋ช์ฃผ" in q or "์ต๊ทผ๋ช์ฃผ" in q:
|
| 450 |
+
return today - timedelta(days=13), today
|
| 451 |
+
|
| 452 |
+
return today - timedelta(days=_DEFAULT_DAYS - 1), today
|
| 453 |
+
|
| 454 |
+
|
| 455 |
+
def _coerce_search_window(
|
| 456 |
+
start: str | None,
|
| 457 |
+
end: str | None,
|
| 458 |
+
*,
|
| 459 |
+
days: int | None,
|
| 460 |
+
weeks: int | None,
|
| 461 |
+
) -> tuple[str, str]:
|
| 462 |
+
today = date.today()
|
| 463 |
+
if start or end:
|
| 464 |
+
resolved_start = _strip_date_sep(start or (end or today.strftime("%Y%m%d")))
|
| 465 |
+
resolved_end = _strip_date_sep(end or today.strftime("%Y%m%d"))
|
| 466 |
+
return resolved_start, resolved_end
|
| 467 |
+
if days:
|
| 468 |
+
begin = today - timedelta(days=max(days - 1, 0))
|
| 469 |
+
return begin.strftime("%Y%m%d"), today.strftime("%Y%m%d")
|
| 470 |
+
if weeks:
|
| 471 |
+
begin = today - timedelta(days=max(weeks * 7 - 1, 0))
|
| 472 |
+
return begin.strftime("%Y%m%d"), today.strftime("%Y%m%d")
|
| 473 |
+
begin = today - timedelta(days=_DEFAULT_DAYS - 1)
|
| 474 |
+
return begin.strftime("%Y%m%d"), today.strftime("%Y%m%d")
|
| 475 |
+
|
| 476 |
+
|
| 477 |
+
def _strip_date_sep(value: str) -> str:
|
| 478 |
+
return (value or "").replace("-", "").replace(".", "").replace("/", "")
|
| 479 |
+
|
| 480 |
+
|
| 481 |
+
def _format_date(value: str) -> str:
|
| 482 |
+
digits = _strip_date_sep(str(value))
|
| 483 |
+
if len(digits) == 8 and digits.isdigit():
|
| 484 |
+
return f"{digits[:4]}-{digits[4:6]}-{digits[6:]}"
|
| 485 |
+
return str(value)
|
src/dartlab/ai/context/finance_context.py
ADDED
|
@@ -0,0 +1,945 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Finance/report ๋ฐ์ดํฐ๋ฅผ LLM context ๋งํฌ๋ค์ด์ผ๋ก ๋ณํํ๋ ํจ์๋ค."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import re
|
| 6 |
+
from typing import Any
|
| 7 |
+
|
| 8 |
+
import polars as pl
|
| 9 |
+
|
| 10 |
+
from dartlab.ai.context.company_adapter import get_headline_ratios, get_ratio_series
|
| 11 |
+
from dartlab.ai.context.formatting import _format_won, df_to_markdown
|
| 12 |
+
from dartlab.ai.metadata import MODULE_META
|
| 13 |
+
|
| 14 |
+
_CONTEXT_ERRORS = (AttributeError, KeyError, OSError, RuntimeError, TypeError, ValueError)
|
| 15 |
+
|
| 16 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 17 |
+
# ์ง๋ฌธ ์ ํ๋ณ ๋ชจ๋ ๋งคํ (registry ์๋ ์์ฑ + override)
|
| 18 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 19 |
+
|
| 20 |
+
from dartlab.core.registry import buildQuestionModules
|
| 21 |
+
|
| 22 |
+
# registry์ ์๋ ๋ชจ๋(sections topic ์ ์ฉ ๋ฑ)์ override๋ก ์ถ๊ฐ
|
| 23 |
+
_QUESTION_MODULES_OVERRIDE: dict[str, list[str]] = {
|
| 24 |
+
"๊ณต์": [],
|
| 25 |
+
"๋ฐฐ๋น": ["treasuryStock"],
|
| 26 |
+
"์๋ณธ": ["treasuryStock"],
|
| 27 |
+
"์ฌ์
": ["businessOverview"],
|
| 28 |
+
"ESG": ["governanceOverview", "boardOfDirectors"],
|
| 29 |
+
"๊ณต๊ธ๋ง": ["segments", "rawMaterial"],
|
| 30 |
+
"๋ณํ": ["disclosureChanges", "businessStatus"],
|
| 31 |
+
"๋ฐธ๋ฅ์์ด์
": ["IS", "BS"],
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
_QUESTION_MODULES: dict[str, list[str]] = {}
|
| 35 |
+
for _qt, _mods in buildQuestionModules().items():
|
| 36 |
+
_QUESTION_MODULES[_qt] = list(_mods)
|
| 37 |
+
for _qt, _extra in _QUESTION_MODULES_OVERRIDE.items():
|
| 38 |
+
_QUESTION_MODULES.setdefault(_qt, []).extend(m for m in _extra if m not in _QUESTION_MODULES.get(_qt, []))
|
| 39 |
+
|
| 40 |
+
_ALWAYS_INCLUDE_MODULES = {"employee"}
|
| 41 |
+
|
| 42 |
+
_CONTEXT_MODULE_BUDGET = 10000 # ์ด ๋ชจ๋ context ๊ธ์ ์ ์ํ (focused tier ๊ธฐ๋ณธ๊ฐ)
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def _resolve_context_budget(tier: str = "focused") -> int:
|
| 46 |
+
"""์ปจํ
์คํธ tier๋ณ ๋ชจ๋ ์์ฐ."""
|
| 47 |
+
return {
|
| 48 |
+
"skeleton": 2000, # tool-capable: ์ต์ ๋งฅ๋ฝ, ๋๊ตฌ๋ก ๋ณด์ถฉ
|
| 49 |
+
"focused": 10000, # ๋ถ๊ธฐ ๋ฐ์ดํฐ ์์ฉ
|
| 50 |
+
"full": 16000, # non-tool ๋ชจ๋ธ: ์ต๋ํ ํฌํจ
|
| 51 |
+
}.get(tier, 10000)
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
def _topic_name_set(company: Any) -> set[str]:
|
| 55 |
+
"""Company.topics์์ ์ค์ topic ์ด๋ฆ๋ง ์์ ํ๊ฒ ์ถ์ถ."""
|
| 56 |
+
try:
|
| 57 |
+
topics = getattr(company, "topics", None)
|
| 58 |
+
except _CONTEXT_ERRORS:
|
| 59 |
+
return set()
|
| 60 |
+
|
| 61 |
+
if topics is None:
|
| 62 |
+
return set()
|
| 63 |
+
|
| 64 |
+
if isinstance(topics, pl.DataFrame):
|
| 65 |
+
if "topic" not in topics.columns:
|
| 66 |
+
return set()
|
| 67 |
+
return {t for t in topics["topic"].drop_nulls().to_list() if isinstance(t, str) and t}
|
| 68 |
+
|
| 69 |
+
if isinstance(topics, pl.Series):
|
| 70 |
+
return {t for t in topics.drop_nulls().to_list() if isinstance(t, str) and t}
|
| 71 |
+
|
| 72 |
+
try:
|
| 73 |
+
return {str(t) for t in topics if isinstance(t, str) and t}
|
| 74 |
+
except TypeError:
|
| 75 |
+
return set()
|
| 76 |
+
|
| 77 |
+
|
| 78 |
+
def _resolve_module_data(company: Any, module_name: str) -> Any:
|
| 79 |
+
"""AI context์ฉ ๋ชจ๋ ํด์.
|
| 80 |
+
|
| 81 |
+
1. Company property/direct attr
|
| 82 |
+
2. registry ๊ธฐ๋ฐ lazy parser (_get_primary)
|
| 83 |
+
3. ์ค์ ์กด์ฌํ๋ topic์ ํํด show()
|
| 84 |
+
"""
|
| 85 |
+
data = getattr(company, module_name, None)
|
| 86 |
+
if data is not None:
|
| 87 |
+
return data
|
| 88 |
+
|
| 89 |
+
get_primary = getattr(company, "_get_primary", None)
|
| 90 |
+
if callable(get_primary):
|
| 91 |
+
try:
|
| 92 |
+
data = get_primary(module_name)
|
| 93 |
+
except _CONTEXT_ERRORS:
|
| 94 |
+
data = None
|
| 95 |
+
except (FileNotFoundError, ImportError, IndexError):
|
| 96 |
+
data = None
|
| 97 |
+
if data is not None:
|
| 98 |
+
return data
|
| 99 |
+
|
| 100 |
+
if hasattr(company, "show") and module_name in _topic_name_set(company):
|
| 101 |
+
try:
|
| 102 |
+
return company.show(module_name)
|
| 103 |
+
except _CONTEXT_ERRORS:
|
| 104 |
+
return None
|
| 105 |
+
|
| 106 |
+
return None
|
| 107 |
+
|
| 108 |
+
|
| 109 |
+
def _extract_module_context(company: Any, module_name: str, max_rows: int = 10) -> str | None:
|
| 110 |
+
"""registry ๋ชจ๋ โ ๋งํฌ๋ค์ด ์์ฝ. DataFrame/dict/list/text ๋ชจ๋ ์ฒ๋ฆฌ."""
|
| 111 |
+
try:
|
| 112 |
+
data = _resolve_module_data(company, module_name)
|
| 113 |
+
if data is None:
|
| 114 |
+
return None
|
| 115 |
+
|
| 116 |
+
if callable(data) and not isinstance(data, type):
|
| 117 |
+
try:
|
| 118 |
+
data = data()
|
| 119 |
+
except (AttributeError, KeyError, OSError, RuntimeError, TypeError, ValueError):
|
| 120 |
+
return None
|
| 121 |
+
|
| 122 |
+
meta = MODULE_META.get(module_name)
|
| 123 |
+
label = meta.label if meta else module_name
|
| 124 |
+
|
| 125 |
+
if isinstance(data, pl.DataFrame):
|
| 126 |
+
if data.is_empty():
|
| 127 |
+
return None
|
| 128 |
+
md = df_to_markdown(data, max_rows=max_rows, meta=meta, compact=True)
|
| 129 |
+
return f"## {label}\n{md}"
|
| 130 |
+
|
| 131 |
+
if isinstance(data, dict):
|
| 132 |
+
items = list(data.items())[:max_rows]
|
| 133 |
+
lines = [f"## {label}"]
|
| 134 |
+
for k, v in items:
|
| 135 |
+
lines.append(f"- {k}: {v}")
|
| 136 |
+
return "\n".join(lines)
|
| 137 |
+
|
| 138 |
+
if isinstance(data, list):
|
| 139 |
+
if not data:
|
| 140 |
+
return None
|
| 141 |
+
lines = [f"## {label}"]
|
| 142 |
+
for item in data[:max_rows]:
|
| 143 |
+
if hasattr(item, "title") and hasattr(item, "chars"):
|
| 144 |
+
lines.append(f"- **{item.title}** ({item.chars}์)")
|
| 145 |
+
else:
|
| 146 |
+
lines.append(f"- {item}")
|
| 147 |
+
if len(data) > max_rows:
|
| 148 |
+
lines.append(f"(... ์์ {max_rows}๊ฑด, ์ ์ฒด {len(data)}๊ฑด)")
|
| 149 |
+
return "\n".join(lines)
|
| 150 |
+
|
| 151 |
+
text = str(data)
|
| 152 |
+
if len(text) > 300:
|
| 153 |
+
text = (
|
| 154 |
+
text[:300]
|
| 155 |
+
+ f"... (์ ์ฒด {len(str(data))}์, explore(action='show', topic='{module_name}')์ผ๋ก ์ ๋ฌธ ํ์ธ)"
|
| 156 |
+
)
|
| 157 |
+
return f"## {label}\n{text}" if text.strip() else None
|
| 158 |
+
|
| 159 |
+
except (AttributeError, KeyError, OSError, RuntimeError, TypeError, ValueError):
|
| 160 |
+
return None
|
| 161 |
+
|
| 162 |
+
|
| 163 |
+
def _build_report_sections(
|
| 164 |
+
company: Any,
|
| 165 |
+
compact: bool = False,
|
| 166 |
+
q_types: list[str] | None = None,
|
| 167 |
+
tier: str = "focused",
|
| 168 |
+
report_names: list[str] | None = None,
|
| 169 |
+
) -> dict[str, str]:
|
| 170 |
+
"""reportEngine pivot ๊ฒฐ๊ณผ + ์ง๋ฌธ ์ ํ๋ณ ๋ชจ๋ ์๋ ์ฃผ์
โ LLM context ์น์
dict."""
|
| 171 |
+
report = getattr(company, "report", None)
|
| 172 |
+
sections: dict[str, str] = {}
|
| 173 |
+
budget = _resolve_context_budget(tier)
|
| 174 |
+
requested_reports = set(report_names or ["dividend", "employee", "majorHolder", "executive", "audit"])
|
| 175 |
+
|
| 176 |
+
# ์ง๋ฌธ ์ ํ๋ณ ์ถ๊ฐ ๋ชจ๋ ์ฃผ์
|
| 177 |
+
extra_modules: set[str] = set() if report_names is not None else set(_ALWAYS_INCLUDE_MODULES)
|
| 178 |
+
if q_types and report_names is None:
|
| 179 |
+
for qt in q_types:
|
| 180 |
+
for mod in _QUESTION_MODULES.get(qt, []):
|
| 181 |
+
extra_modules.add(mod)
|
| 182 |
+
|
| 183 |
+
# ํ๋์ฝ๋ฉ๋ ๊ธฐ์กด report ๋ชจ๋๋ค์ ์ด๋ฆ (์ค๋ณต ๋ฐฉ์ง์ฉ)
|
| 184 |
+
_HARDCODED_REPORT = {"dividend", "employee", "majorHolder", "executive", "audit"}
|
| 185 |
+
if report_names:
|
| 186 |
+
for mod in report_names:
|
| 187 |
+
if mod not in _HARDCODED_REPORT:
|
| 188 |
+
extra_modules.add(mod)
|
| 189 |
+
|
| 190 |
+
# ๋์ ๋ชจ๋ ์ฃผ์
(ํ๋์ฝ๋ฉ์ ์๋ ๊ฒ๋ง)
|
| 191 |
+
budget_used = 0
|
| 192 |
+
for mod in sorted(extra_modules - _HARDCODED_REPORT):
|
| 193 |
+
if budget_used >= budget:
|
| 194 |
+
break
|
| 195 |
+
content = _extract_module_context(company, mod, max_rows=8 if compact else 12)
|
| 196 |
+
if content:
|
| 197 |
+
budget_used += len(content)
|
| 198 |
+
sections[f"module_{mod}"] = content
|
| 199 |
+
|
| 200 |
+
if report is None:
|
| 201 |
+
return sections
|
| 202 |
+
|
| 203 |
+
max_years = 3 if compact else 99
|
| 204 |
+
|
| 205 |
+
div = getattr(report, "dividend", None) if "dividend" in requested_reports else None
|
| 206 |
+
if div is not None and div.years:
|
| 207 |
+
display_years = div.years[-max_years:]
|
| 208 |
+
offset = len(div.years) - len(display_years)
|
| 209 |
+
lines = ["## ๋ฐฐ๋น ์๊ณ์ด (์ ๊ธฐ๋ณด๊ณ ์)"]
|
| 210 |
+
header = "| ์ฐ๋ | " + " | ".join(str(y) for y in display_years) + " |"
|
| 211 |
+
sep = "| --- | " + " | ".join(["---"] * len(display_years)) + " |"
|
| 212 |
+
lines.append(header)
|
| 213 |
+
lines.append(sep)
|
| 214 |
+
|
| 215 |
+
def _fmtList(vals):
|
| 216 |
+
return [str(round(v)) if v is not None else "-" for v in vals]
|
| 217 |
+
|
| 218 |
+
lines.append("| DPS(์) | " + " | ".join(_fmtList(div.dps[offset:])) + " |")
|
| 219 |
+
lines.append(
|
| 220 |
+
"| ๋ฐฐ๋น์์ต๋ฅ (%) | "
|
| 221 |
+
+ " | ".join([f"{v:.2f}" if v is not None else "-" for v in div.dividendYield[offset:]])
|
| 222 |
+
+ " |"
|
| 223 |
+
)
|
| 224 |
+
latest_dps = div.dps[-1] if div.dps else None
|
| 225 |
+
latest_yield = div.dividendYield[-1] if div.dividendYield else None
|
| 226 |
+
if latest_dps is not None or latest_yield is not None:
|
| 227 |
+
lines.append("")
|
| 228 |
+
lines.append("### ๋ฐฐ๋น ํต์ฌ ์์ฝ")
|
| 229 |
+
if latest_dps is not None:
|
| 230 |
+
lines.append(f"- ์ต๊ทผ ์ฐ๋ DPS: {int(round(latest_dps))}์")
|
| 231 |
+
if latest_yield is not None:
|
| 232 |
+
lines.append(f"- ์ต๊ทผ ์ฐ๋ ๋ฐฐ๋น์์ต๋ฅ : {latest_yield:.2f}%")
|
| 233 |
+
if len(display_years) >= 3:
|
| 234 |
+
recent_dps = [
|
| 235 |
+
f"{year}:{int(round(value)) if value is not None else '-'}์"
|
| 236 |
+
for year, value in zip(display_years[-3:], div.dps[offset:][-3:], strict=False)
|
| 237 |
+
]
|
| 238 |
+
lines.append("- ์ต๊ทผ 3๊ฐ๋
DPS ์ถ์ด: " + " โ ".join(recent_dps))
|
| 239 |
+
sections["report_dividend"] = "\n".join(lines)
|
| 240 |
+
|
| 241 |
+
emp = getattr(report, "employee", None) if "employee" in requested_reports else None
|
| 242 |
+
if emp is not None and emp.years:
|
| 243 |
+
display_years = emp.years[-max_years:]
|
| 244 |
+
offset = len(emp.years) - len(display_years)
|
| 245 |
+
lines = ["## ์ง์ํํฉ (์ ๊ธฐ๋ณด๊ณ ์)"]
|
| 246 |
+
header = "| ์ฐ๋ | " + " | ".join(str(y) for y in display_years) + " |"
|
| 247 |
+
sep = "| --- | " + " | ".join(["---"] * len(display_years)) + " |"
|
| 248 |
+
lines.append(header)
|
| 249 |
+
lines.append(sep)
|
| 250 |
+
|
| 251 |
+
def _fmtEmp(vals):
|
| 252 |
+
return [f"{int(v):,}" if v is not None else "-" for v in vals]
|
| 253 |
+
|
| 254 |
+
def _fmtSalary(vals):
|
| 255 |
+
return [f"{int(v):,}" if v is not None else "-" for v in vals]
|
| 256 |
+
|
| 257 |
+
lines.append("| ์ด ์ง์์(๋ช
) | " + " | ".join(_fmtEmp(emp.totalEmployee[offset:])) + " |")
|
| 258 |
+
lines.append("| ํ๊ท ์๊ธ(์ฒ์) | " + " | ".join(_fmtSalary(emp.avgMonthlySalary[offset:])) + " |")
|
| 259 |
+
sections["report_employee"] = "\n".join(lines)
|
| 260 |
+
|
| 261 |
+
mh = getattr(report, "majorHolder", None) if "majorHolder" in requested_reports else None
|
| 262 |
+
if mh is not None and mh.years:
|
| 263 |
+
lines = ["## ์ต๋์ฃผ์ฃผ (์ ๊ธฐ๋ณด๊ณ ์)"]
|
| 264 |
+
if compact:
|
| 265 |
+
latest_ratio = mh.totalShareRatio[-1] if mh.totalShareRatio else None
|
| 266 |
+
ratio_str = f"{latest_ratio:.2f}%" if latest_ratio is not None else "-"
|
| 267 |
+
lines.append(f"- {mh.years[-1]}๋
ํฉ์ฐ ์ง๋ถ์จ: {ratio_str}")
|
| 268 |
+
else:
|
| 269 |
+
header = "| ์ฐ๋ | " + " | ".join(str(y) for y in mh.years) + " |"
|
| 270 |
+
sep = "| --- | " + " | ".join(["---"] * len(mh.years)) + " |"
|
| 271 |
+
lines.append(header)
|
| 272 |
+
lines.append(sep)
|
| 273 |
+
lines.append(
|
| 274 |
+
"| ํฉ์ฐ ์ง๋ถ์จ(%) | "
|
| 275 |
+
+ " | ".join([f"{v:.2f}" if v is not None else "-" for v in mh.totalShareRatio])
|
| 276 |
+
+ " |"
|
| 277 |
+
)
|
| 278 |
+
|
| 279 |
+
if mh.latestHolders:
|
| 280 |
+
holder_limit = 3 if compact else 5
|
| 281 |
+
if not compact:
|
| 282 |
+
lines.append("")
|
| 283 |
+
lines.append(f"### ์ต๊ทผ ์ฃผ์์ฃผ์ฃผ ({mh.years[-1]}๋
)")
|
| 284 |
+
for h in mh.latestHolders[:holder_limit]:
|
| 285 |
+
ratio = f"{h['ratio']:.2f}%" if h.get("ratio") is not None else "-"
|
| 286 |
+
relate = f" ({h['relate']})" if h.get("relate") else ""
|
| 287 |
+
lines.append(f"- {h['name']}{relate}: {ratio}")
|
| 288 |
+
sections["report_majorHolder"] = "\n".join(lines)
|
| 289 |
+
|
| 290 |
+
exe = getattr(report, "executive", None) if "executive" in requested_reports else None
|
| 291 |
+
if exe is not None and exe.totalCount > 0:
|
| 292 |
+
lines = [
|
| 293 |
+
"## ์์ํํฉ (์ ๊ธฐ๋ณด๊ณ ์)",
|
| 294 |
+
f"- ์ด ์์์: {exe.totalCount}๋ช
",
|
| 295 |
+
f"- ์ฌ๋ด์ด์ฌ: {exe.registeredCount}๋ช
",
|
| 296 |
+
f"- ์ฌ์ธ์ด์ฌ: {exe.outsideCount}๋ช
",
|
| 297 |
+
]
|
| 298 |
+
sections["report_executive"] = "\n".join(lines)
|
| 299 |
+
|
| 300 |
+
aud = getattr(report, "audit", None) if "audit" in requested_reports else None
|
| 301 |
+
if aud is not None and aud.years:
|
| 302 |
+
lines = ["## ๊ฐ์ฌ์๊ฒฌ (์ ๊ธฐ๋ณด๊ณ ์)"]
|
| 303 |
+
display_aud = list(zip(aud.years, aud.opinions, aud.auditors))
|
| 304 |
+
if compact:
|
| 305 |
+
display_aud = display_aud[-2:]
|
| 306 |
+
for y, opinion, auditor in display_aud:
|
| 307 |
+
opinion = opinion or "-"
|
| 308 |
+
auditor = auditor or "-"
|
| 309 |
+
lines.append(f"- {y}๋
: {opinion} ({auditor})")
|
| 310 |
+
sections["report_audit"] = "\n".join(lines)
|
| 311 |
+
|
| 312 |
+
return sections
|
| 313 |
+
|
| 314 |
+
|
| 315 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 316 |
+
# financeEngine ๊ธฐ๋ฐ ์ปจํ
์คํธ (1์ฐจ ๋ฐ์ดํฐ ์์ค)
|
| 317 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 318 |
+
|
| 319 |
+
_YEAR_HINT_KEYWORDS: dict[str, int] = {
|
| 320 |
+
"์ต๊ทผ": 3,
|
| 321 |
+
"์ฌํด": 3,
|
| 322 |
+
"์๋
": 3,
|
| 323 |
+
"์ ๋
": 3,
|
| 324 |
+
"์ถ์ด": 5,
|
| 325 |
+
"ํธ๋ ๋": 5,
|
| 326 |
+
"์ถ์ธ": 5,
|
| 327 |
+
"๋ณํ": 5,
|
| 328 |
+
"์ฑ์ฅ": 5,
|
| 329 |
+
"ํ๋ฆ": 5,
|
| 330 |
+
"์ ์ฒด": 15,
|
| 331 |
+
"์ญ์ฌ": 15,
|
| 332 |
+
"์ฅ๊ธฐ": 10,
|
| 333 |
+
}
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
def _detect_year_hint(question: str) -> int:
|
| 337 |
+
"""์ง๋ฌธ์์ ํ์ํ ์ฐ๋ ๋ฒ์ ์ถ์ถ."""
|
| 338 |
+
range_match = re.search(r"(\d+)\s*(?:๊ฐ๋
|๋
)", question)
|
| 339 |
+
if range_match:
|
| 340 |
+
value = int(range_match.group(1))
|
| 341 |
+
if 1 <= value <= 15:
|
| 342 |
+
return value
|
| 343 |
+
|
| 344 |
+
year_match = re.search(r"(20\d{2})", question)
|
| 345 |
+
if year_match:
|
| 346 |
+
return 3
|
| 347 |
+
|
| 348 |
+
for keyword, n in _YEAR_HINT_KEYWORDS.items():
|
| 349 |
+
if keyword in question:
|
| 350 |
+
return n
|
| 351 |
+
|
| 352 |
+
return 5
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
_FE_DISPLAY_ACCOUNTS = {
|
| 356 |
+
"BS": [
|
| 357 |
+
("total_assets", "์์ฐ์ด๊ณ"),
|
| 358 |
+
("current_assets", "์ ๋์์ฐ"),
|
| 359 |
+
("noncurrent_assets", "๋น์ ๋์์ฐ"),
|
| 360 |
+
("total_liabilities", "๋ถ์ฑ์ด๊ณ"),
|
| 361 |
+
("current_liabilities", "์ ๋๋ถ์ฑ"),
|
| 362 |
+
("noncurrent_liabilities", "๋น์ ๋๋ถ์ฑ"),
|
| 363 |
+
("owners_of_parent_equity", "์๋ณธ์ด๊ณ"),
|
| 364 |
+
("cash_and_cash_equivalents", "ํ๊ธ์ฑ์์ฐ"),
|
| 365 |
+
("trade_and_other_receivables", "๋งค์ถ์ฑ๊ถ"),
|
| 366 |
+
("inventories", "์ฌ๊ณ ์์ฐ"),
|
| 367 |
+
("tangible_assets", "์ ํ์์ฐ"),
|
| 368 |
+
("intangible_assets", "๋ฌดํ์์ฐ"),
|
| 369 |
+
("shortterm_borrowings", "๋จ๊ธฐ์ฐจ์
๊ธ"),
|
| 370 |
+
("longterm_borrowings", "์ฅ๊ธฐ์ฐจ์
๊ธ"),
|
| 371 |
+
],
|
| 372 |
+
"IS": [
|
| 373 |
+
("sales", "๋งค์ถ์ก"),
|
| 374 |
+
("cost_of_sales", "๋งค์ถ์๊ฐ"),
|
| 375 |
+
("gross_profit", "๋งค์ถ์ด์ด์ต"),
|
| 376 |
+
("selling_and_administrative_expenses", "ํ๊ด๋น"),
|
| 377 |
+
("operating_profit", "์์
์ด์ต"),
|
| 378 |
+
("finance_income", "๊ธ์ต์์ต"),
|
| 379 |
+
("finance_costs", "๊ธ์ต๋น์ฉ"),
|
| 380 |
+
("profit_before_tax", "๋ฒ์ธ์ธ์ฐจ๊ฐ์ ์ด์ต"),
|
| 381 |
+
("income_taxes", "๋ฒ์ธ์ธ๋น์ฉ"),
|
| 382 |
+
("net_profit", "๋น๊ธฐ์์ด์ต"),
|
| 383 |
+
],
|
| 384 |
+
"CF": [
|
| 385 |
+
("operating_cashflow", "์์
ํ๋CF"),
|
| 386 |
+
("investing_cashflow", "ํฌ์ํ๋CF"),
|
| 387 |
+
("cash_flows_from_financing_activities", "์ฌ๋ฌดํ๋CF"),
|
| 388 |
+
("cash_and_cash_equivalents_end", "๊ธฐ๋งํ๊ธ"),
|
| 389 |
+
],
|
| 390 |
+
}
|
| 391 |
+
|
| 392 |
+
|
| 393 |
+
# ํ๊ธ ๋ผ๋ฒจ โ snakeId ์ญ๋งคํ (Phase 5 validation์ฉ)
|
| 394 |
+
ACCOUNT_LABEL_TO_SNAKE: dict[str, str] = {}
|
| 395 |
+
for _sj_accounts in _FE_DISPLAY_ACCOUNTS.values():
|
| 396 |
+
for _snake_id, _label in _sj_accounts:
|
| 397 |
+
ACCOUNT_LABEL_TO_SNAKE[_label] = _snake_id
|
| 398 |
+
|
| 399 |
+
_QUESTION_ACCOUNT_FILTER: dict[str, dict[str, set[str]]] = {
|
| 400 |
+
"๊ฑด์ ์ฑ": {
|
| 401 |
+
"BS": {
|
| 402 |
+
"total_assets",
|
| 403 |
+
"total_liabilities",
|
| 404 |
+
"owners_of_parent_equity",
|
| 405 |
+
"current_assets",
|
| 406 |
+
"current_liabilities",
|
| 407 |
+
"cash_and_cash_equivalents",
|
| 408 |
+
"shortterm_borrowings",
|
| 409 |
+
"longterm_borrowings",
|
| 410 |
+
},
|
| 411 |
+
"IS": {"operating_profit", "finance_costs", "net_profit"},
|
| 412 |
+
"CF": {"operating_cashflow", "investing_cashflow"},
|
| 413 |
+
},
|
| 414 |
+
"์์ต์ฑ": {
|
| 415 |
+
"IS": {
|
| 416 |
+
"sales",
|
| 417 |
+
"cost_of_sales",
|
| 418 |
+
"gross_profit",
|
| 419 |
+
"selling_and_administrative_expenses",
|
| 420 |
+
"operating_profit",
|
| 421 |
+
"net_profit",
|
| 422 |
+
},
|
| 423 |
+
"BS": {"owners_of_parent_equity", "total_assets"},
|
| 424 |
+
},
|
| 425 |
+
"์ฑ์ฅ์ฑ": {
|
| 426 |
+
"IS": {"sales", "operating_profit", "net_profit"},
|
| 427 |
+
"CF": {"operating_cashflow"},
|
| 428 |
+
},
|
| 429 |
+
"๋ฐฐ๋น": {
|
| 430 |
+
"IS": {"net_profit"},
|
| 431 |
+
"BS": {"owners_of_parent_equity"},
|
| 432 |
+
},
|
| 433 |
+
"ํ๊ธ": {
|
| 434 |
+
"CF": {
|
| 435 |
+
"operating_cashflow",
|
| 436 |
+
"investing_cashflow",
|
| 437 |
+
"cash_flows_from_financing_activities",
|
| 438 |
+
"cash_and_cash_equivalents_end",
|
| 439 |
+
},
|
| 440 |
+
"BS": {"cash_and_cash_equivalents"},
|
| 441 |
+
},
|
| 442 |
+
}
|
| 443 |
+
|
| 444 |
+
|
| 445 |
+
def _get_quarter_counts(company: Any) -> dict[str, int]:
|
| 446 |
+
"""company.timeseries periods์์ ์ฐ๋๋ณ ๋ถ๊ธฐ ์ ๊ณ์ฐ."""
|
| 447 |
+
ts = getattr(company, "timeseries", None)
|
| 448 |
+
if ts is None:
|
| 449 |
+
return {}
|
| 450 |
+
_, periods = ts
|
| 451 |
+
counts: dict[str, int] = {}
|
| 452 |
+
for p in periods:
|
| 453 |
+
year = p.split("-")[0] if "-" in p else p[:4]
|
| 454 |
+
counts[year] = counts.get(year, 0) + 1
|
| 455 |
+
return counts
|
| 456 |
+
|
| 457 |
+
|
| 458 |
+
def _build_finance_engine_section(
|
| 459 |
+
series: dict,
|
| 460 |
+
years: list[str],
|
| 461 |
+
sj_div: str,
|
| 462 |
+
n_years: int,
|
| 463 |
+
account_filter: set[str] | None = None,
|
| 464 |
+
quarter_counts: dict[str, int] | None = None,
|
| 465 |
+
) -> str | None:
|
| 466 |
+
"""financeEngine annual series โ compact ๋งํฌ๋ค์ด ํ
์ด๋ธ.
|
| 467 |
+
|
| 468 |
+
Args:
|
| 469 |
+
account_filter: ์ด set์ ์ํ snake_id๋ง ํ์. None์ด๋ฉด ์ ์ฒด.
|
| 470 |
+
"""
|
| 471 |
+
accounts = _FE_DISPLAY_ACCOUNTS.get(sj_div, [])
|
| 472 |
+
if account_filter:
|
| 473 |
+
accounts = [(sid, label) for sid, label in accounts if sid in account_filter]
|
| 474 |
+
if not accounts:
|
| 475 |
+
return None
|
| 476 |
+
|
| 477 |
+
display_years = years[-n_years:]
|
| 478 |
+
|
| 479 |
+
# ๋ถ๋ถ ์ฐ๋ ํ์: IS/CF๋ 4๋ถ๊ธฐ ๋ฏธ๋ง์ด๋ฉด "(~Q3)" ๋ฑ ํ์, BS๋ ์์ ์์ก์ด๋ฏ๋ก ๋ถํ์
|
| 480 |
+
display_years_labeled = []
|
| 481 |
+
for y in display_years:
|
| 482 |
+
qc = (quarter_counts or {}).get(y, 4)
|
| 483 |
+
if sj_div != "BS" and qc < 4:
|
| 484 |
+
display_years_labeled.append(f"{y}(~Q{qc})")
|
| 485 |
+
else:
|
| 486 |
+
display_years_labeled.append(y)
|
| 487 |
+
display_years_reversed = list(reversed(display_years_labeled))
|
| 488 |
+
|
| 489 |
+
# ์ต์ ์ฐ๋๊ฐ ๋ถ๋ถ์ด๋ฉด YoY ๋น๊ต ๋ฌด์๋ฏธ
|
| 490 |
+
latest_year = display_years[-1]
|
| 491 |
+
latest_partial = sj_div != "BS" and (quarter_counts or {}).get(latest_year, 4) < 4
|
| 492 |
+
|
| 493 |
+
sj_data = series.get(sj_div, {})
|
| 494 |
+
if not sj_data:
|
| 495 |
+
return None
|
| 496 |
+
|
| 497 |
+
rows_data = []
|
| 498 |
+
for snake_id, label in accounts:
|
| 499 |
+
vals = sj_data.get(snake_id)
|
| 500 |
+
if not vals:
|
| 501 |
+
continue
|
| 502 |
+
year_offset = len(years) - n_years
|
| 503 |
+
sliced = vals[year_offset:] if year_offset >= 0 else vals
|
| 504 |
+
has_data = any(v is not None for v in sliced)
|
| 505 |
+
if has_data:
|
| 506 |
+
rows_data.append((label, list(reversed(sliced))))
|
| 507 |
+
|
| 508 |
+
if not rows_data:
|
| 509 |
+
return None
|
| 510 |
+
|
| 511 |
+
sj_labels = {"BS": "์ฌ๋ฌด์ํํ", "IS": "์์ต๊ณ์ฐ์", "CF": "ํ๊ธํ๋ฆํ"}
|
| 512 |
+
header = "| ๊ณ์ | " + " | ".join(display_years_reversed) + " | YoY |"
|
| 513 |
+
sep = "| --- | " + " | ".join(["---"] * len(display_years_reversed)) + " | --- |"
|
| 514 |
+
|
| 515 |
+
# ๊ธฐ๊ฐ ๋ฉํ๋ฐ์ดํฐ ๋ช
์
|
| 516 |
+
sj_meta = {"BS": "์์ ์์ก", "IS": "๊ธฐ๊ฐ flow (standalone)", "CF": "๊ธฐ๊ฐ flow (standalone)"}
|
| 517 |
+
meta_line = f"(๋จ์: ์ต/์กฐ์ | {sj_meta.get(sj_div, 'standalone')})"
|
| 518 |
+
if latest_partial:
|
| 519 |
+
meta_line += f" โ ๏ธ {display_years_labeled[-1]}์ ๋ถ๋ถ์ฐ๋ โ ์ฐ๊ฐ ์ง์ ๋น๊ต ๋ถ๊ฐ"
|
| 520 |
+
|
| 521 |
+
lines = [f"## {sj_labels.get(sj_div, sj_div)}", meta_line, header, sep]
|
| 522 |
+
for label, vals in rows_data:
|
| 523 |
+
cells = []
|
| 524 |
+
for v in vals:
|
| 525 |
+
cells.append(_format_won(v) if v is not None else "-")
|
| 526 |
+
# YoY: ๋ถ๋ถ ์ฐ๋๋ฉด ๋น๊ต ๋ถ๊ฐ
|
| 527 |
+
if latest_partial:
|
| 528 |
+
yoy_str = "-"
|
| 529 |
+
else:
|
| 530 |
+
yoy_str = _calc_yoy(vals[0], vals[1] if len(vals) > 1 else None)
|
| 531 |
+
lines.append(f"| {label} | " + " | ".join(cells) + f" | {yoy_str} |")
|
| 532 |
+
|
| 533 |
+
return "\n".join(lines)
|
| 534 |
+
|
| 535 |
+
|
| 536 |
+
def _buildQuarterlySection(
|
| 537 |
+
series: dict,
|
| 538 |
+
periods: list[str],
|
| 539 |
+
sjDiv: str,
|
| 540 |
+
nQuarters: int = 8,
|
| 541 |
+
accountFilter: set[str] | None = None,
|
| 542 |
+
) -> str | None:
|
| 543 |
+
"""timeseries ๋ถ๊ธฐ๋ณ standalone โ compact ๋งํฌ๋ค์ด ํ
์ด๋ธ.
|
| 544 |
+
|
| 545 |
+
์ต๊ทผ nQuarters ๋ถ๊ธฐ๋ง ํ์. QoQ/YoY ์ปฌ๋ผ ํฌํจ.
|
| 546 |
+
"""
|
| 547 |
+
accounts = _FE_DISPLAY_ACCOUNTS.get(sjDiv, [])
|
| 548 |
+
if accountFilter:
|
| 549 |
+
accounts = [(sid, label) for sid, label in accounts if sid in accountFilter]
|
| 550 |
+
if not accounts:
|
| 551 |
+
return None
|
| 552 |
+
|
| 553 |
+
sjData = series.get(sjDiv, {})
|
| 554 |
+
if not sjData:
|
| 555 |
+
return None
|
| 556 |
+
|
| 557 |
+
displayPeriods = periods[-nQuarters:]
|
| 558 |
+
displayPeriodsReversed = list(reversed(displayPeriods))
|
| 559 |
+
|
| 560 |
+
rowsData = []
|
| 561 |
+
for snakeId, label in accounts:
|
| 562 |
+
vals = sjData.get(snakeId)
|
| 563 |
+
if not vals:
|
| 564 |
+
continue
|
| 565 |
+
offset = len(periods) - nQuarters
|
| 566 |
+
sliced = vals[offset:] if offset >= 0 else vals
|
| 567 |
+
hasData = any(v is not None for v in sliced)
|
| 568 |
+
if hasData:
|
| 569 |
+
rowsData.append((label, list(reversed(sliced))))
|
| 570 |
+
|
| 571 |
+
if not rowsData:
|
| 572 |
+
return None
|
| 573 |
+
|
| 574 |
+
sjLabels = {"BS": "์ฌ๋ฌด์ํํ(๋ถ๊ธฐ)", "IS": "์์ต๊ณ์ฐ์(๋ถ๊ธฐ)", "CF": "ํ๊ธํ๋ฆํ(๋ถ๊ธฐ)"}
|
| 575 |
+
sjMeta = {"BS": "์์ ์์ก", "IS": "๋ถ๊ธฐ standalone", "CF": "๋ถ๊ธฐ standalone"}
|
| 576 |
+
|
| 577 |
+
header = "| ๊ณ์ | " + " | ".join(displayPeriodsReversed) + " | QoQ | YoY |"
|
| 578 |
+
sep = "| --- | " + " | ".join(["---"] * len(displayPeriodsReversed)) + " | --- | --- |"
|
| 579 |
+
metaLine = f"(๋จ์: ์ต/์กฐ์ | {sjMeta.get(sjDiv, 'standalone')})"
|
| 580 |
+
|
| 581 |
+
lines = [f"## {sjLabels.get(sjDiv, sjDiv)}", metaLine, header, sep]
|
| 582 |
+
for label, vals in rowsData:
|
| 583 |
+
cells = [_format_won(v) if v is not None else "-" for v in vals]
|
| 584 |
+
qoq = _calc_yoy(vals[0], vals[1] if len(vals) > 1 else None)
|
| 585 |
+
yoyIdx = 4 if len(vals) > 4 else None
|
| 586 |
+
yoy = _calc_yoy(vals[0], vals[yoyIdx] if yoyIdx is not None else None)
|
| 587 |
+
lines.append(f"| {label} | " + " | ".join(cells) + f" | {qoq} | {yoy} |")
|
| 588 |
+
|
| 589 |
+
return "\n".join(lines)
|
| 590 |
+
|
| 591 |
+
|
| 592 |
+
def _calc_yoy(current: float | None, previous: float | None) -> str:
|
| 593 |
+
"""YoY ์ฆ๊ฐ๋ฅ ๊ณ์ฐ. ๋ถํธ ์ ํ ์ '-', |๋ณ๋๋ฅ |>50%๋ฉด ** ๊ฐ์กฐ."""
|
| 594 |
+
from dartlab.core.finance.ratios import yoy_pct
|
| 595 |
+
|
| 596 |
+
pct = yoy_pct(current, previous)
|
| 597 |
+
if pct is None:
|
| 598 |
+
return "-"
|
| 599 |
+
sign = "+" if pct >= 0 else ""
|
| 600 |
+
marker = "**" if abs(pct) > 50 else ""
|
| 601 |
+
return f"{marker}{sign}{pct:.1f}%{marker}"
|
| 602 |
+
|
| 603 |
+
|
| 604 |
+
def _build_ratios_section(
|
| 605 |
+
company: Any,
|
| 606 |
+
compact: bool = False,
|
| 607 |
+
q_types: list[str] | None = None,
|
| 608 |
+
) -> str | None:
|
| 609 |
+
"""financeEngine RatioResult โ ๋งํฌ๋ค์ด (์ง๋ฌธ ์ ํ๋ณ ํํฐ๋ง).
|
| 610 |
+
|
| 611 |
+
q_types๊ฐ ์ฃผ์ด์ง๋ฉด ๊ด๋ จ ๋น์จ ๊ทธ๋ฃน๋ง ๋
ธ์ถํ์ฌ ํ ํฐ ์ ์ฝ.
|
| 612 |
+
None์ด๋ฉด ์ ์ฒด ๋
ธ์ถ.
|
| 613 |
+
"""
|
| 614 |
+
ratios = get_headline_ratios(company)
|
| 615 |
+
if ratios is None:
|
| 616 |
+
return None
|
| 617 |
+
if not hasattr(ratios, "roe"):
|
| 618 |
+
return None
|
| 619 |
+
|
| 620 |
+
isFinancial = False
|
| 621 |
+
sectorInfo = getattr(company, "sector", None)
|
| 622 |
+
if sectorInfo is not None:
|
| 623 |
+
try:
|
| 624 |
+
from dartlab.analysis.comparative.sector.types import Sector
|
| 625 |
+
|
| 626 |
+
isFinancial = sectorInfo.sector == Sector.FINANCIALS
|
| 627 |
+
except (ImportError, AttributeError):
|
| 628 |
+
isFinancial = False
|
| 629 |
+
|
| 630 |
+
# โโ ํ๋จ ํฌํผ โโ
|
| 631 |
+
def _judge(val: float | None, good: float, caution: float) -> str:
|
| 632 |
+
if val is None:
|
| 633 |
+
return "-"
|
| 634 |
+
return "์ํธ" if val >= good else ("์ฃผ์" if val >= caution else "์ํ")
|
| 635 |
+
|
| 636 |
+
def _judge_inv(val: float | None, good: float, caution: float) -> str:
|
| 637 |
+
if val is None:
|
| 638 |
+
return "-"
|
| 639 |
+
return "์ํธ" if val <= good else ("์ฃผ์" if val <= caution else "์ํ")
|
| 640 |
+
|
| 641 |
+
# โโ ์ง๋ฌธ ์ ํ โ ๋
ธ์ถ ๊ทธ๋ฃน ๋งคํ โโ
|
| 642 |
+
_Q_TYPE_TO_GROUPS: dict[str, list[str]] = {
|
| 643 |
+
"๊ฑด์ ์ฑ": ["์์ต์ฑ_core", "์์ ์ฑ", "ํ๊ธํ๋ฆ", "๋ณตํฉ"],
|
| 644 |
+
"์์ต์ฑ": ["์์ต์ฑ", "ํจ์จ์ฑ", "๋ณตํฉ"],
|
| 645 |
+
"์ฑ์ฅ์ฑ": ["์์ต์ฑ_core", "์ฑ์ฅ"],
|
| 646 |
+
"๋ฐฐ๋น": ["์์ต์ฑ_core", "ํ๊ธํ๋ฆ"],
|
| 647 |
+
"๋ฆฌ์คํฌ": ["์์ ์ฑ", "ํ๊ธํ๋ฆ", "๋ณตํฉ"],
|
| 648 |
+
"ํฌ์": ["์์ต์ฑ_core", "์ฑ์ฅ", "ํ๊ธํ๋ฆ"],
|
| 649 |
+
"์ข
ํฉ": ["์์ต์ฑ", "์์ ์ฑ", "์ฑ์ฅ", "ํจ์จ์ฑ", "ํ๊ธํ๋ฆ", "๋ณตํฉ"],
|
| 650 |
+
}
|
| 651 |
+
|
| 652 |
+
active_groups: set[str] = set()
|
| 653 |
+
if q_types:
|
| 654 |
+
for qt in q_types:
|
| 655 |
+
active_groups.update(_Q_TYPE_TO_GROUPS.get(qt, []))
|
| 656 |
+
if not active_groups:
|
| 657 |
+
active_groups = {"์์ต์ฑ", "์์ ์ฑ", "์ฑ์ฅ", "ํจ์จ์ฑ", "ํ๊ธํ๋ฆ", "๋ณตํฉ"}
|
| 658 |
+
|
| 659 |
+
# "์์ต์ฑ_core"๋ ์์ต์ฑ์ ํต์ฌ๋ง (ROE, ROA, ์์
์ด์ต๋ฅ , ์์ด์ต๋ฅ )
|
| 660 |
+
show_profitability_full = "์์ต์ฑ" in active_groups
|
| 661 |
+
show_profitability_core = show_profitability_full or "์์ต์ฑ_core" in active_groups
|
| 662 |
+
|
| 663 |
+
roeGood, roeCaution = (8, 5) if isFinancial else (10, 5)
|
| 664 |
+
roaGood, roaCaution = (0.5, 0.2) if isFinancial else (5, 2)
|
| 665 |
+
|
| 666 |
+
lines = ["## ํต์ฌ ์ฌ๋ฌด๋น์จ (์๋๊ณ์ฐ)"]
|
| 667 |
+
|
| 668 |
+
# โโ ์์ต์ฑ โโ
|
| 669 |
+
if show_profitability_core:
|
| 670 |
+
prof_rows: list[str] = []
|
| 671 |
+
if ratios.roe is not None:
|
| 672 |
+
prof_rows.append(f"| ROE | {ratios.roe:.1f}% | {_judge(ratios.roe, roeGood, roeCaution)} |")
|
| 673 |
+
if ratios.roa is not None:
|
| 674 |
+
prof_rows.append(f"| ROA | {ratios.roa:.1f}% | {_judge(ratios.roa, roaGood, roaCaution)} |")
|
| 675 |
+
if ratios.operatingMargin is not None:
|
| 676 |
+
prof_rows.append(f"| ์์
์ด์ต๋ฅ | {ratios.operatingMargin:.1f}% | - |")
|
| 677 |
+
if not compact and ratios.netMargin is not None:
|
| 678 |
+
prof_rows.append(f"| ์์ด์ต๋ฅ | {ratios.netMargin:.1f}% | - |")
|
| 679 |
+
if show_profitability_full:
|
| 680 |
+
if ratios.grossMargin is not None:
|
| 681 |
+
prof_rows.append(f"| ๋งค์ถ์ด์ด์ต๋ฅ | {ratios.grossMargin:.1f}% | - |")
|
| 682 |
+
if ratios.ebitdaMargin is not None:
|
| 683 |
+
prof_rows.append(f"| EBITDA๋ง์ง | {ratios.ebitdaMargin:.1f}% | - |")
|
| 684 |
+
if not compact and ratios.roic is not None:
|
| 685 |
+
prof_rows.append(f"| ROIC | {ratios.roic:.1f}% | {_judge(ratios.roic, 15, 8)} |")
|
| 686 |
+
if prof_rows:
|
| 687 |
+
lines.append("\n### ์์ต์ฑ")
|
| 688 |
+
lines.append("| ์งํ | ๊ฐ | ํ๋จ |")
|
| 689 |
+
lines.append("| --- | --- | --- |")
|
| 690 |
+
lines.extend(prof_rows)
|
| 691 |
+
|
| 692 |
+
# โโ ์์ ์ฑ โโ
|
| 693 |
+
if "์์ ์ฑ" in active_groups:
|
| 694 |
+
stab_rows: list[str] = []
|
| 695 |
+
if ratios.debtRatio is not None:
|
| 696 |
+
stab_rows.append(f"| ๋ถ์ฑ๋น์จ | {ratios.debtRatio:.1f}% | {_judge_inv(ratios.debtRatio, 100, 200)} |")
|
| 697 |
+
if ratios.currentRatio is not None:
|
| 698 |
+
stab_rows.append(f"| ์ ๋๋น์จ | {ratios.currentRatio:.1f}% | {_judge(ratios.currentRatio, 150, 100)} |")
|
| 699 |
+
if not compact and ratios.quickRatio is not None:
|
| 700 |
+
stab_rows.append(f"| ๋น์ข๋น์จ | {ratios.quickRatio:.1f}% | {_judge(ratios.quickRatio, 100, 50)} |")
|
| 701 |
+
if not compact and ratios.equityRatio is not None:
|
| 702 |
+
stab_rows.append(f"| ์๊ธฐ์๋ณธ๋น์จ | {ratios.equityRatio:.1f}% | {_judge(ratios.equityRatio, 50, 30)} |")
|
| 703 |
+
if ratios.interestCoverage is not None:
|
| 704 |
+
stab_rows.append(
|
| 705 |
+
f"| ์ด์๋ณด์๋ฐฐ์จ | {ratios.interestCoverage:.1f}x | {_judge(ratios.interestCoverage, 5, 1)} |"
|
| 706 |
+
)
|
| 707 |
+
if not compact and ratios.debtToEbitda is not None:
|
| 708 |
+
stab_rows.append(f"| Debt/EBITDA | {ratios.debtToEbitda:.1f}x | {_judge_inv(ratios.debtToEbitda, 3, 5)} |")
|
| 709 |
+
if not compact and ratios.netDebt is not None:
|
| 710 |
+
stab_rows.append(
|
| 711 |
+
f"| ์์ฐจ์
๊ธ | {_format_won(ratios.netDebt)} | {'์ํธ' if ratios.netDebt <= 0 else '์ฃผ์'} |"
|
| 712 |
+
)
|
| 713 |
+
if not compact and ratios.netDebtRatio is not None:
|
| 714 |
+
stab_rows.append(
|
| 715 |
+
f"| ์์ฐจ์
๊ธ๋น์จ | {ratios.netDebtRatio:.1f}% | {_judge_inv(ratios.netDebtRatio, 30, 80)} |"
|
| 716 |
+
)
|
| 717 |
+
if stab_rows:
|
| 718 |
+
lines.append("\n### ์์ ์ฑ")
|
| 719 |
+
lines.append("| ์งํ | ๊ฐ | ํ๋จ |")
|
| 720 |
+
lines.append("| --- | --- | --- |")
|
| 721 |
+
lines.extend(stab_rows)
|
| 722 |
+
|
| 723 |
+
# โโ ์ฑ์ฅ์ฑ โโ
|
| 724 |
+
if "์ฑ์ฅ" in active_groups:
|
| 725 |
+
grow_rows: list[str] = []
|
| 726 |
+
if ratios.revenueGrowth is not None:
|
| 727 |
+
grow_rows.append(f"| ๋งค์ถ์ฑ์ฅ๋ฅ (YoY) | {ratios.revenueGrowth:.1f}% | - |")
|
| 728 |
+
if ratios.operatingProfitGrowth is not None:
|
| 729 |
+
grow_rows.append(f"| ์์
์ด์ต์ฑ์ฅ๋ฅ | {ratios.operatingProfitGrowth:.1f}% | - |")
|
| 730 |
+
if ratios.netProfitGrowth is not None:
|
| 731 |
+
grow_rows.append(f"| ์์ด์ต์ฑ์ฅ๋ฅ | {ratios.netProfitGrowth:.1f}% | - |")
|
| 732 |
+
if ratios.revenueGrowth3Y is not None:
|
| 733 |
+
grow_rows.append(f"| ๋งค์ถ 3Y CAGR | {ratios.revenueGrowth3Y:.1f}% | - |")
|
| 734 |
+
if not compact and ratios.assetGrowth is not None:
|
| 735 |
+
grow_rows.append(f"| ์์ฐ์ฑ์ฅ๋ฅ | {ratios.assetGrowth:.1f}% | - |")
|
| 736 |
+
if grow_rows:
|
| 737 |
+
lines.append("\n### ์ฑ์ฅ์ฑ")
|
| 738 |
+
lines.append("| ์งํ | ๊ฐ | ํ๋จ |")
|
| 739 |
+
lines.append("| --- | --- | --- |")
|
| 740 |
+
lines.extend(grow_rows)
|
| 741 |
+
|
| 742 |
+
# โโ ํจ์จ์ฑ โโ
|
| 743 |
+
if "ํจ์จ์ฑ" in active_groups and not compact:
|
| 744 |
+
eff_rows: list[str] = []
|
| 745 |
+
if ratios.totalAssetTurnover is not None:
|
| 746 |
+
eff_rows.append(f"| ์ด์์ฐํ์ ์จ | {ratios.totalAssetTurnover:.2f}x | - |")
|
| 747 |
+
if ratios.inventoryTurnover is not None:
|
| 748 |
+
eff_rows.append(f"| ์ฌ๊ณ ์์ฐํ์ ์จ | {ratios.inventoryTurnover:.1f}x | - |")
|
| 749 |
+
if ratios.receivablesTurnover is not None:
|
| 750 |
+
eff_rows.append(f"| ๋งค์ถ์ฑ๊ถํ์ ์จ | {ratios.receivablesTurnover:.1f}x | - |")
|
| 751 |
+
if eff_rows:
|
| 752 |
+
lines.append("\n### ํจ์จ์ฑ")
|
| 753 |
+
lines.append("| ์งํ | ๊ฐ | ํ๋จ |")
|
| 754 |
+
lines.append("| --- | --- | --- |")
|
| 755 |
+
lines.extend(eff_rows)
|
| 756 |
+
|
| 757 |
+
# โโ ํ๊ธํ๋ฆ โโ
|
| 758 |
+
if "ํ๊ธํ๋ฆ" in active_groups:
|
| 759 |
+
cf_rows: list[str] = []
|
| 760 |
+
if ratios.fcf is not None:
|
| 761 |
+
cf_rows.append(f"| FCF | {_format_won(ratios.fcf)} | {'์ํธ' if ratios.fcf > 0 else '์ฃผ์'} |")
|
| 762 |
+
if ratios.operatingCfToNetIncome is not None:
|
| 763 |
+
quality = _judge(ratios.operatingCfToNetIncome, 100, 50)
|
| 764 |
+
cf_rows.append(f"| ์์
CF/์์ด์ต | {ratios.operatingCfToNetIncome:.0f}% | {quality} |")
|
| 765 |
+
if not compact and ratios.capexRatio is not None:
|
| 766 |
+
cf_rows.append(f"| CAPEX๋น์จ | {ratios.capexRatio:.1f}% | - |")
|
| 767 |
+
if not compact and ratios.dividendPayoutRatio is not None:
|
| 768 |
+
cf_rows.append(f"| ๋ฐฐ๋น์ฑํฅ | {ratios.dividendPayoutRatio:.1f}% | - |")
|
| 769 |
+
if cf_rows:
|
| 770 |
+
lines.append("\n### ํ๊ธํ๋ฆ")
|
| 771 |
+
lines.append("| ์งํ | ๊ฐ | ํ๋จ |")
|
| 772 |
+
lines.append("| --- | --- | --- |")
|
| 773 |
+
lines.extend(cf_rows)
|
| 774 |
+
|
| 775 |
+
# โโ ๋ณตํฉ ์งํ โโ
|
| 776 |
+
if "๋ณตํฉ" in active_groups and not compact:
|
| 777 |
+
comp_lines: list[str] = []
|
| 778 |
+
|
| 779 |
+
# DuPont ๋ถํด
|
| 780 |
+
dm = getattr(ratios, "dupontMargin", None)
|
| 781 |
+
dt = getattr(ratios, "dupontTurnover", None)
|
| 782 |
+
dl = getattr(ratios, "dupontLeverage", None)
|
| 783 |
+
if dm is not None and dt is not None and dl is not None and ratios.roe is not None:
|
| 784 |
+
# ์ฃผ์ ๋์ธ ํ๋ณ
|
| 785 |
+
if dm >= dt and dm >= dl:
|
| 786 |
+
driver = "์์ต์ฑ ์ฃผ๋ํ"
|
| 787 |
+
elif dt >= dm and dt >= dl:
|
| 788 |
+
driver = "ํจ์จ์ฑ ์ฃผ๋ํ"
|
| 789 |
+
else:
|
| 790 |
+
driver = "๋ ๋ฒ๋ฆฌ์ง ์ฃผ๋ํ"
|
| 791 |
+
comp_lines.append("\n### DuPont ๋ถํด")
|
| 792 |
+
comp_lines.append(
|
| 793 |
+
f"ROE {ratios.roe:.1f}% = ์์ด์ต๋ฅ ({dm:.1f}%) ร ์์ฐํ์ ์จ({dt:.2f}x) ร ๋ ๋ฒ๋ฆฌ์ง({dl:.2f}x)"
|
| 794 |
+
)
|
| 795 |
+
comp_lines.append(f"โ **{driver}**")
|
| 796 |
+
|
| 797 |
+
# Piotroski F-Score
|
| 798 |
+
pf = getattr(ratios, "piotroskiFScore", None)
|
| 799 |
+
if pf is not None:
|
| 800 |
+
pf_label = "์ฐ์" if pf >= 7 else ("๋ณดํต" if pf >= 4 else "์ทจ์ฝ")
|
| 801 |
+
comp_lines.append("\n### ๋ณตํฉ ์ฌ๋ฌด ์งํ")
|
| 802 |
+
comp_lines.append(f"- **Piotroski F-Score**: {pf}/9 ({pf_label}) โ โฅ7 ์ฐ์, 4-6 ๋ณดํต, <4 ์ทจ์ฝ")
|
| 803 |
+
|
| 804 |
+
# Altman Z-Score
|
| 805 |
+
az = getattr(ratios, "altmanZScore", None)
|
| 806 |
+
if az is not None:
|
| 807 |
+
az_label = "์์ " if az > 2.99 else ("ํ์" if az >= 1.81 else "๋ถ์ค์ํ")
|
| 808 |
+
if pf is None:
|
| 809 |
+
comp_lines.append("\n### ๋ณตํฉ ์ฌ๋ฌด ์งํ")
|
| 810 |
+
comp_lines.append(f"- **Altman Z-Score**: {az:.2f} ({az_label}) โ >2.99 ์์ , 1.81-2.99 ํ์, <1.81 ๋ถ์ค")
|
| 811 |
+
|
| 812 |
+
# ROIC
|
| 813 |
+
if ratios.roic is not None:
|
| 814 |
+
roic_label = "์ฐ์" if ratios.roic >= 15 else ("์ ์ " if ratios.roic >= 8 else "๋ฏธํก")
|
| 815 |
+
comp_lines.append(f"- **ROIC**: {ratios.roic:.1f}% ({roic_label})")
|
| 816 |
+
|
| 817 |
+
# ์ด์ต์ ์ง โ CCC
|
| 818 |
+
ccc = getattr(ratios, "ccc", None)
|
| 819 |
+
dso = getattr(ratios, "dso", None)
|
| 820 |
+
dio = getattr(ratios, "dio", None)
|
| 821 |
+
dpo = getattr(ratios, "dpo", None)
|
| 822 |
+
cfni = ratios.operatingCfToNetIncome
|
| 823 |
+
has_quality = ccc is not None or cfni is not None
|
| 824 |
+
if has_quality:
|
| 825 |
+
comp_lines.append("\n### ์ด์ต์ ์ง")
|
| 826 |
+
if cfni is not None:
|
| 827 |
+
q = "์ํธ" if cfni >= 100 else ("๋ณดํต" if cfni >= 50 else "์ฃผ์")
|
| 828 |
+
comp_lines.append(f"- ์์
CF/์์ด์ต: {cfni:.0f}% ({q}) โ โฅ100% ์ํธ")
|
| 829 |
+
if ccc is not None:
|
| 830 |
+
ccc_parts = []
|
| 831 |
+
if dso is not None:
|
| 832 |
+
ccc_parts.append(f"DSO:{dso:.0f}")
|
| 833 |
+
if dio is not None:
|
| 834 |
+
ccc_parts.append(f"DIO:{dio:.0f}")
|
| 835 |
+
if dpo is not None:
|
| 836 |
+
ccc_parts.append(f"DPO:{dpo:.0f}")
|
| 837 |
+
detail = f" ({' + '.join(ccc_parts)})" if ccc_parts else ""
|
| 838 |
+
comp_lines.append(f"- CCC(ํ๊ธ์ ํ์ฃผ๊ธฐ): {ccc:.0f}์ผ{detail}")
|
| 839 |
+
|
| 840 |
+
if comp_lines:
|
| 841 |
+
lines.extend(comp_lines)
|
| 842 |
+
|
| 843 |
+
# โโ ratioSeries 3๋
์ถ์ธ โโ
|
| 844 |
+
ratio_series = get_ratio_series(company)
|
| 845 |
+
if ratio_series is not None and hasattr(ratio_series, "roe") and ratio_series.roe:
|
| 846 |
+
trend_keys = [("roe", "ROE"), ("operatingMargin", "์์
์ด์ต๋ฅ "), ("debtRatio", "๋ถ์ฑ๋น์จ")]
|
| 847 |
+
if not compact and "์ฑ์ฅ" in active_groups:
|
| 848 |
+
trend_keys.append(("revenueGrowth", "๋งค์ถ์ฑ์ฅ๋ฅ "))
|
| 849 |
+
trend_lines: list[str] = []
|
| 850 |
+
for key, label in trend_keys:
|
| 851 |
+
series_vals = getattr(ratio_series, key, None)
|
| 852 |
+
if series_vals and len(series_vals) >= 2:
|
| 853 |
+
recent = [f"{v:.1f}%" for v in series_vals[-3:] if v is not None]
|
| 854 |
+
if recent:
|
| 855 |
+
arrow = (
|
| 856 |
+
"โ" if series_vals[-1] > series_vals[-2] else "โ" if series_vals[-1] < series_vals[-2] else "โ"
|
| 857 |
+
)
|
| 858 |
+
trend_lines.append(f"- {label}: {' โ '.join(recent)} {arrow}")
|
| 859 |
+
if trend_lines:
|
| 860 |
+
lines.append("")
|
| 861 |
+
lines.append("### ์ถ์ธ (์ต๊ทผ 3๋
)")
|
| 862 |
+
lines.extend(trend_lines)
|
| 863 |
+
|
| 864 |
+
# โโ TTM โโ
|
| 865 |
+
ttm_lines: list[str] = []
|
| 866 |
+
if ratios.revenueTTM is not None:
|
| 867 |
+
ttm_lines.append(f"- TTM ๋งค์ถ: {_format_won(ratios.revenueTTM)}")
|
| 868 |
+
if ratios.operatingIncomeTTM is not None:
|
| 869 |
+
ttm_lines.append(f"- TTM ์์
์ด์ต: {_format_won(ratios.operatingIncomeTTM)}")
|
| 870 |
+
if ratios.netIncomeTTM is not None:
|
| 871 |
+
ttm_lines.append(f"- TTM ์์ด์ต: {_format_won(ratios.netIncomeTTM)}")
|
| 872 |
+
if ttm_lines:
|
| 873 |
+
lines.append("")
|
| 874 |
+
lines.append("### TTM (์ต๊ทผ 4๋ถ๊ธฐ ํฉ์ฐ)")
|
| 875 |
+
lines.extend(ttm_lines)
|
| 876 |
+
|
| 877 |
+
# โโ ๊ฒฝ๊ณ โโ
|
| 878 |
+
if ratios.warnings:
|
| 879 |
+
lines.append("")
|
| 880 |
+
lines.append("### ๊ฒฝ๊ณ ")
|
| 881 |
+
max_warnings = 2 if compact else len(ratios.warnings)
|
| 882 |
+
for w in ratios.warnings[:max_warnings]:
|
| 883 |
+
lines.append(f"- โ ๏ธ {w}")
|
| 884 |
+
|
| 885 |
+
return "\n".join(lines)
|
| 886 |
+
|
| 887 |
+
|
| 888 |
+
def detect_year_range(company: Any, tables: list[str]) -> dict | None:
|
| 889 |
+
"""ํฌํจ๋ ๋ฐ์ดํฐ์ ์ฐ๋ ๋ฒ์ ๊ฐ์ง."""
|
| 890 |
+
all_years: set[int] = set()
|
| 891 |
+
for name in tables:
|
| 892 |
+
try:
|
| 893 |
+
data = getattr(company, name, None)
|
| 894 |
+
if data is None:
|
| 895 |
+
continue
|
| 896 |
+
if isinstance(data, pl.DataFrame):
|
| 897 |
+
if "year" in data.columns:
|
| 898 |
+
years = data["year"].unique().to_list()
|
| 899 |
+
all_years.update(int(y) for y in years if y)
|
| 900 |
+
else:
|
| 901 |
+
year_cols = [c for c in data.columns if c.isdigit() and len(c) == 4]
|
| 902 |
+
all_years.update(int(c) for c in year_cols)
|
| 903 |
+
except _CONTEXT_ERRORS:
|
| 904 |
+
continue
|
| 905 |
+
if not all_years:
|
| 906 |
+
return None
|
| 907 |
+
sorted_years = sorted(all_years)
|
| 908 |
+
return {"min_year": sorted_years[0], "max_year": sorted_years[-1]}
|
| 909 |
+
|
| 910 |
+
|
| 911 |
+
def scan_available_modules(company: Any) -> list[dict[str, str]]:
|
| 912 |
+
"""Company ์ธ์คํด์ค์์ ์ค์ ๋ฐ์ดํฐ๊ฐ ์๋ ๋ชจ๋ ๋ชฉ๋ก์ ๋ฐํ.
|
| 913 |
+
|
| 914 |
+
Returns:
|
| 915 |
+
[{"name": "BS", "label": "์ฌ๋ฌด์ํํ", "type": "DataFrame", "rows": 25}, ...]
|
| 916 |
+
"""
|
| 917 |
+
available = []
|
| 918 |
+
for name, meta in MODULE_META.items():
|
| 919 |
+
try:
|
| 920 |
+
data = getattr(company, name, None)
|
| 921 |
+
if data is None:
|
| 922 |
+
continue
|
| 923 |
+
# method์ธ ๊ฒฝ์ฐ ๊ฑด๋๋ (fsSummary ๋ฑ์ ํธ์ถ ๋น์ฉ์ด ํผ)
|
| 924 |
+
if callable(data) and not isinstance(data, type):
|
| 925 |
+
info: dict[str, Any] = {"name": name, "label": meta.label, "type": "method"}
|
| 926 |
+
available.append(info)
|
| 927 |
+
continue
|
| 928 |
+
if isinstance(data, pl.DataFrame):
|
| 929 |
+
info = {
|
| 930 |
+
"name": name,
|
| 931 |
+
"label": meta.label,
|
| 932 |
+
"type": "table",
|
| 933 |
+
"rows": data.height,
|
| 934 |
+
"cols": len(data.columns),
|
| 935 |
+
}
|
| 936 |
+
elif isinstance(data, dict):
|
| 937 |
+
info = {"name": name, "label": meta.label, "type": "dict", "rows": len(data)}
|
| 938 |
+
elif isinstance(data, list):
|
| 939 |
+
info = {"name": name, "label": meta.label, "type": "list", "rows": len(data)}
|
| 940 |
+
else:
|
| 941 |
+
info = {"name": name, "label": meta.label, "type": "text"}
|
| 942 |
+
available.append(info)
|
| 943 |
+
except _CONTEXT_ERRORS:
|
| 944 |
+
continue
|
| 945 |
+
return available
|
src/dartlab/ai/context/formatting.py
ADDED
|
@@ -0,0 +1,439 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ํฌ๋งทํ
ยท์ ํธ๋ฆฌํฐ ํจ์ โ builder.py์์ ๋ถ๋ฆฌ.
|
| 2 |
+
|
| 3 |
+
์ ๋จ์ ๋ณํ, DataFrameโ๋งํฌ๋ค์ด, ํ์ ์งํ ์๋๊ณ์ฐ ๋ฑ
|
| 4 |
+
builder / finance_context ์์ชฝ์์ ์ฌ์ฌ์ฉํ๋ ์์ ํจ์ ๋ชจ์.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
from typing import Any
|
| 10 |
+
|
| 11 |
+
import polars as pl
|
| 12 |
+
|
| 13 |
+
from dartlab.ai.metadata import ModuleMeta
|
| 14 |
+
|
| 15 |
+
_CONTEXT_ERRORS = (AttributeError, KeyError, OSError, RuntimeError, TypeError, ValueError)
|
| 16 |
+
|
| 17 |
+
# โโ ํต์ฌ ๊ณ์ ํํฐ์ฉ ์์ โโ
|
| 18 |
+
|
| 19 |
+
_KEY_ACCOUNTS_BS = {
|
| 20 |
+
"์์ฐ์ด๊ณ",
|
| 21 |
+
"์ ๋์์ฐ",
|
| 22 |
+
"๋น์ ๋์์ฐ",
|
| 23 |
+
"๋ถ์ฑ์ด๊ณ",
|
| 24 |
+
"์ ๋๋ถ์ฑ",
|
| 25 |
+
"๋น์ ๋๋ถ์ฑ",
|
| 26 |
+
"์๋ณธ์ด๊ณ",
|
| 27 |
+
"์ง๋ฐฐ๊ธฐ์
์์ ์ฃผ์ง๋ถ",
|
| 28 |
+
"ํ๊ธ๋ฐํ๊ธ์ฑ์์ฐ",
|
| 29 |
+
"๋งค์ถ์ฑ๊ถ",
|
| 30 |
+
"์ฌ๊ณ ์์ฐ",
|
| 31 |
+
"์ ํ์์ฐ",
|
| 32 |
+
"๋ฌดํ์์ฐ",
|
| 33 |
+
"ํฌ์๋ถ๋์ฐ",
|
| 34 |
+
"๋จ๊ธฐ์ฐจ์
๊ธ",
|
| 35 |
+
"์ฅ๊ธฐ์ฐจ์
๊ธ",
|
| 36 |
+
"์ฌ์ฑ",
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
_KEY_ACCOUNTS_IS = {
|
| 40 |
+
"๋งค์ถ์ก",
|
| 41 |
+
"๋งค์ถ์๊ฐ",
|
| 42 |
+
"๋งค์ถ์ด์ด์ต",
|
| 43 |
+
"ํ๋งค๋น์๊ด๋ฆฌ๋น",
|
| 44 |
+
"์์
์ด์ต",
|
| 45 |
+
"์์
์์ค",
|
| 46 |
+
"๊ธ์ต์์ต",
|
| 47 |
+
"๊ธ์ต๋น์ฉ",
|
| 48 |
+
"์ด์๋น์ฉ",
|
| 49 |
+
"์ด์์์ต",
|
| 50 |
+
"๋ฒ์ธ์ธ๋น์ฉ์ฐจ๊ฐ์ ์์ด์ต",
|
| 51 |
+
"๋ฒ์ธ์ธ๋น์ฉ",
|
| 52 |
+
"๋น๊ธฐ์์ด์ต",
|
| 53 |
+
"๋น๊ธฐ์์์ค",
|
| 54 |
+
"์ง๋ฐฐ๊ธฐ์
์์ ์ฃผ์ง๋ถ์์ด์ต",
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
_KEY_ACCOUNTS_CF = {
|
| 58 |
+
"์์
ํ๋ํ๊ธํ๋ฆ",
|
| 59 |
+
"์์
ํ๋์ผ๋ก์ธํํ๊ธํ๋ฆ",
|
| 60 |
+
"ํฌ์ํ๋ํ๊ธํ๋ฆ",
|
| 61 |
+
"ํฌ์ํ๋์ผ๋ก์ธํํ๊ธํ๋ฆ",
|
| 62 |
+
"์ฌ๋ฌดํ๋ํ๊ธํ๋ฆ",
|
| 63 |
+
"์ฌ๋ฌดํ๋์ผ๋ก์ธํํ๊ธํ๋ฆ",
|
| 64 |
+
"ํ๊ธ๋ฐํ๊ธ์ฑ์์ฐ์์์ฆ๊ฐ",
|
| 65 |
+
"ํ๊ธ๋ฐํ๊ธ์ฑ์์ฐ์์ฆ๊ฐ",
|
| 66 |
+
"๊ธฐ์ดํ๊ธ๋ฐํ๊ธ์ฑ์์ฐ",
|
| 67 |
+
"๊ธฐ๋งํ๊ธ๋ฐํ๊ธ์ฑ์์ฐ",
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
_KEY_ACCOUNTS_MAP = {
|
| 71 |
+
"BS": _KEY_ACCOUNTS_BS,
|
| 72 |
+
"IS": _KEY_ACCOUNTS_IS,
|
| 73 |
+
"CF": _KEY_ACCOUNTS_CF,
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
|
| 77 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 78 |
+
# ์ซ์ ํฌ๋งทํ
|
| 79 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 80 |
+
|
| 81 |
+
|
| 82 |
+
def _format_won(val: float) -> str:
|
| 83 |
+
"""์ ๋จ์ ์ซ์๋ฅผ ์ฝ๊ธฐ ์ข์ ํ๊ตญ์ด ๋จ์๋ก ๋ณํ."""
|
| 84 |
+
abs_val = abs(val)
|
| 85 |
+
sign = "-" if val < 0 else ""
|
| 86 |
+
if abs_val >= 1e12:
|
| 87 |
+
return f"{sign}{abs_val / 1e12:,.1f}์กฐ"
|
| 88 |
+
if abs_val >= 1e8:
|
| 89 |
+
return f"{sign}{abs_val / 1e8:,.0f}์ต"
|
| 90 |
+
if abs_val >= 1e4:
|
| 91 |
+
return f"{sign}{abs_val / 1e4:,.0f}๋ง"
|
| 92 |
+
if abs_val >= 1:
|
| 93 |
+
return f"{sign}{abs_val:,.0f}"
|
| 94 |
+
return "0"
|
| 95 |
+
|
| 96 |
+
|
| 97 |
+
def _format_krw(val: float) -> str:
|
| 98 |
+
"""๋ฐฑ๋ง์ ๋จ์ ์ซ์๋ฅผ ์ฝ๊ธฐ ์ข์ ํ๊ตญ์ด ๋จ์๋ก ๋ณํ."""
|
| 99 |
+
abs_val = abs(val)
|
| 100 |
+
sign = "-" if val < 0 else ""
|
| 101 |
+
if abs_val >= 1_000_000:
|
| 102 |
+
return f"{sign}{abs_val / 1_000_000:,.1f}์กฐ"
|
| 103 |
+
if abs_val >= 10_000:
|
| 104 |
+
return f"{sign}{abs_val / 10_000:,.0f}์ต"
|
| 105 |
+
if abs_val >= 1:
|
| 106 |
+
return f"{sign}{abs_val:,.0f}"
|
| 107 |
+
if abs_val > 0:
|
| 108 |
+
return f"{sign}{abs_val:.4f}"
|
| 109 |
+
return "0"
|
| 110 |
+
|
| 111 |
+
|
| 112 |
+
def _format_usd(val: float) -> str:
|
| 113 |
+
"""USD ์ซ์๋ฅผ ์ฝ๊ธฐ ์ข์ ์๋ฌธ ๋จ์๋ก ๋ณํ."""
|
| 114 |
+
abs_val = abs(val)
|
| 115 |
+
sign = "-" if val < 0 else ""
|
| 116 |
+
if abs_val >= 1e12:
|
| 117 |
+
return f"{sign}${abs_val / 1e12:,.1f}T"
|
| 118 |
+
if abs_val >= 1e9:
|
| 119 |
+
return f"{sign}${abs_val / 1e9:,.1f}B"
|
| 120 |
+
if abs_val >= 1e6:
|
| 121 |
+
return f"{sign}${abs_val / 1e6:,.0f}M"
|
| 122 |
+
if abs_val >= 1e3:
|
| 123 |
+
return f"{sign}${abs_val / 1e3:,.0f}K"
|
| 124 |
+
if abs_val >= 1:
|
| 125 |
+
return f"{sign}${abs_val:,.0f}"
|
| 126 |
+
return "$0"
|
| 127 |
+
|
| 128 |
+
|
| 129 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 130 |
+
# ๊ณ์ ํํฐ
|
| 131 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 132 |
+
|
| 133 |
+
|
| 134 |
+
def _filter_key_accounts(df: pl.DataFrame, module_name: str) -> pl.DataFrame:
|
| 135 |
+
"""์ฌ๋ฌด์ ํ์์ ํต์ฌ ๊ณ์ ๋ง ํํฐ๋ง."""
|
| 136 |
+
if "๊ณ์ ๋ช
" not in df.columns or module_name not in _KEY_ACCOUNTS_MAP:
|
| 137 |
+
return df
|
| 138 |
+
|
| 139 |
+
key_set = _KEY_ACCOUNTS_MAP[module_name]
|
| 140 |
+
mask = pl.lit(False)
|
| 141 |
+
for keyword in key_set:
|
| 142 |
+
mask = mask | pl.col("๊ณ์ ๋ช
").str.contains(keyword)
|
| 143 |
+
|
| 144 |
+
filtered = df.filter(mask)
|
| 145 |
+
if filtered.height < 5:
|
| 146 |
+
return df
|
| 147 |
+
return filtered
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 151 |
+
# ์
์ข
๋ช
์ถ์ถ
|
| 152 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 153 |
+
|
| 154 |
+
|
| 155 |
+
def _get_sector(company: Any) -> str | None:
|
| 156 |
+
"""Company์์ ์
์ข
๋ช
์ถ์ถ."""
|
| 157 |
+
try:
|
| 158 |
+
overview = getattr(company, "companyOverview", None)
|
| 159 |
+
if isinstance(overview, dict):
|
| 160 |
+
sector = overview.get("indutyName") or overview.get("sector")
|
| 161 |
+
if sector:
|
| 162 |
+
return sector
|
| 163 |
+
|
| 164 |
+
detail = getattr(company, "companyOverviewDetail", None)
|
| 165 |
+
if isinstance(detail, dict):
|
| 166 |
+
sector = detail.get("sector") or detail.get("indutyName")
|
| 167 |
+
if sector:
|
| 168 |
+
return sector
|
| 169 |
+
except _CONTEXT_ERRORS:
|
| 170 |
+
pass
|
| 171 |
+
|
| 172 |
+
return None
|
| 173 |
+
|
| 174 |
+
|
| 175 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 176 |
+
# DataFrame โ ๋งํฌ๋ค์ด ๋ณํ
|
| 177 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
def df_to_markdown(
|
| 181 |
+
df: pl.DataFrame,
|
| 182 |
+
max_rows: int = 30,
|
| 183 |
+
meta: ModuleMeta | None = None,
|
| 184 |
+
compact: bool = False,
|
| 185 |
+
market: str = "KR",
|
| 186 |
+
) -> str:
|
| 187 |
+
"""Polars DataFrame โ ๋ฉํ๋ฐ์ดํฐ ์ฃผ์ ํฌํจ Markdown ํ
์ด๋ธ.
|
| 188 |
+
|
| 189 |
+
Args:
|
| 190 |
+
compact: True๋ฉด ์ซ์๋ฅผ ์ต/์กฐ ๋จ์๋ก ๋ณํ (LLM ์ปจํ
์คํธ์ฉ).
|
| 191 |
+
market: "KR"์ด๋ฉด ํ๊ธ ๋ผ๋ฒจ, "US"๋ฉด ์๋ฌธ ๋ผ๋ฒจ.
|
| 192 |
+
"""
|
| 193 |
+
if df is None or df.height == 0:
|
| 194 |
+
return "(๋ฐ์ดํฐ ์์)"
|
| 195 |
+
|
| 196 |
+
# account ์ปฌ๋ผ์ snakeId โ ํ๊ธ/์๋ฌธ ๋ผ๋ฒจ ์๋ ๋ณํ
|
| 197 |
+
if "account" in df.columns:
|
| 198 |
+
try:
|
| 199 |
+
from dartlab.core.finance.labels import get_account_labels
|
| 200 |
+
|
| 201 |
+
locale = "kr" if market == "KR" else "en"
|
| 202 |
+
_labels = get_account_labels(locale)
|
| 203 |
+
df = df.with_columns(pl.col("account").replace(_labels).alias("account"))
|
| 204 |
+
except ImportError:
|
| 205 |
+
pass
|
| 206 |
+
|
| 207 |
+
effective_max = meta.maxRows if meta else max_rows
|
| 208 |
+
if compact:
|
| 209 |
+
effective_max = min(effective_max, 20)
|
| 210 |
+
|
| 211 |
+
if "year" in df.columns:
|
| 212 |
+
df = df.sort("year", descending=True)
|
| 213 |
+
|
| 214 |
+
if df.height > effective_max:
|
| 215 |
+
display_df = df.head(effective_max)
|
| 216 |
+
truncated = True
|
| 217 |
+
else:
|
| 218 |
+
display_df = df
|
| 219 |
+
truncated = False
|
| 220 |
+
|
| 221 |
+
parts = []
|
| 222 |
+
|
| 223 |
+
is_krw = not meta or meta.unit in ("๋ฐฑ๋ง์", "")
|
| 224 |
+
if meta and meta.unit and meta.unit != "๋ฐฑ๋ง์":
|
| 225 |
+
parts.append(f"(๋จ์: {meta.unit})")
|
| 226 |
+
elif compact and is_krw:
|
| 227 |
+
parts.append("(๋จ์: ์ต/์กฐ์, ์๋ณธ ๋ฐฑ๋ง์)")
|
| 228 |
+
|
| 229 |
+
if not compact and meta and meta.columns:
|
| 230 |
+
col_map = {c.name: c for c in meta.columns}
|
| 231 |
+
described = []
|
| 232 |
+
for col in display_df.columns:
|
| 233 |
+
if col in col_map:
|
| 234 |
+
c = col_map[col]
|
| 235 |
+
desc = f"`{col}`: {c.description}"
|
| 236 |
+
if c.unit:
|
| 237 |
+
desc += f" ({c.unit})"
|
| 238 |
+
described.append(desc)
|
| 239 |
+
if described:
|
| 240 |
+
parts.append(" | ".join(described))
|
| 241 |
+
|
| 242 |
+
cols = display_df.columns
|
| 243 |
+
if not compact and meta and meta.columns:
|
| 244 |
+
col_map = {c.name: c for c in meta.columns}
|
| 245 |
+
header_cells = []
|
| 246 |
+
for col in cols:
|
| 247 |
+
if col in col_map:
|
| 248 |
+
header_cells.append(f"{col} ({col_map[col].description})")
|
| 249 |
+
else:
|
| 250 |
+
header_cells.append(col)
|
| 251 |
+
header = "| " + " | ".join(header_cells) + " |"
|
| 252 |
+
else:
|
| 253 |
+
header = "| " + " | ".join(cols) + " |"
|
| 254 |
+
|
| 255 |
+
sep = "| " + " | ".join(["---"] * len(cols)) + " |"
|
| 256 |
+
|
| 257 |
+
rows = []
|
| 258 |
+
for row in display_df.iter_rows():
|
| 259 |
+
cells = []
|
| 260 |
+
for i, val in enumerate(row):
|
| 261 |
+
if val is None:
|
| 262 |
+
cells.append("-")
|
| 263 |
+
elif isinstance(val, (int, float)):
|
| 264 |
+
col_name = cols[i]
|
| 265 |
+
if compact and is_krw and col_name.isdigit() and len(col_name) == 4:
|
| 266 |
+
cells.append(_format_krw(float(val)))
|
| 267 |
+
elif isinstance(val, float):
|
| 268 |
+
if abs(val) >= 1:
|
| 269 |
+
cells.append(f"{val:,.0f}")
|
| 270 |
+
else:
|
| 271 |
+
cells.append(f"{val:.4f}")
|
| 272 |
+
elif col_name == "year" or (isinstance(val, int) and 1900 <= val <= 2100):
|
| 273 |
+
cells.append(str(val))
|
| 274 |
+
else:
|
| 275 |
+
cells.append(f"{val:,}")
|
| 276 |
+
else:
|
| 277 |
+
cells.append(str(val))
|
| 278 |
+
rows.append("| " + " | ".join(cells) + " |")
|
| 279 |
+
|
| 280 |
+
parts.append("\n".join([header, sep] + rows))
|
| 281 |
+
|
| 282 |
+
if truncated:
|
| 283 |
+
parts.append(f"(์์ {effective_max}ํ ํ์, ์ ์ฒด {df.height}ํ)")
|
| 284 |
+
|
| 285 |
+
return "\n".join(parts)
|
| 286 |
+
|
| 287 |
+
|
| 288 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 289 |
+
# ํ์ ์งํ ์๋๊ณ์ฐ
|
| 290 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 291 |
+
|
| 292 |
+
|
| 293 |
+
def _find_account_value(df: pl.DataFrame, keyword: str, year_col: str) -> float | None:
|
| 294 |
+
"""๊ณ์ ๋ช
์์ ํค์๋๋ฅผ ํฌํจํ๋ ํ์ ๊ฐ ์ถ์ถ."""
|
| 295 |
+
if "๊ณ์ ๋ช
" not in df.columns or year_col not in df.columns:
|
| 296 |
+
return None
|
| 297 |
+
matched = df.filter(pl.col("๊ณ์ ๋ช
").str.contains(keyword))
|
| 298 |
+
if matched.height == 0:
|
| 299 |
+
return None
|
| 300 |
+
val = matched.row(0, named=True).get(year_col)
|
| 301 |
+
return val if isinstance(val, (int, float)) else None
|
| 302 |
+
|
| 303 |
+
|
| 304 |
+
def _compute_derived_metrics(name: str, df: pl.DataFrame, company: Any = None) -> str | None:
|
| 305 |
+
"""ํต์ฌ ์ฌ๋ฌด์ ํ์์ YoY ์ฑ์ฅ๋ฅ /๋น์จ ์๋๊ณ์ฐ.
|
| 306 |
+
|
| 307 |
+
๊ฐ์ : ROE, ์ด๏ฟฝ๏ฟฝ๋ณด์๋ฐฐ์จ, FCF, EBITDA ๋ฑ ์ถ๊ฐ.
|
| 308 |
+
"""
|
| 309 |
+
if name not in ("BS", "IS", "CF") or df is None or df.height == 0:
|
| 310 |
+
return None
|
| 311 |
+
|
| 312 |
+
year_cols = sorted(
|
| 313 |
+
[c for c in df.columns if c.isdigit() and len(c) == 4],
|
| 314 |
+
reverse=True,
|
| 315 |
+
)
|
| 316 |
+
if len(year_cols) < 2:
|
| 317 |
+
return None
|
| 318 |
+
|
| 319 |
+
lines = []
|
| 320 |
+
|
| 321 |
+
if name == "IS":
|
| 322 |
+
targets = {
|
| 323 |
+
"๋งค์ถ์ก": "๋งค์ถ ์ฑ์ฅ๋ฅ ",
|
| 324 |
+
"์์
์ด์ต": "์์
์ด์ต ์ฑ์ฅ๋ฅ ",
|
| 325 |
+
"๋น๊ธฐ์์ด์ต": "์์ด์ต ์ฑ์ฅ๋ฅ ",
|
| 326 |
+
}
|
| 327 |
+
for acct, label in targets.items():
|
| 328 |
+
metrics = []
|
| 329 |
+
for i in range(min(len(year_cols) - 1, 3)):
|
| 330 |
+
cur = _find_account_value(df, acct, year_cols[i])
|
| 331 |
+
prev = _find_account_value(df, acct, year_cols[i + 1])
|
| 332 |
+
if cur is not None and prev is not None and prev != 0:
|
| 333 |
+
yoy = (cur - prev) / abs(prev) * 100
|
| 334 |
+
metrics.append(f"{year_cols[i]}/{year_cols[i + 1]}: {yoy:+.1f}%")
|
| 335 |
+
if metrics:
|
| 336 |
+
lines.append(f"- {label}: {', '.join(metrics)}")
|
| 337 |
+
|
| 338 |
+
# ์์
์ด์ต๋ฅ , ์์ด์ต๋ฅ
|
| 339 |
+
latest = year_cols[0]
|
| 340 |
+
rev = _find_account_value(df, "๋งค์ถ์ก", latest)
|
| 341 |
+
oi = _find_account_value(df, "์์
์ด์ต", latest)
|
| 342 |
+
ni = _find_account_value(df, "๋น๊ธฐ์์ด์ต", latest)
|
| 343 |
+
if rev and rev != 0:
|
| 344 |
+
if oi is not None:
|
| 345 |
+
lines.append(f"- {latest} ์์
์ด์ต๋ฅ : {oi / rev * 100:.1f}%")
|
| 346 |
+
if ni is not None:
|
| 347 |
+
lines.append(f"- {latest} ์์ด์ต๋ฅ : {ni / rev * 100:.1f}%")
|
| 348 |
+
|
| 349 |
+
# ์ด์๋ณด์๋ฐฐ์จ (์์
์ด์ต / ์ด์๋น์ฉ)
|
| 350 |
+
interest = _find_account_value(df, "์ด์๋น์ฉ", latest)
|
| 351 |
+
if interest is None:
|
| 352 |
+
interest = _find_account_value(df, "๊ธ์ต๋น์ฉ", latest)
|
| 353 |
+
if oi is not None and interest is not None and interest != 0:
|
| 354 |
+
icr = oi / abs(interest)
|
| 355 |
+
lines.append(f"- {latest} ์ด์๋ณด์๋ฐฐ์จ: {icr:.1f}x")
|
| 356 |
+
|
| 357 |
+
# ROE (์์ด์ต / ์๋ณธ์ด๊ณ) โ BS๊ฐ ์์ ๋
|
| 358 |
+
if company and ni is not None:
|
| 359 |
+
try:
|
| 360 |
+
bs = getattr(company, "BS", None)
|
| 361 |
+
if isinstance(bs, pl.DataFrame) and latest in bs.columns:
|
| 362 |
+
equity = _find_account_value(bs, "์๋ณธ์ด๊ณ", latest)
|
| 363 |
+
if equity and equity != 0:
|
| 364 |
+
roe = ni / equity * 100
|
| 365 |
+
lines.append(f"- {latest} ROE: {roe:.1f}%")
|
| 366 |
+
total_asset = _find_account_value(bs, "์์ฐ์ด๊ณ", latest)
|
| 367 |
+
if total_asset and total_asset != 0:
|
| 368 |
+
roa = ni / total_asset * 100
|
| 369 |
+
lines.append(f"- {latest} ROA: {roa:.1f}%")
|
| 370 |
+
except _CONTEXT_ERRORS:
|
| 371 |
+
pass
|
| 372 |
+
|
| 373 |
+
elif name == "BS":
|
| 374 |
+
latest = year_cols[0]
|
| 375 |
+
debt = _find_account_value(df, "๋ถ์ฑ์ด๊ณ", latest)
|
| 376 |
+
equity = _find_account_value(df, "์๋ณธ์ด๊ณ", latest)
|
| 377 |
+
ca = _find_account_value(df, "์ ๋์์ฐ", latest)
|
| 378 |
+
cl = _find_account_value(df, "์ ๋๋ถ์ฑ", latest)
|
| 379 |
+
ta = _find_account_value(df, "์์ฐ์ด๊ณ", latest)
|
| 380 |
+
|
| 381 |
+
if debt is not None and equity is not None and equity != 0:
|
| 382 |
+
lines.append(f"- {latest} ๋ถ์ฑ๋น์จ: {debt / equity * 100:.1f}%")
|
| 383 |
+
if ca is not None and cl is not None and cl != 0:
|
| 384 |
+
lines.append(f"- {latest} ์ ๋๋น์จ: {ca / cl * 100:.1f}%")
|
| 385 |
+
if debt is not None and ta is not None and ta != 0:
|
| 386 |
+
lines.append(f"- {latest} ๋ถ์ฑ์ด๊ณ/์์ฐ์ด๊ณ: {debt / ta * 100:.1f}%")
|
| 387 |
+
|
| 388 |
+
# ์ด์์ฐ ์ฆ๊ฐ์จ
|
| 389 |
+
for i in range(min(len(year_cols) - 1, 2)):
|
| 390 |
+
cur = _find_account_value(df, "์์ฐ์ด๊ณ", year_cols[i])
|
| 391 |
+
prev = _find_account_value(df, "์์ฐ์ด๊ณ", year_cols[i + 1])
|
| 392 |
+
if cur is not None and prev is not None and prev != 0:
|
| 393 |
+
yoy = (cur - prev) / abs(prev) * 100
|
| 394 |
+
lines.append(f"- ์ด์์ฐ ์ฆ๊ฐ์จ {year_cols[i]}/{year_cols[i + 1]}: {yoy:+.1f}%")
|
| 395 |
+
|
| 396 |
+
elif name == "CF":
|
| 397 |
+
latest = year_cols[0]
|
| 398 |
+
op_cf = _find_account_value(df, "์์
ํ๋", latest)
|
| 399 |
+
inv_cf = _find_account_value(df, "ํฌ์ํ๋", latest)
|
| 400 |
+
fin_cf = _find_account_value(df, "์ฌ๋ฌดํ๋", latest)
|
| 401 |
+
|
| 402 |
+
if op_cf is not None and inv_cf is not None:
|
| 403 |
+
fcf = op_cf + inv_cf
|
| 404 |
+
lines.append(f"- {latest} FCF(์์
CF+ํฌ์CF): {_format_krw(fcf)}")
|
| 405 |
+
|
| 406 |
+
# CF ํจํด ํด์
|
| 407 |
+
if op_cf is not None and inv_cf is not None and fin_cf is not None:
|
| 408 |
+
pattern = f"{'+' if op_cf >= 0 else '-'}/{'+' if inv_cf >= 0 else '-'}/{'+' if fin_cf >= 0 else '-'}"
|
| 409 |
+
pattern_desc = _interpret_cf_pattern(op_cf >= 0, inv_cf >= 0, fin_cf >= 0)
|
| 410 |
+
lines.append(f"- {latest} CF ํจํด(์์
/ํฌ์/์ฌ๋ฌด): {pattern} โ {pattern_desc}")
|
| 411 |
+
|
| 412 |
+
for i in range(min(len(year_cols) - 1, 2)):
|
| 413 |
+
cur = _find_account_value(df, "์์
ํ๋", year_cols[i])
|
| 414 |
+
prev = _find_account_value(df, "์์
ํ๋", year_cols[i + 1])
|
| 415 |
+
if cur is not None and prev is not None and prev != 0:
|
| 416 |
+
yoy = (cur - prev) / abs(prev) * 100
|
| 417 |
+
lines.append(f"- ์์
ํ๋CF ๋ณ๋ {year_cols[i]}/{year_cols[i + 1]}: {yoy:+.1f}%")
|
| 418 |
+
|
| 419 |
+
if not lines:
|
| 420 |
+
return None
|
| 421 |
+
|
| 422 |
+
return "### ์ฃผ์ ์งํ (์๋๊ณ์ฐ)\n" + "\n".join(lines)
|
| 423 |
+
|
| 424 |
+
|
| 425 |
+
def _interpret_cf_pattern(op_pos: bool, inv_pos: bool, fin_pos: bool) -> str:
|
| 426 |
+
"""ํ๊ธํ๋ฆ ํจํด ํด์."""
|
| 427 |
+
if op_pos and not inv_pos and not fin_pos:
|
| 428 |
+
return "์ฐ๋ ๊ธฐ์
ํ (์์
์ด์ต์ผ๋ก ํฌ์+์ํ)"
|
| 429 |
+
if op_pos and not inv_pos and fin_pos:
|
| 430 |
+
return "์ฑ์ฅ ํฌ์ํ (์์
+์ฐจ์
์ผ๋ก ์ ๊ทน ํฌ์)"
|
| 431 |
+
if op_pos and inv_pos and not fin_pos:
|
| 432 |
+
return "๊ตฌ์กฐ์กฐ์ ํ (์์ฐ ๋งค๊ฐ+๋ถ์ฑ ์ํ)"
|
| 433 |
+
if not op_pos and not inv_pos and fin_pos:
|
| 434 |
+
return "์ํ ์ ํธ (์์
์ ์์ธ๋ฐ ์ฐจ์
์ผ๋ก ํฌ์)"
|
| 435 |
+
if not op_pos and inv_pos and fin_pos:
|
| 436 |
+
return "์๊ธฐ ๊ด๋ฆฌํ (์์ฐ ๋งค๊ฐ+์ฐจ์
์ผ๋ก ์์
๋ณด์ )"
|
| 437 |
+
if not op_pos and inv_pos and not fin_pos:
|
| 438 |
+
return "์ถ์ํ (์์ฐ ๋งค๊ฐ์ผ๋ก ๋ถ์ฑ ์ํ)"
|
| 439 |
+
return "๊ธฐํ ํจํด"
|
src/dartlab/ai/context/snapshot.py
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ํต์ฌ ์์น ์ค๋
์ท ๋น๋ โ server ์์กด์ฑ ์๋ ์์ ๋ก์ง.
|
| 2 |
+
|
| 3 |
+
server/chat.py์ build_snapshot()์์ ์ถ์ถ.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from __future__ import annotations
|
| 7 |
+
|
| 8 |
+
from typing import Any
|
| 9 |
+
|
| 10 |
+
from dartlab.ai.context.company_adapter import get_headline_ratios
|
| 11 |
+
|
| 12 |
+
|
| 13 |
+
def _fmt(val: float | int | None, suffix: str = "") -> str | None:
|
| 14 |
+
if val is None:
|
| 15 |
+
return None
|
| 16 |
+
abs_v = abs(val)
|
| 17 |
+
sign = "-" if val < 0 else ""
|
| 18 |
+
if abs_v >= 1e12:
|
| 19 |
+
return f"{sign}{abs_v / 1e12:,.1f}์กฐ{suffix}"
|
| 20 |
+
if abs_v >= 1e8:
|
| 21 |
+
return f"{sign}{abs_v / 1e8:,.0f}์ต{suffix}"
|
| 22 |
+
if abs_v >= 1e4:
|
| 23 |
+
return f"{sign}{abs_v / 1e4:,.0f}๋ง{suffix}"
|
| 24 |
+
if abs_v >= 1:
|
| 25 |
+
return f"{sign}{abs_v:,.0f}{suffix}"
|
| 26 |
+
return f"0{suffix}"
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def _pct(val: float | None) -> str | None:
|
| 30 |
+
return f"{val:.1f}%" if val is not None else None
|
| 31 |
+
|
| 32 |
+
|
| 33 |
+
def _judge_pct(val: float | None, good: float, caution: float) -> str | None:
|
| 34 |
+
if val is None:
|
| 35 |
+
return None
|
| 36 |
+
if val >= good:
|
| 37 |
+
return "good"
|
| 38 |
+
if val >= caution:
|
| 39 |
+
return "caution"
|
| 40 |
+
return "danger"
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def _judge_pct_inv(val: float | None, good: float, caution: float) -> str | None:
|
| 44 |
+
if val is None:
|
| 45 |
+
return None
|
| 46 |
+
if val <= good:
|
| 47 |
+
return "good"
|
| 48 |
+
if val <= caution:
|
| 49 |
+
return "caution"
|
| 50 |
+
return "danger"
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
def build_snapshot(company: Any, *, includeInsights: bool = True) -> dict | None:
|
| 54 |
+
"""ratios + ํต์ฌ ์๊ณ์ด์์ ์ฆ์ ํ์ํ ์ค๋
์ท ๋ฐ์ดํฐ ์ถ์ถ."""
|
| 55 |
+
ratios = get_headline_ratios(company)
|
| 56 |
+
if ratios is None:
|
| 57 |
+
return None
|
| 58 |
+
if not hasattr(ratios, "revenueTTM"):
|
| 59 |
+
return None
|
| 60 |
+
|
| 61 |
+
isFinancial = False
|
| 62 |
+
sectorInfo = getattr(company, "sector", None)
|
| 63 |
+
if sectorInfo is not None:
|
| 64 |
+
try:
|
| 65 |
+
from dartlab.analysis.comparative.sector.types import Sector
|
| 66 |
+
|
| 67 |
+
isFinancial = sectorInfo.sector == Sector.FINANCIALS
|
| 68 |
+
except (ImportError, AttributeError):
|
| 69 |
+
isFinancial = False
|
| 70 |
+
|
| 71 |
+
items: list[dict[str, Any]] = []
|
| 72 |
+
roeGood, roeCaution = (8, 5) if isFinancial else (10, 5)
|
| 73 |
+
roaGood, roaCaution = (0.5, 0.2) if isFinancial else (5, 2)
|
| 74 |
+
|
| 75 |
+
if ratios.revenueTTM is not None:
|
| 76 |
+
items.append({"label": "๋งค์ถ(TTM)", "value": _fmt(ratios.revenueTTM), "status": None})
|
| 77 |
+
if ratios.operatingIncomeTTM is not None:
|
| 78 |
+
items.append(
|
| 79 |
+
{
|
| 80 |
+
"label": "์์
์ด์ต(TTM)",
|
| 81 |
+
"value": _fmt(ratios.operatingIncomeTTM),
|
| 82 |
+
"status": "good" if ratios.operatingIncomeTTM > 0 else "danger",
|
| 83 |
+
}
|
| 84 |
+
)
|
| 85 |
+
if ratios.netIncomeTTM is not None:
|
| 86 |
+
items.append(
|
| 87 |
+
{
|
| 88 |
+
"label": "์์ด์ต(TTM)",
|
| 89 |
+
"value": _fmt(ratios.netIncomeTTM),
|
| 90 |
+
"status": "good" if ratios.netIncomeTTM > 0 else "danger",
|
| 91 |
+
}
|
| 92 |
+
)
|
| 93 |
+
if ratios.operatingMargin is not None:
|
| 94 |
+
items.append(
|
| 95 |
+
{
|
| 96 |
+
"label": "์์
์ด์ต๋ฅ ",
|
| 97 |
+
"value": _pct(ratios.operatingMargin),
|
| 98 |
+
"status": _judge_pct(ratios.operatingMargin, 10, 5),
|
| 99 |
+
}
|
| 100 |
+
)
|
| 101 |
+
if ratios.roe is not None:
|
| 102 |
+
items.append({"label": "ROE", "value": _pct(ratios.roe), "status": _judge_pct(ratios.roe, roeGood, roeCaution)})
|
| 103 |
+
if ratios.roa is not None:
|
| 104 |
+
items.append({"label": "ROA", "value": _pct(ratios.roa), "status": _judge_pct(ratios.roa, roaGood, roaCaution)})
|
| 105 |
+
if ratios.debtRatio is not None:
|
| 106 |
+
items.append(
|
| 107 |
+
{
|
| 108 |
+
"label": "๋ถ์ฑ๋น์จ",
|
| 109 |
+
"value": _pct(ratios.debtRatio),
|
| 110 |
+
"status": _judge_pct_inv(ratios.debtRatio, 100, 200),
|
| 111 |
+
}
|
| 112 |
+
)
|
| 113 |
+
if ratios.currentRatio is not None:
|
| 114 |
+
items.append(
|
| 115 |
+
{
|
| 116 |
+
"label": "์ ๋๋น์จ",
|
| 117 |
+
"value": _pct(ratios.currentRatio),
|
| 118 |
+
"status": _judge_pct(ratios.currentRatio, 150, 100),
|
| 119 |
+
}
|
| 120 |
+
)
|
| 121 |
+
if ratios.fcf is not None:
|
| 122 |
+
items.append({"label": "FCF", "value": _fmt(ratios.fcf), "status": "good" if ratios.fcf > 0 else "danger"})
|
| 123 |
+
if ratios.revenueGrowth3Y is not None:
|
| 124 |
+
items.append(
|
| 125 |
+
{
|
| 126 |
+
"label": "๋งค์ถ 3Y CAGR",
|
| 127 |
+
"value": _pct(ratios.revenueGrowth3Y),
|
| 128 |
+
"status": _judge_pct(ratios.revenueGrowth3Y, 5, 0),
|
| 129 |
+
}
|
| 130 |
+
)
|
| 131 |
+
if ratios.roic is not None:
|
| 132 |
+
items.append(
|
| 133 |
+
{
|
| 134 |
+
"label": "ROIC",
|
| 135 |
+
"value": _pct(ratios.roic),
|
| 136 |
+
"status": _judge_pct(ratios.roic, 15, 8),
|
| 137 |
+
}
|
| 138 |
+
)
|
| 139 |
+
if ratios.interestCoverage is not None:
|
| 140 |
+
items.append(
|
| 141 |
+
{
|
| 142 |
+
"label": "์ด์๋ณด์๋ฐฐ์จ",
|
| 143 |
+
"value": f"{ratios.interestCoverage:.1f}x",
|
| 144 |
+
"status": _judge_pct(ratios.interestCoverage, 5, 1),
|
| 145 |
+
}
|
| 146 |
+
)
|
| 147 |
+
pf = getattr(ratios, "piotroskiFScore", None)
|
| 148 |
+
if pf is not None:
|
| 149 |
+
items.append(
|
| 150 |
+
{
|
| 151 |
+
"label": "Piotroski F",
|
| 152 |
+
"value": f"{pf}/9",
|
| 153 |
+
"status": "good" if pf >= 7 else ("caution" if pf >= 4 else "danger"),
|
| 154 |
+
}
|
| 155 |
+
)
|
| 156 |
+
az = getattr(ratios, "altmanZScore", None)
|
| 157 |
+
if az is not None:
|
| 158 |
+
items.append(
|
| 159 |
+
{
|
| 160 |
+
"label": "Altman Z",
|
| 161 |
+
"value": f"{az:.2f}",
|
| 162 |
+
"status": "good" if az > 2.99 else ("caution" if az >= 1.81 else "danger"),
|
| 163 |
+
}
|
| 164 |
+
)
|
| 165 |
+
|
| 166 |
+
annual = getattr(company, "annual", None)
|
| 167 |
+
trend = None
|
| 168 |
+
if annual is not None:
|
| 169 |
+
series, years = annual
|
| 170 |
+
if years and len(years) >= 2:
|
| 171 |
+
rev_list = series.get("IS", {}).get("sales")
|
| 172 |
+
if rev_list:
|
| 173 |
+
n = min(5, len(rev_list))
|
| 174 |
+
recent_years = years[-n:]
|
| 175 |
+
recent_vals = rev_list[-n:]
|
| 176 |
+
trend = {"years": recent_years, "values": list(recent_vals)}
|
| 177 |
+
|
| 178 |
+
if not items:
|
| 179 |
+
return None
|
| 180 |
+
|
| 181 |
+
snapshot: dict[str, Any] = {"items": items}
|
| 182 |
+
if trend:
|
| 183 |
+
snapshot["trend"] = trend
|
| 184 |
+
if ratios.warnings:
|
| 185 |
+
snapshot["warnings"] = ratios.warnings[:3]
|
| 186 |
+
|
| 187 |
+
if includeInsights:
|
| 188 |
+
try:
|
| 189 |
+
from dartlab.analysis.financial.insight.pipeline import analyze as insight_analyze
|
| 190 |
+
|
| 191 |
+
insight_result = insight_analyze(company.stockCode, company=company)
|
| 192 |
+
if insight_result is not None:
|
| 193 |
+
snapshot["grades"] = insight_result.grades()
|
| 194 |
+
snapshot["anomalyCount"] = len(insight_result.anomalies)
|
| 195 |
+
except (ImportError, AttributeError, FileNotFoundError, OSError, RuntimeError, TypeError, ValueError):
|
| 196 |
+
pass
|
| 197 |
+
|
| 198 |
+
return snapshot
|
src/dartlab/ai/conversation/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""AI conversation package."""
|
src/dartlab/ai/conversation/data_ready.py
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""AI ๋ถ์ ์ ๋ฐ์ดํฐ ์ค๋น ์ํ๋ฅผ ์์ฝํ๋ ํฌํผ."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from datetime import datetime
|
| 6 |
+
from typing import Any
|
| 7 |
+
|
| 8 |
+
_DATA_CATEGORIES = ("docs", "finance", "report")
|
| 9 |
+
|
| 10 |
+
|
| 11 |
+
def getDataReadyStatus(stockCode: str) -> dict[str, Any]:
|
| 12 |
+
"""์ข
๋ชฉ์ docs/finance/report ๋ก์ปฌ ์ค๋น ์ํ๋ฅผ ๋ฐํํ๋ค."""
|
| 13 |
+
from dartlab.core.dataLoader import _dataDir
|
| 14 |
+
|
| 15 |
+
categories: dict[str, dict[str, Any]] = {}
|
| 16 |
+
available: list[str] = []
|
| 17 |
+
missing: list[str] = []
|
| 18 |
+
|
| 19 |
+
for category in _DATA_CATEGORIES:
|
| 20 |
+
filePath = _dataDir(category) / f"{stockCode}.parquet"
|
| 21 |
+
ready = filePath.exists()
|
| 22 |
+
updatedAt = None
|
| 23 |
+
if ready:
|
| 24 |
+
updatedAt = datetime.fromtimestamp(filePath.stat().st_mtime).strftime("%Y-%m-%d %H:%M")
|
| 25 |
+
available.append(category)
|
| 26 |
+
else:
|
| 27 |
+
missing.append(category)
|
| 28 |
+
|
| 29 |
+
categories[category] = {
|
| 30 |
+
"ready": ready,
|
| 31 |
+
"updatedAt": updatedAt,
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
return {
|
| 35 |
+
"stockCode": stockCode,
|
| 36 |
+
"allReady": not missing,
|
| 37 |
+
"available": available,
|
| 38 |
+
"missing": missing,
|
| 39 |
+
"categories": categories,
|
| 40 |
+
}
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
def formatDataReadyStatus(stockCode: str, *, detailed: bool = False) -> str:
|
| 44 |
+
"""๋ฐ์ดํฐ ์ค๋น ์ํ๋ฅผ LLM/UI์ฉ ํ
์คํธ๋ก ๋ ๋๋งํ๋ค."""
|
| 45 |
+
status = getDataReadyStatus(stockCode)
|
| 46 |
+
|
| 47 |
+
if not detailed:
|
| 48 |
+
readyText = ", ".join(status["available"]) if status["available"] else "์์"
|
| 49 |
+
missingText = ", ".join(status["missing"]) if status["missing"] else "์์"
|
| 50 |
+
if status["allReady"]:
|
| 51 |
+
return "- ๋ฐ์ดํฐ ์ํ: docs, finance, report๊ฐ ๋ชจ๋ ์ค๋น๋์ด ์์ต๋๋ค."
|
| 52 |
+
return (
|
| 53 |
+
f"- ๋ฐ์ดํฐ ์ํ: ์ค๋น๋จ={readyText}; ๋๋ฝ={missingText}. "
|
| 54 |
+
"๋๋ฝ๋ ๋ฐ์ดํฐ๊ฐ ์์ผ๋ฉด ๋ต๋ณ ๋ฒ์๊ฐ ์ ํ๋ ์ ์์ต๋๋ค."
|
| 55 |
+
)
|
| 56 |
+
|
| 57 |
+
lines = [f"## {stockCode} ๋ฐ์ดํฐ ์ํ", ""]
|
| 58 |
+
for category in _DATA_CATEGORIES:
|
| 59 |
+
info = status["categories"][category]
|
| 60 |
+
if info["ready"]:
|
| 61 |
+
lines.append(f"- **{category}**: โ
์์ (์ต์ข
๊ฐฑ์ : {info['updatedAt']})")
|
| 62 |
+
else:
|
| 63 |
+
lines.append(f"- **{category}**: โ ์์")
|
| 64 |
+
|
| 65 |
+
if status["allReady"]:
|
| 66 |
+
lines.append("\n๋ชจ๋ ๋ฐ์ดํฐ๊ฐ ์ค๋น๋์ด ์์ต๋๋ค. ๋ฐ๋ก ๋ถ์์ ์งํํ ์ ์์ต๋๋ค.")
|
| 67 |
+
else:
|
| 68 |
+
lines.append(
|
| 69 |
+
"\n์ผ๋ถ ๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค. `download_data` ๋๊ตฌ๋ก ๋ค์ด๋ก๋ํ๊ฑฐ๋, ์ฌ์ฉ์์๊ฒ ๋ค์ด๋ก๋ ์ฌ๋ถ๋ฅผ ๋ฌผ์ด๋ณด์ธ์."
|
| 70 |
+
)
|
| 71 |
+
return "\n".join(lines)
|
src/dartlab/ai/conversation/dialogue.py
ADDED
|
@@ -0,0 +1,476 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""๋ํ ์ํ/๋ชจ๋ ๋ถ๋ฅ โ server ์์กด์ฑ ์๋ ์์ ๋ก์ง.
|
| 2 |
+
|
| 3 |
+
server/dialogue.py์์ ์ถ์ถ. ๊ฒฝ๋ ํ์
(types.py) ๊ธฐ๋ฐ.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from __future__ import annotations
|
| 7 |
+
|
| 8 |
+
import re
|
| 9 |
+
from dataclasses import dataclass
|
| 10 |
+
from typing import Any
|
| 11 |
+
|
| 12 |
+
from ..types import HistoryItem, ViewContextInfo
|
| 13 |
+
from .intent import has_analysis_intent, is_meta_question
|
| 14 |
+
|
| 15 |
+
_LEGACY_VIEWER_RE = re.compile(
|
| 16 |
+
r"\[์ฌ์ฉ์๊ฐ ํ์ฌ\s+(?P<company>.+?)\((?P<stock>[A-Za-z0-9]+)\)\s+๊ณต์๋ฅผ ๋ณด๊ณ ์์ต๋๋ค"
|
| 17 |
+
r"(?:\s+โ\s+ํ์ฌ ์น์
:\s+(?P<label>.+?)\((?P<topic>[^()]+)\))?\]",
|
| 18 |
+
)
|
| 19 |
+
_LEGACY_DATA_RE = re.compile(r'\[์ฌ์ฉ์๊ฐ ํ์ฌ\s+"(?P<label>.+?)"\s+๋ฐ์ดํฐ๋ฅผ ๋ณด๊ณ ์์ต๋๋ค\]')
|
| 20 |
+
|
| 21 |
+
_CODING_KEYWORDS = (
|
| 22 |
+
"์ฝ๋",
|
| 23 |
+
"๋ฒ๊ทธ",
|
| 24 |
+
"์๋ฌ",
|
| 25 |
+
"๋ฆฌํฉํฐ",
|
| 26 |
+
"๋ฆฌํฉํ ๋ง",
|
| 27 |
+
"ํ์ผ",
|
| 28 |
+
"ํจ์",
|
| 29 |
+
"ํ
์คํธ",
|
| 30 |
+
"๊ตฌํ",
|
| 31 |
+
"์์ ",
|
| 32 |
+
"patch",
|
| 33 |
+
"diff",
|
| 34 |
+
"workspace",
|
| 35 |
+
"cli",
|
| 36 |
+
"codex",
|
| 37 |
+
)
|
| 38 |
+
_EXPLORE_KEYWORDS = (
|
| 39 |
+
"์ด๋ค ๋ฐ์ดํฐ",
|
| 40 |
+
"๋ฌด์จ ๋ฐ์ดํฐ",
|
| 41 |
+
"๋ญ ๋ณผ ์",
|
| 42 |
+
"๋ญ๊ฐ ์์ด",
|
| 43 |
+
"์ด๋ค ๊ธฐ๋ฅ",
|
| 44 |
+
"๊ฐ๋ฅํ ๊ฒ",
|
| 45 |
+
"๊ฐ๋ฅํ๊ฑฐ",
|
| 46 |
+
"๋ฒ์",
|
| 47 |
+
"์ผ๋ง๋",
|
| 48 |
+
"๋ ๋ฐ์ ์",
|
| 49 |
+
"์ถ๊ฐ ์์ง",
|
| 50 |
+
"openapi",
|
| 51 |
+
)
|
| 52 |
+
_FOLLOW_UP_PREFIXES = ("๊ทธ๋ผ", "๊ทธ๋ฌ๋ฉด", "์ด๊ฑด", "์ด๊ฑฐ", "๊ทธ๊ฑฐ", "์", "์ด์งธ์", "๋", "๊ณ์", "์ด์ด")
|
| 53 |
+
|
| 54 |
+
_VIEWER_INTENT_KEYWORDS = (
|
| 55 |
+
"๋ณด์ฌ์ค",
|
| 56 |
+
"๋ณด์ฌ ์ค",
|
| 57 |
+
"๋ณด์ฌ์ฃผ์ธ์",
|
| 58 |
+
"์ด์ด์ค",
|
| 59 |
+
"์ด์ด ์ค",
|
| 60 |
+
"๊ณต์ ๋ณด๊ธฐ",
|
| 61 |
+
"๊ณต์ ์ด๊ธฐ",
|
| 62 |
+
"์๋ฌธ ๋ณด๊ธฐ",
|
| 63 |
+
"์๋ฌธ ๋ณด์ฌ",
|
| 64 |
+
"sections ๋ณด์ฌ",
|
| 65 |
+
"section ๋ณด์ฌ",
|
| 66 |
+
"show me",
|
| 67 |
+
"open viewer",
|
| 68 |
+
)
|
| 69 |
+
_DIALOGUE_MODE_LABELS = {
|
| 70 |
+
"capability": "๊ธฐ๋ฅ ํ์",
|
| 71 |
+
"coding": "์ฝ๋ฉ ์์
",
|
| 72 |
+
"company_explore": "ํ์ฌ ํ์",
|
| 73 |
+
"company_analysis": "ํ์ฌ ๋ถ์",
|
| 74 |
+
"follow_up": "ํ์ ์ง๋ฌธ",
|
| 75 |
+
"general_chat": "์ผ๋ฐ ๋ํ",
|
| 76 |
+
}
|
| 77 |
+
_USER_GOAL_LABELS = {
|
| 78 |
+
"capability": "์ง๊ธ ๊ฐ๋ฅํ ๊ธฐ๋ฅ/๋ฒ์๋ฅผ ํ์ธ",
|
| 79 |
+
"coding": "์ฝ๋ ์์
์คํ ๋๋ ๊ฒํ ",
|
| 80 |
+
"company_explore": "ํ์ฌ ํ์ฌ์์ ๋ณผ ์ ์๋ ๋ฐ์ดํฐ์ ๊ฒฝ๋ก ํ์ธ",
|
| 81 |
+
"company_analysis": "ํ์ฌ ํ์ฌ์ ๊ตฌ์ฒด์ ๋ถ์",
|
| 82 |
+
"follow_up": "์ด์ ๋งฅ๋ฝ์ ์ด์ด์ ์ถ๊ฐ ํ์ธ",
|
| 83 |
+
"general_chat": "์ผ๋ฐ ์ง๋ฌธ ๋๋ ๊ฐ๋ฒผ์ด ๋ํ",
|
| 84 |
+
}
|
| 85 |
+
_STATE_TRANSITION_HINTS: dict[str, str] = {
|
| 86 |
+
"general_chatโcompany_analysis": "์ผ๋ฐ ๋ํ์์ ๋ถ์์ผ๋ก ์ ํ๋จ. ๋ฐ๋ก ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ์ ์ํ์ธ์. ์ด์ ์ก๋ด ๋งฅ๋ฝ์ ๋ฌด์.",
|
| 87 |
+
"general_chatโcompany_explore": "ํ์ฌ ํ์์ผ๋ก ์ ํ๋จ. ํด๋น ๊ธฐ์
์ ๋ฐ์ดํฐ ํํฉ์ ๋จผ์ ์๋ ค์ฃผ์ธ์.",
|
| 88 |
+
"company_analysisโfollow_up": "์ฌํ ์ง๋ฌธ. ์ง์ ๋ถ์์ ํต์ฌ ์์น๋ฅผ ๊ธฐ์ตํ๊ณ ์ด์ด๊ฐ์ธ์.",
|
| 89 |
+
"company_analysisโgeneral_chat": "๋ถ์์์ ์ผ๋ฐ ๋ํ๋ก ์ ํ๋จ. ์งง๊ณ ์น๊ทผํ๊ฒ.",
|
| 90 |
+
"company_exploreโcompany_analysis": "ํ์์์ ๋ถ์์ผ๋ก ์ ํ๋จ. ๊ตฌ์ฒด์ ์์น์ ํ๋จ์ ์ ์ํ์ธ์.",
|
| 91 |
+
"follow_upโcompany_analysis": "์๋ก์ด ๋ถ์ ์์ฒญ. ์ด์ ๋งฅ๋ฝ ์ฐธ๊ณ ํ๋ ์ ์ง๋ฌธ์ ์ง์ค.",
|
| 92 |
+
"capabilityโcompany_analysis": "๊ธฐ๋ฅ ์ง๋ฌธ ํ ๋ถ์ ์์ฒญ. ๋ฐ๋ก ๋ถ์ ๊ฒฐ๊ณผ๋ฅผ ์ ์ํ์ธ์.",
|
| 93 |
+
"codingโcompany_analysis": "์ฝ๋ ์์
์์ ๋ถ์์ผ๋ก ์ ํ๋จ. ์ฝ๋ ๋งฅ๋ฝ์ ๋ด๋ ค๋๊ณ ์ฌ๋ฌด ๋ถ์์ ์ง์ค.",
|
| 94 |
+
}
|
| 95 |
+
|
| 96 |
+
# โโ topic ํํธ ๋งคํ โโ
|
| 97 |
+
_TOPIC_HINTS: dict[str, str] = {
|
| 98 |
+
"์ฌ์
": "businessOverview",
|
| 99 |
+
"์ฌ์
๊ฐ์": "businessOverview",
|
| 100 |
+
"์ฌ์
๊ฐ์": "businessOverview",
|
| 101 |
+
"์ฌ์
์ ๊ฐ์": "businessOverview",
|
| 102 |
+
"๋ฐฐ๋น": "dividend",
|
| 103 |
+
"์ง์": "employee",
|
| 104 |
+
"์์": "executive",
|
| 105 |
+
"์ฃผ์ฃผ": "majorHolder",
|
| 106 |
+
"์ต๋์ฃผ์ฃผ": "majorHolder",
|
| 107 |
+
"๊ฐ์ฌ": "audit",
|
| 108 |
+
"๋ฆฌ์คํฌ": "riskManagement",
|
| 109 |
+
"์ํ": "riskManagement",
|
| 110 |
+
"์์ก": "litigation",
|
| 111 |
+
"ํ์ฌ ๊ฐ์": "companyOverview",
|
| 112 |
+
"ํ์ฌ๊ฐ์": "companyOverview",
|
| 113 |
+
"์ฌ๋ฌด": "financialStatements",
|
| 114 |
+
"์ฐ๊ฒฐ์ฌ๋ฌด": "consolidatedStatements",
|
| 115 |
+
"์ฃผ์": "financialNotes",
|
| 116 |
+
"๋ด๋ถํต์ ": "internalControl",
|
| 117 |
+
"ํฌ์": "investmentInOtherDetail",
|
| 118 |
+
"์ํ์ฌ": "subsidiaryDetail",
|
| 119 |
+
"R&D": "rndDetail",
|
| 120 |
+
"์ฐ๊ตฌ๊ฐ๋ฐ": "rndDetail",
|
| 121 |
+
"์ ํ": "productService",
|
| 122 |
+
"๋งค์ถ": "salesRevenue",
|
| 123 |
+
"์๋ณธ๋ณ๋": "capitalChange",
|
| 124 |
+
"์๊ธ์กฐ๋ฌ": "fundraising",
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
@dataclass(frozen=True)
|
| 129 |
+
class ConversationState:
|
| 130 |
+
question: str
|
| 131 |
+
dialogue_mode: str
|
| 132 |
+
user_goal: str
|
| 133 |
+
company: str | None = None
|
| 134 |
+
stock_code: str | None = None
|
| 135 |
+
market: str | None = None
|
| 136 |
+
topic: str | None = None
|
| 137 |
+
topic_label: str | None = None
|
| 138 |
+
period: str | None = None
|
| 139 |
+
viewer_data: dict | None = None
|
| 140 |
+
question_types: tuple[str, ...] = ()
|
| 141 |
+
modules: tuple[str, ...] = ()
|
| 142 |
+
prev_dialogue_mode: str | None = None
|
| 143 |
+
prev_question_types: tuple[str, ...] = ()
|
| 144 |
+
turn_count: int = 0
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
# โโ ๋ด๋ถ ํฌํผ โโ
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def _infer_market(
|
| 151 |
+
*,
|
| 152 |
+
company: Any | None = None,
|
| 153 |
+
stock_code: str | None = None,
|
| 154 |
+
view_context: ViewContextInfo | None = None,
|
| 155 |
+
history_market: str | None = None,
|
| 156 |
+
) -> str | None:
|
| 157 |
+
if view_context and view_context.company and view_context.company.market:
|
| 158 |
+
return view_context.company.market.lower()
|
| 159 |
+
if history_market:
|
| 160 |
+
return history_market.lower()
|
| 161 |
+
company_market = getattr(company, "market", None)
|
| 162 |
+
if isinstance(company_market, str) and company_market.strip():
|
| 163 |
+
return company_market.lower()
|
| 164 |
+
code = stock_code or getattr(company, "stockCode", None) or getattr(company, "ticker", None)
|
| 165 |
+
if isinstance(code, str) and code:
|
| 166 |
+
return "dart" if code.isdigit() and len(code) == 6 else "edgar"
|
| 167 |
+
return None
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
def _last_history_meta(history: list[HistoryItem] | None) -> Any | None:
|
| 171 |
+
if not history:
|
| 172 |
+
return None
|
| 173 |
+
for item in reversed(history):
|
| 174 |
+
if item.meta:
|
| 175 |
+
return item.meta
|
| 176 |
+
return None
|
| 177 |
+
|
| 178 |
+
|
| 179 |
+
def _parse_legacy_view_context(question: str) -> tuple[str, ViewContextInfo | None]:
|
| 180 |
+
from ..types import ViewContextCompany
|
| 181 |
+
|
| 182 |
+
cleaned = question
|
| 183 |
+
viewer_match = _LEGACY_VIEWER_RE.search(question)
|
| 184 |
+
if viewer_match:
|
| 185 |
+
cleaned = cleaned.replace(viewer_match.group(0), "").strip()
|
| 186 |
+
return (
|
| 187 |
+
cleaned,
|
| 188 |
+
ViewContextInfo(
|
| 189 |
+
type="viewer",
|
| 190 |
+
company=ViewContextCompany(
|
| 191 |
+
company=viewer_match.group("company"),
|
| 192 |
+
corpName=viewer_match.group("company"),
|
| 193 |
+
stockCode=viewer_match.group("stock"),
|
| 194 |
+
),
|
| 195 |
+
topic=viewer_match.group("topic"),
|
| 196 |
+
topicLabel=viewer_match.group("label"),
|
| 197 |
+
),
|
| 198 |
+
)
|
| 199 |
+
|
| 200 |
+
data_match = _LEGACY_DATA_RE.search(question)
|
| 201 |
+
if data_match:
|
| 202 |
+
cleaned = cleaned.replace(data_match.group(0), "").strip()
|
| 203 |
+
return cleaned, ViewContextInfo(type="data", data={"label": data_match.group("label")})
|
| 204 |
+
|
| 205 |
+
return cleaned, None
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
def _classify_dialogue_mode(question: str, *, has_company: bool) -> str:
|
| 209 |
+
lowered = question.lower().strip()
|
| 210 |
+
if any(keyword in lowered for keyword in _CODING_KEYWORDS):
|
| 211 |
+
return "coding"
|
| 212 |
+
if is_meta_question(question):
|
| 213 |
+
return "capability"
|
| 214 |
+
if has_company:
|
| 215 |
+
if has_analysis_intent(question):
|
| 216 |
+
return "company_analysis"
|
| 217 |
+
if any(keyword in lowered for keyword in _EXPLORE_KEYWORDS):
|
| 218 |
+
return "company_explore"
|
| 219 |
+
if len(question.strip()) <= 18 or any(lowered.startswith(prefix) for prefix in _FOLLOW_UP_PREFIXES):
|
| 220 |
+
return "follow_up"
|
| 221 |
+
return "company_explore"
|
| 222 |
+
return "general_chat"
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
# โโ ๊ณต๊ฐ API โโ
|
| 226 |
+
|
| 227 |
+
|
| 228 |
+
def detect_viewer_intent(question: str, *, topics: list[str] | None = None) -> dict[str, str] | None:
|
| 229 |
+
"""์ง๋ฌธ์์ '๋ณด์ฌ์ค' ์๋ + topic์ ๊ฐ์งํ๋ค.
|
| 230 |
+
|
| 231 |
+
Returns:
|
| 232 |
+
{"topic": "businessOverview"} ๋๋ None.
|
| 233 |
+
topic ํน์ ๋ถ๊ฐ ์ {"topic": ""} (Viewer ํญ๋ง ์ ํ).
|
| 234 |
+
"""
|
| 235 |
+
lowered = question.lower().strip()
|
| 236 |
+
has_show = any(kw in lowered for kw in _VIEWER_INTENT_KEYWORDS)
|
| 237 |
+
if not has_show:
|
| 238 |
+
return None
|
| 239 |
+
|
| 240 |
+
if topics:
|
| 241 |
+
for t in topics:
|
| 242 |
+
if t.lower() in lowered or t in question:
|
| 243 |
+
return {"topic": t}
|
| 244 |
+
|
| 245 |
+
for hint, topic in _TOPIC_HINTS.items():
|
| 246 |
+
if hint in question:
|
| 247 |
+
return {"topic": topic}
|
| 248 |
+
|
| 249 |
+
return {"topic": ""}
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
def build_conversation_state(
|
| 253 |
+
question: str,
|
| 254 |
+
*,
|
| 255 |
+
history: list[HistoryItem] | None = None,
|
| 256 |
+
company: Any | None = None,
|
| 257 |
+
view_context: ViewContextInfo | None = None,
|
| 258 |
+
) -> ConversationState:
|
| 259 |
+
"""๋ํ ์ํ๋ฅผ ๋น๋ํ๋ค.
|
| 260 |
+
|
| 261 |
+
server์์๋ Pydantic ๋ชจ๋ธ์ ๊ฒฝ๋ ํ์
์ผ๋ก ๋ณํ ํ ํธ์ถ.
|
| 262 |
+
standalone/core์์๋ ์ง์ ํธ์ถ.
|
| 263 |
+
"""
|
| 264 |
+
cleaned_question, legacy_view_context = _parse_legacy_view_context(question)
|
| 265 |
+
active_view = view_context or legacy_view_context
|
| 266 |
+
history_meta = _last_history_meta(history)
|
| 267 |
+
|
| 268 |
+
company_name = getattr(company, "corpName", None)
|
| 269 |
+
stock_code = getattr(company, "stockCode", None)
|
| 270 |
+
if not company_name and history_meta and history_meta.company:
|
| 271 |
+
company_name = history_meta.company
|
| 272 |
+
if not stock_code and history_meta and history_meta.stockCode:
|
| 273 |
+
stock_code = history_meta.stockCode
|
| 274 |
+
|
| 275 |
+
if active_view and active_view.company:
|
| 276 |
+
company_name = company_name or active_view.company.corpName or active_view.company.company
|
| 277 |
+
stock_code = stock_code or active_view.company.stockCode
|
| 278 |
+
|
| 279 |
+
topic = None
|
| 280 |
+
topic_label = None
|
| 281 |
+
period = None
|
| 282 |
+
viewer_data = None
|
| 283 |
+
if active_view and active_view.type == "viewer":
|
| 284 |
+
topic = active_view.topic
|
| 285 |
+
topic_label = active_view.topicLabel or active_view.topic
|
| 286 |
+
period = active_view.period
|
| 287 |
+
viewer_data = active_view.data
|
| 288 |
+
elif history_meta:
|
| 289 |
+
topic = history_meta.topic
|
| 290 |
+
topic_label = history_meta.topicLabel or history_meta.topic
|
| 291 |
+
|
| 292 |
+
modules = tuple(history_meta.modules or []) if history_meta and history_meta.modules else ()
|
| 293 |
+
|
| 294 |
+
try:
|
| 295 |
+
from dartlab.ai.conversation.prompts import _classify_question_multi
|
| 296 |
+
|
| 297 |
+
question_types = tuple(_classify_question_multi(cleaned_question))
|
| 298 |
+
except (ImportError, AttributeError, ValueError):
|
| 299 |
+
question_types = ()
|
| 300 |
+
|
| 301 |
+
dialogue_mode = _classify_dialogue_mode(cleaned_question, has_company=bool(company_name or stock_code))
|
| 302 |
+
user_goal = _USER_GOAL_LABELS[dialogue_mode]
|
| 303 |
+
market = _infer_market(
|
| 304 |
+
company=company,
|
| 305 |
+
stock_code=stock_code,
|
| 306 |
+
view_context=active_view,
|
| 307 |
+
history_market=history_meta.market if history_meta else None,
|
| 308 |
+
)
|
| 309 |
+
|
| 310 |
+
prev_dialogue_mode = history_meta.dialogueMode if history_meta else None
|
| 311 |
+
prev_question_types = tuple(history_meta.questionTypes or []) if history_meta and history_meta.questionTypes else ()
|
| 312 |
+
turn_count = len(history) if history else 0
|
| 313 |
+
|
| 314 |
+
return ConversationState(
|
| 315 |
+
question=cleaned_question or question,
|
| 316 |
+
dialogue_mode=dialogue_mode,
|
| 317 |
+
user_goal=user_goal,
|
| 318 |
+
company=company_name,
|
| 319 |
+
stock_code=stock_code,
|
| 320 |
+
market=market,
|
| 321 |
+
topic=topic,
|
| 322 |
+
topic_label=topic_label,
|
| 323 |
+
period=period,
|
| 324 |
+
viewer_data=viewer_data,
|
| 325 |
+
question_types=question_types,
|
| 326 |
+
modules=modules,
|
| 327 |
+
prev_dialogue_mode=prev_dialogue_mode,
|
| 328 |
+
prev_question_types=prev_question_types,
|
| 329 |
+
turn_count=turn_count,
|
| 330 |
+
)
|
| 331 |
+
|
| 332 |
+
|
| 333 |
+
def conversation_state_to_meta(state: ConversationState) -> dict[str, Any]:
|
| 334 |
+
payload: dict[str, Any] = {
|
| 335 |
+
"company": state.company,
|
| 336 |
+
"stockCode": state.stock_code,
|
| 337 |
+
"market": state.market,
|
| 338 |
+
"topic": state.topic,
|
| 339 |
+
"topicLabel": state.topic_label,
|
| 340 |
+
"dialogueMode": state.dialogue_mode,
|
| 341 |
+
"questionTypes": list(state.question_types) if state.question_types else None,
|
| 342 |
+
"userGoal": state.user_goal,
|
| 343 |
+
"turnCount": state.turn_count if state.turn_count > 0 else None,
|
| 344 |
+
}
|
| 345 |
+
return {key: value for key, value in payload.items() if value not in (None, [], "", 0)}
|
| 346 |
+
|
| 347 |
+
|
| 348 |
+
def build_dialogue_policy(state: ConversationState) -> str:
|
| 349 |
+
from dartlab.ai.tools.registry import get_coding_runtime_policy
|
| 350 |
+
|
| 351 |
+
coding_runtime_enabled, coding_runtime_reason = get_coding_runtime_policy()
|
| 352 |
+
lines = [
|
| 353 |
+
"## ํ์ฌ ๋ํ ์ํ",
|
| 354 |
+
f"- ๋ํ ๋ชจ๋: {_DIALOGUE_MODE_LABELS.get(state.dialogue_mode, state.dialogue_mode)}",
|
| 355 |
+
f"- ์ฌ์ฉ์ ๋ชฉํ: {state.user_goal}",
|
| 356 |
+
]
|
| 357 |
+
if state.company and state.stock_code:
|
| 358 |
+
lines.append(f"- ํ์ฌ ํ์ฌ: {state.company} ({state.stock_code})")
|
| 359 |
+
elif state.company:
|
| 360 |
+
lines.append(f"- ํ์ฌ ํ์ฌ: {state.company}")
|
| 361 |
+
if state.market:
|
| 362 |
+
lines.append(f"- ์์ฅ: {state.market}")
|
| 363 |
+
if state.topic_label or state.topic:
|
| 364 |
+
topic_desc = state.topic_label or state.topic
|
| 365 |
+
if state.period:
|
| 366 |
+
topic_desc += f" ({state.period})"
|
| 367 |
+
lines.append(f"- ํ์ฌ ๋ณด๊ณ ์๋ ์ฃผ์ : {topic_desc}")
|
| 368 |
+
if state.modules:
|
| 369 |
+
lines.append(f"- ์ง์ ๋ถ์ ๋ชจ๋: {', '.join(f'`{name}`' for name in state.modules[:8])}")
|
| 370 |
+
if state.question_types:
|
| 371 |
+
lines.append(f"- ๊ฐ์ง๋ ์ง๋ฌธ ์ ํ: {', '.join(state.question_types)}")
|
| 372 |
+
if state.turn_count > 0:
|
| 373 |
+
lines.append(f"- ๋ํ ํด: {state.turn_count}ํ์ฐจ")
|
| 374 |
+
if state.prev_dialogue_mode:
|
| 375 |
+
lines.append(f"- ์ง์ ๋ชจ๋: {_DIALOGUE_MODE_LABELS.get(state.prev_dialogue_mode, state.prev_dialogue_mode)}")
|
| 376 |
+
if state.prev_question_types:
|
| 377 |
+
lines.append(f"- ์ง์ ์ง๋ฌธ ์ ํ: {', '.join(state.prev_question_types)}")
|
| 378 |
+
|
| 379 |
+
if state.prev_dialogue_mode and state.prev_dialogue_mode != state.dialogue_mode:
|
| 380 |
+
transition = f"{state.prev_dialogue_mode}โ{state.dialogue_mode}"
|
| 381 |
+
hint = _STATE_TRANSITION_HINTS.get(transition)
|
| 382 |
+
if hint:
|
| 383 |
+
lines.append(f"- ์ ํ ํํธ: {hint}")
|
| 384 |
+
|
| 385 |
+
lines.extend(["", "## ๋ํ ์งํ ๊ท์น"])
|
| 386 |
+
|
| 387 |
+
if state.turn_count >= 2 and state.company:
|
| 388 |
+
lines.extend(
|
| 389 |
+
[
|
| 390 |
+
"### ๋ฉํฐํด ์ฐ์์ฑ",
|
| 391 |
+
"- ์ด์ ํด์ ๋ถ์ ๊ฒฐ๊ณผ์ ๋งฅ๋ฝ์ ์ด์ด๋ฐ์ผ์ธ์. ๊ฐ์ ํ์ฌ ๋ฐ๋ณต ์๊ฐ ๋ถํ์.",
|
| 392 |
+
"- ์ฌ์ฉ์๊ฐ ์งง๊ฒ ๋ฌผ์ผ๋ฉด ์ด์ ๋งฅ๋ฝ์์ ๊ฐ์ฅ ๊ด๋ จ ์๋ ๋ฐ์ดํฐ๋ฅผ ์๋ ํ์ฉํ์ธ์.",
|
| 393 |
+
"- ์ง์ ๋ถ์ ๋ชจ๋์ด ์์ผ๋ฉด ํด๋น ๋ชจ๋ ๋ฐ์ดํฐ๋ฅผ ์ฐ์ ์ฐธ์กฐํ์ธ์.",
|
| 394 |
+
"",
|
| 395 |
+
]
|
| 396 |
+
)
|
| 397 |
+
if state.dialogue_mode == "capability":
|
| 398 |
+
lines.extend(
|
| 399 |
+
[
|
| 400 |
+
"- ๊ฐ๋ฅํ ๊ฒ / ๋ฐ๋ก ํ ์ ์๋ ๊ฒ / ์์ง ์ ๋๋ ๊ฒ์ ๋จผ์ 3์ค ์์ ์ ๋ฆฌํ์ธ์.",
|
| 401 |
+
"- ๋ฐ๋ก ์คํ ๊ฐ๋ฅํ ๋ค์ ์ง๋ฌธ์ด๋ ์ก์
์ 2~4๊ฐ ์ ์ํ์ธ์.",
|
| 402 |
+
"- ์ค์ ๋ก ๋ฑ๋ก๋ ๋๊ตฌ์ ๋ฐํ์ ์ํ๋ง ๋งํ๊ณ ์ถ์ธกํ์ง ๋ง์ธ์.",
|
| 403 |
+
"",
|
| 404 |
+
"## ์๋ต ํ
ํ๋ฆฟ",
|
| 405 |
+
"1. ๊ฐ๋ฅํ ๊ฒ: ํ์ฌ ์ธ์
์์ ๋ฐ๋ก ๊ฐ๋ฅํ ๊ธฐ๋ฅ 2~4๊ฐ",
|
| 406 |
+
"2. ๋ฐ๋ก ํ ์ ์๏ฟฝ๏ฟฝ๏ฟฝ ๊ฒ: ์ง๊ธ ์ฆ์ ์คํ ๊ฐ๋ฅํ ์กฐํ/๋ถ์/์ ์ฅ ์์
",
|
| 407 |
+
"3. ์์ง ์ ๋๋ ๊ฒ: ๋ฏธ์ง์ ๋๋ ํ์ฌ ์ธ์
์์ ๋ซํ ๊ธฐ๋ฅ",
|
| 408 |
+
"4. ๋ค์ ์ก์
: ์ฌ์ฉ์๊ฐ ๋ฐ๋ก ๋ณต์ฌํด์ ๋ฌผ์ ์ ์๋ ์ง๋ฌธ 2~4๊ฐ",
|
| 409 |
+
]
|
| 410 |
+
)
|
| 411 |
+
elif state.dialogue_mode == "coding":
|
| 412 |
+
lines.extend(
|
| 413 |
+
[
|
| 414 |
+
"- ๋จผ์ ์์
๋ฒ์์ ์ ์ฝ์ ์งง๊ฒ ์์ฝํ์ธ์.",
|
| 415 |
+
"- ์์ ๊ฒฐ๊ณผ๋ฅผ ๋งํ ๋ ๋ณ๊ฒฝ์ , ๊ฒ์ฆ, ๋จ์ ๋ฆฌ์คํฌ๋ฅผ ๋ถ๋ฆฌํด์ ์ค๋ช
ํ์ธ์.",
|
| 416 |
+
]
|
| 417 |
+
)
|
| 418 |
+
if coding_runtime_enabled:
|
| 419 |
+
lines.append(
|
| 420 |
+
"- ์ด ์ธ์
์์๋ coding runtime์ด ์ด๋ ค ์์ผ๋ฏ๋ก ์คํ ๊ฐ๋ฅํ ์ฝ๋ ์์
์ด๋ฉด `run_coding_task` ์ฌ์ฉ์ ์ฐ์ ๊ฒํ ํ์ธ์."
|
| 421 |
+
)
|
| 422 |
+
else:
|
| 423 |
+
lines.append(
|
| 424 |
+
f"- ์ด ์ธ์
์์๋ coding runtime์ด ๋นํ์ฑํ๋์ด ์์ผ๋ ์ค์ ์ฝ๋ ์์ ์ ์ฝ์ํ์ง ๋ง๊ณ , ํ
์คํธ ๊ธฐ๋ฐ ์์ ์๊ณผ ํ์ฑํ ์กฐ๊ฑด๋ง ์๋ดํ์ธ์. ({coding_runtime_reason})"
|
| 425 |
+
)
|
| 426 |
+
lines.extend(
|
| 427 |
+
[
|
| 428 |
+
"",
|
| 429 |
+
"## ์๋ต ํ
ํ๋ฆฟ",
|
| 430 |
+
"1. ์์
๋ฒ์: ๋ฌด์์ ๊ณ ์น๊ฑฐ๋ ๋ง๋ค์ง ํ๋ ๋ฌธ์ฅ์ผ๋ก ์์ฝ",
|
| 431 |
+
"2. ์คํ ์ํ: ์ค์ ์ฝ๋ ์์
๊ฐ๋ฅ ์ฌ๋ถ ๋๋ ๋งํ ์ด์ ",
|
| 432 |
+
"3. ๋ณ๊ฒฝ์ : ํ์ผ/๋์ ๊ธฐ์ค ํต์ฌ ๋ณ๊ฒฝ ๋๋ ์ ์์",
|
| 433 |
+
"4. ๊ฒ์ฆ: ํ
์คํธ/๋น๋/ํ์ธ ๋ฐฉ๋ฒ",
|
| 434 |
+
"5. ๋จ์ ๋ฆฌ์คํฌ: ์์ง ํ์ธ๋์ง ์์ ์ 1~2๊ฐ",
|
| 435 |
+
]
|
| 436 |
+
)
|
| 437 |
+
elif state.dialogue_mode == "company_analysis":
|
| 438 |
+
lines.extend(
|
| 439 |
+
[
|
| 440 |
+
"- ํต์ฌ ๊ฒฐ๋ก 1~2๋ฌธ์ฅ์ ๋จผ์ ์ ์ํ๊ณ ๊ณง๋ฐ๋ก ๊ทผ๊ฑฐ ํ๋ฅผ ๋ถ์ด์ธ์.",
|
| 441 |
+
"- ์ซ์๋ ๋ฐ๋์ ํด์๊ณผ ํจ๊ป ์ ์ํ๊ณ , ๋ง์ง๋ง์ ์ถ๊ฐ drill-down ์ ์ 1~2๊ฐ๋ฅผ ๋จ๊ธฐ์ธ์.",
|
| 442 |
+
"- ์ฌ์ฉ์๊ฐ ์ด๋ฏธ ๋ณด๊ณ ์๋ topic์ด ์์ผ๋ฉด ๊ทธ topic์ ์ฐ์ ํ์ฉํ์ธ์.",
|
| 443 |
+
"",
|
| 444 |
+
"## ์๋ต ํ
ํ๋ฆฟ",
|
| 445 |
+
"1. ํ์ค ๊ฒฐ๋ก : ๊ฐ์ฅ ์ค์ํ ํ๋จ 1~2๋ฌธ์ฅ",
|
| 446 |
+
"2. ๊ทผ๊ฑฐ ํ: ํต์ฌ ์์น 2๊ฐ ์ด์์ด๋ฉด ๋ฐ๋์ ํ๋ก ์ ๋ฆฌ",
|
| 447 |
+
"3. ํด์: ์ซ์๊ฐ ์๋ฏธํ๋ ๋ณํ์ ์์ธ",
|
| 448 |
+
"4. ๋ค์ drill-down: ๋ ํ๋ณผ ์ฃผ์ 1~2๊ฐ",
|
| 449 |
+
]
|
| 450 |
+
)
|
| 451 |
+
elif state.dialogue_mode in {"company_explore", "follow_up"}:
|
| 452 |
+
lines.extend(
|
| 453 |
+
[
|
| 454 |
+
"- ์ด์ ๋งฅ๋ฝ์ ์ด์ด๋ฐ์ ๋ถํ์ํ ์ฌ์ง๋ฌธ ์์ด ๋ฐ๋ก ๋ตํ์ธ์.",
|
| 455 |
+
"- ํ์ฌ ํ์ฌ์์ ๋ฐ๋ก ๋ณผ ์ ์๋ ๋ฐ์ดํฐ๋ ๋ค์ ํ์ ๊ฒฝ๋ก๋ฅผ ๋จผ์ ๋ณด์ฌ์ฃผ์ธ์.",
|
| 456 |
+
"- ์งง์ ๋ต ํ ๊ตฌ์ฒด์ drill-down ์ต์
์ ์ ์ํ์ธ์.",
|
| 457 |
+
"",
|
| 458 |
+
"## ์๋ต ํ
ํ๋ฆฟ",
|
| 459 |
+
"1. ์ง์ ๋ต: ์ฌ์ฉ์์ ํ์ฌ ์ง๋ฌธ์ ๋ฐ๋ก ๋ต๋ณ",
|
| 460 |
+
"2. ์ง๊ธ ๋ณผ ์ ์๋ ๋ฐ์ดํฐ/๊ฒฝ๋ก: topic, show, trace, OpenAPI ์ค ์ ์ ํ ๊ฒฝ๋ก",
|
| 461 |
+
"3. ๋ค์ ์ ํ์ง: ์ด์ด์ ๋ฌผ์ ๋งํ drill-down ์ง๋ฌธ 2~3๊ฐ",
|
| 462 |
+
]
|
| 463 |
+
)
|
| 464 |
+
else:
|
| 465 |
+
lines.extend(
|
| 466 |
+
[
|
| 467 |
+
"- ์งง๊ณ ์ง์ ์ ์ผ๋ก ๋ตํ๊ณ , ํ์ํ ๊ฒฝ์ฐ์๋ง ๋ค์ ํ๋์ ์ ์ํ์ธ์.",
|
| 468 |
+
"- ํ์ฌ ๋งฅ๋ฝ์ด ์์ผ๋ฉด ํน์ ์ข
๋ชฉ๋ช
/์ฝ๋๊ฐ ์์ผ๋ฉด ๋ ์ ํํ ๋์์ค ์ ์๋ค๊ณ ์๋ดํ์ธ์.",
|
| 469 |
+
"",
|
| 470 |
+
"## ์๋ต ํ
ํ๋ฆฟ",
|
| 471 |
+
"1. ์ง์ ๋ต๋ณ",
|
| 472 |
+
"2. ํ์ํ๋ฉด ์งง์ ๋ณด์ถฉ ์ค๋ช
",
|
| 473 |
+
"3. ํ์ํ ๊ฒฝ์ฐ์๋ง ๋ค์ ํ๋ 1~2๊ฐ",
|
| 474 |
+
]
|
| 475 |
+
)
|
| 476 |
+
return "\n".join(lines)
|
src/dartlab/ai/conversation/focus.py
ADDED
|
@@ -0,0 +1,231 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ํฌ์ปค์ค/diff ์ปจํ
์คํธ ๋น๋ โ server ์์กด์ฑ ์๋ ์์ ๋ก์ง.
|
| 2 |
+
|
| 3 |
+
server/chat.py์ build_focus_context(), build_diff_context()์์ ์ถ์ถ.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from __future__ import annotations
|
| 7 |
+
|
| 8 |
+
from typing import Any
|
| 9 |
+
|
| 10 |
+
import polars as pl
|
| 11 |
+
|
| 12 |
+
from .dialogue import ConversationState
|
| 13 |
+
|
| 14 |
+
|
| 15 |
+
def _stringify_focus_value(value: Any, *, max_rows: int = 12, max_chars: int = 2400) -> str:
|
| 16 |
+
from dartlab.ai.context.builder import df_to_markdown
|
| 17 |
+
|
| 18 |
+
if value is None:
|
| 19 |
+
return "(๋ฐ์ดํฐ ์์)"
|
| 20 |
+
if isinstance(value, pl.DataFrame):
|
| 21 |
+
return df_to_markdown(value, max_rows=max_rows, compact=True)
|
| 22 |
+
text = str(value)
|
| 23 |
+
return text if len(text) <= max_chars else text[:max_chars] + "\n... (truncated)"
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def _build_topic_diff_snippet(company: Any, topic: str, *, max_entries: int = 3) -> str | None:
|
| 27 |
+
"""ํน์ topic์ ์ต๊ทผ ๊ธฐ๊ฐ๊ฐ ๋ณํ๋ฅผ ์์ฝ ํ
์คํธ๋ก ๋ฐํ."""
|
| 28 |
+
if not hasattr(company, "diff"):
|
| 29 |
+
return None
|
| 30 |
+
try:
|
| 31 |
+
topic_diff_df = company.diff(topic)
|
| 32 |
+
except (AttributeError, KeyError, TypeError, ValueError):
|
| 33 |
+
return None
|
| 34 |
+
if topic_diff_df is None or not isinstance(topic_diff_df, pl.DataFrame) or topic_diff_df.height == 0:
|
| 35 |
+
return None
|
| 36 |
+
|
| 37 |
+
lines = ["### ๊ธฐ๊ฐ๊ฐ ๋ณํ ์ด๋ ฅ"]
|
| 38 |
+
for row in topic_diff_df.head(max_entries).iter_rows(named=True):
|
| 39 |
+
from_p = row.get("fromPeriod", "?")
|
| 40 |
+
to_p = row.get("toPeriod", "?")
|
| 41 |
+
status = row.get("status", "?")
|
| 42 |
+
from_len = row.get("fromLen", 0)
|
| 43 |
+
to_len = row.get("toLen", 0)
|
| 44 |
+
delta = to_len - from_len
|
| 45 |
+
sign = "+" if delta > 0 else ""
|
| 46 |
+
lines.append(f"- {from_p} โ {to_p}: **{status}** (๊ธ์์ {from_len:,} โ {to_len:,}, {sign}{delta:,})")
|
| 47 |
+
return "\n".join(lines)
|
| 48 |
+
|
| 49 |
+
|
| 50 |
+
def build_focus_context(company: Any, state: ConversationState) -> str | None:
|
| 51 |
+
"""ํ์ฌ viewer/topic ๋งฅ๋ฝ์ LLM ์
๋ ฅ์ฉ ๊ทผ๊ฑฐ ๋ธ๋ก์ผ๋ก ์น๊ฒฉ."""
|
| 52 |
+
if not state.topic or not hasattr(company, "show"):
|
| 53 |
+
return None
|
| 54 |
+
|
| 55 |
+
lines = ["## ํ์ฌ ์ฌ์ฉ์๊ฐ ๋ณด๊ณ ์๋ ์น์
"]
|
| 56 |
+
lines.append(f"- topic: `{state.topic}`")
|
| 57 |
+
if state.topic_label:
|
| 58 |
+
lines.append(f"- label: {state.topic_label}")
|
| 59 |
+
if state.period:
|
| 60 |
+
lines.append(f"- period: {state.period}")
|
| 61 |
+
if state.company and state.stock_code:
|
| 62 |
+
lines.append(f"- company: {state.company} ({state.stock_code})")
|
| 63 |
+
|
| 64 |
+
# ๋ทฐ์ด์์ ์ ํํ ๋ธ๋ก ๋ฐ์ดํฐ๊ฐ ์์ผ๋ฉด ์ง์ ์ฝ์
|
| 65 |
+
if state.viewer_data:
|
| 66 |
+
vd = state.viewer_data
|
| 67 |
+
lines.append("")
|
| 68 |
+
lines.append("### ์ฌ์ฉ์๊ฐ ์ ํํ ๋ธ๋ก")
|
| 69 |
+
if vd.get("topicLabel"):
|
| 70 |
+
lines.append(f"- ์ฃผ์ : {vd['topicLabel']}")
|
| 71 |
+
if vd.get("blockType"):
|
| 72 |
+
lines.append(f"- ์ ํ: {vd['blockType']}")
|
| 73 |
+
if vd.get("preview"):
|
| 74 |
+
lines.append(f"- ๋ฏธ๋ฆฌ๋ณด๊ธฐ: {vd['preview']}")
|
| 75 |
+
table = vd.get("table")
|
| 76 |
+
if table and table.get("columns") and table.get("rows"):
|
| 77 |
+
cols = table["columns"]
|
| 78 |
+
rows = table["rows"]
|
| 79 |
+
lines.append("")
|
| 80 |
+
lines.append("#### ๋ธ๋ก ํ
์ด๋ธ ๋ฐ์ดํฐ")
|
| 81 |
+
lines.append("| " + " | ".join(str(c) for c in cols) + " |")
|
| 82 |
+
lines.append("| " + " | ".join("---" for _ in cols) + " |")
|
| 83 |
+
for row in rows[:30]:
|
| 84 |
+
vals = [str(row.get(c, "")) for c in cols]
|
| 85 |
+
lines.append("| " + " | ".join(vals) + " |")
|
| 86 |
+
if len(rows) > 30:
|
| 87 |
+
lines.append(f"... ์ธ {len(rows) - 30}ํ")
|
| 88 |
+
lines.append("")
|
| 89 |
+
lines.append("์ ๋ธ๋ก ๋ฐ์ดํฐ๋ฅผ ๊ทผ๊ฑฐ๋ก ๋ถ์ํด์ฃผ์ธ์.")
|
| 90 |
+
|
| 91 |
+
try:
|
| 92 |
+
if state.period:
|
| 93 |
+
overview = company.show(state.topic, period=state.period)
|
| 94 |
+
else:
|
| 95 |
+
overview = company.show(state.topic)
|
| 96 |
+
except (AttributeError, KeyError, TypeError, ValueError):
|
| 97 |
+
overview = None
|
| 98 |
+
|
| 99 |
+
if isinstance(overview, pl.DataFrame) and overview.height > 0:
|
| 100 |
+
lines.append("")
|
| 101 |
+
lines.append("### ๋ธ๋ก ๋ชฉ์ฐจ")
|
| 102 |
+
lines.append(_stringify_focus_value(overview, max_rows=6))
|
| 103 |
+
|
| 104 |
+
block_col = (
|
| 105 |
+
"block" if "block" in overview.columns else "blockOrder" if "blockOrder" in overview.columns else None
|
| 106 |
+
)
|
| 107 |
+
if block_col:
|
| 108 |
+
first_block = overview.row(0, named=True).get(block_col)
|
| 109 |
+
if isinstance(first_block, int):
|
| 110 |
+
try:
|
| 111 |
+
block_value = company.show(state.topic, first_block)
|
| 112 |
+
except (AttributeError, KeyError, TypeError, ValueError):
|
| 113 |
+
block_value = None
|
| 114 |
+
if block_value is not None:
|
| 115 |
+
lines.append("")
|
| 116 |
+
lines.append(f"### ํ์ฌ ์น์
๋ํ block={first_block}")
|
| 117 |
+
lines.append(_stringify_focus_value(block_value))
|
| 118 |
+
|
| 119 |
+
# ์ค์ ํ
์คํธ ๋ณธ๋ฌธ ํฌํจ
|
| 120 |
+
if isinstance(overview, pl.DataFrame) and overview.height > 0:
|
| 121 |
+
block_col_for_text = (
|
| 122 |
+
"block" if "block" in overview.columns else "blockOrder" if "blockOrder" in overview.columns else None
|
| 123 |
+
)
|
| 124 |
+
if block_col_for_text:
|
| 125 |
+
text_chars = 0
|
| 126 |
+
max_text_body = 4000
|
| 127 |
+
for row in overview.iter_rows(named=True):
|
| 128 |
+
btype = row.get("type", row.get("blockType", ""))
|
| 129 |
+
if btype != "text":
|
| 130 |
+
continue
|
| 131 |
+
bidx = row.get(block_col_for_text)
|
| 132 |
+
if not isinstance(bidx, int):
|
| 133 |
+
continue
|
| 134 |
+
try:
|
| 135 |
+
block_value = company.show(state.topic, bidx)
|
| 136 |
+
except (AttributeError, KeyError, TypeError, ValueError):
|
| 137 |
+
continue
|
| 138 |
+
if block_value is None:
|
| 139 |
+
continue
|
| 140 |
+
body = _stringify_focus_value(block_value, max_rows=20, max_chars=2000)
|
| 141 |
+
if text_chars + len(body) > max_text_body:
|
| 142 |
+
break
|
| 143 |
+
lines.append("")
|
| 144 |
+
lines.append(f"### ๊ณต์ ์๋ฌธ (block {bidx})")
|
| 145 |
+
lines.append(body)
|
| 146 |
+
text_chars += len(body)
|
| 147 |
+
|
| 148 |
+
if hasattr(company, "trace"):
|
| 149 |
+
try:
|
| 150 |
+
trace = company.trace(state.topic)
|
| 151 |
+
except (AttributeError, KeyError, TypeError, ValueError):
|
| 152 |
+
trace = None
|
| 153 |
+
if trace:
|
| 154 |
+
lines.append("")
|
| 155 |
+
lines.append("### source trace")
|
| 156 |
+
lines.append(_stringify_focus_value(trace, max_chars=1600))
|
| 157 |
+
|
| 158 |
+
diff_text = _build_topic_diff_snippet(company, state.topic)
|
| 159 |
+
if diff_text:
|
| 160 |
+
lines.append("")
|
| 161 |
+
lines.append(diff_text)
|
| 162 |
+
|
| 163 |
+
return "\n".join(lines)
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
def build_diff_context(company: Any, *, top_n: int = 8) -> str | None:
|
| 167 |
+
"""์ ์ฒด sections diff ์์ฝ์ LLM ์ปจํ
์คํธ ๋ฌธ์์ด๋ก ๋ณํ."""
|
| 168 |
+
if not hasattr(company, "diff"):
|
| 169 |
+
return None
|
| 170 |
+
try:
|
| 171 |
+
summary_df = company.diff()
|
| 172 |
+
except (AttributeError, KeyError, TypeError, ValueError):
|
| 173 |
+
return None
|
| 174 |
+
if summary_df is None or not isinstance(summary_df, pl.DataFrame) or summary_df.height == 0:
|
| 175 |
+
return None
|
| 176 |
+
|
| 177 |
+
changed_col = "changed" if "changed" in summary_df.columns else "changedCount"
|
| 178 |
+
periods_col = "periods" if "periods" in summary_df.columns else "totalPeriods"
|
| 179 |
+
rate_col = "changeRate"
|
| 180 |
+
|
| 181 |
+
if changed_col not in summary_df.columns:
|
| 182 |
+
return None
|
| 183 |
+
|
| 184 |
+
agg_cols = [
|
| 185 |
+
pl.col(periods_col).max().alias("periods"),
|
| 186 |
+
pl.col(changed_col).sum().alias("changed"),
|
| 187 |
+
]
|
| 188 |
+
if rate_col in summary_df.columns:
|
| 189 |
+
agg_cols.append(pl.col(rate_col).max().alias("changeRate"))
|
| 190 |
+
group_cols = ["topic"]
|
| 191 |
+
if "chapter" in summary_df.columns:
|
| 192 |
+
group_cols.insert(0, "chapter")
|
| 193 |
+
summary_df = summary_df.group_by(group_cols).agg(agg_cols)
|
| 194 |
+
changed_col = "changed"
|
| 195 |
+
periods_col = "periods"
|
| 196 |
+
|
| 197 |
+
_FINANCE_TOPICS = {
|
| 198 |
+
"financialNotes",
|
| 199 |
+
"financialStatements",
|
| 200 |
+
"consolidatedStatements",
|
| 201 |
+
"auditReport",
|
| 202 |
+
"auditOpinion",
|
| 203 |
+
}
|
| 204 |
+
summary_df = summary_df.filter(~pl.col("topic").is_in(_FINANCE_TOPICS))
|
| 205 |
+
|
| 206 |
+
changed = summary_df.filter(pl.col(changed_col) > 0)
|
| 207 |
+
if changed.height == 0:
|
| 208 |
+
return None
|
| 209 |
+
|
| 210 |
+
if rate_col in changed.columns:
|
| 211 |
+
changed = changed.sort([rate_col, changed_col], descending=[True, False]).head(top_n)
|
| 212 |
+
else:
|
| 213 |
+
changed = changed.sort(changed_col, descending=True).head(top_n)
|
| 214 |
+
|
| 215 |
+
lines = [
|
| 216 |
+
"## ๊ณต์ ํ
์คํธ ๋ณํ ํซ์คํ",
|
| 217 |
+
f"์ต๊ทผ ๊ธฐ๊ฐ๊ฐ ํ
์คํธ ๋ณ๊ฒฝ์ด ๋ง์ topic {changed.height}๊ฐ:",
|
| 218 |
+
"",
|
| 219 |
+
"| topic | ๊ธฐ๊ฐ์ | ๋ณ๊ฒฝํ์ | ๋ณํ์จ |",
|
| 220 |
+
"|-------|--------|----------|--------|",
|
| 221 |
+
]
|
| 222 |
+
for row in changed.iter_rows(named=True):
|
| 223 |
+
topic = row.get("topic", "?")
|
| 224 |
+
total = row.get(periods_col, 0)
|
| 225 |
+
cnt = row.get(changed_col, 0)
|
| 226 |
+
rate = row.get(rate_col, cnt / max(total - 1, 1) if total > 1 else 0)
|
| 227 |
+
lines.append(f"| {topic} | {total} | {cnt} | {rate:.0%} |")
|
| 228 |
+
|
| 229 |
+
lines.append("")
|
| 230 |
+
lines.append("๋ณํ์จ์ด ๋์ ์น์
์ ์ฌ์
์ ๋ต, ๋ฆฌ์คํฌ, ์ค์ ๋ณ๋ ๋ฑ ํต์ฌ ๋ณํ๋ฅผ ๋ด๊ณ ์์ ๊ฐ๋ฅ์ฑ์ด ๋์ต๋๋ค.")
|
| 231 |
+
return "\n".join(lines)
|
src/dartlab/ai/conversation/history.py
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ํ์คํ ๋ฆฌ ์์ถ/๋น๋ โ server ์์กด์ฑ ์๋ ์์ ๋ก์ง.
|
| 2 |
+
|
| 3 |
+
server/chat.py์ build_history_messages(), compress_history()์์ ์ถ์ถ.
|
| 4 |
+
๊ฒฝ๋ ํ์
(types.py) ๊ธฐ๋ฐ.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
from ..types import HistoryItem
|
| 10 |
+
|
| 11 |
+
_MAX_HISTORY_TURNS = 10
|
| 12 |
+
_MAX_HISTORY_CHARS = 12000
|
| 13 |
+
_MAX_HISTORY_MESSAGE_CHARS = 1800
|
| 14 |
+
_COMPRESS_TURN_THRESHOLD = 5
|
| 15 |
+
|
| 16 |
+
|
| 17 |
+
def _compress_history_text(text: str) -> str:
|
| 18 |
+
"""๊ธธ์ด์ง ๊ณผ๊ฑฐ ๋ํ๋ฅผ ์๋ค ํต์ฌ๋ง ๋จ๊ธฐ๋๋ก ์์ถ."""
|
| 19 |
+
if len(text) <= _MAX_HISTORY_MESSAGE_CHARS:
|
| 20 |
+
return text
|
| 21 |
+
head = int(_MAX_HISTORY_MESSAGE_CHARS * 0.65)
|
| 22 |
+
tail = _MAX_HISTORY_MESSAGE_CHARS - head
|
| 23 |
+
return text[:head].rstrip() + "\n...\n" + text[-tail:].lstrip()
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def build_history_messages(history: list[HistoryItem] | None) -> list[dict[str, str]]:
|
| 27 |
+
"""ํ์คํ ๋ฆฌ๋ฅผ LLM messages ํฌ๋งท์ผ๋ก ๋ณํ. ์ต๊ทผ Nํด๋ง ์ ์ง."""
|
| 28 |
+
if not history:
|
| 29 |
+
return []
|
| 30 |
+
trimmed = history[-(_MAX_HISTORY_TURNS * 2) :]
|
| 31 |
+
prepared: list[dict[str, str]] = []
|
| 32 |
+
for h in trimmed:
|
| 33 |
+
role = h.role if h.role in ("user", "assistant") else "user"
|
| 34 |
+
text = h.text.strip()
|
| 35 |
+
if not text:
|
| 36 |
+
continue
|
| 37 |
+
if role == "assistant" and h.meta:
|
| 38 |
+
summary_parts: list[str] = []
|
| 39 |
+
if h.meta.company or h.meta.stockCode:
|
| 40 |
+
company_text = h.meta.company or "?"
|
| 41 |
+
if h.meta.stockCode:
|
| 42 |
+
company_text += f" ({h.meta.stockCode})"
|
| 43 |
+
summary_parts.append(company_text)
|
| 44 |
+
if h.meta.market:
|
| 45 |
+
summary_parts.append(f"์์ฅ: {h.meta.market}")
|
| 46 |
+
if h.meta.topicLabel or h.meta.topic:
|
| 47 |
+
summary_parts.append(f"์ฃผ์ : {h.meta.topicLabel or h.meta.topic}")
|
| 48 |
+
if h.meta.dialogueMode:
|
| 49 |
+
summary_parts.append(f"๋ชจ๋: {h.meta.dialogueMode}")
|
| 50 |
+
if h.meta.userGoal:
|
| 51 |
+
summary_parts.append(f"๋ชฉํ: {h.meta.userGoal}")
|
| 52 |
+
if h.meta.modules:
|
| 53 |
+
summary_parts.append(f"๋ชจ๋: {', '.join(h.meta.modules)}")
|
| 54 |
+
if h.meta.questionTypes:
|
| 55 |
+
summary_parts.append(f"์ ํ: {', '.join(h.meta.questionTypes)}")
|
| 56 |
+
if summary_parts:
|
| 57 |
+
text = f"[์ด์ ๋ํ ์ํ: {' | '.join(summary_parts)}]\n{text}"
|
| 58 |
+
prepared.append({"role": role, "content": _compress_history_text(text)})
|
| 59 |
+
|
| 60 |
+
total = 0
|
| 61 |
+
selected: list[dict[str, str]] = []
|
| 62 |
+
for item in reversed(prepared):
|
| 63 |
+
content_len = len(item["content"])
|
| 64 |
+
if selected and total + content_len > _MAX_HISTORY_CHARS:
|
| 65 |
+
break
|
| 66 |
+
selected.append(item)
|
| 67 |
+
total += content_len
|
| 68 |
+
return list(reversed(selected))
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def compress_history(history: list[HistoryItem] | None) -> list[HistoryItem] | None:
|
| 72 |
+
"""๋ฉํฐํด ํ์คํ ๋ฆฌ ์์ถ: ์ค๋๋ ํด์ ๊ตฌ์กฐํ๋ ์์ฝ์ผ๋ก ๋์ฒด.
|
| 73 |
+
|
| 74 |
+
5ํด(10 ๋ฉ์์ง) ์ด์์ด๋ฉด ๊ฐ์ฅ ์ค๋๋ ํด๋ค์ 1๊ฐ ์์ฝ ๋ฉ์์ง๋ก ๊ต์ฒด.
|
| 75 |
+
์ต๊ทผ 4ํด(8 ๋ฉ์์ง)์ ์๋ณธ ์ ์ง.
|
| 76 |
+
"""
|
| 77 |
+
if not history or len(history) <= _COMPRESS_TURN_THRESHOLD * 2:
|
| 78 |
+
return history
|
| 79 |
+
|
| 80 |
+
keep_count = 8
|
| 81 |
+
old_messages = history[:-keep_count]
|
| 82 |
+
recent_messages = history[-keep_count:]
|
| 83 |
+
|
| 84 |
+
companies_mentioned: set[str] = set()
|
| 85 |
+
topics_discussed: list[str] = []
|
| 86 |
+
qa_pairs: list[str] = []
|
| 87 |
+
|
| 88 |
+
for msg in old_messages:
|
| 89 |
+
text = msg.text.strip()
|
| 90 |
+
if not text:
|
| 91 |
+
continue
|
| 92 |
+
|
| 93 |
+
if msg.meta:
|
| 94 |
+
if msg.meta.company:
|
| 95 |
+
companies_mentioned.add(msg.meta.company)
|
| 96 |
+
if msg.meta.topicLabel:
|
| 97 |
+
topics_discussed.append(msg.meta.topicLabel)
|
| 98 |
+
|
| 99 |
+
if msg.role == "user":
|
| 100 |
+
brief = text[:80] + "..." if len(text) > 80 else text
|
| 101 |
+
qa_pairs.append(f"- Q: {brief}")
|
| 102 |
+
elif msg.role == "assistant":
|
| 103 |
+
sentences = text.split(".")
|
| 104 |
+
brief = ".".join(sentences[:2]).strip()
|
| 105 |
+
if brief and not brief.endswith("."):
|
| 106 |
+
brief += "."
|
| 107 |
+
if len(brief) > 150:
|
| 108 |
+
brief = brief[:150] + "..."
|
| 109 |
+
if brief:
|
| 110 |
+
qa_pairs.append(f" A: {brief}")
|
| 111 |
+
|
| 112 |
+
if not qa_pairs:
|
| 113 |
+
return history
|
| 114 |
+
|
| 115 |
+
summary_lines = ["[์ด์ ๋ํ ์์ฝ]"]
|
| 116 |
+
if companies_mentioned:
|
| 117 |
+
summary_lines.append(f"๊ด์ฌ ๊ธฐ์
: {', '.join(sorted(companies_mentioned))}")
|
| 118 |
+
if topics_discussed:
|
| 119 |
+
unique_topics = list(dict.fromkeys(topics_discussed))[:5]
|
| 120 |
+
summary_lines.append(f"๋ถ์ ์ฃผ์ : {', '.join(unique_topics)}")
|
| 121 |
+
summary_lines.append("")
|
| 122 |
+
summary_lines.extend(qa_pairs[-8:])
|
| 123 |
+
|
| 124 |
+
summary_text = "\n".join(summary_lines)
|
| 125 |
+
summary_msg = HistoryItem(role="assistant", text=summary_text)
|
| 126 |
+
return [summary_msg, *recent_messages]
|
src/dartlab/ai/conversation/intent.py
ADDED
|
@@ -0,0 +1,291 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""์๋ ๋ถ๋ฅ โ ๋ถ์/๋ฉํ/์์๋ํ ํ๋ณ.
|
| 2 |
+
|
| 3 |
+
server/resolve.py์์ ์ถ์ถํ ์์ ๋ฌธ์์ด ๋งค์นญ ๋ก์ง.
|
| 4 |
+
์๋ฒ ์์กด์ฑ ์์.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import re as _re
|
| 10 |
+
|
| 11 |
+
_META_KEYWORDS = frozenset(
|
| 12 |
+
{
|
| 13 |
+
"๋ฒ์ ",
|
| 14 |
+
"version",
|
| 15 |
+
"๋์๋ง",
|
| 16 |
+
"๋์",
|
| 17 |
+
"help",
|
| 18 |
+
"์ฌ์ฉ๋ฒ",
|
| 19 |
+
"์ฌ์ฉ๋ฐฉ๋ฒ",
|
| 20 |
+
"๋ญํ ์์",
|
| 21 |
+
"๋ญํ ์์",
|
| 22 |
+
"๋ญ ํ ์",
|
| 23 |
+
"๋ญ ํ ์",
|
| 24 |
+
"ํ ์์",
|
| 25 |
+
"๊ธฐ๋ฅ",
|
| 26 |
+
"๋ฐ์ดํฐ",
|
| 27 |
+
"๋ช๊ฐ",
|
| 28 |
+
"๋ช ๊ฐ",
|
| 29 |
+
"๊ฐ์",
|
| 30 |
+
"๋ชฉ๋ก",
|
| 31 |
+
"๋ฆฌ์คํธ",
|
| 32 |
+
"์ํ",
|
| 33 |
+
"์๋ณธ",
|
| 34 |
+
"raw",
|
| 35 |
+
"๋ชจ๋",
|
| 36 |
+
"module",
|
| 37 |
+
"๋ค์ด๋ก๋",
|
| 38 |
+
"์ค์น",
|
| 39 |
+
"์
๋ฐ์ดํธ",
|
| 40 |
+
"์๋
",
|
| 41 |
+
"๋ฐ๊ฐ",
|
| 42 |
+
"๊ณ ๋ง",
|
| 43 |
+
"์๋
ํ์ธ์",
|
| 44 |
+
"hello",
|
| 45 |
+
"hi",
|
| 46 |
+
"thanks",
|
| 47 |
+
"์ด๋ป๊ฒ",
|
| 48 |
+
"how",
|
| 49 |
+
"what",
|
| 50 |
+
"why",
|
| 51 |
+
"์ค์ ",
|
| 52 |
+
"config",
|
| 53 |
+
"provider",
|
| 54 |
+
"๋ชจ๋ธ",
|
| 55 |
+
"ollama",
|
| 56 |
+
"๋ฌธ์",
|
| 57 |
+
"docs",
|
| 58 |
+
"ํ์ผ",
|
| 59 |
+
"์ ์ฅ",
|
| 60 |
+
"opendart",
|
| 61 |
+
"openedgar",
|
| 62 |
+
"openapi",
|
| 63 |
+
"api",
|
| 64 |
+
"dart api",
|
| 65 |
+
"edgar api",
|
| 66 |
+
"์์ง",
|
| 67 |
+
"engine",
|
| 68 |
+
"spec",
|
| 69 |
+
"์คํ",
|
| 70 |
+
"tool",
|
| 71 |
+
"๋๊ตฌ",
|
| 72 |
+
"๋ฐํ์",
|
| 73 |
+
"runtime",
|
| 74 |
+
"codex",
|
| 75 |
+
"gpt",
|
| 76 |
+
"claude",
|
| 77 |
+
"mcp",
|
| 78 |
+
"์๋ฒ",
|
| 79 |
+
"server",
|
| 80 |
+
"์ข
๋ชฉ๊ฒ์",
|
| 81 |
+
"search",
|
| 82 |
+
}
|
| 83 |
+
)
|
| 84 |
+
|
| 85 |
+
_ANALYSIS_KEYWORDS = frozenset(
|
| 86 |
+
{
|
| 87 |
+
"๋ถ์",
|
| 88 |
+
"๊ฑด์ ์ฑ",
|
| 89 |
+
"์์ต์ฑ",
|
| 90 |
+
"์ฑ์ฅ์ฑ",
|
| 91 |
+
"๋ฐฐ๋น",
|
| 92 |
+
"์ค์ ",
|
| 93 |
+
"์ฌ๋ฌด",
|
| 94 |
+
"๋งค์ถ",
|
| 95 |
+
"์์
์ด์ต",
|
| 96 |
+
"์์ด์ต",
|
| 97 |
+
"๋ถ์ฑ",
|
| 98 |
+
"์์ฐ",
|
| 99 |
+
"ํ๊ธํ๋ฆ",
|
| 100 |
+
"ROE",
|
| 101 |
+
"ROA",
|
| 102 |
+
"PER",
|
| 103 |
+
"PBR",
|
| 104 |
+
"EPS",
|
| 105 |
+
"EBITDA",
|
| 106 |
+
"FCF",
|
| 107 |
+
"๋ฆฌ์คํฌ",
|
| 108 |
+
"์ํ",
|
| 109 |
+
"๊ฐ์ฌ",
|
| 110 |
+
"์ง๋ฐฐ๊ตฌ์กฐ",
|
| 111 |
+
"์์",
|
| 112 |
+
"์ฃผ์ฃผ",
|
| 113 |
+
"๋น๊ต",
|
| 114 |
+
"์ถ์ธ",
|
| 115 |
+
"์ถ์ด",
|
| 116 |
+
"ํธ๋ ๋",
|
| 117 |
+
"์ ๋ง",
|
| 118 |
+
"์ด๋",
|
| 119 |
+
"์ด๋ค๊ฐ",
|
| 120 |
+
"๊ด์ฐฎ",
|
| 121 |
+
"์ข์๊ฐ",
|
| 122 |
+
"๋ถ์ํด",
|
| 123 |
+
"์๋ ค์ค",
|
| 124 |
+
"์๋ ค ์ค",
|
| 125 |
+
"๋ณด์ฌ์ค",
|
| 126 |
+
"๋ณด์ฌ ์ค",
|
| 127 |
+
"ํด์ค",
|
| 128 |
+
"ํด ์ค",
|
| 129 |
+
"ํ๊ฐ",
|
| 130 |
+
}
|
| 131 |
+
)
|
| 132 |
+
|
| 133 |
+
_SYSTEM_ENTITIES = frozenset(
|
| 134 |
+
{
|
| 135 |
+
"opendart",
|
| 136 |
+
"openedgar",
|
| 137 |
+
"dartlab",
|
| 138 |
+
"dart api",
|
| 139 |
+
"edgar api",
|
| 140 |
+
"openapi",
|
| 141 |
+
"dart ์์คํ
",
|
| 142 |
+
"edgar ์์คํ
",
|
| 143 |
+
"mcp",
|
| 144 |
+
"codex",
|
| 145 |
+
"claude",
|
| 146 |
+
"gpt",
|
| 147 |
+
"ollama",
|
| 148 |
+
}
|
| 149 |
+
)
|
| 150 |
+
|
| 151 |
+
_GREETING_ONLY_PATTERNS = frozenset(
|
| 152 |
+
{
|
| 153 |
+
"์๋
",
|
| 154 |
+
"์๋
ํ์ธ์",
|
| 155 |
+
"๋ฐ๊ฐ",
|
| 156 |
+
"๋ฐ๊ฐ์ต๋๋ค",
|
| 157 |
+
"๊ณ ๋ง",
|
| 158 |
+
"๊ณ ๋ง์ต๋๋ค",
|
| 159 |
+
"๊ฐ์ฌํฉ๋๋ค",
|
| 160 |
+
"๊ฐ์ฌํด์",
|
| 161 |
+
"hello",
|
| 162 |
+
"hi",
|
| 163 |
+
"thanks",
|
| 164 |
+
"thank you",
|
| 165 |
+
}
|
| 166 |
+
)
|
| 167 |
+
|
| 168 |
+
_ANALYSIS_CONTEXT_OVERRIDES = {
|
| 169 |
+
"๊ฐ์ฌ": ["๊ฐ์ฌ์๊ฒฌ", "๊ฐ์ฌ๋ณด๊ณ ์", "๊ฐ์ฌ์ธ", "๊ฐ์ฌ์์", "๋ด๋ถ๊ฐ์ฌ", "์ธ๋ถ๊ฐ์ฌ"],
|
| 170 |
+
"๋น๊ต": ["๋น๊ตํด", "๋น๊ต๋ถ์", "๋น๊ตํ"],
|
| 171 |
+
}
|
| 172 |
+
|
| 173 |
+
_TENTATIVE_PATTERNS = (
|
| 174 |
+
"์ถ์๋ฐ",
|
| 175 |
+
"์ถ์ด",
|
| 176 |
+
"ํ ๊น",
|
| 177 |
+
"ํ ์ ์",
|
| 178 |
+
"๊ฐ๋ฅ",
|
| 179 |
+
"๋ญ๊ฐ ์",
|
| 180 |
+
"์ด๋ค ๊ฒ",
|
| 181 |
+
"์ด๋ค๊ฒ",
|
| 182 |
+
"์ด๋ค ๊ฒ",
|
| 183 |
+
"๊ถ๊ธ",
|
| 184 |
+
"๋ญ ๋ณผ",
|
| 185 |
+
"๋ญ ๋ด",
|
| 186 |
+
"๋ฌด์์",
|
| 187 |
+
)
|
| 188 |
+
|
| 189 |
+
_PURE_CONVERSATION_TOKENS = frozenset(
|
| 190 |
+
{
|
| 191 |
+
"์",
|
| 192 |
+
"ใ
ใ
",
|
| 193 |
+
"ใ
",
|
| 194 |
+
"๊ทธ๋",
|
| 195 |
+
"๋ต",
|
| 196 |
+
"๋ค",
|
| 197 |
+
"๋ญํด",
|
| 198 |
+
"ใ
ใ
",
|
| 199 |
+
"ใ
ใ
",
|
| 200 |
+
"์ข์",
|
| 201 |
+
"์คํค",
|
| 202 |
+
"ok",
|
| 203 |
+
"yes",
|
| 204 |
+
"no",
|
| 205 |
+
"yeah",
|
| 206 |
+
"์๊ฒ ์ด",
|
| 207 |
+
"๊ทธ๋ ๊ตฌ๋",
|
| 208 |
+
"์ํ",
|
| 209 |
+
"์ค",
|
| 210 |
+
"์",
|
| 211 |
+
"ใ
ใ
",
|
| 212 |
+
"ใ
ใ
",
|
| 213 |
+
"ใดใด",
|
| 214 |
+
"์๋",
|
| 215 |
+
"๋์ด",
|
| 216 |
+
}
|
| 217 |
+
)
|
| 218 |
+
|
| 219 |
+
_PURE_CONVERSATION_RE = _re.compile(
|
| 220 |
+
r"๋ํ.*๊ณ์|๊ณ์.*๋ํ|๋ํ.*์.*๋|์ด์ด์.*์๊ธฐ|์ก๋ด|๊ทธ๋ฅ.*์๊ธฐ"
|
| 221 |
+
r"|์๊ธฐ.*ํ์|๋ง.*๊ฑธ์ด|์ฑํ
|์๊น.*๋ง|๋ค๋ฅธ.*์๊ธฐ",
|
| 222 |
+
)
|
| 223 |
+
|
| 224 |
+
|
| 225 |
+
def is_meta_question(question: str) -> bool:
|
| 226 |
+
"""๋ผ์ด๋ธ๋ฌ๋ฆฌ/์์คํ
์ ๋ํ ๋ฉํ ์ง๋ฌธ์ธ์ง ํ๋ณ."""
|
| 227 |
+
q = question.lower().replace(" ", "")
|
| 228 |
+
q_raw = question.lower()
|
| 229 |
+
|
| 230 |
+
for entity in _SYSTEM_ENTITIES:
|
| 231 |
+
if entity.replace(" ", "") in q:
|
| 232 |
+
return True
|
| 233 |
+
|
| 234 |
+
q_stripped = question.strip().rstrip("!?.~")
|
| 235 |
+
if q_stripped in _GREETING_ONLY_PATTERNS or q_stripped.lower() in _GREETING_ONLY_PATTERNS:
|
| 236 |
+
return True
|
| 237 |
+
|
| 238 |
+
for ambiguous, analysis_contexts in _ANALYSIS_CONTEXT_OVERRIDES.items():
|
| 239 |
+
if ambiguous in q_raw:
|
| 240 |
+
if any(ctx in q_raw for ctx in analysis_contexts):
|
| 241 |
+
return False
|
| 242 |
+
|
| 243 |
+
for kw in _META_KEYWORDS:
|
| 244 |
+
if kw.replace(" ", "") in q:
|
| 245 |
+
return True
|
| 246 |
+
return False
|
| 247 |
+
|
| 248 |
+
|
| 249 |
+
def has_analysis_intent(question: str) -> bool:
|
| 250 |
+
"""๋ถ์ ์๋๊ฐ ์๋ ์ง๋ฌธ์ธ์ง ํ๋ณ."""
|
| 251 |
+
q_lower = question.lower().replace(" ", "")
|
| 252 |
+
for entity in _SYSTEM_ENTITIES:
|
| 253 |
+
if entity.replace(" ", "") in q_lower:
|
| 254 |
+
return False
|
| 255 |
+
|
| 256 |
+
q_stripped = question.strip().rstrip("!?.~")
|
| 257 |
+
if q_stripped in _GREETING_ONLY_PATTERNS or q_stripped.lower() in _GREETING_ONLY_PATTERNS:
|
| 258 |
+
return False
|
| 259 |
+
|
| 260 |
+
has_kw = False
|
| 261 |
+
for kw in _ANALYSIS_KEYWORDS:
|
| 262 |
+
if kw in question:
|
| 263 |
+
if kw == "๊ฐ์ฌ":
|
| 264 |
+
analysis_contexts = _ANALYSIS_CONTEXT_OVERRIDES.get("๊ฐ์ฌ", [])
|
| 265 |
+
if not any(ctx in question for ctx in analysis_contexts):
|
| 266 |
+
continue
|
| 267 |
+
has_kw = True
|
| 268 |
+
break
|
| 269 |
+
if not has_kw:
|
| 270 |
+
return False
|
| 271 |
+
for pat in _TENTATIVE_PATTERNS:
|
| 272 |
+
if pat in question:
|
| 273 |
+
return False
|
| 274 |
+
return True
|
| 275 |
+
|
| 276 |
+
|
| 277 |
+
def is_pure_conversation(question: str) -> bool:
|
| 278 |
+
"""์์ ๋ํ ํจํด์ธ์ง ํ๋ณ."""
|
| 279 |
+
q = question.strip()
|
| 280 |
+
q_low = q.lower()
|
| 281 |
+
|
| 282 |
+
if q_low in _PURE_CONVERSATION_TOKENS:
|
| 283 |
+
return True
|
| 284 |
+
if _PURE_CONVERSATION_RE.search(q_low):
|
| 285 |
+
return True
|
| 286 |
+
if len(q) <= 6:
|
| 287 |
+
for kw in _ANALYSIS_KEYWORDS:
|
| 288 |
+
if kw in q:
|
| 289 |
+
return False
|
| 290 |
+
return True
|
| 291 |
+
return False
|
src/dartlab/ai/conversation/prompts.py
ADDED
|
@@ -0,0 +1,565 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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ฆฝ, ์ง๋ฌธ ๋ถ๋ฅ, ์๋ต ํ์ฑ)๋ง ๋ด๋นํ๋ค.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
import re as _re
|
| 10 |
+
from typing import Any
|
| 11 |
+
|
| 12 |
+
from .templates.analysis_rules import (
|
| 13 |
+
CROSS_VALIDATION_COMPACT as _CROSS_VALIDATION_COMPACT,
|
| 14 |
+
)
|
| 15 |
+
from .templates.analysis_rules import (
|
| 16 |
+
CROSS_VALIDATION_RULES as _CROSS_VALIDATION_RULES,
|
| 17 |
+
)
|
| 18 |
+
from .templates.analysis_rules import (
|
| 19 |
+
FEW_SHOT_COMPACT as _FEW_SHOT_COMPACT,
|
| 20 |
+
)
|
| 21 |
+
from .templates.analysis_rules import (
|
| 22 |
+
FEW_SHOT_EXAMPLES as _FEW_SHOT_EXAMPLES,
|
| 23 |
+
)
|
| 24 |
+
from .templates.analysis_rules import (
|
| 25 |
+
QUESTION_TYPE_MAP as _QUESTION_TYPE_MAP,
|
| 26 |
+
)
|
| 27 |
+
from .templates.analysis_rules import (
|
| 28 |
+
REPORT_PROMPT as _REPORT_PROMPT,
|
| 29 |
+
)
|
| 30 |
+
from .templates.analysis_rules import (
|
| 31 |
+
REPORT_PROMPT_COMPACT as _REPORT_PROMPT_COMPACT,
|
| 32 |
+
)
|
| 33 |
+
from .templates.analysis_rules import (
|
| 34 |
+
TOPIC_COMPACT as _TOPIC_COMPACT,
|
| 35 |
+
)
|
| 36 |
+
from .templates.analysis_rules import (
|
| 37 |
+
TOPIC_PROMPTS as _TOPIC_PROMPTS,
|
| 38 |
+
)
|
| 39 |
+
from .templates.benchmarks import _INDUSTRY_BENCHMARKS, _SECTOR_MAP
|
| 40 |
+
from .templates.self_critique import (
|
| 41 |
+
SELF_CRITIQUE_PROMPT,
|
| 42 |
+
)
|
| 43 |
+
from .templates.self_critique import (
|
| 44 |
+
SIGNAL_KEYWORDS as _SIGNAL_KEYWORDS,
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
# โโ ํ
ํ๋ฆฟ ๋ฐ์ดํฐ ์ํฌํธ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 48 |
+
from .templates.system_base import (
|
| 49 |
+
EDGAR_SUPPLEMENT_EN,
|
| 50 |
+
EDGAR_SUPPLEMENT_KR,
|
| 51 |
+
SYSTEM_PROMPT_COMPACT,
|
| 52 |
+
SYSTEM_PROMPT_EN,
|
| 53 |
+
SYSTEM_PROMPT_KR,
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
# โโ ํ๋ฌ๊ทธ์ธ ์์คํ
ํ๋กฌํํธ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 57 |
+
|
| 58 |
+
_PLUGIN_SYSTEM_PROMPT = """
|
| 59 |
+
## ํ๋ฌ๊ทธ์ธ ํ์ฅ ์์คํ
|
| 60 |
+
- dartlab์ ํ๋ฌ๊ทธ์ธ์ผ๋ก ํ์ฅ ๊ฐ๋ฅํฉ๋๋ค. `uv pip install dartlab-plugin-xxx` ํ ์ค๋ก ์ ๋ฐ์ดํฐ/๋๊ตฌ/๋ถ์์ ์ถ๊ฐํ ์ ์์ต๋๋ค.
|
| 61 |
+
- ์ฌ์ฉ์๊ฐ "ํ๋ฌ๊ทธ์ธ ๋ง๋ค์ด์ค", "์ปค์คํ
๋ถ์ ๋ง๋ค๊ธฐ", "ESG ํ๋ฌ๊ทธ์ธ" ๊ฐ์ ์์ฒญ์ ํ๋ฉด `create_plugin` ๋๊ตฌ๋ฅผ ์ฌ์ฉํ์ธ์.
|
| 62 |
+
- `create_plugin`์ ์ฆ์ ์ฌ์ฉ ๊ฐ๋ฅํ ์์ ํ ํจํค์ง ๊ตฌ์กฐ(pyproject.toml + register ํจ์ + ๋ก์ง ํ์ผ)๋ฅผ ์๋ ์์ฑํฉ๋๋ค.
|
| 63 |
+
- ๋ถ์ ์ค ํ๋ฌ๊ทธ์ธ ์ถ์ฒ ํํธ๊ฐ ์ ๊ณต๋๋ฉด, ๋ต๋ณ ๋์ ์์ฐ์ค๋ฝ๊ฒ ์๋ดํ์ธ์.
|
| 64 |
+
"""
|
| 65 |
+
|
| 66 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 67 |
+
# ์ง๋ฌธ ๋ถ๋ฅ
|
| 68 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
def _classify_question(question: str) -> str | None:
|
| 72 |
+
"""์ง๋ฌธ ํ
์คํธ๋ฅผ ๋ถ์ ์ ํ์ผ๋ก ๋ถ๋ฅ.
|
| 73 |
+
|
| 74 |
+
Returns:
|
| 75 |
+
"๊ฑด์ ์ฑ", "์์ต์ฑ", "์ฑ์ฅ์ฑ", "๋ฐฐ๋น", "์ง๋ฐฐ๊ตฌ์กฐ", "๋ฆฌ์คํฌ", "์ข
ํฉ" ๋๋ None
|
| 76 |
+
"""
|
| 77 |
+
scores: dict[str, int] = {}
|
| 78 |
+
for q_type, keywords in _QUESTION_TYPE_MAP.items():
|
| 79 |
+
score = sum(1 for kw in keywords if kw in question)
|
| 80 |
+
if score > 0:
|
| 81 |
+
scores[q_type] = score
|
| 82 |
+
|
| 83 |
+
if not scores:
|
| 84 |
+
return None
|
| 85 |
+
|
| 86 |
+
return max(scores, key=scores.get)
|
| 87 |
+
|
| 88 |
+
|
| 89 |
+
def _classify_question_multi(question: str, max_types: int = 3) -> list[str]:
|
| 90 |
+
"""๋ณตํฉ ์ง๋ฌธ์์ ์ฌ๋ฌ ๋ถ์ ์ ํ์ ๊ฐ์ง.
|
| 91 |
+
|
| 92 |
+
Returns:
|
| 93 |
+
๋งค์นญ๋ ์ ํ ๋ฆฌ์คํธ (์ ์ ๋์ ์, ์ต๋ max_types๊ฐ)
|
| 94 |
+
"""
|
| 95 |
+
scores: dict[str, int] = {}
|
| 96 |
+
for q_type, keywords in _QUESTION_TYPE_MAP.items():
|
| 97 |
+
score = sum(1 for kw in keywords if kw in question)
|
| 98 |
+
if score > 0:
|
| 99 |
+
scores[q_type] = score
|
| 100 |
+
|
| 101 |
+
if not scores:
|
| 102 |
+
return []
|
| 103 |
+
|
| 104 |
+
sorted_types = sorted(scores, key=scores.get, reverse=True)
|
| 105 |
+
return sorted_types[:max_types]
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def _match_sector(sector_name: str) -> str | None:
|
| 109 |
+
"""KRX ์
์ข
๋ช
์์ ๋ฒค์น๋งํฌ ํค ๋งค์นญ."""
|
| 110 |
+
if not sector_name:
|
| 111 |
+
return None
|
| 112 |
+
|
| 113 |
+
# ์ ํ ๋งค์นญ
|
| 114 |
+
if sector_name in _SECTOR_MAP:
|
| 115 |
+
return _SECTOR_MAP[sector_name]
|
| 116 |
+
|
| 117 |
+
# ํค์๋ ๋ถ๋ถ ๋งค์นญ
|
| 118 |
+
for keyword, benchmark_key in _SECTOR_MAP.items():
|
| 119 |
+
if keyword in sector_name:
|
| 120 |
+
return benchmark_key
|
| 121 |
+
|
| 122 |
+
return None
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 126 |
+
# ์์คํ
ํ๋กฌํํธ ์กฐ๋ฆฝ
|
| 127 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 128 |
+
|
| 129 |
+
|
| 130 |
+
def build_system_prompt(
|
| 131 |
+
custom: str | None = None,
|
| 132 |
+
lang: str = "ko",
|
| 133 |
+
included_modules: list[str] | None = None,
|
| 134 |
+
sector: str | None = None,
|
| 135 |
+
question_type: str | None = None,
|
| 136 |
+
question_types: list[str] | None = None,
|
| 137 |
+
compact: bool = False,
|
| 138 |
+
report_mode: bool = False,
|
| 139 |
+
market: str = "KR",
|
| 140 |
+
allow_tools: bool = True,
|
| 141 |
+
) -> str:
|
| 142 |
+
"""์์คํ
ํ๋กฌํํธ ์กฐ๋ฆฝ (๋จ์ผ ๋ฌธ์์ด ๋ฐํ).
|
| 143 |
+
|
| 144 |
+
Args:
|
| 145 |
+
custom: ์ฌ์ฉ์ ์ง์ ํ๋กฌํํธ (์์ผ๋ฉด ์ด๊ฒ๋ง ๏ฟฝ๏ฟฝ์ฉ)
|
| 146 |
+
lang: "ko" ๋๋ "en"
|
| 147 |
+
included_modules: ์ปจํ
์คํธ์ ํฌํจ๋ ๋ชจ๋ ๋ชฉ๋ก โ ํ ํฝ ํ๋กฌํํธ ๋์ ์ถ๊ฐ
|
| 148 |
+
sector: KRX ์
์ข
๋ช
โ ์
์ข
๋ณ ๋ฒค์น๋งํฌ ์ถ๊ฐ
|
| 149 |
+
question_type: ๋จ์ผ ์ง๋ฌธ ์ ํ โ Few-shot ์์ ์ถ๊ฐ (ํ์ํธํ)
|
| 150 |
+
question_types: ๋ณต์ ์ง๋ฌธ ์ ํ โ question_type๋ณด๋ค ์ฐ์
|
| 151 |
+
compact: True๋ฉด ์ํ ๋ชจ๋ธ์ฉ ๊ฐ๊ฒฐ ํ๋กฌํํธ (Ollama)
|
| 152 |
+
report_mode: True๋ฉด ์ ๋ฌธ ๋ถ์๋ณด๊ณ ์ ๊ตฌ์กฐ ํ๋กฌํํธ ์ถ๊ฐ
|
| 153 |
+
market: "KR" ๋๋ "US" โ EDGAR ๊ธฐ์
์ด๋ฉด US ๋ณด์ถฉ ํ๋กฌํํธ ์ถ๊ฐ
|
| 154 |
+
"""
|
| 155 |
+
static, dynamic = build_system_prompt_parts(
|
| 156 |
+
custom=custom,
|
| 157 |
+
lang=lang,
|
| 158 |
+
included_modules=included_modules,
|
| 159 |
+
sector=sector,
|
| 160 |
+
question_type=question_type,
|
| 161 |
+
question_types=question_types,
|
| 162 |
+
compact=compact,
|
| 163 |
+
report_mode=report_mode,
|
| 164 |
+
market=market,
|
| 165 |
+
allow_tools=allow_tools,
|
| 166 |
+
)
|
| 167 |
+
if dynamic:
|
| 168 |
+
return static + "\n" + dynamic
|
| 169 |
+
return static
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
def build_system_prompt_parts(
|
| 173 |
+
custom: str | None = None,
|
| 174 |
+
lang: str = "ko",
|
| 175 |
+
included_modules: list[str] | None = None,
|
| 176 |
+
sector: str | None = None,
|
| 177 |
+
question_type: str | None = None,
|
| 178 |
+
question_types: list[str] | None = None,
|
| 179 |
+
compact: bool = False,
|
| 180 |
+
report_mode: bool = False,
|
| 181 |
+
market: str = "KR",
|
| 182 |
+
allow_tools: bool = True,
|
| 183 |
+
) -> tuple[str, str]:
|
| 184 |
+
"""์์คํ
ํ๋กฌํํธ๋ฅผ (์ ์ , ๋์ ) 2ํํธ๋ก ๋ถ๋ฆฌ ๋ฐํ.
|
| 185 |
+
|
| 186 |
+
์ ์ ๋ถ๋ถ: base + ๋ฒค์น๋งํฌ + ํ ํฝ + ๊ต์ฐจ๊ฒ์ฆ + Few-shot (์บ์ ๋์)
|
| 187 |
+
๋์ ๋ถ๋ถ: report_mode + ํ๋ฌ๊ทธ์ธ (๋งค ์์ฒญ ๋ณ๊ฒฝ ๊ฐ๋ฅ)
|
| 188 |
+
|
| 189 |
+
Claude prompt caching์ cache_control breakpoint๋ฅผ ์ ์ฉํ ๋
|
| 190 |
+
์ ์ ๋ถ๋ถ ๋์ ๋ง์ปค๋ฅผ ์ฝ์
ํ๋ฉด ์บ์ ํํธ์จ์ด ๊ทน๋ํ๋๋ค.
|
| 191 |
+
"""
|
| 192 |
+
if custom:
|
| 193 |
+
return custom, ""
|
| 194 |
+
|
| 195 |
+
q_types = question_types or ([question_type] if question_type else [])
|
| 196 |
+
|
| 197 |
+
def _strip_tool_guidance(text: str) -> str:
|
| 198 |
+
stripped = text
|
| 199 |
+
if "## ๊ณต์ ๋ฐ์ดํฐ ์ ๊ทผ๋ฒ (๋๊ตฌ ์ฌ์ฉ)" in stripped:
|
| 200 |
+
stripped = _re.sub(
|
| 201 |
+
r"\n## ๊ณต์ ๋ฐ์ดํฐ ์ ๊ทผ๋ฒ \(๋๊ตฌ ์ฌ์ฉ\).*?(?=\n## ๋ฐธ๋ฅ์์ด์
๋ถ์ ํ๋ ์์ํฌ|\Z)",
|
| 202 |
+
"\n",
|
| 203 |
+
stripped,
|
| 204 |
+
flags=_re.DOTALL,
|
| 205 |
+
)
|
| 206 |
+
stripped = _re.sub(
|
| 207 |
+
r"\n## ๋ถ์ ์์ ํ๋กํ ์ฝ.*?(?=\n## ๋ฐ์ดํฐ ๊ด๋ฆฌ ์์น|\Z)",
|
| 208 |
+
"\n",
|
| 209 |
+
stripped,
|
| 210 |
+
flags=_re.DOTALL,
|
| 211 |
+
)
|
| 212 |
+
if "## ๊ณต์ ๋๊ตฌ" in stripped:
|
| 213 |
+
stripped = _re.sub(
|
| 214 |
+
r"\n## ๊ณต์ ๋๊ตฌ.*?(?=\n## ์ ๋ฌธ๊ฐ ๋ถ์ ํ์|\Z)",
|
| 215 |
+
"\n",
|
| 216 |
+
stripped,
|
| 217 |
+
flags=_re.DOTALL,
|
| 218 |
+
)
|
| 219 |
+
stripped = _re.sub(
|
| 220 |
+
r"\n## ๋ถ์ ์์ ํ๋กํ ์ฝ.*?(?=\Z)",
|
| 221 |
+
"\n",
|
| 222 |
+
stripped,
|
| 223 |
+
flags=_re.DOTALL,
|
| 224 |
+
)
|
| 225 |
+
return stripped
|
| 226 |
+
|
| 227 |
+
no_tools_note = (
|
| 228 |
+
"## ํ์ฌ ์คํ ์ ์ฝ\n"
|
| 229 |
+
"- ์ด๋ฒ ๋ต๋ณ์์๋ ๋๊ตฌ ํธ์ถ์ ์ฌ์ฉํ ์ ์์ต๋๋ค.\n"
|
| 230 |
+
"- `explore()`, `finance()`, `analyze()` ๊ฐ์ ๋๊ตฌ ํธ์ถ ๊ณํ์ ๋ฌธ์ฅ์ผ๋ก ์ถ๋ ฅํ์ง ๋ง์ธ์.\n"
|
| 231 |
+
"- `IS/BS/CF/ratios/TTM/costByNature/businessOverview` ๊ฐ์ ๋ด๋ถ ์ฝ์ด๋ ๋ชจ๋๋ช
์ ๊ทธ๋๋ก ์ฐ์ง ๋ง๊ณ "
|
| 232 |
+
"`์์ต๊ณ์ฐ์/์ฌ๋ฌด์ํํ/ํ๊ธํ๋ฆํ/์ฌ๋ฌด๋น์จ/์ต๊ทผ 4๋ถ๊ธฐ ํฉ์ฐ/์ฑ๊ฒฉ๋ณ ๋น์ฉ ๋ถ๋ฅ/์ฌ์
์ ๊ฐ์`์ฒ๋ผ ์ฌ์ฉ์ ์ธ์ด๋ก ๋ฐ๊พธ์ธ์.\n"
|
| 233 |
+
"- ์ด๋ฏธ ์ ๊ณต๋ ์ปจํ
์คํธ๋ง ์ฌ์ฉํด ๋ฐ๋ก ๋ต๋ณํ๊ณ , ํ์ธ ์ง๋ฌธ์ด ํ์ํ๋ฉด ํ ๋ฌธ์ฅ๋ง ํ์ธ์."
|
| 234 |
+
)
|
| 235 |
+
|
| 236 |
+
if compact:
|
| 237 |
+
base = _strip_tool_guidance(SYSTEM_PROMPT_COMPACT) if not allow_tools else SYSTEM_PROMPT_COMPACT
|
| 238 |
+
static_parts: list[str] = []
|
| 239 |
+
dynamic_parts: list[str] = []
|
| 240 |
+
|
| 241 |
+
benchmark_key = _match_sector(sector) if sector else None
|
| 242 |
+
if benchmark_key and benchmark_key in _INDUSTRY_BENCHMARKS:
|
| 243 |
+
static_parts.append(_INDUSTRY_BENCHMARKS[benchmark_key])
|
| 244 |
+
elif "์ผ๋ฐ" in _INDUSTRY_BENCHMARKS:
|
| 245 |
+
static_parts.append(_INDUSTRY_BENCHMARKS["์ผ๋ฐ"])
|
| 246 |
+
|
| 247 |
+
if included_modules:
|
| 248 |
+
module_set = set(included_modules)
|
| 249 |
+
for _tname, (trigger_modules, prompt_text) in _TOPIC_COMPACT.items():
|
| 250 |
+
if module_set & trigger_modules:
|
| 251 |
+
static_parts.append(prompt_text)
|
| 252 |
+
|
| 253 |
+
if included_modules:
|
| 254 |
+
fs_modules = {"BS", "IS", "CF"}
|
| 255 |
+
if fs_modules & set(included_modules):
|
| 256 |
+
static_parts.append(_CROSS_VALIDATION_COMPACT)
|
| 257 |
+
|
| 258 |
+
for qt in q_types[:1]:
|
| 259 |
+
if qt in _FEW_SHOT_COMPACT:
|
| 260 |
+
static_parts.append(_FEW_SHOT_COMPACT[qt])
|
| 261 |
+
|
| 262 |
+
# ๋์ : report_mode + ํ๋ฌ๊ทธ์ธ
|
| 263 |
+
if report_mode:
|
| 264 |
+
dynamic_parts.append(_REPORT_PROMPT_COMPACT)
|
| 265 |
+
|
| 266 |
+
if not allow_tools:
|
| 267 |
+
dynamic_parts.append(no_tools_note)
|
| 268 |
+
|
| 269 |
+
dynamic_parts.append(
|
| 270 |
+
"\nํ๋ฌ๊ทธ์ธ: ์ฌ์ฉ์๊ฐ 'ํ๋ฌ๊ทธ์ธ ๋ง๋ค์ด์ค'ํ๋ฉด create_plugin ๋๊ตฌ ์ฌ์ฉ. "
|
| 271 |
+
"ํ๋ฌ๊ทธ์ธ ์ถ์ฒ ํํธ๊ฐ ์์ผ๋ฉด ๋ต๋ณ ๋์ ์๋ด."
|
| 272 |
+
)
|
| 273 |
+
|
| 274 |
+
if market == "US":
|
| 275 |
+
static_parts.append(EDGAR_SUPPLEMENT_KR)
|
| 276 |
+
|
| 277 |
+
static = base + "\n".join(static_parts) if static_parts else base
|
| 278 |
+
dynamic = "\n".join(dynamic_parts)
|
| 279 |
+
return static, dynamic
|
| 280 |
+
|
| 281 |
+
if lang == "ko":
|
| 282 |
+
base = SYSTEM_PROMPT_KR
|
| 283 |
+
else:
|
| 284 |
+
base = SYSTEM_PROMPT_EN
|
| 285 |
+
if not allow_tools:
|
| 286 |
+
base = _strip_tool_guidance(base)
|
| 287 |
+
static_parts = []
|
| 288 |
+
dynamic_parts = []
|
| 289 |
+
|
| 290 |
+
# ์ ์ : ๋ฒค์น๋งํฌ + ํ ํฝ + ๊ต์ฐจ๊ฒ์ฆ + Few-shot
|
| 291 |
+
benchmark_key = _match_sector(sector) if sector else None
|
| 292 |
+
if benchmark_key and benchmark_key in _INDUSTRY_BENCHMARKS:
|
| 293 |
+
static_parts.append(_INDUSTRY_BENCHMARKS[benchmark_key])
|
| 294 |
+
elif "์ผ๋ฐ" in _INDUSTRY_BENCHMARKS:
|
| 295 |
+
static_parts.append(_INDUSTRY_BENCHMARKS["์ผ๋ฐ"])
|
| 296 |
+
|
| 297 |
+
if included_modules:
|
| 298 |
+
module_set = set(included_modules)
|
| 299 |
+
for _topic_name, (trigger_modules, prompt_text) in _TOPIC_PROMPTS.items():
|
| 300 |
+
if module_set & trigger_modules:
|
| 301 |
+
static_parts.append(prompt_text)
|
| 302 |
+
|
| 303 |
+
if included_modules:
|
| 304 |
+
fs_modules = {"BS", "IS", "CF"}
|
| 305 |
+
if fs_modules & set(included_modules):
|
| 306 |
+
static_parts.append(_CROSS_VALIDATION_RULES)
|
| 307 |
+
|
| 308 |
+
for qt in q_types[:2]:
|
| 309 |
+
if qt in _FEW_SHOT_EXAMPLES:
|
| 310 |
+
static_parts.append(_FEW_SHOT_EXAMPLES[qt])
|
| 311 |
+
|
| 312 |
+
# EDGAR(US) ๋ณด์ถฉ ํ๋กฌํํธ
|
| 313 |
+
if market == "US":
|
| 314 |
+
edgar_supp = EDGAR_SUPPLEMENT_EN if lang == "en" else EDGAR_SUPPLEMENT_KR
|
| 315 |
+
static_parts.append(edgar_supp)
|
| 316 |
+
|
| 317 |
+
# ๋์ : report_mode + ํ๋ฌ๊ทธ์ธ
|
| 318 |
+
if report_mode:
|
| 319 |
+
dynamic_parts.append(_REPORT_PROMPT)
|
| 320 |
+
|
| 321 |
+
if not allow_tools:
|
| 322 |
+
dynamic_parts.append(no_tools_note)
|
| 323 |
+
|
| 324 |
+
dynamic_parts.append(_PLUGIN_SYSTEM_PROMPT)
|
| 325 |
+
|
| 326 |
+
static = base + "\n".join(static_parts) if static_parts else base
|
| 327 |
+
dynamic = "\n".join(dynamic_parts)
|
| 328 |
+
return static, dynamic
|
| 329 |
+
|
| 330 |
+
|
| 331 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 332 |
+
# Self-Critique
|
| 333 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 334 |
+
|
| 335 |
+
|
| 336 |
+
def build_critique_messages(
|
| 337 |
+
original_response: str,
|
| 338 |
+
context_text: str,
|
| 339 |
+
question: str,
|
| 340 |
+
) -> list[dict[str, str]]:
|
| 341 |
+
"""Self-Critique์ฉ ๋ฉ์์ง ๋ฆฌ์คํธ ์์ฑ."""
|
| 342 |
+
return [
|
| 343 |
+
{"role": "system", "content": SELF_CRITIQUE_PROMPT},
|
| 344 |
+
{
|
| 345 |
+
"role": "user",
|
| 346 |
+
"content": (
|
| 347 |
+
f"## ์๋ณธ ์ง๋ฌธ\n{question}\n\n"
|
| 348 |
+
f"## ์ ๊ณต๋ ๋ฐ์ดํฐ\n{context_text[:3000]}\n\n"
|
| 349 |
+
f"## ๊ฒํ ๋์ ์๋ต\n{original_response}"
|
| 350 |
+
),
|
| 351 |
+
},
|
| 352 |
+
]
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
def parse_critique_result(critique_text: str) -> tuple[bool, str]:
|
| 356 |
+
"""Self-Critique ๊ฒฐ๊ณผ ํ์ฑ.
|
| 357 |
+
|
| 358 |
+
Returns:
|
| 359 |
+
(passed, revised_or_original)
|
| 360 |
+
- passed=True์ด๋ฉด ์๋ณธ ๊ทธ๋๋ก ์ฌ์ฉ
|
| 361 |
+
- passed=False์ด๋ฉด ์์ ๋ ์๋ต ๋ฐํ
|
| 362 |
+
"""
|
| 363 |
+
stripped = critique_text.strip()
|
| 364 |
+
if stripped.upper().startswith("PASS"):
|
| 365 |
+
return True, ""
|
| 366 |
+
|
| 367 |
+
if "REVISED:" in stripped:
|
| 368 |
+
idx = stripped.index("REVISED:")
|
| 369 |
+
revised = stripped[idx + len("REVISED:") :].strip()
|
| 370 |
+
if revised:
|
| 371 |
+
return False, revised
|
| 372 |
+
|
| 373 |
+
return True, ""
|
| 374 |
+
|
| 375 |
+
|
| 376 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 377 |
+
# Structured Output โ ์๋ต ๋ฉํ๋ฐ์ดํฐ ์ถ์ถ
|
| 378 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 379 |
+
|
| 380 |
+
_GRADE_PATTERN = _re.compile(
|
| 381 |
+
r"(?:์ข
ํฉ|๊ฒฐ๋ก |ํ๋จ|๋ฑ๊ธ|ํ๊ฐ)[:\s]*[*]*([A-F][+-]?|์ํธ|๋ณดํต|์ฃผ์|์ํ|์ฐ์|๋งค์ฐ ์ฐ์|์ทจ์ฝ)[*]*",
|
| 382 |
+
_re.IGNORECASE,
|
| 383 |
+
)
|
| 384 |
+
|
| 385 |
+
|
| 386 |
+
def extract_response_meta(response_text: str) -> dict[str, Any]:
|
| 387 |
+
"""LLM ์๋ต์์ ๊ตฌ์กฐํ๋ ๋ฉํ๋ฐ์ดํฐ ์ถ์ถ.
|
| 388 |
+
|
| 389 |
+
Returns:
|
| 390 |
+
{
|
| 391 |
+
"grade": "์ํธ" | "์ฃผ์" | "์ํ" | "A" | None,
|
| 392 |
+
"signals": {"positive": [...], "negative": [...]},
|
| 393 |
+
"tables_count": int,
|
| 394 |
+
"has_conclusion": bool,
|
| 395 |
+
}
|
| 396 |
+
"""
|
| 397 |
+
meta: dict[str, Any] = {
|
| 398 |
+
"grade": None,
|
| 399 |
+
"signals": {"positive": [], "negative": []},
|
| 400 |
+
"tables_count": 0,
|
| 401 |
+
"has_conclusion": False,
|
| 402 |
+
}
|
| 403 |
+
|
| 404 |
+
grade_match = _GRADE_PATTERN.search(response_text)
|
| 405 |
+
if grade_match:
|
| 406 |
+
meta["grade"] = grade_match.group(1).strip("*")
|
| 407 |
+
|
| 408 |
+
for direction, keywords in _SIGNAL_KEYWORDS.items():
|
| 409 |
+
for kw in keywords:
|
| 410 |
+
if kw in response_text:
|
| 411 |
+
meta["signals"][direction].append(kw)
|
| 412 |
+
|
| 413 |
+
meta["tables_count"] = len(_re.findall(r"\|-{2,}", response_text)) // 2
|
| 414 |
+
|
| 415 |
+
conclusion_keywords = ["๊ฒฐ๋ก ", "์ข
ํฉ ํ๊ฐ", "์ข
ํฉ ํ๋จ", "์ข
ํฉ:", "Conclusion"]
|
| 416 |
+
meta["has_conclusion"] = any(kw in response_text for kw in conclusion_keywords)
|
| 417 |
+
|
| 418 |
+
return meta
|
| 419 |
+
|
| 420 |
+
|
| 421 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 422 |
+
# Guided Generation โ JSON โ ๋งํฌ๋ค์ด ๋ณํ
|
| 423 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 424 |
+
|
| 425 |
+
|
| 426 |
+
def guided_json_to_markdown(data: dict[str, Any]) -> str:
|
| 427 |
+
"""Guided Generation JSON ์๋ต์ ๋งํฌ๋ค์ด์ผ๋ก ๋ณํ."""
|
| 428 |
+
parts: list[str] = []
|
| 429 |
+
|
| 430 |
+
grade = data.get("grade", "")
|
| 431 |
+
summary = data.get("summary", "")
|
| 432 |
+
if summary:
|
| 433 |
+
parts.append(f"**{summary}**")
|
| 434 |
+
parts.append("")
|
| 435 |
+
|
| 436 |
+
metrics = data.get("metrics", [])
|
| 437 |
+
if metrics:
|
| 438 |
+
parts.append("## ํต์ฌ ์งํ")
|
| 439 |
+
parts.append("| ์งํ | ๊ฐ | ์ฐ๋ | ์ถ์ธ | ํ๋จ |")
|
| 440 |
+
parts.append("|------|-----|------|------|------|")
|
| 441 |
+
for m in metrics:
|
| 442 |
+
name = m.get("name", "-")
|
| 443 |
+
value = m.get("value", "-")
|
| 444 |
+
year = m.get("year", "-")
|
| 445 |
+
trend = m.get("trend", "-")
|
| 446 |
+
assessment = m.get("assessment", "-")
|
| 447 |
+
parts.append(f"| {name} | **{value}** | {year} | {trend} | {assessment} |")
|
| 448 |
+
parts.append("")
|
| 449 |
+
|
| 450 |
+
positives = data.get("positives", [])
|
| 451 |
+
if positives:
|
| 452 |
+
parts.append("## ๊ธ์ ์ ํธ")
|
| 453 |
+
for p in positives:
|
| 454 |
+
parts.append(f"- {p}")
|
| 455 |
+
parts.append("")
|
| 456 |
+
|
| 457 |
+
risks = data.get("risks", [])
|
| 458 |
+
if risks:
|
| 459 |
+
parts.append("## ๋ฆฌ์คํฌ")
|
| 460 |
+
for r in risks:
|
| 461 |
+
desc = r.get("description", "-") if isinstance(r, dict) else str(r)
|
| 462 |
+
severity = r.get("severity", "") if isinstance(r, dict) else ""
|
| 463 |
+
severity_badge = f" [{severity}]" if severity else ""
|
| 464 |
+
parts.append(f"- โ ๏ธ {desc}{severity_badge}")
|
| 465 |
+
parts.append("")
|
| 466 |
+
|
| 467 |
+
conclusion = data.get("conclusion", "")
|
| 468 |
+
if conclusion:
|
| 469 |
+
grade_badge = f" **[{grade}]**" if grade else ""
|
| 470 |
+
parts.append(f"## ๊ฒฐ๋ก {grade_badge}")
|
| 471 |
+
parts.append(conclusion)
|
| 472 |
+
|
| 473 |
+
return "\n".join(parts)
|
| 474 |
+
|
| 475 |
+
|
| 476 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 477 |
+
# ๋์ ์ฑํ
ํ๋กฌํํธ
|
| 478 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 479 |
+
|
| 480 |
+
|
| 481 |
+
def build_dynamic_chat_prompt(state: Any = None) -> str:
|
| 482 |
+
"""์ค์๊ฐ ๋ฐ์ดํฐ ํํฉ์ ํฌํจํ ์ฑํ
์์คํ
ํ๋กฌํํธ ์์ฑ.
|
| 483 |
+
|
| 484 |
+
state๊ฐ ConversationState์ด๋ฉด dialogue_policy๋ฅผ ์๋ ํฉ๋ฅ.
|
| 485 |
+
"""
|
| 486 |
+
from dartlab.ai.tools.registry import get_coding_runtime_policy
|
| 487 |
+
|
| 488 |
+
def _count(category: str) -> int:
|
| 489 |
+
try:
|
| 490 |
+
from dartlab.core.dataLoader import _dataDir
|
| 491 |
+
|
| 492 |
+
data_dir = _dataDir(category)
|
| 493 |
+
except (FileNotFoundError, ImportError, KeyError, OSError, PermissionError, ValueError):
|
| 494 |
+
return 0
|
| 495 |
+
if not data_dir.exists():
|
| 496 |
+
return 0
|
| 497 |
+
return len(list(data_dir.glob("*.parquet")))
|
| 498 |
+
|
| 499 |
+
docs_count = _count("docs")
|
| 500 |
+
finance_count = _count("finance")
|
| 501 |
+
edgar_docs_count = _count("edgarDocs")
|
| 502 |
+
edgar_finance_count = _count("edgar")
|
| 503 |
+
coding_runtime_enabled, coding_runtime_reason = get_coding_runtime_policy()
|
| 504 |
+
coding_surface = (
|
| 505 |
+
"- ๋ก์ปฌ ์์ ์ ์ฑ
์ด ํ์ฉ๋๋ฉด coding runtime์ผ๋ก ์ค์ ์ฝ๋ ์์
์ ์์ ๊ฐ๋ฅ"
|
| 506 |
+
if coding_runtime_enabled
|
| 507 |
+
else f"- ํ์ฌ ์ธ์
์์๋ ํ
์คํธ ๊ธฐ๋ฐ ์ฝ๋ ๋ณด์กฐ๋ง ๊ฐ๋ฅํ๊ณ ์ค์ ์ฝ๋ ์์
runtime์ ๋นํ์ฑํ๋จ ({coding_runtime_reason})"
|
| 508 |
+
)
|
| 509 |
+
|
| 510 |
+
try:
|
| 511 |
+
import dartlab
|
| 512 |
+
|
| 513 |
+
version = dartlab.__version__ if hasattr(dartlab, "__version__") else "unknown"
|
| 514 |
+
except ImportError:
|
| 515 |
+
version = "unknown"
|
| 516 |
+
|
| 517 |
+
prompt = (
|
| 518 |
+
"๋น์ ์ DartLab์ ๊ธ์ต ๋ถ์ AI ์ด์์คํดํธ์
๋๋ค. "
|
| 519 |
+
"ํ๊ตญ DART ์ ์๊ณต์์ ๋ฏธ๊ตญ SEC EDGAR ๋ฐ์ดํฐ๋ฅผ ํจ๊ป ๋ค๋ฃจ๋ฉฐ, "
|
| 520 |
+
"์ฌ์ฉ์๊ฐ ์ง๊ธ ๋ฌด์์ ํ ์ ์๋์ง ๋จผ์ ์ค๋ช
ํ๊ณ ๋ค์ ํ๋๊น์ง ์ ์ํฉ๋๋ค.\n\n"
|
| 521 |
+
f"## DartLab ์ ๋ณด\n"
|
| 522 |
+
f"- **๋ฒ์ **: {version}\n"
|
| 523 |
+
f"- **Python ๋ผ์ด๋ธ๋ฌ๋ฆฌ**: `pip install dartlab` (PyPI)\n"
|
| 524 |
+
f"- **GitHub**: https://github.com/eddmpython/dartlab\n\n"
|
| 525 |
+
f"## ํ์ฌ ๋ณด์ ๋ฐ์ดํฐ (์ค์๊ฐ)\n"
|
| 526 |
+
f"- **DART docs**: {docs_count}๊ฐ ๊ธฐ์
์ ์ ๊ธฐ๋ณด๊ณ ์ ํ์ฑ ๋ฐ์ดํฐ\n"
|
| 527 |
+
f"- **DART finance**: {finance_count}๊ฐ ์์ฅ๊ธฐ์
์ XBRL ์ฌ๋ฌด์ ํ\n"
|
| 528 |
+
f"- **EDGAR docs**: {edgar_docs_count}๊ฐ ticker์ SEC ๊ณต์ ๋ฌธ์ ๋ฐ์ดํฐ\n"
|
| 529 |
+
f"- **EDGAR finance**: {edgar_finance_count}๊ฐ ticker์ companyfacts ๋ฐ์ดํฐ\n\n"
|
| 530 |
+
"## ์ฌ์ฉ ๊ฐ๋ฅํ ๊ธฐ๋ฅ\n"
|
| 531 |
+
"์ฌ์ฉ์๊ฐ ๊ธฐ๋ฅ์ด๋ ๋ฐ์ดํฐ์ ๋ํด ๋ฌผ์ผ๋ฉด ์๋๋ฅผ ์๋ดํ์ธ์:\n"
|
| 532 |
+
"- `์ผ์ฑ์ ์ ๋ถ์ํด์ค` โ ์ข
๋ชฉ๋ช
+ ์ง๋ฌธ์ผ๋ก ์ฌ๋ฌด๋ถ์\n"
|
| 533 |
+
"- `AAPL ์ด๋ค ๋ฐ์ดํฐ๊ฐ ์์ด?` โ EDGAR company ๊ธฐ์ค ์ฌ์ฉ ๊ฐ๋ฅ ๋ฐ์ดํฐ ํ์ธ\n"
|
| 534 |
+
"- `EDGAR์์ ๋ ๋ฐ์ ์ ์์ด?` โ ์ถ๊ฐ ์์ง ๊ฐ๋ฅํ ๋ฒ์์ ๊ฒฝ๋ก ์ค๋ช
\n"
|
| 535 |
+
"- `OpenDart/OpenEdgar๋ก ๋ญ๊ฐ ๋ผ?` โ ๊ณต๊ฐ API ๋ฒ์ ์ค๋ช
\n"
|
| 536 |
+
"- `AAPL filings ์๋ฌธ ๊ฐ์ ธ์์ค` / `์ผ์ฑ์ ์ ๋ฐฐ๋น OpenAPI๋ก ์กฐํํด์ค` โ ๊ณต๊ฐ API ์ง์ ํธ์ถ\n"
|
| 537 |
+
"- `GPT ์ฐ๊ฒฐํ๋ฉด ์ฝ๋ฉ๋ ๋ผ?` โ ํ์ฌ ๊ฐ๋ฅํ ์ฝ๋ฉ ๋ณด์กฐ์ ๋ฏธ์ง์ ๋ฒ์ ์ค๋ช
\n"
|
| 538 |
+
"- `๋ฐ์ดํฐ ํํฉ ์๋ ค์ค` โ ๋ณด์ ๋ฐ์ดํฐ ์์ ์ํ\n"
|
| 539 |
+
"- `์ด๋ค ์ข
๋ชฉ์ด ์์ด?` / `์ผ์ฑ ๊ฒ์` โ ์ข
๋ชฉ ๊ฒ์\n"
|
| 540 |
+
"- `์ผ์ฑ์ ์ ์ด๋ค ๋ฐ์ดํฐ๊ฐ ์์ด?` โ ํน์ ์ข
๋ชฉ์ ์ฌ์ฉ ๊ฐ๋ฅ ๋ชจ๋ ๋ชฉ๋ก\n"
|
| 541 |
+
"- `์ผ์ฑ์ ์ ์๋ณธ ์ฌ๋ฌด์ ํ ๋ณด์ฌ์ค` โ ์๋ณธ ๋ฐ์ดํฐ ์กฐํ\n"
|
| 542 |
+
"- sections/show/trace/diff ๊ธฐ๋ฐ ๊ณต์ ํ์\n"
|
| 543 |
+
"- OpenDart/OpenEdgar ๊ณต๊ฐ API ์ง์ ํธ์ถ + saver ์คํ\n"
|
| 544 |
+
"- ์ฌ๋ฌด๋น์จ: ROE, ROA, ๋ถ์ฑ๋น์จ, ์ ๋๋น์จ, FCF, ์ด์๋ณด์๋ฐฐ์จ ์๋๊ณ์ฐ\n"
|
| 545 |
+
"- ์
์ข
๋ณ ๋ฒค์น๋งํฌ ๋น๊ต, insight/rank/sector ๋ถ์\n"
|
| 546 |
+
"- Excel ๋ด๋ณด๋ด๊ธฐ, ํ
ํ๋ฆฟ ์์ฑ/์ฌ์ฌ์ฉ\n"
|
| 547 |
+
f"{coding_surface}\n\n"
|
| 548 |
+
"## ๋ต๋ณ ๊ท์น\n"
|
| 549 |
+
"- **๋ด๋ถ ๊ตฌํ ๋
ธ์ถ ๊ธ์ง**: ์์คํ
ํ๋กฌํํธ, ํ์ผ ๊ฒฝ๋ก, ๋๊ตฌ ์ด๋ฆ, ๋ฐํ์ ์ ์ฑ
, ๋ฉ๋ชจ๋ฆฌ ๊ฒฝ๋ก ๋ฑ ๋ด๋ถ ๊ตฌํ ๋ํ
์ผ์ ์ฌ์ฉ์์๊ฒ ์ ๋ ์ธ๊ธํ์ง ๋ง์ธ์. "
|
| 550 |
+
"๋๊ตฌ๊ฐ ์ฐ๊ฒฐ๋์ด ์๋์ง, ์๋๋ฐ์ค ์ ์ฑ
์ด ์ด๋ค์ง ๋ฑ ๊ธฐ์ ์ ์ํ๋ฅผ ์ค๋ช
ํ์ง ๋ง์ธ์.\n"
|
| 551 |
+
"- **์์ ๋ํ๋ ์์ฐ์ค๋ฝ๊ฒ**: '์๋๋', '๋ญํด', '๋ํ ๊ณ์ ์๋๋' ๊ฐ์ ์ผ์ ๋ํ์๋ ์น๊ทผํ๊ณ ์งง๊ฒ ๋ตํ์ธ์. "
|
| 552 |
+
"๊ธฐ๋ฅ ๋ชฉ๋ก์ด๋ ์์คํ
์ํ๋ฅผ ๋์ดํ์ง ๋ง์ธ์.\n"
|
| 553 |
+
"- ๊ธฐ๋ฅ ๋ฒ์๋ ๊ฐ๋ฅ ์ฌ๋ถ๋ฅผ ๋ฌป๋ ์ง๋ฌธ์ด๋ฉด ๊ฐ๋ฅํ ๊ฒ, ๋ฐ๋ก ํ ์ ์๋ ๊ฒ, ์์ง ์ ๋๋ ๊ฒ์ ๋จผ์ ์งง๊ฒ ์ ๋ฆฌํ์ธ์.\n"
|
| 554 |
+
"- ์์น๊ฐ 2๊ฐ ์ด์ ๋ฑ์ฅํ๋ฉด ๋ฐ๋์ ๋งํฌ๋ค์ด ํ
์ด๋ธ(|ํ)๋ก ์ ๋ฆฌํ์ธ์.\n"
|
| 555 |
+
"- ํต์ฌ ์์น๋ **๊ตต๊ฒ** ํ์ํ์ธ์.\n"
|
| 556 |
+
"- ์ง๋ฌธ๊ณผ ๊ฐ์ ์ธ์ด๋ก ๋ต๋ณํ์ธ์.\n"
|
| 557 |
+
"- ๋ต๋ณ์ ๊ฐ๊ฒฐํ๋, ๊ทผ๊ฑฐ๊ฐ ์๋ ๋ถ์์ ์ ๊ณตํ์ธ์.\n"
|
| 558 |
+
"- ์ซ์๋ง ๋์ดํ์ง ๋ง๊ณ ํด์์ ์ง์คํ์ธ์.\n"
|
| 559 |
+
"- ํน์ ์ข
๋ชฉ์ ๋ถ์ํ๋ ค๋ฉด ์ข
๋ชฉ๋ช
์ด๋ ์ข
๋ชฉ์ฝ๋๋ฅผ ์๋ ค๋ฌ๋ผ๊ณ ์๋ดํ์ธ์."
|
| 560 |
+
)
|
| 561 |
+
if state is not None:
|
| 562 |
+
from dartlab.ai.conversation.dialogue import build_dialogue_policy
|
| 563 |
+
|
| 564 |
+
prompt += "\n\n" + build_dialogue_policy(state)
|
| 565 |
+
return prompt
|
src/dartlab/ai/conversation/suggestions.py
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ํ์ฌ ์ํ์ ๋ง๋ ์ถ์ฒ ์ง๋ฌธ ์์ฑ๊ธฐ."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from typing import Any
|
| 6 |
+
|
| 7 |
+
import polars as pl
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
def _hasFrame(data: Any) -> bool:
|
| 11 |
+
return isinstance(data, pl.DataFrame) and data.height > 0
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
def _hasTimeseries(company: Any) -> bool:
|
| 15 |
+
try:
|
| 16 |
+
timeseries = getattr(company.finance, "timeseries", None) if hasattr(company, "finance") else None
|
| 17 |
+
if callable(timeseries):
|
| 18 |
+
timeseries = timeseries()
|
| 19 |
+
if isinstance(timeseries, tuple):
|
| 20 |
+
timeseries = timeseries[0] if timeseries else None
|
| 21 |
+
return bool(timeseries)
|
| 22 |
+
except (AttributeError, TypeError, ValueError):
|
| 23 |
+
return False
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
def _pushUnique(items: list[str], question: str) -> None:
|
| 27 |
+
if question and question not in items:
|
| 28 |
+
items.append(question)
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
def suggestQuestions(company: Any) -> list[str]:
|
| 32 |
+
"""ํ์ฌ ๋ฐ์ดํฐ ์ํ์ ๋ง์ถฐ ์ถ์ฒ ์ง๋ฌธ 5~8๊ฐ๋ฅผ ์์ฑํ๋ค."""
|
| 33 |
+
suggestions: list[str] = []
|
| 34 |
+
|
| 35 |
+
_pushUnique(suggestions, "์ด ํ์ฌ์ ํต์ฌ ํฌ์ ํฌ์ธํธ๋ฅผ ํ๋์ ์ ๋ฆฌํด์ฃผ์ธ์")
|
| 36 |
+
_pushUnique(suggestions, "์ฌ๋ฌด๊ฑด์ ์ฑ๊ณผ ํ๊ธํ๋ฆ์ ํจ๊ป ์ ๊ฒํด์ฃผ์ธ์")
|
| 37 |
+
|
| 38 |
+
if _hasFrame(getattr(company, "IS", None)):
|
| 39 |
+
_pushUnique(suggestions, "์ต๊ทผ ์์ต์ฑ ์ถ์ธ์ ์ด์ต์ ์ง์ ๋ถ์ํด์ฃผ์ธ์")
|
| 40 |
+
_pushUnique(suggestions, "๋งค์ถ ์ฑ์ฅ๋ฅ ๊ณผ ์์
์ด์ต๋ฅ ๋ณํ์ ์์ธ์ ์ค๋ช
ํด์ฃผ์ธ์")
|
| 41 |
+
|
| 42 |
+
if _hasFrame(getattr(company, "BS", None)):
|
| 43 |
+
_pushUnique(suggestions, "๋ถ์ฑ ๊ตฌ์กฐ์ ์ ๋์ฑ ๋ฆฌ์คํฌ๋ฅผ ์ ๊ฒํด์ฃผ์ธ์")
|
| 44 |
+
|
| 45 |
+
if _hasFrame(getattr(company, "CF", None)):
|
| 46 |
+
_pushUnique(suggestions, "์์
ํ๊ธํ๋ฆ์ด ์ด์ต์ ์ ๋ฐ๋ผ์ค๊ณ ์๋์ง ํ๊ฐํด์ฃผ์ธ์")
|
| 47 |
+
|
| 48 |
+
if _hasFrame(getattr(company, "dividend", None)):
|
| 49 |
+
_pushUnique(suggestions, "๋ฐฐ๋น ์ง์๊ฐ๋ฅ์ฑ๊ณผ ์ฃผ์ฃผํ์ ์ ์ฑ
์ ํ๊ฐํด์ฃผ์ธ์")
|
| 50 |
+
|
| 51 |
+
if _hasTimeseries(company):
|
| 52 |
+
_pushUnique(suggestions, "์ ์ ์ฃผ๊ฐ์ ๋ฐธ๋ฅ์์ด์
์ ์ฐ์ถํด์ฃผ์ธ์")
|
| 53 |
+
_pushUnique(suggestions, "๊ฒฝ๊ธฐ์นจ์ฒด ์๋๋ฆฌ์ค์์ ์ด ํ์ฌ๊ฐ ์ผ๋ง๋ ๋ฒํธ์ง ๋ถ์ํด์ฃผ์ธ์")
|
| 54 |
+
|
| 55 |
+
topics = []
|
| 56 |
+
try:
|
| 57 |
+
topics = list(getattr(company, "topics", None) or [])
|
| 58 |
+
except (AttributeError, TypeError):
|
| 59 |
+
topics = []
|
| 60 |
+
|
| 61 |
+
topicText = " ".join(str(topic) for topic in topics).lower()
|
| 62 |
+
if "risk" in topicText or "๋ฆฌ์คํฌ" in topicText:
|
| 63 |
+
_pushUnique(suggestions, "์ต๊ทผ ๊ณต์์์ ๋๋ฌ๋ ํต์ฌ ๋ฆฌ์คํฌ๋ฅผ ์์ฝํด์ฃผ์ธ์")
|
| 64 |
+
if "dividend" in topicText or "๋ฐฐ๋น" in topicText:
|
| 65 |
+
_pushUnique(suggestions, "๋ฐฐ๋น ๊ด๋ จ ๊ณต์ ๋ฌธ๋งฅ๊น์ง ํฌํจํด ํด์ํด์ฃผ์ธ์")
|
| 66 |
+
if "segments" in topicText or "segment" in topicText or "๋ถ๋ฌธ" in topicText:
|
| 67 |
+
_pushUnique(suggestions, "์ฌ์
๋ถ๋ฌธ๋ณ ์ค์ ๊ณผ ์ฑ์ฅ์ฑ์ ๋น๊ตํด์ฃผ์ธ์")
|
| 68 |
+
|
| 69 |
+
_pushUnique(suggestions, "์ต๊ทผ ๊ณต์ ์ค ๊ผญ ์ฝ์ด์ผ ํ ๋ฌธ์๋ฅผ ์ฐ์ ์์๋ก ๊ณจ๋ผ์ฃผ์ธ์")
|
| 70 |
+
return suggestions[:8]
|
src/dartlab/ai/conversation/templates/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
"""ํ๋กฌํํธ ํ
ํ๋ฆฟ ๋ฐ์ดํฐ โ ์์คํ
ํ๋กฌํํธ, ๋ฒค์น๋งํฌ, ๋ถ์ ๊ท์น, Self-Critique."""
|
src/dartlab/ai/conversation/templates/analysis_rules.py
ADDED
|
@@ -0,0 +1,897 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""๊ต์ฐจ๊ฒ์ฆ ๊ท์น, ํ ํฝ ํ๋กฌํํธ, Few-shot ์์ (์ผ๋ฐ + Compact)."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 6 |
+
# ๊ต์ฐจ๊ฒ์ฆ ๊ท์น
|
| 7 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 8 |
+
|
| 9 |
+
CROSS_VALIDATION_RULES = """
|
| 10 |
+
## ๊ต์ฐจ๊ฒ์ฆ ์ฒดํฌ๋ฆฌ์คํธ
|
| 11 |
+
|
| 12 |
+
### A. ์ด์ต์ ์ง ๊ฒ์ฆ
|
| 13 |
+
1. **์์
์ด์ต vs ์์
CF**: ์์
์ด์ต ํ์ + ์์
CF ์ ์ โ ๋ฐ์์ฃผ์ ์ด์ต ์์ฌ. 3๋
๋์ ๋น๊ต ํ์.
|
| 14 |
+
2. **๋งค์ถ์ฑ๊ถ ํ์ vs ๋งค์ถ**: ๋งค์ถ์ฑ๊ถ ์ฆ๊ฐ์จ์ด ๋งค์ถ ์ฆ๊ฐ์จ์ 2๊ธฐ ์ฐ์ ์ด๊ณผ โ ๋งค์ถ ์ธ์ ๊ณต๊ฒฉ์ฑ ๋๋ ๋์ ๋ฆฌ์คํฌ.
|
| 15 |
+
3. **Accrual Ratio**: (์์ด์ต - ์์
CF) / ํ๊ท ์์ฐ์ด๊ณ > 10% โ ๋ฐ์์ฃผ์ ์ด์ต ๊ณผ๋ ์์ฌ.
|
| 16 |
+
4. **์ด์ ์๋ณธ ์ฌ์ดํด**: (๋งค์ถ์ฑ๊ถ์ผ์ + ์ฌ๊ณ ์ผ์ - ๋งค์
์ฑ๋ฌด์ผ์)์ ์ถ์ด โ ์
ํ ์ ํ๊ธ ์ ํ ์ง์ฐ.
|
| 17 |
+
|
| 18 |
+
### B. ์ฌ๋ฌด๊ตฌ์กฐ ๊ฒ์ฆ
|
| 19 |
+
5. **DuPont ๋ถํด**: ROE = ์์ด์ต๋ฅ ร ์ด์์ฐํ์ ์จ ร ์ฌ๋ฌด๋ ๋ฒ๋ฆฌ์ง. ROE ๊ฐ์ ์ด ๋ ๋ฒ๋ฆฌ์ง์๋ง ์์กดํ๋ฉด ์ํ.
|
| 20 |
+
6. **CAPEX vs ๊ฐ๊ฐ์๊ฐ**: CAPEX/๊ฐ๊ฐ์๊ฐ๋น < 0.5 ์ง์ โ ์ค๋น ๋
ธํํ, ๋ฏธ๋ ๊ฒฝ์๋ ฅ ํผ์.
|
| 21 |
+
7. **๋ถ์ฑ๋น์จ ๊ธ๋ฑ**: ์ ๋
๋๋น 30%p ์ด์ ์์น ์ BS/CF ๊ต์ฐจ ๋ถ์ (์ฐจ์
์ฆ๊ฐ vs ์๋ณธ ๊ฐ์ ๊ตฌ๋ถ).
|
| 22 |
+
8. **์ด์๋ณด์๋ฐฐ์จ**: < 1์ด๋ฉด ์ฌ๋ฌด ์๊ธฐ, < 1.5x์ด๋ฉด ์ฃผ์. ์์
์ด์ต์ผ๋ก ์ด์๋น์ฉ ์ปค๋ฒ ๋ถ๊ฐ.
|
| 23 |
+
|
| 24 |
+
### C. ์ฌ์
์ผ๊ด์ฑ ๊ฒ์ฆ
|
| 25 |
+
9. **๋ถ๋ฌธ ํฉ์ฐ vs ์ฐ๊ฒฐ**: ๋ถ๋ฌธ๋ณ ๋งค์ถ ํฉ๊ณ โ ์ฐ๊ฒฐ ๋งค์ถ โ ์กฐ์ ํญ๋ชฉ ๋๋ ๋ถ๋ฌธ ๋ถ๋ฅ ๋ณ๊ฒฝ ํ์ธ.
|
| 26 |
+
10. **์์
์ด์ต๋ฅ vs ๋์ข
์
๊ณ**: ์
์ข
ํ๊ท ๋๋น +10%p ์ด์ โ ์ง์๊ฐ๋ฅ ๊ฒฝ์์ฐ์ ๋๋ ์ผํ์ฑ. ์์ธ ๊ท๋ช
ํ์.
|
| 27 |
+
|
| 28 |
+
### D. ์ ๋ขฐ์ฑ ๊ฒ์ฆ
|
| 29 |
+
11. **FCF ์ถ์ธ**: FCF(์์
CF - CAPEX) 3๋
์ฐ์ ์์ โ ์ธ๋ถ ์๊ธ ์์กด๋ ์์น, ๋ฐฐ๋น ์ง์๊ฐ๋ฅ์ฑ ์๋ฌธ.
|
| 30 |
+
12. **๊ฐ์ฌ์๊ฒฌ**: ์ ์ ์ธ ์๊ฒฌ(ํ์ /๋ถ์ ์ /์๊ฒฌ๊ฑฐ์ ), ๊ฐ์กฐ์ฌํญ ์กด์ฌ, ๊ฐ์ฌ์ธ ๊ต์ฒด โ ์ฌ๋ฌด์ ํ ์ ๋ขฐ์ฑ ๊ฒฝ๊ณ .
|
| 31 |
+
"""
|
| 32 |
+
|
| 33 |
+
CROSS_VALIDATION_COMPACT = (
|
| 34 |
+
"\n## ๊ต์ฐจ๊ฒ์ฆ\n"
|
| 35 |
+
"- ์์
์ด์ต ํ์ + ์์
CF ์ ์ โ ์ด์ต์ ์ง ์์ฌ (3๋
๋์ ๋น๊ต)\n"
|
| 36 |
+
"- ๋งค์ถ์ฑ๊ถ ์ฆ๊ฐ์จ > ๋งค์ถ ์ฆ๊ฐ์จ 2๊ธฐ ์ฐ์ โ ๋์/๊ณต๊ฒฉ์ ๋งค์ถ์ธ์\n"
|
| 37 |
+
"- Accrual Ratio(NI-OCF)/์์ฐ > 10% โ ๋ฐ์์ฃผ์ ๊ณผ๋\n"
|
| 38 |
+
"- DuPont: ROE ๊ฐ์ ์ด ๋ ๋ฒ๋ฆฌ์ง ์์กด์ด๋ฉด ์ํ\n"
|
| 39 |
+
"- CAPEX/๊ฐ๊ฐ์๊ฐ < 0.5 ์ง์ โ ์ค๋น ๋
ธํํ\n"
|
| 40 |
+
"- ๋ถ์ฑ๋น์จ YoY 30%pโ โ BS/CF ๊ต์ฐจ ํ์ธ\n"
|
| 41 |
+
"- ์ด์๋ณด์๋ฐฐ์จ < 1 โ ์ฌ๋ฌด ์๊ธฐ\n"
|
| 42 |
+
"- FCF 3๋
์ฐ์ ์์ โ ์ธ๋ถ ์๊ธ ์์กด\n"
|
| 43 |
+
"- ๊ฐ์ฌ์๊ฒฌ ๋น์ ์ /๊ฐ์ฌ์ธ ๊ต์ฒด โ ์ ๋ขฐ์ฑ ๊ฒฝ๊ณ \n"
|
| 44 |
+
)
|
| 45 |
+
|
| 46 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 47 |
+
# ๋งค์ถ ์์ธก AI ๋ณด์ ๊ท์น
|
| 48 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 49 |
+
|
| 50 |
+
FORECAST_OVERLAY_RULES = """
|
| 51 |
+
## ๋งค์ถ ์์ธก AI ๋ณด์ ๊ท์น (v3)
|
| 52 |
+
|
| 53 |
+
์์ง์ด ๊ณ์ฐํ ๋งค์ถ ์์ธก์ ์ธ๊ณ ์ง์์ผ๋ก ๋ณด์ ํฉ๋๋ค.
|
| 54 |
+
|
| 55 |
+
### ์์น
|
| 56 |
+
- ์์ง ์ซ์๊ฐ ๊ธฐ๋ณธ๊ฐ. ๊ทผ๊ฑฐ ์์ด ๋ณ๊ฒฝํ์ง ๋ง์ธ์.
|
| 57 |
+
- ๋ณด์ ํ ๋๋ ๋ฐ๋์ ๊ตฌ์ฒด์ ๊ทผ๊ฑฐ๋ฅผ ์ ์ํ์ธ์ (์ฐ์
๋ฆฌํฌํธ, ๊ท์ ๋ณํ, ๊ฒฝ์์ฌ ๋ํฅ ๋ฑ).
|
| 58 |
+
- "~ํ ์ ์๋ค" ๊ฐ์ ๊ฐ๋ฅ์ฑ๋ง์ผ๋ก ์ซ์๋ฅผ ๋ฐ๊พธ์ง ๋ง์ธ์. ํ์คํ ํธ๋ ๋๋ง ๋ฐ์.
|
| 59 |
+
|
| 60 |
+
### ๋ณด์ ์ถ๋ ฅ ํ์ (๊ตฌ์กฐํ ํ์)
|
| 61 |
+
๋ณด์ ์ ์๋ ํ์์ JSON์ ํ
์คํธ์ ํฌํจํด ์ฃผ์ธ์:
|
| 62 |
+
|
| 63 |
+
```json
|
| 64 |
+
{
|
| 65 |
+
"growth_adjustment": [+2.0, +1.5, +0.5],
|
| 66 |
+
"direction": "up",
|
| 67 |
+
"magnitude": "moderate",
|
| 68 |
+
"scenario_shift": {"bull": +5, "bear": -5},
|
| 69 |
+
"reasoning": ["๋ฐ๋์ฒด ์ํผ์ฌ์ดํด ์ง์
โ DRAM ASP +25% ์ ๋ง (TrendForce 2026Q1)"]
|
| 70 |
+
}
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
ํ๋ ์ค๋ช
:
|
| 74 |
+
- **growth_adjustment**: ์ฐ๋๋ณ ์ฑ์ฅ๋ฅ ๋ณด์ (%p). ์์=์ํฅ, ์์=ํํฅ. ๊ฐ๋๋ ์ผ: ์ฐ๊ฐ ยฑ10%p, ์ด ยฑ20%p.
|
| 75 |
+
- **direction**: "up" | "down" | "neutral"
|
| 76 |
+
- **magnitude**: "minor" (<2%p) | "moderate" (2-5%p) | "major" (>5%p)
|
| 77 |
+
- **scenario_shift**: Bull/Bear ํ๋ฅ ์ด๋ (%p). Base๋ ์๋ ์กฐ์ . ์๋ต ๊ฐ๋ฅ.
|
| 78 |
+
- **reasoning**: ๊ฐ ๋ณด์ ์ ๊ทผ๊ฑฐ. ๋น์ด์์ผ๋ฉด ๋ณด์ ๊ฑฐ๋ถ๋จ.
|
| 79 |
+
|
| 80 |
+
### ์ธ๊ทธ๋จผํธ ๋ถ์ (v3 ์ ๊ท)
|
| 81 |
+
์์ง์ด ์ธ๊ทธ๋จผํธ๋ณ ์์ธก์ ์ ๊ณตํ๋ฉด:
|
| 82 |
+
- ๊ฐ ์ธ๊ทธ๋จผํธ์ ์ฑ์ฅ๋ฅ ์ด ํฉ๋ฆฌ์ ์ธ์ง ํ๊ฐ
|
| 83 |
+
- ์ธ๊ทธ๋จผํธ ๊ฐ ์๋์ง/์นด๋๋ฐ๋ฆฌ์ ์ด์
๊ฐ๋ฅ์ฑ ์ธ๊ธ
|
| 84 |
+
- ํน์ ์ธ๊ทธ๋จผํธ๊ฐ ๊ตฌ์กฐ์ ๋ณํ(๊ท์ , ๊ธฐ์ , ๊ฒฝ์)์ ๋
ธ์ถ๋๋ฉด ํด๋น ์ธ๊ทธ๋จผํธ ๊ธฐ์ค์ผ๋ก ๋ณด์
|
| 85 |
+
|
| 86 |
+
### ์์ฃผ์๊ณ ํด์ (v3 ์ ๊ท)
|
| 87 |
+
์์ง์ด ์์ฃผ์๊ณ ์๊ทธ๋์ ์ ๊ณตํ๋ฉด:
|
| 88 |
+
- B/R ratio ์ถ์ธ์ ์๋ฏธ ํด์ (์ฐ์
๋งฅ๋ฝ)
|
| 89 |
+
- ์์ฃผ์๊ณ ํ์ง ํ๊ฐ (์ทจ์ ์ํ, ๊ฐ๊ฒฉ ๋ณ๋, ๊ณ ๊ฐ ์ง์ค๋)
|
| 90 |
+
|
| 91 |
+
### ๊ธ์ง
|
| 92 |
+
- ์์ง ๊ฒฐ๊ณผ๋ฅผ ๋ฌด์ํ๊ณ ์์ ํ ์๋ก์ด ์ซ์ ์ ์
|
| 93 |
+
- ์ถ์ฒ ์๋ "์์ฅ์์๋~" ํํ
|
| 94 |
+
- ๊ณผ๋๏ฟฝ๏ฟฝ๏ฟฝ ์ ๋ฐ๋ (์์์ ์ดํ ์ฑ์ฅ๋ฅ ๋ณด์ ๋ฑ)
|
| 95 |
+
"""
|
| 96 |
+
|
| 97 |
+
FORECAST_OVERLAY_COMPACT = (
|
| 98 |
+
"\n## ๋งค์ถ ์์ธก ๋ณด์ (v3)\n"
|
| 99 |
+
"- ์์ง ์ซ์๊ฐ ๊ธฐ๋ณธ๊ฐ, ๊ทผ๊ฑฐ ์์ด ๋ณ๊ฒฝ ๊ธ์ง\n"
|
| 100 |
+
"- ๋ณด์ ์ JSON ํ์ ํ์: growth_adjustment, direction, magnitude, reasoning\n"
|
| 101 |
+
"- ์ฐ๊ฐ ๋ณด์ ยฑ10%p ์บก, ์ด ยฑ20%p ์บก, reasoning ์์ผ๋ฉด ๊ฑฐ๋ถ\n"
|
| 102 |
+
"- ์ธ๊ทธ๋จผํธ๋ณ ๋ถ์: ๋ถ๋ฌธ๋ณ ์ฑ์ฅ๋ฅ ํ๊ฐ, ์๋์ง/์นด๋๋ฐ๋ฆฌ์ ์ด์
\n"
|
| 103 |
+
"- ์์ฃผ์๊ณ : B/R ratio ํด์, ์ทจ์ ์ํ, ๊ณ ๊ฐ ์ง์ค๋\n"
|
| 104 |
+
"- ์์ง ๋ฌด์ํ๊ณ ์ ์ซ์ ๊ธ์ง, ์ถ์ฒ ์๋ ํํ ๊ธ์ง\n"
|
| 105 |
+
)
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 109 |
+
# ํ ํฝ๋ณ ์ถ๊ฐ ํ๋กฌํํธ
|
| 110 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 111 |
+
|
| 112 |
+
TOPIC_PROMPTS: dict[str, tuple[set[str], str]] = {
|
| 113 |
+
"governance": (
|
| 114 |
+
{"majorHolder", "executive", "boardOfDirectors", "holderOverview", "auditSystem"},
|
| 115 |
+
"\n## ์ง๋ฐฐ๊ตฌ์กฐ ๋ถ์ ์ฐธ๊ณ \n"
|
| 116 |
+
"- ์ฌ์ธ์ด์ฌ ๋น์จ 1/3 ์ด์์ ์๋ฒ์ ์๊ฑด (์์ฐ์ด์ก 2์กฐ ์ด์)\n"
|
| 117 |
+
"- ์ต๋์ฃผ์ฃผ ์ง๋ถ์จ 30% ์ด์์ด๋ฉด ๊ฒฝ์๊ถ ์์ \n"
|
| 118 |
+
"- ๊ฐ์ฌ์์ํ ์ ์ ์ฌ์ธ์ด์ฌ ์ฌ๋ถ ํ์ธ\n"
|
| 119 |
+
"- ์ด์ฌํ ์ถ์๋ฅ 80% ๋ฏธ๋ง์ ํ์์ ์ด์ ์ฐ๋ ค\n",
|
| 120 |
+
),
|
| 121 |
+
"risk": (
|
| 122 |
+
{"contingentLiability", "sanction", "riskDerivative", "internalControl"},
|
| 123 |
+
"\n## ๋ฆฌ์คํฌ ๋ถ์ ์ฐธ๊ณ \n"
|
| 124 |
+
"- ์ฐ๋ฐ๋ถ์ฑ๋ ํ์ฌ ์ธ์๋์ง ์์ ์ ์ฌ ๋ถ์ฑ\n"
|
| 125 |
+
"- ์ฑ๋ฌด๋ณด์ฆ ๊ธ์ก์ด ์๊ธฐ์๋ณธ ๋๋น ๋์ผ๋ฉด ์ํ\n"
|
| 126 |
+
"- ๋ด๋ถํต์ ์ทจ์ฝ์ ์ ์ฌ๋ฌด์ ํ ์ ๋ขฐ์ฑ์ ์ํฅ\n"
|
| 127 |
+
"- ๋ฐ๋ณต ์ ์ฌ๋ ๊ตฌ์กฐ์ ์ปดํ๋ผ์ด์ธ์ค ๋ฌธ์ \n",
|
| 128 |
+
),
|
| 129 |
+
"dividend": (
|
| 130 |
+
{"dividend", "shareCapital"},
|
| 131 |
+
"\n## ๋ฐฐ๋น ๋ถ์ ์ฐธ๊ณ \n"
|
| 132 |
+
"- ๋ฐฐ๋น์ฑํฅ 100% ์ด๊ณผ = ์์ด์ต ์ด์ ๋ฐฐ๋น (์ง์ ๋ถ๊ฐ๋ฅ)\n"
|
| 133 |
+
"- DPS ์ฐ์ ์ฆ๊ฐ๋ ์ฃผ์ฃผํ์ ์์ง์ ์งํ\n"
|
| 134 |
+
"- ์๊ธฐ์ฃผ์ ์๊ฐ์ ์ถ๊ฐ์ ์ฃผ์ฃผํ์ ์๋จ\n",
|
| 135 |
+
),
|
| 136 |
+
"investment": (
|
| 137 |
+
{"rnd", "tangibleAsset", "subsidiary", "investmentInOther"},
|
| 138 |
+
"\n## ํฌ์ ๋ถ์ ์ฐธ๊ณ \n"
|
| 139 |
+
"- R&D ๋น์จ์ด ๋งค์ถ ๋๋น ๋์ผ๋ฉด ๊ธฐ์ ์ง์ฝ์ ๊ธฐ์
\n"
|
| 140 |
+
"- CAPEX๊ฐ ๊ฐ๊ฐ์๊ฐ์ ์ด๊ณผํ๋ฉด ์ฑ์ฅ ํฌ์ ์ค\n"
|
| 141 |
+
"- ์ํ์ฌ ํฌ์ ์ฆ๊ฐ๋ ์ฌ์
๋ค๊ฐํ ๋๋ ์์ง๊ณ์ดํ\n",
|
| 142 |
+
),
|
| 143 |
+
"business": (
|
| 144 |
+
{"businessOverview", "segments", "productService", "salesOrder", "rawMaterial", "subsidiary"},
|
| 145 |
+
"\n## ์ฌ์
/์ ๋ต ๋ถ์ ํ๋ ์์ํฌ\n"
|
| 146 |
+
"- **์์ฅ๊ตฌ์กฐ**: ์์ ๊ธฐ์
์ง์ค๋, ์ง์
์ฅ๋ฒฝ, ๊ท์ ํ๊ฒฝ (businessOverview์์ ์ถ๋ก )\n"
|
| 147 |
+
"- **๊ฒฝ์ ํฌ์ง์
**: ์์ฅ์ ์ ์จ ์ถ์ด, ์ ํ ๋ฏน์ค ๋ณํ (segments/productService)\n"
|
| 148 |
+
"- **๊ฐ์น์ฌ์ฌ**: ์์ฌ๋ฃ ์์กด๋(rawMaterial), ๊ณ ๊ฐ ์ง์ค๋(salesOrder ์์ ๋งค์ถ์ฒ ๋น์ค)\n"
|
| 149 |
+
"- **์์ง๊ณ์ดํ**: ์ํ์ฌ ๊ตฌ์กฐ(subsidiary)์ ๋ถ๋ฌธ๊ฐ ์๋์ง\n"
|
| 150 |
+
"- **์ ๋ต์ ๋ฆฌ์คํฌ**: ๋จ์ผ ์ ํ/๊ณ ๊ฐ ์์กด, ์์ฌ๋ฃ ๊ฐ๊ฒฉ ๋ณ๋, ํ์จ ๋
ธ์ถ\n",
|
| 151 |
+
),
|
| 152 |
+
"profitability": (
|
| 153 |
+
{"IS", "segments", "costByNature", "productService"},
|
| 154 |
+
"\n## ์์ต์ฑ ์ฌ์ธต ๋ถ์ ๊ฐ์ด๋\n"
|
| 155 |
+
"- **์๊ฐ๊ตฌ์กฐ ๋ถํด**: ๋งค์ถ์๊ฐ์จ, ํ๊ด๋น์จ ์ถ์ด (costByNature๋ก ์ธ๊ฑด๋น/๊ฐ๊ฐ์๊ฐ/์ธ์ฃผ๋น ์ธ๋ถ ํ์ธ)\n"
|
| 156 |
+
"- **์์
๋ ๋ฒ๋ฆฌ์ง**: ๊ณ ์ ๋น(์ธ๊ฑด๋น, ๊ฐ๊ฐ์๊ฐ) ๋น์ค ๋์ผ๋ฉด ๋งค์ถ ์ฆ๊ฐ ์ ์ด์ต๋ฅ ๊ธ๋ฑ\n"
|
| 157 |
+
"- **๋ง์ง ์ง์์ฑ**: ์ผํ์ฑ ์ด์ต(์์ฐ์ฒ๋ถ, ๋ณดํ๊ธ) ์ ๊ฑฐ ํ recurring margin ํ๋จ\n"
|
| 158 |
+
"- **๋ถ๋ฌธ๋ณ ์์ต์ฑ**: segments์์ ๊ณ ๋ง์ง/์ ๋ง์ง ๋ถ๋ฌธ ์๋ณ, ๋งค์ถ ๋ฏน์ค ํจ๊ณผ ๋ถ์\n",
|
| 159 |
+
),
|
| 160 |
+
"growth": (
|
| 161 |
+
{"IS", "segments", "rnd", "tangibleAsset", "subsidiary", "productService"},
|
| 162 |
+
"\n## ์ฑ์ฅ์ฑ ๋ถ์ ๊ฐ์ด๋\n"
|
| 163 |
+
"- **์ ๊ธฐ์ vs ๋น์ ๊ธฐ์ **: ๊ธฐ์กด ์ฌ์
์ฑ์ฅ vs M&A/์ํ์ฌ ํธ์
ํจ๊ณผ ๋ถ๋ฆฌ\n"
|
| 164 |
+
"- **์ค๋นํฌ์ ์ฌ์ดํด**: CAPEX/๊ฐ๊ฐ์๊ฐ๋น > 1.5x๋ฉด ์ ๊ทน ํ์ฅ๊ธฐ\n"
|
| 165 |
+
"- **R&D ํ์ดํ๋ผ์ธ**: R&D/๋งค์ถ ๋น์จ ์ถ์ด + ๋ฌดํ์์ฐ ์๋ณธํ ๋น์จ ๋์ ํ์ธ\n"
|
| 166 |
+
"- **์์ฅ ์นจํฌ์จ**: ์
์ข
์ฑ์ฅ๋ฅ vs ์์ฌ ์ฑ์ฅ๋ฅ ๋น๊ต โ ์ ์ ์จ ๋ณํ ์ถ๋ก \n",
|
| 167 |
+
),
|
| 168 |
+
"comprehensive": (
|
| 169 |
+
{"IS", "BS", "CF", "segments", "riskFactor", "dividend", "audit"},
|
| 170 |
+
"\n## ์ข
ํฉ ๋ถ์ ํ๋ ์์ํฌ (์ ์ฉ๋ถ์ ๋ณด๊ณ ์ ๊ตฌ์กฐ)\n"
|
| 171 |
+
"1. **์ฌ์
๊ฐ์**: ์์ฅ ์์น, ๊ฒฝ์ ๊ตฌ๋, ํต์ฌ ๊ฒฝ์๋ ฅ\n"
|
| 172 |
+
"2. **์ฌ๋ฌด ๋ถ์**: ์์ต์ฑ(IS) โ ๊ฑด์ ์ฑ(BS) โ ํ๊ธํ๋ฆ(CF) ์์\n"
|
| 173 |
+
"3. **DuPont ๋ถํด**: ROE = ์์ด์ต๋ฅ ร ์์ฐํ์ ์จ ร ์ฌ๋ฌด๋ ๋ฒ๋ฆฌ์ง โ ์ฃผ์ ๋์ธ ์๋ณ\n"
|
| 174 |
+
"4. **ํ๊ธํ๋ฆ ํ์ง**: ์์
CF/์์ด์ต, FCF ์ถ์ด, ์ด์ ์๋ณธ ์ฌ์ดํด ๋ณํ\n"
|
| 175 |
+
"5. **๋ฆฌ์คํฌ**: ์ฌ๋ฌด ๋ฆฌ๏ฟฝ๏ฟฝํฌ + ์ฌ์
๋ฆฌ์คํฌ + ์ง๋ฐฐ๊ตฌ์กฐ ๋ฆฌ์คํฌ\n"
|
| 176 |
+
"6. **์ข
ํฉ ํ๋จ**: ๊ฐ์ /์ฝ์ ๋งคํธ๋ฆญ์ค + ํฅํ ๋ชจ๋ํฐ๋ง ํฌ์ธํธ\n",
|
| 177 |
+
),
|
| 178 |
+
"disclosure": (
|
| 179 |
+
{"audit", "accountingPolicy", "relatedPartyTx", "contingentLiability"},
|
| 180 |
+
"\n## ๊ณต์/์ฃผ์ ๋ถ์ ๊ฐ์ด๋\n"
|
| 181 |
+
"- **ํ๊ณ์ ์ฑ
๋ณ๊ฒฝ**: ์์ต์ธ์, ๊ฐ๊ฐ์๊ฐ, ์ฌ๊ณ ํ๊ฐ ๋ฐฉ๋ฒ ๋ณ๊ฒฝ์ ์ด์ต ์กฐ์ ์ ํธ์ผ ์ ์์\n"
|
| 182 |
+
"- **ํน์๊ด๊ณ์๊ฑฐ๋**: ๊ฑฐ๋ ๊ท๋ชจ, ๊ฐ๊ฒฉ ์ ์ ์ฑ, ๋งค์ถ ์ค ๋น์ค ๋ณํ ์ถ์ \n"
|
| 183 |
+
"- **์ฐ๋ฐ๋ถ์ฑ**: ์์ก/๋ณด์ฆ/PF ๊ท๋ชจ๊ฐ ์๊ธฐ์๋ณธ ๋๋น 10% ์ด๊ณผ ์ ์ฃผ์\n"
|
| 184 |
+
"- **๊ฐ์ฌ์๊ฒฌ**: ๊ณ์๊ธฐ์
๋ถํ์ค์ฑ ๊ฐ์กฐ, ํ์ ์๊ฒฌ, ๊ฐ์ฌ์ธ ๊ต์ฒด ์ด๋ ฅ ํ์ธ\n",
|
| 185 |
+
),
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
TOPIC_COMPACT: dict[str, tuple[set[str], str]] = {
|
| 189 |
+
"governance": (
|
| 190 |
+
{"majorHolder", "executive", "boardOfDirectors", "holderOverview", "auditSystem"},
|
| 191 |
+
"\n## ์ง๋ฐฐ๊ตฌ์กฐ ์ฐธ๊ณ \n"
|
| 192 |
+
"- ์ฌ์ธ์ด์ฌ 1/3โ ์๋ฒ ์๊ฑด, ์ต๋์ฃผ์ฃผ 30%โ ๊ฒฝ์๊ถ ์์ \n"
|
| 193 |
+
"- ๊ฐ์ฌ์์ํ ์ฌ์ธ์ด์ฌ ์ ์ ์ฌ๋ถ, ์ด์ฌํ ์ถ์๋ฅ 80%โ ์ฃผ์\n",
|
| 194 |
+
),
|
| 195 |
+
"risk": (
|
| 196 |
+
{"contingentLiability", "sanction", "riskDerivative", "internalControl"},
|
| 197 |
+
"\n## ๋ฆฌ์คํฌ ์ฐธ๊ณ \n"
|
| 198 |
+
"- ์ฐ๋ฐ๋ถ์ฑ = ์ ์ฌ ๋ถ์ฑ, ์ฑ๋ฌด๋ณด์ฆ/์๋ณธ ๋น์จ ํ์ธ\n"
|
| 199 |
+
"- ๋ด๋ถํต์ ์ทจ์ฝ โ ์ฌ๋ฌด์ ํ ์ ๋ขฐ์ฑโ, ๋ฐ๋ณต ์ ์ฌ โ ๊ตฌ์กฐ์ ๋ฌธ์ \n",
|
| 200 |
+
),
|
| 201 |
+
"dividend": (
|
| 202 |
+
{"dividend", "shareCapital"},
|
| 203 |
+
"\n## ๋ฐฐ๋น ์ฐธ๊ณ \n- ๋ฐฐ๋น์ฑํฅ 100%โ ์ง์ ๋ถ๊ฐ, DPS ์ฐ์์ฆ๊ฐ = ์ฃผ์ฃผํ์ ์์ง\n",
|
| 204 |
+
),
|
| 205 |
+
"investment": (
|
| 206 |
+
{"rnd", "tangibleAsset", "subsidiary", "investmentInOther"},
|
| 207 |
+
"\n## ํฌ์ ์ฐธ๊ณ \n- CAPEX > ๊ฐ๊ฐ์๊ฐ = ์ฑ์ฅ ํฌ์, R&D/๋งค์ถโ = ๊ธฐ์ ์ง์ฝ\n",
|
| 208 |
+
),
|
| 209 |
+
"business": (
|
| 210 |
+
{"businessOverview", "segments", "productService", "salesOrder", "rawMaterial", "subsidiary"},
|
| 211 |
+
"\n## ์ฌ์
์ฐธ๊ณ \n- ์์ฅ๊ตฌ์กฐยท๊ฒฝ์ํฌ์ง์
(segments), ๊ณ ๊ฐ์ง์ค๋(salesOrder), ์์ฌ๋ฃ ์์กด(rawMaterial)\n"
|
| 212 |
+
"- ๋จ์ผ ์ ํ/๊ณ ๊ฐ ์์กด, ํ์จ ๋
ธ์ถ = ์ ๋ต์ ๋ฆฌ์คํฌ\n",
|
| 213 |
+
),
|
| 214 |
+
"profitability": (
|
| 215 |
+
{"IS", "segments", "costByNature", "productService"},
|
| 216 |
+
"\n## ์์ต์ฑ ์ฐธ๊ณ \n- ์๊ฐ๊ตฌ์กฐ ๋ถํด: ๋งค์ถ์๊ฐ์จ+ํ๊ด๋น์จ ์ถ์ด. ์ผํ์ฑ ์ ๊ฑฐ ํ recurring margin\n"
|
| 217 |
+
"- ๋ถ๋ฌธ๋ณ ๊ณ ๋ง์ง/์ ๋ง์ง ์๋ณ, ์์
๋ ๋ฒ๋ฆฌ์ง(๊ณ ์ ๋น ๋น์ค) ํ์ธ\n",
|
| 218 |
+
),
|
| 219 |
+
"growth": (
|
| 220 |
+
{"IS", "segments", "rnd", "tangibleAsset", "subsidiary", "productService"},
|
| 221 |
+
"\n## ์ฑ์ฅ์ฑ ์ฐธ๊ณ \n- ์ ๊ธฐ์ vs M&A ์ฑ์ฅ ๋ถ๋ฆฌ. CAPEX/๊ฐ๊ฐ์๊ฐ >1.5x = ํ์ฅ๊ธฐ\n"
|
| 222 |
+
"- R&D/๋งค์ถ + ๋ฌดํ์์ฐ ์๋ณธํ ๋์ ํ์ธ\n",
|
| 223 |
+
),
|
| 224 |
+
"comprehensive": (
|
| 225 |
+
{"IS", "BS", "CF", "segments", "riskFactor", "dividend", "audit"},
|
| 226 |
+
"\n## ์ข
ํฉ ์ฐธ๊ณ \n- ์ฌ์
โ์์ต์ฑ(IS)โ๊ฑด์ ์ฑ(BS)โCFโ๋ฆฌ์คํฌ ์์\n"
|
| 227 |
+
"- DuPont(ROE ๋์ธ), CF ํ์ง, ๊ฐ์ /์ฝ์ ๋งคํธ๋ฆญ์ค ์ ์\n",
|
| 228 |
+
),
|
| 229 |
+
"disclosure": (
|
| 230 |
+
{"audit", "accountingPolicy", "relatedPartyTx", "contingentLiability"},
|
| 231 |
+
"\n## ๊ณต์ ์ฐธ๊ณ \n- ํ๊ณ์ ์ฑ
๋ณ๊ฒฝ=์ด์ต์กฐ์ ๊ฐ๋ฅ, ํน์๊ด๊ณ์ ๋น์คโ ์ฃผ์\n"
|
| 232 |
+
"- ์ฐ๋ฐ๋ถ์ฑ/์๋ณธ 10%โ ๊ฒฝ๊ณ , ๊ฐ์ฌ์ธ ๊ต์ฒด ์ด๋ ฅ ํ์ธ\n",
|
| 233 |
+
),
|
| 234 |
+
}
|
| 235 |
+
|
| 236 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 237 |
+
# Few-shot ์์
|
| 238 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 239 |
+
|
| 240 |
+
FEW_SHOT_EXAMPLES: dict[str, str] = {
|
| 241 |
+
"๊ฑด์ ์ฑ": """
|
| 242 |
+
## ๋ถ์ ์์ (์ฌ๋ฌด ๊ฑด์ ์ฑ)
|
| 243 |
+
|
| 244 |
+
Q: ์ด ๊ธฐ์
์ ์ฌ๋ฌด ๊ฑด์ ์ฑ์ ๋ถ์ํด์ฃผ์ธ์.
|
| 245 |
+
|
| 246 |
+
A: ## ์ฌ๋ฌด ๊ฑด์ ์ฑ ์ฌ์ธต ๋ถ์
|
| 247 |
+
|
| 248 |
+
### ํต์ฌ ์์ฝ
|
| 249 |
+
๋ถ์ฑ๋น์จ 45.2%๋ก ์ํธํ๋, **DuPont ๋ถํด ๊ฒฐ๊ณผ ROE ๊ฐ์ ์ ์ฃผ๋์ธ์ด ๋ ๋ฒ๋ฆฌ์ง๊ฐ ์๋ ์์ต์ฑ**์์ ํ์ธ. ์ด์ต์ ์ง๋ CF ๊ธฐ์ค ์ํธ.
|
| 250 |
+
|
| 251 |
+
### 1. ์ฌ๋ฌด๊ตฌ์กฐ (BS ๊ธฐ์ค)
|
| 252 |
+
| ์งํ | 2022 | 2023 | ๋ณ๋ | ํ๋จ |
|
| 253 |
+
|------|------|------|------|------|
|
| 254 |
+
| ๋ถ์ฑ๋น์จ | 52.1% | **45.2%** | โผ6.9%p | ์ํธ |
|
| 255 |
+
| ์ ๋๋น์จ | 172.5% | **185.3%** | โฒ12.8%p | ์ํธ |
|
| 256 |
+
| ์ด์๋ณด์๋ฐฐ์จ | 8.2x | **10.5x** | โฒ2.3x | ์ํธ |
|
| 257 |
+
|
| 258 |
+
### 2. DuPont ๋ถํด (ROE ๊ฒ์ฆ)
|
| 259 |
+
- ROE 21.0% = ์์ด์ต๋ฅ 10.5% ร ์์ฐํ์ ์จ 0.8x ร ๋ ๋ฒ๋ฆฌ์ง 2.5x
|
| 260 |
+
- ๋ ๋ฒ๋ฆฌ์ง 2.5x๋ ์ ๋
(2.65x)๋ณด๋ค ํ๋ฝ โ ROE ๊ฐ์ ์ **์์ด์ต๋ฅ ๊ฐ์ (9.2%โ10.5%)** ์ฃผ๋
|
| 261 |
+
- โญ ๊ฑด์ ํ ROE ๊ตฌ์กฐ (๋ ๋ฒ๋ฆฌ์ง ์์กด ์๋)
|
| 262 |
+
|
| 263 |
+
### 3. ์ด์ต์ ์ง + ์ด์ ์๋ณธ
|
| 264 |
+
| ๊ฒ์ฆ ํญ๋ชฉ | ๊ฐ | ํ๋จ |
|
| 265 |
+
|-----------|-----|------|
|
| 266 |
+
| ์์
CF/์์ด์ต | 152% (3,200/2,100) | โญ ์ํธ |
|
| 267 |
+
| Accrual Ratio | 3.1% | โญ ์ํธ (<10%) |
|
| 268 |
+
| ์ด์ ์๋ณธ ์ฌ์ดํด(CCC) | 42์ผ โ 45์ผ | โณ ์ํญ ์
ํ |
|
| 269 |
+
| FCF | +1,200๋ฐฑ๋ง์ | โญ ์ํธ |
|
| 270 |
+
|
| 271 |
+
### 4. ๊ฐ์ฌ์๊ฒฌ: ์ ์ (2020-2023 ์ฐ์), ๊ฐ์ฌ์ธ ๊ต์ฒด ์์
|
| 272 |
+
|
| 273 |
+
### ๊ฒฐ๋ก
|
| 274 |
+
๋ถ์ฑ๋น์จ ๊ฐ์ , ์ด์๋ณด์๋ฐฐ์จ 10x+ ์์ , DuPont์ ๏ฟฝ๏ฟฝ๏ฟฝ์ต์ฑ ์ฃผ๋ ROE.
|
| 275 |
+
์ด์ต์ ์ง ์ํธ(CF/NI 152%, Accrual 3.1%). **์ฌ๋ฌด ๊ฑด์ ์ฑ ์ํธ.**
|
| 276 |
+
๋ชจ๋ํฐ๋ง: ์ด์ ์๋ณธ ์ฌ์ดํด ์ํญ ์
ํ(+3์ผ) ์ถ์ด ์ฃผ์.
|
| 277 |
+
""",
|
| 278 |
+
"์์ต์ฑ": """
|
| 279 |
+
## ๋ถ์ ์์ (์์ต์ฑ)
|
| 280 |
+
|
| 281 |
+
Q: ์์ต์ฑ์ ๋ถ์ํด์ฃผ์ธ์.
|
| 282 |
+
|
| 283 |
+
A: ## ์์ต์ฑ ์ฌ์ธต ๋ถ์
|
| 284 |
+
|
| 285 |
+
### ํต์ฌ ์์ฝ
|
| 286 |
+
์์
์ด์ต๋ฅ ์ด 13.9%โ15.0%๋ก ๊ฐ์ ๋์์ผ๋, **๋ง์ง ๋ถํด ๊ฒฐ๊ณผ ๊ฐ์ ์ ์ฃผ์ธ์ ์๊ฐ์จ ํ๋ฝ(โผ2.3%p)**์ด๋ฉฐ ํ๊ด๋น๋ ์คํ๋ ค ์ฆ๊ฐ(โฒ1.2%p). ์์ฌ๋ฃ ๊ฐ๊ฒฉ ๋ฐ๋ฑ ์ ๋ง์ง ์๋ฐ ๊ฐ๋ฅ.
|
| 287 |
+
|
| 288 |
+
### 1. ๋ง์ง ๋ถํด (IS ๊ธฐ์ค, ์ธ๊ณผ ๋ถ์)
|
| 289 |
+
| ํญ๋ชฉ | 2022 | 2023 | ๋ณ๋ | ์์ธ |
|
| 290 |
+
|------|------|------|------|------|
|
| 291 |
+
| ๋งค์ถ์๊ฐ์จ | 62.1% | 59.8% | โผ2.3%p | ์์ฌ๋ฃ ๊ฐ๊ฒฉโ |
|
| 292 |
+
| ํ๊ด๋น์จ | 24.0% | 25.2% | โฒ1.2%p | ์ธ๋ ฅํ์ถฉ(+8.3%) + R&Dโ |
|
| 293 |
+
| **์์
์ด์ต๋ฅ ** | **13.9%** | **15.0%** | **โฒ1.1%p** | ์๊ฐโ > ํ๊ด๋นโ |
|
| 294 |
+
|
| 295 |
+
โ ์ํจ๊ณผ +1.1%p = ์๊ฐ๊ฐ์ (+2.3%p) - ํ๊ด๋น์ฆ๊ฐ(-1.2%p)
|
| 296 |
+
|
| 297 |
+
### 2. DuPont ๋ถํด (ROE 21.0%)
|
| 298 |
+
| ๊ตฌ์ฑ์์ | ๊ฐ | ํ๋จ |
|
| 299 |
+
|----------|-----|------|
|
| 300 |
+
| ์์ด์ต๋ฅ | 10.5% | ์ฃผ๋์ธ (์ ๋
9.2%โ10.5%) |
|
| 301 |
+
| ์์ฐํ์ ์จ | 0.8x | ์์ |
|
| 302 |
+
| ์ฌ๋ฌด๋ ๋ฒ๋ฆฌ์ง | 2.5x | ์ ๋
๋๋น ํ๋ฝ(๊ฑด์ ํ) |
|
| 303 |
+
|
| 304 |
+
โ ROE ๊ฐ์ ์ **์์ต์ฑ ์ฃผ๋**, ๋ ๋ฒ๋ฆฌ์ง ์์กด ์๋ ๊ฑด์ ํ ๊ตฌ์กฐ
|
| 305 |
+
|
| 306 |
+
### 3. ์ด์ต์ ์ง
|
| 307 |
+
- ์์
CF/์์ด์ต: 152% โ โญ ์ํธ
|
| 308 |
+
- Accrual Ratio: 3.1% โ โญ ์ํธ (<10%)
|
| 309 |
+
- ๋งค์ถ์ฑ๊ถ ์ฆ๊ฐ์จ(8.2%) < ๋งค์ถ ์ฆ๊ฐ์จ(11.1%) โ โญ ์ ์
|
| 310 |
+
|
| 311 |
+
### ๊ฒฐ๋ก
|
| 312 |
+
์์ต์ฑ **์ํธ**. ๋ง์ง ๊ฐ์ ์ ํต์ฌ ๋์ธ์ ์์ฌ๋ฃ๋น ํ๋ฝ์ด๋ฏ๋ก, **์์์ฌ ๊ฐ๊ฒฉ ๋ฐ๋ฑ ์ ์ด์ต๋ฅ 1~2%p ์๋ฐ** ๊ฐ๋ฅ.
|
| 313 |
+
ํ๊ด๋น ์ค R&D ์ฆ๊ฐ(8.5%โ9.2%)๋ ์ค์ฅ๊ธฐ ๊ฒฝ์๋ ฅ ํฌ์๋ก ๊ธ์ ์ .
|
| 314 |
+
๋ชจ๋ํฐ๋ง: ์์ฌ๋ฃ ๊ฐ๊ฒฉ ์ถ์ด, ํ๊ฐ ์ ๊ฐ๋ ฅ, ๋ถ๋ฌธ๋ณ ๋ง์ง ๋ณํ.
|
| 315 |
+
""",
|
| 316 |
+
"์ฑ์ฅ์ฑ": """
|
| 317 |
+
## ๋ถ์ ์์ (์ฑ์ฅ์ฑ)
|
| 318 |
+
|
| 319 |
+
Q: ์ฑ์ฅ์ฑ์ ์ด๋ค๊ฐ์?
|
| 320 |
+
|
| 321 |
+
A: ## ์ฑ์ฅ์ฑ ๋ถ์
|
| 322 |
+
|
| 323 |
+
### 1. ๋งค์ถ ์ฑ์ฅ๋ฅ (IS ๊ธฐ์ค)
|
| 324 |
+
- 2023/2022: +11.1% (20,000/18,000)
|
| 325 |
+
- 2022/2021: +12.5% (18,000/16,000)
|
| 326 |
+
- 3Y CAGR: +11.8% โ ์์ ์ ๋ ์๋ฆฟ์ ์ฑ์ฅ
|
| 327 |
+
|
| 328 |
+
### 2. ์ฌ์
๋ถ๋ฌธ๋ณ ์ฑ์ฅ (segment ๊ธฐ์ค)
|
| 329 |
+
- A ๋ถ๋ฌธ: +15.3% (์ฑ์ฅ ๊ฒฌ์ธ)
|
| 330 |
+
- B ๋ถ๋ฌธ: +5.1% (์์ )
|
| 331 |
+
|
| 332 |
+
### 3. R&D ํฌ์ (์ฑ์ฅ ์ง์๊ฐ๋ฅ์ฑ)
|
| 333 |
+
- R&D/๋งค์ถ: 8.5% โ ๊ธฐ์ ํฌ์ ์ง์ ์ค
|
| 334 |
+
|
| 335 |
+
### 4. ์ด์์ฐ ์ฆ๊ฐ์จ
|
| 336 |
+
- 2023/2022: +8.2% โ ๋งค์ถ ์ฑ์ฅ๋ฅ ํํ (์์ฐ ํจ์จ์ฑ ๊ฐ์ )
|
| 337 |
+
|
| 338 |
+
### ๊ฒฐ๋ก
|
| 339 |
+
์์ ์ ๋ ์๋ฆฟ์ ๋งค์ถ ์ฑ์ฅ ์ ์ง ์ค. R&D ํฌ์ ์ง์์ผ๋ก ์ฑ์ฅ ๋ชจ๋ฉํ
์ํธ.
|
| 340 |
+
""",
|
| 341 |
+
"๋ฐฐ๋น": """
|
| 342 |
+
## ๋ถ์ ์์ (๋ฐฐ๋น)
|
| 343 |
+
|
| 344 |
+
Q: ๋ฐฐ๋น ์ ์ฑ
์ ๋ถ์ํด์ฃผ์ธ์.
|
| 345 |
+
|
| 346 |
+
A: ## ๋ฐฐ๋น ๋ถ์
|
| 347 |
+
|
| 348 |
+
### 1. ๋ฐฐ๋น ์ถ์ด
|
| 349 |
+
| ์ฐ๋ | DPS(์) | ๋ฐฐ๋น์์ต๋ฅ | ๋ฐฐ๋น์ฑํฅ |
|
| 350 |
+
|------|---------|------------|----------|
|
| 351 |
+
| 2023 | 1,500 | 2.8% | 35.7% |
|
| 352 |
+
| 2022 | 1,200 | 2.5% | 33.3% |
|
| 353 |
+
| 2021 | 1,000 | 2.2% | 31.3% |
|
| 354 |
+
|
| 355 |
+
### 2. ๋ฐฐ๋น ์ง์๊ฐ๋ฅ์ฑ
|
| 356 |
+
- DPS 3๋
์ฐ์ ์ฆ๊ฐ (+25.0%, +20.0%)
|
| 357 |
+
- ๋ฐฐ๋น์ฑํฅ 30-36% โ ์์ ์ ๋ฒ์
|
| 358 |
+
- FCF ๋๋น ๋ฐฐ๋น: ์ถฉ๋ถํ ์ปค๋ฒ๋ฆฌ์ง
|
| 359 |
+
|
| 360 |
+
### ๊ฒฐ๋ก
|
| 361 |
+
DPS ์ฐ์ ์ฆ๊ฐ, ๋ฐฐ๋น์ฑํฅ ์ ์ ๋ฒ์ ๋ด. **์ฃผ์ฃผํ์ ์ ์ฑ
์ํธ** ํ๋จ.
|
| 362 |
+
""",
|
| 363 |
+
"์ง๋ฐฐ๊ตฌ์กฐ": """
|
| 364 |
+
## ๋ถ์ ์์ (์ง๋ฐฐ๊ตฌ์กฐ)
|
| 365 |
+
|
| 366 |
+
Q: ์ง๋ฐฐ๊ตฌ์กฐ๋ฅผ ๋ถ์ํด์ฃผ์ธ์.
|
| 367 |
+
|
| 368 |
+
A: ## ์ง๋ฐฐ๊ตฌ์กฐ ๋ถ์
|
| 369 |
+
|
| 370 |
+
### 1. ์ต๋์ฃผ์ฃผ (majorHolder ๊ธฐ์ค)
|
| 371 |
+
- ์ต๋์ฃผ์ฃผ: OO๊ทธ๋ฃน ํ์ฅ ์ธ ํน์๊ด๊ณ์ธ
|
| 372 |
+
- ์ง๋ถ์จ: 35.2% โ ๊ฒฝ์๊ถ ์์
|
| 373 |
+
|
| 374 |
+
### 2. ์ด์ฌํ ๊ตฌ์ฑ (executive ๊ธฐ์ค)
|
| 375 |
+
- ์ด ์ด์ฌ: 8๋ช
(์ฌ๋ด 5, ์ฌ์ธ 3)
|
| 376 |
+
- ์ฌ์ธ์ด์ฌ ๋น์จ: 37.5% โ ์๋ฒ 1/3 ์๊ฑด ์ถฉ์กฑ
|
| 377 |
+
|
| 378 |
+
### 3. ๊ฐ์ฌ (audit ๊ธฐ์ค)
|
| 379 |
+
- ๊ฐ์ฌ์๊ฒฌ: ์ ์ (5๋
์ฐ์)
|
| 380 |
+
- ๊ฐ์ฌ์ธ: 4๋ ํ๊ณ๋ฒ์ธ
|
| 381 |
+
|
| 382 |
+
### ๊ฒฐ๋ก
|
| 383 |
+
๊ฒฝ์๊ถ ์์ , ์ด์ฌํ ๋
๋ฆฝ์ฑ ๊ธฐ๋ณธ ์๊ฑด ์ถฉ์กฑ, ๊ฐ์ฌ์๊ฒฌ ์ํธ.
|
| 384 |
+
""",
|
| 385 |
+
"ํฌ์": """
|
| 386 |
+
## ๋ถ์ ์์ (ํฌ์ ๋ถ์)
|
| 387 |
+
|
| 388 |
+
Q: ์ด ๊ธฐ์
์ ํฌ์ ํํฉ์ ๋ถ์ํด์ฃผ์ธ์.
|
| 389 |
+
|
| 390 |
+
A: ## ํฌ์ ๋ถ์
|
| 391 |
+
|
| 392 |
+
### 1. R&D ํฌ์ (rnd ๊ธฐ์ค)
|
| 393 |
+
| ์ฐ๋ | R&D๋น์ฉ | ๋งค์ถ ๋๋น |
|
| 394 |
+
|------|---------|-----------|
|
| 395 |
+
| 2023 | 2,500 | 12.5% |
|
| 396 |
+
| 2022 | 2,100 | 11.7% |
|
| 397 |
+
| 2021 | 1,800 | 11.3% |
|
| 398 |
+
|
| 399 |
+
### 2. ์ค๋นํฌ์ (tangibleAsset / CF ๊ธฐ์ค)
|
| 400 |
+
- CAPEX(์ ํ์์ฐ ์ทจ๋): 3,000๋ฐฑ๋ง์ (CF 2023)
|
| 401 |
+
- ๊ฐ๊ฐ์๊ฐ: 2,200๋ฐฑ๋ง์ โ CAPEX > ๊ฐ๊ฐ์๊ฐ: ์ฑ์ฅ ํฌ์ ์ค
|
| 402 |
+
|
| 403 |
+
### 3. ์ํ์ฌ ํฌ์ (subsidiary ๊ธฐ์ค)
|
| 404 |
+
- ์ฃผ์ ์ํ์ฌ 3๊ฐ, ์ด ํฌ์์ก 5,200๋ฐฑ๋ง์
|
| 405 |
+
- ์ง๋ถ์จ 100% 1๊ฐ, 51% 2๊ฐ
|
| 406 |
+
|
| 407 |
+
### ๊ฒฐ๋ก
|
| 408 |
+
R&D์ ์ค๋น์ ์ ๊ทน ํฌ์ ์ค. ๊ธฐ์ ๊ฒฝ์๋ ฅ ๊ฐํ์ ์์ฐ๋ฅ๋ ฅ ํ๋ ๋์ ์ถ์ง.
|
| 409 |
+
R&D ๋น์จ 12%+ ์์ค์ ์
์ข
์์๊ถ.
|
| 410 |
+
""",
|
| 411 |
+
"์ข
ํฉ": """
|
| 412 |
+
## ๋ถ์ ์์ (์ข
ํฉ ๋ถ์)
|
| 413 |
+
|
| 414 |
+
Q: ์ด ๊ธฐ์
์ ์ข
ํฉ ๋ถ์ํด์ฃผ์ธ์.
|
| 415 |
+
|
| 416 |
+
A: ## ์ข
ํฉ ๋ถ์ (์ ์ฉ๋ถ์ ๋ณด๊ณ ์ ๊ตฌ์กฐ)
|
| 417 |
+
|
| 418 |
+
### ํต์ฌ ์์ฝ
|
| 419 |
+
์์ต์ฑยท๊ฑด์ ์ฑยทํ๊ธํ๋ฆ ๋ชจ๋ ์ํธํ ์ฐ๋ ๊ธฐ์
. **DuPont์ ROE 21%๋ ์์ต์ฑ ์ฃผ๋**์ด๋ฉฐ, ์ด์ต์ ์ง๋ CF ๊ธฐ์ค ๊ฒ์ฆ๋จ. ์ฃผ์ ๋ชจ๋ํฐ๋ง: ์์ฌ๋ฃ ๊ฐ๊ฒฉ ๋ณ๋ ๋ฆฌ์คํฌ.
|
| 420 |
+
|
| 421 |
+
### 1. ์ฌ์
ํฌ์ง์
๋
|
| 422 |
+
- ์ฃผ๋ ฅ A๋ถ๋ฌธ ๋งค์ถ๋น์ค 65%, ์ฑ์ฅ๋ฅ +15.3% (segments) โ ํต์ฌ ์ฑ์ฅ ์์ง
|
| 423 |
+
- ์์ 3 ๊ณ ๏ฟฝ๏ฟฝ ๋งค์ถ ๋น์ค 32% (salesOrder) โ ๊ณ ๊ฐ ์ง์ค ๋ฆฌ์คํฌ ๋ฎ์
|
| 424 |
+
- R&D/๋งค์ถ 9.2% โ ๊ธฐ์ ํฌ์ ์ง์ (rnd)
|
| 425 |
+
|
| 426 |
+
### 2. ์์ต์ฑ (IS ๊ธฐ์ค)
|
| 427 |
+
| ์งํ | 2022 | 2023 | ๋ณ๋ | ํ๋จ |
|
| 428 |
+
|------|------|------|------|------|
|
| 429 |
+
| ์์
์ด์ต๋ฅ | 13.9% | **15.0%** | โฒ1.1%p | ์ํธ |
|
| 430 |
+
| ROE (DuPont) | 18.0% | **21.0%** | โฒ3.0%p | ์ฐ์ |
|
| 431 |
+
|
| 432 |
+
โ ๋ง์ง ๊ฐ์ ์์ธ: ๋งค์ถ์๊ฐ์จ โผ2.3%p(์์ฌ๋ฃโ) > ํ๊ด๋น์จ โฒ1.2%p(์ธ๋ ฅ+R&D)
|
| 433 |
+
|
| 434 |
+
### 3. ์ฌ๋ฌด๊ฑด์ ์ฑ (BS ๊ธฐ์ค)
|
| 435 |
+
| ์งํ | 2023 | ํ๋จ |
|
| 436 |
+
|------|------|------|
|
| 437 |
+
| ๋ถ์ฑ๋น์จ | **45.2%** | ์ํธ (<100%) |
|
| 438 |
+
| ์ ๋๋น์จ | **185.3%** | ์ํธ (>150%) |
|
| 439 |
+
| ์ด์๋ณด์๋ฐฐ์จ | **10.5x** | ์ํธ (>5x) |
|
| 440 |
+
|
| 441 |
+
### 4. ํ๊ธํ๋ฆ ํ์ง (CF ๊ธฐ์ค)
|
| 442 |
+
| ๊ฒ์ฆ | ๊ฒฐ๊ณผ | ํ๋จ |
|
| 443 |
+
|------|------|------|
|
| 444 |
+
| ์์
CF/์์ด์ต | 152% | โญ ์ด์ต์ ์ง ์ํธ |
|
| 445 |
+
| FCF | +1,200๋ฐฑ๋ง | โญ ์์ฒด ์๊ธ ์กฐ๋ฌ |
|
| 446 |
+
| Accrual Ratio | 3.1% | โญ ๋ฐ์์ฃผ์ ์ ์ |
|
| 447 |
+
|
| 448 |
+
### 5. ๋ฆฌ์คํฌ ์ ๊ฒ
|
| 449 |
+
- โญ ๊ฐ์ฌ์๊ฒฌ: ์ ์ 4๋
์ฐ์, ๊ฐ์ฌ์ธ ๊ต์ฒด ์์
|
| 450 |
+
- โญ ์ฐ๋ฐ๋ถ์ฑ: ์๊ธฐ์๋ณธ ๋๋น 2.1% (๋ฏธ๋ฏธ)
|
| 451 |
+
- โญ ํน์๊ด๊ณ์๊ฑฐ๋: ๋งค์ถ ๋๋น 1.3% (์ ์ ๋ฒ์)
|
| 452 |
+
- โณ ์์ฌ๋ฃ ๊ฐ๊ฒฉ ๋ณ๋: ๋งค์ถ์๊ฐ์จ ๊ฐ์ ์ด ์์ฌ๋ฃโ ์์กด โ ๋ฐ๋ฑ ์ ๋ง์ง ์๋ฐ
|
| 453 |
+
|
| 454 |
+
### 6. ๋ฐธ๋ฅ์์ด์
|
| 455 |
+
| ์งํ | ํ์ฌ | ์นํฐ ํ๊ท | ํ๋จ |
|
| 456 |
+
|------|------|-----------|------|
|
| 457 |
+
| PER | 12.5x | 15.2x | ํ ์ธ (17.8%) |
|
| 458 |
+
| PBR | 2.1x | 2.4x | ํ ์ธ (12.5%) |
|
| 459 |
+
| EV/EBITDA | 8.3x | 9.7x | ํ ์ธ (14.4%) |
|
| 460 |
+
|
| 461 |
+
โ ์์ต์ฑ ๋๋น ๋ฉํฐํ ํ ์ธ ์ํ. ์ฑ์ฅ ์ง์ ์ re-rating ์ฌ์ง.
|
| 462 |
+
|
| 463 |
+
### 7. ์๋๋ฆฌ์ค ๋ถ์
|
| 464 |
+
| ์๋๋ฆฌ์ค | ํต์ฌ ์ ์ | ์์ ์ํฅ |
|
| 465 |
+
|---------|-----------|-----------|
|
| 466 |
+
| **Base** | ๋งค์ถ +8%, OPM 15% ์ ์ง | ์์
์ด์ต +8%, EPS ์์ ์ฑ์ฅ |
|
| 467 |
+
| **Bull** | A๋ถ๋ฌธ +20%, ์์ฌ๋ฃโ ์ง์, ์ ์ฌ์
๊ธฐ์ฌ | OPM 17%+, ROE 25%+ |
|
| 468 |
+
| **Bear** | ์์ฌ๋ฃ +15%, A๋ถ๋ฌธ ๋ํ, ํ์จโ | OPM 11~12%, FCF ์ถ์ |
|
| 469 |
+
|
| 470 |
+
### ๊ฐ์ /์ฝ์ ๋งคํธ๋ฆญ์ค
|
| 471 |
+
| ๊ฐ์ | ์ฝ์ /์ฃผ์ |
|
| 472 |
+
|------|-----------|
|
| 473 |
+
| ์์ต์ฑ ์ฃผ๋ ROE 21% | ๋ง์ง ๊ฐ์ ์ด ์์ฌ๋ฃโ ์์กด |
|
| 474 |
+
| ์ด์ต์ ์ง ์ํธ (CF/NI 152%) | ์ด์ ์๋ณธ ์ฌ์ดํด ์ํญ ์
ํ |
|
| 475 |
+
| ๋ฎ์ ๋ถ์ฑ๋น์จ + FCF ์์ | ์
ํฉ ๋ณ๋ ๋
ธ์ถ |
|
| 476 |
+
| ์นํฐ ๋๋น ๋ฐธ๋ฅ์์ด์
ํ ์ธ | |
|
| 477 |
+
| R&D ํฌ์ ์ง์ (9.2%) | |
|
| 478 |
+
|
| 479 |
+
### ์ข
ํฉ ํ๋จ
|
| 480 |
+
**์์ต์ฑยท๊ฑด์ ์ฑยทํ๊ธํ๋ฆ ๋ชจ๋ ์ํธ**ํ ์ฐ๋ ๊ธฐ์
. ์นํฐ ๋๋น ๋ฐธ๋ฅ์์ด์
ํ ์ธ ์ํ๋ก ํฌ์ ๋งค๋ ฅ๋ ์ํธ.
|
| 481 |
+
ํฅํ ๋ชจ๋ํฐ๋ง: โ ์์ฌ๋ฃ ๊ฐ๊ฒฉ ๋ฐ๋ฑ ์ ๋ง์ง ์ํฅ โก์ด์ ์๋ณธ ์ฌ์ดํด ์ถ์ด โขA๋ถ๋ฌธ ์ฑ์ฅ ์ง์์ฑ โฃ๋ฐธ๋ฅ์์ด์
re-rating ์ด๋งค
|
| 482 |
+
""",
|
| 483 |
+
"์ํฐํจํด": """
|
| 484 |
+
## โ ๏ธ ๋์ ์์ (์ ๋ ๋ฐ๋ผํ์ง ๋ง์ธ์)
|
| 485 |
+
|
| 486 |
+
**์ํฐํจํด 1: ๋๊ตฌ ํธ์ถ ์์ด ์ผ๋ฐ ์ง์์ผ๋ก ๋ต๋ณ**
|
| 487 |
+
|
| 488 |
+
Q: ์ผ์ฑ์ ์ ๋งค์ถ ์ถ์ด๋?
|
| 489 |
+
A (๋์ ์): "์ผ์ฑ์ ์๋ ๋ฐ๋์ฒด์ ์ค๋งํธํฐ ์ฌ์
์ผ๋ก ๋งค์ถ ์ฝ 300์กฐ์ ๊ท๋ชจ์..."
|
| 490 |
+
โ โ ๋๊ตฌ๋ฅผ ํธ์ถํ์ง ์๊ณ ์ผ๋ฐ ์ง์์ผ๋ก ์์น๋ฅผ ์ฑ์. finance(action='data', module='IS') ํธ์ถ์ด ํ์.
|
| 491 |
+
|
| 492 |
+
**์ํฐํจํด 2: ํ ๋ฒ ์คํจํ๊ณ ํฌ๊ธฐ**
|
| 493 |
+
|
| 494 |
+
Q: ๋ถ๋ฌธ๋ณ ๋งค์ถ์?
|
| 495 |
+
A (๋์ ์): finance(data, module='segments') โ [๋ฐ์ดํฐ ์์] โ "๋ถ๋ฌธ๋ณ ๋งค์ถ ๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค."
|
| 496 |
+
โ โ ๋์ ์๋ ์์ด ํฌ๊ธฐ. explore(action='show', topic='segments')๋ก ๊ณต์ ์๋ฌธ ํ์ธ, explore(action='search', keyword='๋ถ๋ฌธ')์ผ๋ก ๊ฒ์, finance(action='modules')๋ก ๋ค๋ฅธ ๋ชจ๋ ํ์ธ ๋ฑ ๋์ ๊ฒฝ๋ก๋ฅผ ์๋ํด์ผ ํจ.
|
| 497 |
+
|
| 498 |
+
**์ฌ๋ฐ๋ฅธ ์คํจ ๋ณต๊ตฌ ์์:**
|
| 499 |
+
|
| 500 |
+
Q: ๋ฐฐ๋น 5๋
์น ๋ฐ์ดํฐ ๋ณด์ฌ์ค
|
| 501 |
+
A (์ข์ ์):
|
| 502 |
+
1. finance(action='report', apiType='dividend') โ 2๋
๋ง ์กด์ฌ
|
| 503 |
+
2. finance(action='data', module='CF') โ ๋ฐฐ๋น๊ธ ์ง๊ธ์ก 3๋
์น ํ์ธ
|
| 504 |
+
3. explore(action='show', topic='dividend') โ ๋ฐฐ๋น์ ์ฑ
์์ ํ์ธ
|
| 505 |
+
โ โญ 3๊ฐ ์์ค๋ฅผ ์ข
ํฉํ์ฌ 5๋
๋ฐฐ๋น ์ถ์ด ํ
์ด๋ธ ๊ตฌ์ฑ
|
| 506 |
+
""",
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
FEW_SHOT_COMPACT: dict[str, str] = {
|
| 510 |
+
"๊ฑด์ ์ฑ": (
|
| 511 |
+
"\n## ์์ (๊ฑด์ ์ฑ)\n"
|
| 512 |
+
"Q: ์ฌ๋ฌด ๊ฑด์ ์ฑ์?\n"
|
| 513 |
+
"A: **๋ถ์ฑ๋น์จ 45.2%(์ํธ)**, ์ ๋๋น์จ 185.3%, ์ด์๋ณด์๋ฐฐ์จ 10.5x.\n"
|
| 514 |
+
"DuPont: ROE 21% ์ค ๋ ๋ฒ๋ฆฌ์ง 2.5x๋ ์ ๋
ๆฏ ํ๋ฝ โ ์์ต์ฑ ์ฃผ๋ ROE(๊ฑด์ ).\n"
|
| 515 |
+
"์ด์ต์ ์ง: CF/NI 152%, Accrual 3.1% โ ๋ฐ์์ฃผ์ ์ ์.\n"
|
| 516 |
+
"์ด์ ์๋ณธ CCC 42โ45์ผ ์ํญ ์
ํ ๋ชจ๋ํฐ๋ง ํ์. **๊ฑด์ ์ฑ ์ํธ.**\n"
|
| 517 |
+
),
|
| 518 |
+
"์์ต์ฑ": (
|
| 519 |
+
"\n## ์์ (์์ต์ฑ)\n"
|
| 520 |
+
"Q: ์์ต์ฑ ๋ถ์ํด์ค\n"
|
| 521 |
+
"A: ์์
์ด์ต๋ฅ 13.9%โ**15.0%(โฒ1.1%p)**.\n"
|
| 522 |
+
"**์์ธ ๋ถํด**: ๋งค์ถ์๊ฐ์จ โผ2.3%p(์์ฌ๋ฃโ) > ํ๊ด๋น์จ โฒ1.2%p(์ธ๋ ฅ+R&D).\n"
|
| 523 |
+
"DuPont: ROE 21% = ์์ด์ต๋ฅ 10.5%รํ์ 0.8xร๋ ๋ฒ๋ฆฌ์ง 2.5x โ ์์ต์ฑ ์ฃผ๋.\n"
|
| 524 |
+
"CF/NI 152%, Accrual 3.1% โ ์ด์ต์ ์ง ์ํธ.\n"
|
| 525 |
+
"**์์ต์ฑ ์ฐ์.** ๋จ ์์ฌ๋ฃ ๋ฐ๋ฑ ์ ๋ง์ง 1~2%p ์๋ฐ ๊ฐ๋ฅ.\n"
|
| 526 |
+
),
|
| 527 |
+
"์ข
ํฉ": (
|
| 528 |
+
"\n## ์์ (์ข
ํฉ)\n"
|
| 529 |
+
"Q: ์ข
ํฉ ๋ถ์ํด์ค\n"
|
| 530 |
+
"A: **์์ต์ฑ**: OPM 15%(์๊ฐ๏ฟฝ๏ฟฝ๏ฟฝโ ์ฃผ๋), DuPont ROE 21%(์์ต์ฑ ์ฃผ๋) โ ์ํธ\n"
|
| 531 |
+
"**๊ฑด์ ์ฑ**: ๋ถ์ฑ๋น์จ 45%, ์ ๋๋น์จ 185%, ์ด์๋ณด์ 10.5x โ ์ํธ\n"
|
| 532 |
+
"**CF ํ์ง**: CF/NI 152%, Accrual 3.1%, FCF +1,200M โ ์ํธ\n"
|
| 533 |
+
"**๋ฆฌ์คํฌ**: ๊ฐ์ฌ ์ ์ , ์ฐ๋ฐ๋ถ์ฑ 2.1%, ํน์๊ด๊ณ 1.3% โ ์ํธ\n"
|
| 534 |
+
"**๋ฐธ๋ฅ์์ด์
**: PER 12.5x(์นํฐ 15.2x), PBR 2.1x โ ํ ์ธ ์ํ\n"
|
| 535 |
+
"**์๋๋ฆฌ์ค**: Base OPM 15%์ ์ง, Bull 17%+(์์ฌ๋ฃโ+์ ์ฌ์
), Bear 11%(์์ฌ๋ฃโ)\n"
|
| 536 |
+
"**๊ฐ์ **: ์์ต์ฑ ์ฃผ๋ ROE, ๋ฎ์ ๋ถ์ฑ, R&D 9.2%, ๋ฐธ๋ฅ์์ด์
ํ ์ธ\n"
|
| 537 |
+
"**์ฃผ์**: ์์ฌ๋ฃ ์์กด ๋ง์ง, CCC +3์ผ. **์ข
ํฉ: ์ฐ๋ ๊ธฐ์
.**\n"
|
| 538 |
+
),
|
| 539 |
+
"๋ฐฐ๋น": (
|
| 540 |
+
"\n## ์์ (๋ฐฐ๋น)\n"
|
| 541 |
+
"Q: ๋ฐฐ๋น ๋ถ์ํด์ค\n"
|
| 542 |
+
"A: | ์ฐ๋ | DPS | ์์ต๋ฅ | ์ฑํฅ |\n"
|
| 543 |
+
"|------|-----|--------|------|\n"
|
| 544 |
+
"| 2023 | 1,500์ | 2.8% | 35.7% |\n"
|
| 545 |
+
"| 2022 | 1,200์ | 2.5% | 33.3% |\n\n"
|
| 546 |
+
"DPS 3๋
์ฐ์โ, ์ฑํฅ 30~36% ์์ ๋ฒ์. FCF ์ถฉ๋ถ. "
|
| 547 |
+
"**์ฃผ์ฃผํ์ ์ํธ.**\n"
|
| 548 |
+
),
|
| 549 |
+
"์ง๋ฐฐ๊ตฌ์กฐ": (
|
| 550 |
+
"\n## ์์ (์ง๋ฐฐ๊ตฌ์กฐ)\n"
|
| 551 |
+
"Q: ์ง๋ฐฐ๊ตฌ์กฐ ๋ถ์ํด์ค\n"
|
| 552 |
+
"A: ์ต๋์ฃผ์ฃผ ์ง๋ถ 35.2% โ ๊ฒฝ์๊ถ ์์ . "
|
| 553 |
+
"์ฌ์ธ์ด์ฌ 3/8(37.5%) โ 1/3 ์๊ฑด ์ถฉ์กฑ. "
|
| 554 |
+
"๊ฐ์ฌ์๊ฒฌ ์ ์ 5๋
์ฐ์. **์ง๋ฐฐ๊ตฌ์กฐ ์ํธ.**\n"
|
| 555 |
+
),
|
| 556 |
+
}
|
| 557 |
+
|
| 558 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 559 |
+
# ์ง๋ฌธ ๋ถ๋ฅ ํค์๋ ๋งคํ
|
| 560 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 561 |
+
|
| 562 |
+
_CORE_QUESTION_KEYWORDS: dict[str, list[str]] = {
|
| 563 |
+
"๊ฑด์ ์ฑ": [
|
| 564 |
+
"๊ฑด์ ",
|
| 565 |
+
"์์ ",
|
| 566 |
+
"๋ถ์ฑ",
|
| 567 |
+
"์ ๋",
|
| 568 |
+
"์์ ",
|
| 569 |
+
"์ฌ๋ฌด์ํ",
|
| 570 |
+
"์ํ",
|
| 571 |
+
"๊ฑด๊ฐ",
|
| 572 |
+
"๋ถ์ค",
|
| 573 |
+
"์ง๊ธ๋ฅ๋ ฅ",
|
| 574 |
+
"์ ์ฉ",
|
| 575 |
+
"์ฑ๋ฌด",
|
| 576 |
+
"์๋ณธ์ ์ ",
|
| 577 |
+
"BIS",
|
| 578 |
+
"๋ ๋ฒ๋ฆฌ์ง",
|
| 579 |
+
"์ฐจ์
",
|
| 580 |
+
],
|
| 581 |
+
"์์ต์ฑ": [
|
| 582 |
+
"์์ต",
|
| 583 |
+
"์ด์ต๋ฅ ",
|
| 584 |
+
"๋ง์ง",
|
| 585 |
+
"ROE",
|
| 586 |
+
"ROA",
|
| 587 |
+
"์์
์ด์ต",
|
| 588 |
+
"์์ด์ต",
|
| 589 |
+
"EBITDA",
|
| 590 |
+
"๋ฒ",
|
| 591 |
+
"์ด์ค",
|
| 592 |
+
"์์ง",
|
| 593 |
+
"์๊ฐ",
|
| 594 |
+
"์๊ฐ์จ",
|
| 595 |
+
"๋งค์ถ์๊ฐ",
|
| 596 |
+
"ํ๊ด๋น",
|
| 597 |
+
"OPM",
|
| 598 |
+
"GPM",
|
| 599 |
+
"๋น๊ธฐ์์ด์ต",
|
| 600 |
+
],
|
| 601 |
+
"์ฑ์ฅ์ฑ": [
|
| 602 |
+
"์ฑ์ฅ",
|
| 603 |
+
"๋งค์ถ์ฆ๊ฐ",
|
| 604 |
+
"CAGR",
|
| 605 |
+
"์ ๋ง",
|
| 606 |
+
"๋ฏธ๋",
|
| 607 |
+
"๋งค์ถ",
|
| 608 |
+
"์ค์ ",
|
| 609 |
+
"์ถ์ธ",
|
| 610 |
+
"ํธ๋ ๋",
|
| 611 |
+
"์ถ์ด",
|
| 612 |
+
"์์ฅ์ ์ ",
|
| 613 |
+
"์์ฃผ",
|
| 614 |
+
"์์ฃผ์๊ณ ",
|
| 615 |
+
"๋ฐฑ๋ก๊ทธ",
|
| 616 |
+
"ํ์ดํ๋ผ์ธ",
|
| 617 |
+
],
|
| 618 |
+
"๋ฐฐ๋น": ["๋ฐฐ๋น", "DPS", "์ฃผ์ฃผํ์", "๋ฐฐ๋น์ฑํฅ", "๋ฐฐ๋น๋ฅ ", "๋ฐฐ๋น์์ต๋ฅ "],
|
| 619 |
+
"์ง๋ฐฐ๊ตฌ์กฐ": [
|
| 620 |
+
"์ง๋ฐฐ",
|
| 621 |
+
"์ฃผ์ฃผ",
|
| 622 |
+
"์ด์ฌ",
|
| 623 |
+
"๊ฐ์ฌ",
|
| 624 |
+
"๊ฒฝ์๊ถ",
|
| 625 |
+
"๊ฑฐ๋ฒ๋์ค",
|
| 626 |
+
"ESG",
|
| 627 |
+
"์ฌ์ธ์ด์ฌ",
|
| 628 |
+
"์์",
|
| 629 |
+
"์ด์ฌํ",
|
| 630 |
+
"๊ฐ์ฌ์์",
|
| 631 |
+
"๋ณด์",
|
| 632 |
+
"์คํก์ต์
",
|
| 633 |
+
],
|
| 634 |
+
"๋ฆฌ์คํฌ": [
|
| 635 |
+
"๋ฆฌ์คํฌ",
|
| 636 |
+
"์ํ",
|
| 637 |
+
"์ฐ๋ฐ",
|
| 638 |
+
"์์ก",
|
| 639 |
+
"์ ์ฌ",
|
| 640 |
+
"์ด์",
|
| 641 |
+
"์ ์ฌํํฉ",
|
| 642 |
+
"๋ณด์ฆ",
|
| 643 |
+
"ํ์",
|
| 644 |
+
"ํ์จ",
|
| 645 |
+
"๊ธ๋ฆฌ",
|
| 646 |
+
"์์์ฌ",
|
| 647 |
+
"์์ฌ๋ฃ",
|
| 648 |
+
"๊ณต๊ธ๋ง",
|
| 649 |
+
"supply",
|
| 650 |
+
"์ง์ ํ",
|
| 651 |
+
"๊ท์ ",
|
| 652 |
+
"์์กํํฉ",
|
| 653 |
+
"์ฐ๋ฐ์ฑ๋ฌด",
|
| 654 |
+
],
|
| 655 |
+
"ํฌ์": [
|
| 656 |
+
"ํฌ์",
|
| 657 |
+
"R&D",
|
| 658 |
+
"์ฐ๊ตฌ๊ฐ๋ฐ",
|
| 659 |
+
"์ค๋น",
|
| 660 |
+
"CAPEX",
|
| 661 |
+
"์ํ์ฌ",
|
| 662 |
+
"์ถ์",
|
| 663 |
+
"ํนํ",
|
| 664 |
+
"์ง์ฌ๊ถ",
|
| 665 |
+
"M&A",
|
| 666 |
+
"์ธ์",
|
| 667 |
+
"๋งค๊ฐ",
|
| 668 |
+
"ํฉ์",
|
| 669 |
+
],
|
| 670 |
+
"์ข
ํฉ": ["์ข
ํฉ", "์ ๋ฐ", "์ ์ฒด", "๋ถ์ํด", "์ด๋", "์ด๋ค๊ฐ", "์ข์๊ฐ", "๊ด์ฐฎ"],
|
| 671 |
+
"๊ณต์": [
|
| 672 |
+
"๊ณต์",
|
| 673 |
+
"์ฌ์
๋ณด๊ณ ์",
|
| 674 |
+
"์๋ฌธ",
|
| 675 |
+
"์น์
",
|
| 676 |
+
"section",
|
| 677 |
+
"topic",
|
| 678 |
+
"๋ณด์ฌ์ค",
|
| 679 |
+
"๋ณด์ฌ ์ค",
|
| 680 |
+
"์ฃผ์",
|
| 681 |
+
"notes",
|
| 682 |
+
"๊ฐ์ฃผ",
|
| 683 |
+
"ํ๊ณ์ ์ฑ
",
|
| 684 |
+
],
|
| 685 |
+
"์ฌ์
": [
|
| 686 |
+
"์ฌ์
",
|
| 687 |
+
"์์ฅ",
|
| 688 |
+
"๊ฒฝ์",
|
| 689 |
+
"์ ํ",
|
| 690 |
+
"์๋น์ค",
|
| 691 |
+
"์ ๋ต",
|
| 692 |
+
"ํ์จ",
|
| 693 |
+
"๊ณ์ฝ",
|
| 694 |
+
"๊ณ ๊ฐ",
|
| 695 |
+
"์ฌ์
๊ฐ์",
|
| 696 |
+
"๋ถ๋ฌธ",
|
| 697 |
+
"์ธ๊ทธ๋จผํธ",
|
| 698 |
+
"segment",
|
| 699 |
+
"์ฌ์
๋ถ",
|
| 700 |
+
"๋งค์ถ๊ตฌ์ฑ",
|
| 701 |
+
"๋งค์ถ๋น์ค",
|
| 702 |
+
"ํ๋ชฉ",
|
| 703 |
+
"์์ฌ๋ฃ",
|
| 704 |
+
"๊ณต๊ธ๋ง",
|
| 705 |
+
"์๊ฐ๊ตฌ์กฐ",
|
| 706 |
+
"๊ฐ์น์ฌ์ฌ",
|
| 707 |
+
"๋ฐธ๋ฅ์ฒด์ธ",
|
| 708 |
+
"๋น์ฆ๋์ค๋ชจ๋ธ",
|
| 709 |
+
"์ฌ์
๊ตฌ์กฐ",
|
| 710 |
+
],
|
| 711 |
+
"๊ด๊ณ์ฌ": [
|
| 712 |
+
"๊ด๊ณ์ฌ",
|
| 713 |
+
"๊ณ์ด์ฌ",
|
| 714 |
+
"์ํ์ฌ",
|
| 715 |
+
"ํน์๊ด๊ณ",
|
| 716 |
+
"affiliate",
|
| 717 |
+
"subsidiary",
|
| 718 |
+
"๊ด๊ณํ์ฌ",
|
| 719 |
+
"์ฐ๊ฒฐ๋์",
|
| 720 |
+
"์ง๋ถ๋ฒ",
|
| 721 |
+
],
|
| 722 |
+
"์๋ณธ": [
|
| 723 |
+
"์๋ณธ๊ธ",
|
| 724 |
+
"์ฆ์",
|
| 725 |
+
"๊ฐ์",
|
| 726 |
+
"์ ์์ฆ์",
|
| 727 |
+
"๋ฌด์์ฆ์",
|
| 728 |
+
"์๊ธฐ์ฃผ์",
|
| 729 |
+
"์์ฌ์ฃผ",
|
| 730 |
+
"์ ํ์ฌ์ฑ",
|
| 731 |
+
"CB",
|
| 732 |
+
"BW",
|
| 733 |
+
"์ ์ฃผ์ธ์๊ถ",
|
| 734 |
+
"์๋ณธ๋ณ๋",
|
| 735 |
+
"์ฃผ์๋ฐํ",
|
| 736 |
+
],
|
| 737 |
+
"์ธ๋ ฅ": [
|
| 738 |
+
"์ธ๋ ฅ",
|
| 739 |
+
"์ง์",
|
| 740 |
+
"์ข
์
์",
|
| 741 |
+
"๊ณ ์ฉ",
|
| 742 |
+
"์ธ์",
|
| 743 |
+
"์ฑ์ฉ",
|
| 744 |
+
"ํด์ง",
|
| 745 |
+
"์์๋ณด์",
|
| 746 |
+
"์คํก์ต์
",
|
| 747 |
+
"์ด์ฌ๋ณด์",
|
| 748 |
+
],
|
| 749 |
+
"ESG": [
|
| 750 |
+
"ESG",
|
| 751 |
+
"ํ๊ฒฝ",
|
| 752 |
+
"์ฌํ์ ์ฑ
์",
|
| 753 |
+
"ํ์",
|
| 754 |
+
"๊ธฐํ",
|
| 755 |
+
"ํ์๋ฐฐ์ถ",
|
| 756 |
+
"์นํ๊ฒฝ",
|
| 757 |
+
"์ง์๊ฐ๋ฅ",
|
| 758 |
+
"CSR",
|
| 759 |
+
"๋
น์",
|
| 760 |
+
"์จ์ค๊ฐ์ค",
|
| 761 |
+
"์๋์ง",
|
| 762 |
+
],
|
| 763 |
+
"๊ณต๊ธ๋ง": [
|
| 764 |
+
"๊ณต๊ธ๋ง",
|
| 765 |
+
"๊ณต๊ธ์ฌ",
|
| 766 |
+
"๊ณ ๊ฐ ์ง์ค",
|
| 767 |
+
"HHI",
|
| 768 |
+
"๊ณต๊ธ ๋ฆฌ์คํฌ",
|
| 769 |
+
"๊ฑฐ๋์ฒ",
|
| 770 |
+
"๋ฉํ",
|
| 771 |
+
"์กฐ๋ฌ",
|
| 772 |
+
"supply chain",
|
| 773 |
+
],
|
| 774 |
+
"๋ณํ": [
|
| 775 |
+
"๋ณํ ๊ฐ์ง",
|
| 776 |
+
"๋ฌด์์ด ๋ฌ๋ผ",
|
| 777 |
+
"๊ณต์ ๋ณ๊ฒฝ",
|
| 778 |
+
"๋ญ๊ฐ ๋ฐ๋",
|
| 779 |
+
"๋ฌ๋ผ์ง",
|
| 780 |
+
"๋ณ๊ฒฝ ์ฌํญ",
|
| 781 |
+
],
|
| 782 |
+
"๋ฐธ๋ฅ์์ด์
": [
|
| 783 |
+
"์ ์ ์ฃผ๊ฐ",
|
| 784 |
+
"๋ชฉํ๊ฐ",
|
| 785 |
+
"DCF",
|
| 786 |
+
"๋ฐธ๋ฅ์์ด์
",
|
| 787 |
+
"valuation",
|
| 788 |
+
"์ ํ๊ฐ",
|
| 789 |
+
"๊ณ ํ๊ฐ",
|
| 790 |
+
"๋ด์ฌ๊ฐ์น",
|
| 791 |
+
"fair value",
|
| 792 |
+
"DDM",
|
| 793 |
+
"ํ ์ธ",
|
| 794 |
+
],
|
| 795 |
+
}
|
| 796 |
+
|
| 797 |
+
|
| 798 |
+
def _buildQuestionTypeMap() -> dict[str, list[str]]:
|
| 799 |
+
"""core keywords + CapabilitySpec.questionTypes/ai_hint์์ ์๋ ์์งํ ํค์๋ ๋ณํฉ."""
|
| 800 |
+
try:
|
| 801 |
+
from dartlab.core.capabilities import get_capability_specs
|
| 802 |
+
|
| 803 |
+
autoKeywords: dict[str, set[str]] = {}
|
| 804 |
+
for spec in get_capability_specs():
|
| 805 |
+
for qt in spec.questionTypes:
|
| 806 |
+
if spec.ai_hint:
|
| 807 |
+
autoKeywords.setdefault(qt, set()).update(w.strip() for w in spec.ai_hint.split(",") if w.strip())
|
| 808 |
+
merged: dict[str, list[str]] = {}
|
| 809 |
+
for qt, coreKws in _CORE_QUESTION_KEYWORDS.items():
|
| 810 |
+
merged[qt] = list(set(coreKws) | autoKeywords.get(qt, set()))
|
| 811 |
+
for qt, kws in autoKeywords.items():
|
| 812 |
+
if qt not in merged:
|
| 813 |
+
merged[qt] = list(kws)
|
| 814 |
+
return merged
|
| 815 |
+
except ImportError:
|
| 816 |
+
return dict(_CORE_QUESTION_KEYWORDS)
|
| 817 |
+
|
| 818 |
+
|
| 819 |
+
QUESTION_TYPE_MAP: dict[str, list[str]] = _CORE_QUESTION_KEYWORDS
|
| 820 |
+
|
| 821 |
+
|
| 822 |
+
def refreshQuestionTypeMap() -> None:
|
| 823 |
+
"""๋๊ตฌ ๋ฑ๋ก ํ ํธ์ถํ์ฌ QUESTION_TYPE_MAP์ ๊ฐฑ์ ํ๋ค."""
|
| 824 |
+
global QUESTION_TYPE_MAP
|
| 825 |
+
QUESTION_TYPE_MAP = _buildQuestionTypeMap()
|
| 826 |
+
|
| 827 |
+
|
| 828 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 829 |
+
# ์ ๋ฌธ ๋ถ์๋ณด๊ณ ์ ๋ชจ๋ ํ๋กฌํํธ
|
| 830 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 831 |
+
|
| 832 |
+
REPORT_PROMPT = """
|
| 833 |
+
## ์ ๋ฌธ ๋ถ์๋ณด๊ณ ์ ๋ชจ๋
|
| 834 |
+
|
| 835 |
+
์๋ 9๊ฐ ์น์
๊ตฌ์กฐ๋ก ์ฒด๊ณ์ ๋ณด๊ณ ์๋ฅผ ์์ฑํ์ธ์. ๊ฐ ์น์
์์ ๋๊ตฌ๋ฅผ ์ ๊ทน ํธ์ถํ์ฌ ๋ฐ์ดํฐ๋ฅผ ์์งํฉ๋๋ค.
|
| 836 |
+
|
| 837 |
+
### 1. ๊ธฐ์
๊ฐ์
|
| 838 |
+
- ์ฌ์
์ค๋ช
, ํต์ฌ ์ ํ/์๋น์ค, ์์ฅ ํฌ์ง์
|
| 839 |
+
- explore(action='show', topic='businessOverview'), explore(action='show', topic='segments') ํ์ฉ
|
| 840 |
+
|
| 841 |
+
### 2. ์ฌ๋ฌด ๋ถ์
|
| 842 |
+
- ๋งค์ถ/์ด์ต 3~5๋
์ถ์ด + ์ธ๊ณผ ๋ถํด (๋ฌผ๋ร๋จ๊ฐร๋ฏน์ค)
|
| 843 |
+
- ์๊ฐ๊ตฌ์กฐ: ์๊ฐ์จ, ํ๊ด๋น์จ ์ถ์ด (explore(action='show', topic='costByNature'))
|
| 844 |
+
- DuPont ๋ถํด: ROE = ์์ด์ต๋ฅ ร ์์ฐํ์ ์จ ร ๋ ๋ฒ๋ฆฌ์ง
|
| 845 |
+
|
| 846 |
+
### 3. ์ด์ต์ ์ง & ํ๊ธํ๋ฆ
|
| 847 |
+
- ์์
CF/์์ด์ต ๋น์จ, Accrual Ratio
|
| 848 |
+
- ์ด์ ์๋ณธ ์ฌ์ดํด: DSO/DIO/DPO โ CCC ์ถ์ด
|
| 849 |
+
- FCF ์ถ์ด ๋ฐ ์๋ณธ ๋ฐฐ๋ถ (๋ฐฐ๋น, ์์ฌ์ฃผ, ํฌ์)
|
| 850 |
+
|
| 851 |
+
### 4. ์ฌ๋ฌด ๊ฑด์ ์ฑ
|
| 852 |
+
- ๋ถ์ฑ๋น์จ, ์ ๋๋น์จ, ์ด์๋ณด์๋ฐฐ์จ
|
| 853 |
+
- Altman Z-Score, Piotroski F-Score
|
| 854 |
+
- ์ฐจ์
๊ธ ๋ง๊ธฐ ๊ตฌ์กฐ (๊ฐ๋ฅ ์)
|
| 855 |
+
|
| 856 |
+
### 5. ์ฌ์
๋ฆฌ์คํฌ
|
| 857 |
+
- ์ ์ ์ ํธ ์ฒดํฌ ๊ฒฐ๊ณผ (๊ฐ์ฌ์ธ ๊ต์ฒด, ๋งค์ถ์ฑ๊ถ/์ฌ๊ณ ๊ธ์ฆ, CF<NI ๋ฑ)
|
| 858 |
+
- ์
์ข
ํนํ ๋ฆฌ์คํฌ (๋ฒค์น๋งํฌ ๊ธฐ์ค ๋๋น ๋ถ์)
|
| 859 |
+
- ์ฐ๋ฐ๋ถ์ฑ, ํน์๊ด๊ณ์๊ฑฐ๋ (explore(action='show', topic='contingentLiability'), explore(action='show', topic='relatedPartyTx'))
|
| 860 |
+
|
| 861 |
+
### 6. ๊ฒฝ์์ง & ์ง๋ฐฐ๊ตฌ์กฐ
|
| 862 |
+
- ์ต๋์ฃผ์ฃผ ์ง๋ถ์จ ๋ณ๋, ์ฌ์ธ์ด์ฌ ๋น์จ
|
| 863 |
+
- ๊ฐ์ฌ์๊ฒฌ ์ด๋ ฅ, ์์ ๋ณด์ ์์ค
|
| 864 |
+
- ๋ด๋ถํต์ (explore(action='show', topic='auditSystem'))
|
| 865 |
+
|
| 866 |
+
### 7. ๋ฐธ๋ฅ์์ด์
|
| 867 |
+
- **๋ฐธ๋ฅ์์ด์
์ข
ํฉ**: `analyze(action='valuation')` ํธ์ถ โ DCF/์๋๊ฐ์น ์ข
ํฉ ๋ฐธ๋ฅ์์ด์
|
| 868 |
+
- **๊ต์ฐจ๊ฒ์ฆ**: DCF vs ์๋๊ฐ์น ๊ดด๋ฆฌ ๋ถ์ (ยฑ30% ์ด๋ด๋ฉด ์ ๋ขฐ๋ ๋์)
|
| 869 |
+
- **ํ์ฌ๊ฐ ๋๋น ํ๋จ**: ์ ํ๊ฐ/์ ์ /๊ณ ํ๊ฐ + ์์ ๋ง์ง (%)
|
| 870 |
+
- โป ๊ตฌ์ฒด์ ๋ชฉํ์ฃผ๊ฐ ์ ์ ๊ธ์ง โ "์ ์ ๊ฐ์น ๋ฒ์" ํํ๋ก ์ ๊ณต
|
| 871 |
+
|
| 872 |
+
### 8. ์๋๋ฆฌ์ค ๋ถ์
|
| 873 |
+
- `analyze(action='valuation')` ๊ฒฐ๊ณผ ๊ธฐ๋ฐ Bull/Base/Bear 3๊ฐ ์๋๋ฆฌ์ค ๋ถ์
|
| 874 |
+
- **Base Case** (ํ์ฌ ์ถ์ธ ์ฐ์ฅ): ๋งค์ถ ์ฑ์ฅ๋ฅ ยท๋ง์ง ์ ์ง ์ ์์ ์ ์ ๊ฐ
|
| 875 |
+
- **Bull Case** (์ฑ์ฅ ๊ฐ์): ํต์ฌ ์ฑ์ฅ ๋๋ผ์ด๋ฒ + ๋ง์ง ํ๋ + ๋๊ด์ ํ ์ธ์จ
|
| 876 |
+
- **Bear Case** (๋ฆฌ์คํฌ ํ์คํ): ํต์ฌ ๋ฆฌ์คํฌ + ๋ง์ง ์์ถ + ๋ณด์์ ํ ์ธ์จ
|
| 877 |
+
- **ํ๋ฅ ๊ฐ์ค ์ ์ ๊ฐ์น**: Base 50% + Bull 25% + Bear 25%
|
| 878 |
+
- ํ์ ์ ๋ฏผ๊ฐ๋ ๋ถ์: WACC ร ์๊ตฌ์ฑ์ฅ๋ฅ ๋ณํ์ ๋ฐ๋ฅธ ์ ์ ๊ฐ์น ๋ฒ์ ์ ์
|
| 879 |
+
|
| 880 |
+
### 9. ์ข
ํฉ ํ๊ฐ
|
| 881 |
+
- **๊ฐ์ /์ฝ์ ๋งคํธ๋ฆญ์ค** (ํ๋ก ์ ๋ฆฌ)
|
| 882 |
+
- **ํฌ์ ํ๋จ ์์ฝ**: ๋ฐธ๋ฅ์์ด์
+ ์๋๋ฆฌ์ค + ์ด์ต์ ์ง ์ข
ํฉ
|
| 883 |
+
- **ํต์ฌ ๋ชจ๋ํฐ๋ง ํฌ์ธํธ** (ํฅํ 1๋
์ฃผ์ํ ๋ณ์ 3~5๊ฐ)
|
| 884 |
+
- **๊ฒฐ๋ก **: ํฌ์ ๋งค๋ ฅ๋์ ๋ฆฌ์คํฌ-๋ฆฌํด ํ๋กํ์ผ ํ์ค ์์ฝ
|
| 885 |
+
|
| 886 |
+
**๊ท์น**:
|
| 887 |
+
- ๋ชจ๋ ์์น์ ์ถ์ฒ(์ด๋ ์ฌ๋ฌด์ ํ/๊ณต์์ ์ด๋ ํญ๋ชฉ)๋ฅผ ๋ช
์
|
| 888 |
+
- ๋๊ตฌ(finance, explore, analyze ๋ฑ)๋ฅผ ์ ๊ทน ์ฌ์ฉํ์ฌ ๋ฐ์ดํฐ ์์ง ํ ๋ถ์
|
| 889 |
+
- ๋จ์ ๋์ด์ด ์๋ ์ธ๊ณผ ๋ถ์ + ๊ต์ฐจ๊ฒ์ฆ ์ํ
|
| 890 |
+
- ๋ฐธ๋ฅ์์ด์
๊ณผ ์๋๋ฆฌ์ค ๋ถ์ ์ ๊ตฌ์ฒด์ ์์น์ ๋
ผ๊ฑฐ๋ฅผ ์ ์
|
| 891 |
+
"""
|
| 892 |
+
|
| 893 |
+
REPORT_PROMPT_COMPACT = """
|
| 894 |
+
## ๋ณด๊ณ ์ ๋ชจ๋
|
| 895 |
+
9๊ฐ ์น์
์ผ๋ก ๊ตฌ์กฐํ: 1.๊ธฐ์
๊ฐ์ 2.์ฌ๋ฌด๋ถ์(DuPont+์ธ๊ณผ๋ถํด) 3.์ด์ต์์ง(CF/NI+Accrual+CCC) 4.์ฌ๋ฌด๊ฑด์ ์ฑ(Z-Score+F-Score) 5.๋ฆฌ์คํฌ(์ ์์ ํธ+์ฐ๋ฐ๋ถ์ฑ) 6.์ง๋ฐฐ๊ตฌ์กฐ(๊ฐ์ฌ+์์๋ณด์) 7.๋ฐธ๋ฅ์์ด์
(DCF+DDM+์๋๊ฐ์น+๊ต์ฐจ๊ฒ์ฆ) 8.์๋๋ฆฌ์ค(Base/Bull/Bear+ํ๋ฅ ๊ฐ์ค+๋ฏผ๊ฐ๋+๊ฒฝ์ ์๋ฎฌ๋ ์ด์
) 9.์ข
ํฉ(๊ฐ์ ์ฝ์ ํ+ํฌ์ํ๋จ+๋ชจ๋ํฐ๋ง)
|
| 896 |
+
์์น์ ์ถ์ฒ ๋ช
์. ๋๊ตฌ ์ ๊ทน ์ฌ์ฉ. ๋ฐธ๋ฅ์์ด์
์ analyze(action='valuation')๋ก ์ข
ํ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 ์๋ ๊ฐฑ์ ๋๊ณ ,
|
| 5 |
+
_meta.updated๋ก ๊ฐฑ์ ์์ ์ ์ถ์ ํ๋ค.
|
| 6 |
+
"""
|
| 7 |
+
|
| 8 |
+
from __future__ import annotations
|
| 9 |
+
|
| 10 |
+
BENCHMARK_DATA: dict[str, dict] = {
|
| 11 |
+
"๋ฐ๋์ฒด": {
|
| 12 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 13 |
+
"์งํ": {
|
| 14 |
+
"์์
์ด์ต๋ฅ ": {"good": 20, "normal_low": 10, "normal_high": 20, "unit": "%"},
|
| 15 |
+
"ROE": {"good": 15, "normal_low": 8, "normal_high": 15, "unit": "%"},
|
| 16 |
+
"R&D/๋งค์ถ": {"good": 15, "normal_low": 8, "normal_high": 15, "unit": "%"},
|
| 17 |
+
},
|
| 18 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 19 |
+
"**์ฌ์ดํด ์์น**: ์ฌ๊ณ ์ผ์ ์ถ์ธ๋ก ํ๋จ (์ฌ๊ณ ์ผ์โ = ๋ค์ด์ฌ์ดํด ์ง์
). 3-5๋
ํ๊ท ์ผ๋ก ์์ต์ฑ ํ๋จ",
|
| 20 |
+
"**CAPEX ๊ฐ๋**: CAPEX/๋งค์ถ 30%+ = ๊ณต๊ฒฉ์ ํฌ์๊ธฐ, ๋ค์ด์ฌ์ดํด ์ ๊ฐ๊ฐ์๊ฐ ๋ถ๋ด ๊ธ์ฆ",
|
| 21 |
+
"**๋ฉ๋ชจ๋ฆฌ vs ๋น๋ฉ๋ชจ๋ฆฌ**: segments์์ ๋ถ๋ฆฌ ํ์ธ. ๊ฐ๊ฒฉ ๋ณ๋์ฑ ํฌ๊ฒ ๋ค๋ฆ",
|
| 22 |
+
],
|
| 23 |
+
"ํ๊ณํจ์ ": [
|
| 24 |
+
"๊ฐ๊ฐ์๊ฐ๋น ๋น์ค ๋์ EBITDA์ ์์
์ด์ต ๊ดด๋ฆฌ ํผ. EBITDA ๊ธฐ์ค ๋ถ์ ๋ณํ ํ์",
|
| 25 |
+
],
|
| 26 |
+
"topicํ์ธ": [
|
| 27 |
+
"explore(action='show', topic='segments')",
|
| 28 |
+
"explore(action='show', topic='tangibleAsset')",
|
| 29 |
+
"explore(action='show', topic='rnd')",
|
| 30 |
+
],
|
| 31 |
+
},
|
| 32 |
+
"์ ์ฝ/๋ฐ์ด์ค": {
|
| 33 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 34 |
+
"์งํ": {
|
| 35 |
+
"์์
์ด์ต๋ฅ ": {"good": 15, "normal_low": 5, "normal_high": 15, "unit": "%", "note": "์ ์ ๊ฐ๋ฅ"},
|
| 36 |
+
"R&D/๋งค์ถ": {"good": 20, "normal_low": 10, "normal_high": 20, "unit": "%"},
|
| 37 |
+
},
|
| 38 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 39 |
+
"**ํ์ดํ๋ผ์ธ ๋จ๊ณ**: ๋ฐ์ด์คํ
์ ๋งค์ถ ์ ๋จ๊ณ์ผ ์ ์์ (์ ์ ์ ์). ์์ ๋จ๊ณ๊ฐ ํต์ฌ ๊ฐ์น",
|
| 40 |
+
"**๊ธฐ์ ์ด์ (L/O)**: ๋ง์ผ์คํค/๋ก์ดํฐ ์์ต์ ์ผํ์ฑ ํ๋จ. recurring ๋งค์ถ๊ณผ ๋ถ๋ฆฌ ๋ถ์",
|
| 41 |
+
"**R&D ์๋ณธํ**: ๊ฐ๋ฐ๋น ์๋ณธํ ๋น์จ ์์น ์ ์ค์ง ๋น์ฉ ๊ณผ์ ํ์ โ ๏ธ",
|
| 42 |
+
],
|
| 43 |
+
"ํ๊ณํจ์ ": [
|
| 44 |
+
"์์์คํจ ์ ์๋ณธํ๋ ๊ฐ๋ฐ๋น ์ผ์ ์๊ฐ โ ๋๊ท๋ชจ ์์ค. ๋ฌดํ์์ฐ ์ค ๊ฐ๋ฐ๋น ๋น์ค ํ์ธ",
|
| 45 |
+
],
|
| 46 |
+
"topicํ์ธ": [
|
| 47 |
+
"explore(action='show', topic='rnd')",
|
| 48 |
+
"explore(action='show', topic='productService')",
|
| 49 |
+
"explore(action='search', keyword='๊ฐ๋ฐ๋น')",
|
| 50 |
+
],
|
| 51 |
+
},
|
| 52 |
+
"๊ธ์ต/์ํ": {
|
| 53 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 54 |
+
"์งํ": {
|
| 55 |
+
"ROE": {"good": 10, "normal_low": 6, "normal_high": 10, "unit": "%"},
|
| 56 |
+
"NIM(์์ด์๋ง์ง)": {"good": 1.8, "normal_low": 1.4, "normal_high": 1.8, "unit": "%"},
|
| 57 |
+
"NPL๋น์จ": {"good": 0.5, "normal_low": 0.5, "normal_high": 1.5, "unit": "%", "invert": True},
|
| 58 |
+
"BIS์๊ธฐ์๋ณธ๋น์จ": {"good": 14, "normal_low": 10, "normal_high": 14, "unit": "%"},
|
| 59 |
+
},
|
| 60 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 61 |
+
"**๊ฑด์ ์ฑ ์งํ**: ์ผ๋ฐ ๋ถ์ฑ๋น์จ ๋์ BIS๋น์จ ์ฌ์ฉ. ๋์์ถฉ๋น๊ธ์ ์
๋ฅ ์ถ์ด = ์์ฐ๊ฑด์ ์ฑ ์ ํ์งํ",
|
| 62 |
+
"**์์ต ๊ตฌ์กฐ**: ์์ด์์ด์ต vs ๋น์ด์์ด์ต ๋น์ค. NIM ์ถ์ด๊ฐ ํต์ฌ ์์ต์ฑ ์งํ",
|
| 63 |
+
"**NPL ์ด๋**: ์ ์โ์์ฃผ์โ๊ณ ์ โํ์์๋ฌธโ์ถ์ ์์ค ์ด๋๋ฅ . ์์ฃผ์ ๊ธ์ฆ์ ๋ฏธ๋ ๋ถ์ค ์ ํ",
|
| 64 |
+
],
|
| 65 |
+
"ํ๊ณํจ์ ": [
|
| 66 |
+
"๋์์ถฉ๋น๊ธ ์ ๋ฆฝ๋ฅ ์กฐ์ ์ผ๋ก ์ด์ต ๊ด๋ฆฌ ๊ฐ๋ฅ. ์ถฉ๋น๊ธ/๋ถ์ค์ฑ๊ถ ๋น์จ ํ์ธ",
|
| 67 |
+
],
|
| 68 |
+
"topicํ์ธ": [
|
| 69 |
+
"explore(action='show', topic='riskFactor')",
|
| 70 |
+
"explore(action='search', keyword='๋์ถ')",
|
| 71 |
+
"explore(action='search', keyword='์ถฉ๋น๊ธ')",
|
| 72 |
+
],
|
| 73 |
+
},
|
| 74 |
+
"๊ธ์ต/๋ณดํ": {
|
| 75 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 76 |
+
"์งํ": {
|
| 77 |
+
"ROE": {"good": 10, "normal_low": 5, "normal_high": 10, "unit": "%"},
|
| 78 |
+
"์ํด์จ(์๋ณด)": {"good": 80, "normal_low": 80, "normal_high": 85, "unit": "%", "invert": True},
|
| 79 |
+
"ํฉ์ฐ๋น์จ(CR)": {"good": 100, "normal_low": 100, "normal_high": 105, "unit": "%", "invert": True},
|
| 80 |
+
},
|
| 81 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 82 |
+
"**K-ICS(2023~)**: ์ ์๋ณธ ์ ์ ์ฑ ๊ธฐ์ค. ๋ณดํ๋ถ์ฑ ์๊ฐํ๊ฐ ์ํฅ์ผ๋ก ์๋ณธ ๊ธ๋ณ๋ ๊ฐ๋ฅ",
|
| 83 |
+
"**์ํด์จ/ํฉ์ฐ๋น์จ**: CR > 100% = ๋ณดํ ์์
๋ง์ผ๋ก ์ด์ต ๋ถ๊ฐ, ํฌ์์์ต ์์กด",
|
| 84 |
+
],
|
| 85 |
+
"ํ๊ณํจ์ ": [
|
| 86 |
+
"IFRS 17 ๋์
(2023~)์ผ๋ก ๋ณดํ์์ต ์ธ์ ๊ธฐ์ค ๋ณ๊ฒฝ. ์ ๋
๋น๊ต ์ ์ฃผ์",
|
| 87 |
+
],
|
| 88 |
+
"topicํ์ธ": [],
|
| 89 |
+
},
|
| 90 |
+
"๊ธ์ต/์ฆ๊ถ": {
|
| 91 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 92 |
+
"์งํ": {
|
| 93 |
+
"ROE": {"good": 12, "normal_low": 6, "normal_high": 12, "unit": "%"},
|
| 94 |
+
"์์๋ณธ๋น์จ(NCR)": {"good": 300, "normal_low": 150, "normal_high": 300, "unit": "%"},
|
| 95 |
+
"ํ๊ด๋น/์์์
์์ต": {"good": 50, "normal_low": 50, "normal_high": 65, "unit": "%", "invert": True},
|
| 96 |
+
},
|
| 97 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 98 |
+
"**์์ต ๋ณ๋์ฑ**: ์์ฅ ๋ณ๋์ฑ์ ๋ฐ๋ฅธ ํธ๋ ์ด๋ฉ ์์ต ๊ธ๋ณ. ์์๋ฃ vs ์๊ธฐ๋งค๋งค ๋น์ค ๋ถ์",
|
| 99 |
+
"**IB ์์ต**: PF ๊ด๋ จ ์ฐ๋ฐ๋ถ์ฑ ๊ท๋ชจ ๋ฐ๋์ ํ์ธ. ๋ถ๋์ฐ PF ๋
ธ์ถ = ๊ฑด์ค์
๊ณผ ๋์ผ ๋ฆฌ์คํฌ",
|
| 100 |
+
],
|
| 101 |
+
"ํ๊ณํจ์ ": [
|
| 102 |
+
"ํ์์ํ ํ๊ฐ์์ต์ด ์์
์ด์ต์ ํฐ ์ํฅ. ์คํ vs ๋ฏธ์คํ ๊ตฌ๋ถ ํ์",
|
| 103 |
+
],
|
| 104 |
+
"topicํ์ธ": [],
|
| 105 |
+
},
|
| 106 |
+
"์๋์ฐจ": {
|
| 107 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 108 |
+
"์งํ": {
|
| 109 |
+
"์์
์ด์ต๋ฅ ": {"good": 8, "normal_low": 4, "normal_high": 8, "unit": "%"},
|
| 110 |
+
"ํ๋งค๋์ ์ฑ์ฅ๋ฅ ": {"good": 5, "normal_low": 0, "normal_high": 5, "unit": "%"},
|
| 111 |
+
"R&D/๋งค์ถ": {"good": 5, "normal_low": 3, "normal_high": 5, "unit": "%"},
|
| 112 |
+
},
|
| 113 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 114 |
+
"**ํ์จ ๋ฏผ๊ฐ๋**: ์์ถ ๋น์ค ๋์ ๊ธฐ์
์ ์/๋ฌ๋ฌ ํ์จ 10์ ๋ณ๋ ์ ์์
์ด์ต ์ํฅ ์ถ์ ",
|
| 115 |
+
"**์ ๊ธฐ์ฐจ ์ ํ**: ์ ๊ธฐ์ฐจ ๊ด๋ จ ํฌ์(CAPEX/R&D) ๋น์ค ํ์ธ. ์ ํ ํฌ์ ๋ถ๋ด vs ๋ฏธ๋ ์ฑ์ฅ",
|
| 116 |
+
"**์ธ์ผํฐ๋ธ**: ํ๋งค ๋ณด์กฐ๊ธ ์ฆ๊ฐ๋ ์์ ์ฝํ ์ ํธ. ๋ฏน์ค(๊ณ ๊ธ์ฐจ ๋น์ค) ๋ณํ ์ถ์ ",
|
| 117 |
+
],
|
| 118 |
+
"ํ๊ณํจ์ ": [],
|
| 119 |
+
"topicํ์ธ": [
|
| 120 |
+
"explore(action='show', topic='segments')",
|
| 121 |
+
"explore(action='show', topic='productService')",
|
| 122 |
+
"explore(action='show', topic='rawMaterial')",
|
| 123 |
+
],
|
| 124 |
+
},
|
| 125 |
+
"ํํ": {
|
| 126 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 127 |
+
"์งํ": {
|
| 128 |
+
"์์
์ด์ต๋ฅ ": {"good": 10, "normal_low": 5, "normal_high": 10, "unit": "%"},
|
| 129 |
+
"EBITDA๋ง์ง": {"good": 15, "normal_low": 8, "normal_high": 15, "unit": "%"},
|
| 130 |
+
},
|
| 131 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 132 |
+
"**์คํ๋ ๋**: ์ ํ๊ฐ - ์๋ฃ๊ฐ(๋ํํ) ์ถ์ด๊ฐ ํต์ฌ ์์ต์ฑ ์งํ. rawMaterial์์ ์๋ฃ๋น ํ์ธ",
|
| 133 |
+
"**์
์คํธ๋ฆผ/๋ค์ด์คํธ๋ฆผ**: ๋ค์ด์คํธ๋ฆผ์ผ์๋ก ์์ต ์์ . segments์์ ๋ถ๋ฌธ๋ณ ๋ง์ง ์ฐจ์ด ํ์ธ",
|
| 134 |
+
"**์ค๋น ํฌ์ ์ฌ์ดํด**: ๋๊ท๋ชจ ์ฆ์ค ์๋ฃ ์ ๊ฐ๊ฐ์๊ฐ ๋ถ๋ด ๊ธ์ฆ. CAPEX/๊ฐ๊ฐ์๊ฐ ์ถ์ด",
|
| 135 |
+
],
|
| 136 |
+
"ํ๊ณํจ์ ": [
|
| 137 |
+
"์ ๊ฐ ๊ธ๋ณ ์ ์ฌ๊ณ ํ๊ฐ ์์ต์ด ์์
์ด์ต์ ํฐ ์ํฅ (์ ์
์ ์ถ vs ๊ฐ์คํ๊ท )",
|
| 138 |
+
],
|
| 139 |
+
"topicํ์ธ": [],
|
| 140 |
+
},
|
| 141 |
+
"์ฒ ๊ฐ": {
|
| 142 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 143 |
+
"์งํ": {
|
| 144 |
+
"์์
์ด์ต๋ฅ ": {"good": 8, "normal_low": 3, "normal_high": 8, "unit": "%"},
|
| 145 |
+
"๋ถ์ฑ๋น์จ": {"good": 80, "normal_low": 80, "normal_high": 150, "unit": "%", "invert": True},
|
| 146 |
+
},
|
| 147 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 148 |
+
"**์์ฌ๋ฃ ์์กด**: ์ฒ ๊ด์ยท์ ์ฐํ ๊ฐ๊ฒฉ ๋ณ๋์ด ์ง์ ์๊ฐ์จ ๊ฒฐ์ . rawMaterial ํ์ธ",
|
| 149 |
+
"**์ค๊ตญ ๊ณต๊ธ๊ณผ์**: ์
ํฉ ํต์ฌ ๋ณ์. ์ค๊ตญ ์์ถ ์ฆ๊ฐ ์ ๊ฐ๊ฒฉ ํ๋ฝ ์๋ ฅ",
|
| 150 |
+
"**์ค๋น ๊ฐ๊ฐ์๊ฐ**: ๋๊ท๋ชจ ์ค๋น โ ๊ฐ๊ฐ์๊ฐ ๋ถ๋ด ํผ. EBITDA ๊ธฐ์ค ๋ถ์ ๋ณํ",
|
| 151 |
+
],
|
| 152 |
+
"ํ๊ณํจ์ ": [],
|
| 153 |
+
"topicํ์ธ": [],
|
| 154 |
+
},
|
| 155 |
+
"๊ฑด์ค": {
|
| 156 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 157 |
+
"์งํ": {
|
| 158 |
+
"์์
์ด์ต๋ฅ ": {"good": 5, "normal_low": 2, "normal_high": 5, "unit": "%"},
|
| 159 |
+
"์์ฃผ์๊ณ /๋งค์ถ": {"good": 3, "normal_low": 2, "normal_high": 3, "unit": "๋ฐฐ"},
|
| 160 |
+
"๋ถ์ฑ๋น์จ": {"good": 150, "normal_low": 150, "normal_high": 250, "unit": "%", "invert": True},
|
| 161 |
+
},
|
| 162 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 163 |
+
"**PF ์ฐ๋ฐ๋ถ์ฑ**: contingentLiability์์ PF ๋ณด์ฆ ๊ท๋ชจ ํ์ธ. ์๊ธฐ์๋ณธ ๋๋น 20% ์ด๊ณผ ์ โ ๏ธ",
|
| 164 |
+
"**๊ณต์ฌ๋ฏธ์๊ธ/์ ์๊ธ**: ๊ณต์ฌ๋ฏธ์๊ธ ๊ธ์ฆ = ๋๊ธ ํ์ ์ง์ฐ, ์ ์๊ธ ๊ฐ์ = ์์ฃผ ๋ํ ์ ํธ",
|
| 165 |
+
"**์งํ๋ฅ ์์ต์ธ์**: K-IFRS 15 ๊ธฐ์ค. ์๊ฐ์จ ๋ณ๋์ ๋ฐ๋ผ ๋งค์ถยท์ด์ต ๊ธ๋ณ๋ ๊ฐ๋ฅ",
|
| 166 |
+
],
|
| 167 |
+
"ํ๊ณํจ์ ": [
|
| 168 |
+
"๊ณต์ฌ์์ค์ถฉ๋น๋ถ์ฑ ๋ฏธ์ธ์ โ ํฅํ ์์ค ํญํ. ์งํ๋ฅ ์ฐ์ ๊ธฐ์ค ๋ณ๊ฒฝ ์ฃผ์",
|
| 169 |
+
],
|
| 170 |
+
"topicํ์ธ": [
|
| 171 |
+
"explore(action='show', topic='contingentLiability')",
|
| 172 |
+
"explore(action='show', topic='salesOrder')",
|
| 173 |
+
"explore(action='search', keyword='๊ณต์ฌ')",
|
| 174 |
+
],
|
| 175 |
+
},
|
| 176 |
+
"์ ํต": {
|
| 177 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 178 |
+
"์งํ": {
|
| 179 |
+
"์์
์ด์ต๋ฅ ": {"good": 5, "normal_low": 2, "normal_high": 5, "unit": "%"},
|
| 180 |
+
"์ฌ๊ณ ํ์ ์จ": {"good": 12, "normal_low": 6, "normal_high": 12, "unit": "ํ"},
|
| 181 |
+
"๋งค์ถ์ฑ์ฅ๋ฅ ": {"good": 5, "normal_low": 0, "normal_high": 5, "unit": "%"},
|
| 182 |
+
},
|
| 183 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 184 |
+
"**์ฑ๋ ์ ํ**: ์จ๋ผ์ธ ๋งค์ถ ๋น์ค ์ถ์ด. ์คํ๋ผ์ธ ์ ํฌ ํจ์จ์ฑ(์ ํฌ๋น ๋งค์ถ) ํ์ธ",
|
| 185 |
+
"**๋ฆฌ์ค๋ถ์ฑ**: IFRS 16 ์ ์ฉ์ผ๋ก ์์ฐจ ๊ด๋ จ ๋ถ์ฑ ๋ํญ ์ฆ๊ฐ. ์ค์ง ๋ถ์ฑ๋น์จ vs ํ๊ณ ๋ถ์ฑ๋น์จ ๊ตฌ๋ถ",
|
| 186 |
+
"**์ฌ๊ณ ๊ด๋ฆฌ**: ์ฌ๊ณ ํ์ ์จ ์
ํ = ์ฒดํ ์ฌ๊ณ ๋ฆฌ์คํฌ. ์ฌ๊ณ ์ผ์ ์ถ์ด ํ์ธ",
|
| 187 |
+
],
|
| 188 |
+
"ํ๊ณํจ์ ": [],
|
| 189 |
+
"topicํ์ธ": [],
|
| 190 |
+
},
|
| 191 |
+
"IT/์ํํธ์จ์ด": {
|
| 192 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 193 |
+
"์งํ": {
|
| 194 |
+
"์์
์ด์ต๋ฅ ": {"good": 15, "normal_low": 8, "normal_high": 15, "unit": "%"},
|
| 195 |
+
"๋งค์ถ์ฑ์ฅ๋ฅ (YoY)": {"good": 20, "normal_low": 10, "normal_high": 20, "unit": "%"},
|
| 196 |
+
"์ธ๊ฑด๋น/๋งค์ถ": {"good": 40, "normal_low": 40, "normal_high": 55, "unit": "%", "invert": True},
|
| 197 |
+
},
|
| 198 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 199 |
+
"**SaaS ๊ธฐ์
**: ARR(์ฐ๊ฐ๋ฐ๋ณต์์ต) ์ฑ์ฅ๋ฅ ๊ณผ ๊ณ ๊ฐ์ดํ๋ฅ ์ด ํต์ฌ. ๊ตฌ๋
๋งค์ถ ๋น์ค ์ถ์ ",
|
| 200 |
+
"**๊ณ ๊ฐ ์ง์ค๋**: ์์ ๊ณ ๊ฐ ๋งค์ถ ๋น์ค 30%+ โ ์์กด ๋ฆฌ์คํฌ. salesOrder ํ์ธ",
|
| 201 |
+
"**์ธ๋ ฅ ์์กด**: ์ธ๊ฑด๋น/๋งค์ถ ๋น์จ์ด ํต์ฌ ์๊ฐ. ์ธ๋ ฅ ์ฆ๊ฐ๊ณผ 1์ธ๋น ๋งค์ถ ์ถ์ด",
|
| 202 |
+
],
|
| 203 |
+
"ํ๊ณํจ์ ": [
|
| 204 |
+
"R&D ์๋ณธํ ๋น์จ ๋์ผ๋ฉด ์ค์ง ๋น์ฉ ๊ณผ์ ํ์. ๋ฌดํ์์ฐ ์ค ๊ฐ๋ฐ๋น ๋น์ค ํ์ธ",
|
| 205 |
+
],
|
| 206 |
+
"topicํ์ธ": [],
|
| 207 |
+
},
|
| 208 |
+
"ํต์ ": {
|
| 209 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 210 |
+
"์งํ": {
|
| 211 |
+
"EBITDA๋ง์ง": {"good": 35, "normal_low": 25, "normal_high": 35, "unit": "%"},
|
| 212 |
+
"๋ฐฐ๋น์์ต๋ฅ ": {"good": 5, "normal_low": 3, "normal_high": 5, "unit": "%"},
|
| 213 |
+
"๋ถ์ฑ๋น์จ": {"good": 100, "normal_low": 100, "normal_high": 150, "unit": "%", "invert": True},
|
| 214 |
+
},
|
| 215 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 216 |
+
"**ARPU**: ๊ฐ์
์๋น ๋งค์ถ ์ถ์ด๊ฐ ํต์ฌ KPI. 5G ๊ฐ์
์ ๋น์ค = ARPU ์์น ๋๋ ฅ",
|
| 217 |
+
"**์ค๋น ํฌ์**: 5G/์ธํ๋ผ ํฌ์ ๊ฐ๊ฐ์๊ฐ ๋ถ๋ด. CAPEX/๋งค์ถ ๋น์จ ์ถ์ด ํ์ธ",
|
| 218 |
+
"**๋ฐฐ๋น ์์ ์ฑ**: ์์ ์ ํ๊ธํ๋ฆ ๊ธฐ๋ฐ ๊ณ ๋ฐฐ๋น. FCF ๋๋น ๋ฐฐ๋น๊ธ ๋น์จ๋ก ์ง์๊ฐ๋ฅ์ฑ ํ๋จ",
|
| 219 |
+
],
|
| 220 |
+
"ํ๊ณํจ์ ": [],
|
| 221 |
+
"topicํ์ธ": [],
|
| 222 |
+
},
|
| 223 |
+
"์ ๋ ฅ/์๋์ง": {
|
| 224 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 225 |
+
"์งํ": {
|
| 226 |
+
"์์
์ด์ต๋ฅ ": {"good": 8, "normal_low": 3, "normal_high": 8, "unit": "%"},
|
| 227 |
+
"๋ถ์ฑ๋น์จ": {"good": 200, "normal_low": 200, "normal_high": 300, "unit": "%", "invert": True},
|
| 228 |
+
},
|
| 229 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 230 |
+
"**๊ท์ ์ฐ์
**: ์ ๊ธฐ์๊ธ ์ธ์/์ธํ๊ฐ ์์ต์ฑ ์ง๊ฒฐ. ์ ๋ถ ์ ์ฑ
๋ณ์ ํ์ธ",
|
| 231 |
+
"**์ฐ๋ฃ๋น ๋ณ๋**: ์ฐ๋ฃ๋น ์ฆ๊ฐ โ ๋ฏธ์๊ธ/๋ฏธ์ง๊ธ๊ธ ๋ณ๋์ผ๋ก BS์ ์ํฅ",
|
| 232 |
+
"**์ ์ฌ์ ์ ํ**: ์ ์ฌ์์๋์ง ํฌ์ ๋น์ค ์ถ์ด. ํ์ ๊ท์ ๋์ ๋น์ฉ ์ฆ๊ฐ",
|
| 233 |
+
],
|
| 234 |
+
"ํ๊ณํจ์ ": [],
|
| 235 |
+
"topicํ์ธ": [],
|
| 236 |
+
},
|
| 237 |
+
"์ํ": {
|
| 238 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 239 |
+
"์งํ": {
|
| 240 |
+
"์์
์ด์ต๋ฅ ": {"good": 8, "normal_low": 4, "normal_high": 8, "unit": "%"},
|
| 241 |
+
"ROE": {"good": 12, "normal_low": 6, "normal_high": 12, "unit": "%"},
|
| 242 |
+
"๋งค์ถ์ฑ์ฅ๋ฅ ": {"good": 5, "normal_low": 0, "normal_high": 5, "unit": "%"},
|
| 243 |
+
},
|
| 244 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 245 |
+
"**์์ฌ๋ฃ ๊ฐ๊ฒฉ**: ๊ณก๋ฌผยท์ ์ง ๊ฐ๊ฒฉ ๋ณ๋์ด ์ง์ ์๊ฐ์จ ๊ฒฐ์ . rawMaterial ํ์ธ",
|
| 246 |
+
"**๊ฐ๊ฒฉ ์ ๊ฐ๋ ฅ**: ๋ธ๋๋ ํ์์ ๋ฐ๋ผ ์๊ฐ ์์น๋ถ ํ๊ฐ ์ ๊ฐ ๊ฐ๋ฅ ์ฌ๋ถ ์ฐจ์ด",
|
| 247 |
+
"**ํด์ธ ๋น์ค**: ํด์ธ ๋งค์ถ ๋น์ค ์ฆ๊ฐ ์ถ์ด. ํ์จ ์ํฅ๊ณผ ์ฑ์ฅ ๊ธฐํ ๋์ ํ๊ฐ",
|
| 248 |
+
],
|
| 249 |
+
"ํ๊ณํจ์ ": [],
|
| 250 |
+
"topicํ์ธ": [],
|
| 251 |
+
},
|
| 252 |
+
"์ฌ์ /์๋ฅ": {
|
| 253 |
+
"_meta": {"updated": "2026-03", "source": "์
์ข
ํ๊ท ๊ธฐ๋ฐ"},
|
| 254 |
+
"์งํ": {
|
| 255 |
+
"์์
์ด์ต๋ฅ ": {"good": 10, "normal_low": 5, "normal_high": 10, "unit": "%"},
|
| 256 |
+
"์ฌ๊ณ ํ์ ์จ": {"good": 6, "normal_low": 3, "normal_high": 6, "unit": "ํ"},
|
| 257 |
+
},
|
| 258 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 259 |
+
"**์ฌ๊ณ ๊ด๋ฆฌ**: ์์ฆ์ฑ ์ํ์ด๋ฏ๋ก ์ฌ๊ณ ์์ง์จ์ด ํต์ฌ. ์ฌ๊ณ ์ผ์ ๊ธ์ฆ = ์ฒดํ ๋ฆฌ์คํฌ",
|
| 260 |
+
"**๋ธ๋๋ vs OEM**: ์์ฒด ๋ธ๋๋(๊ณ ๋ง์ง) vs OEM(์ ๋ง์ง) ๋งค์ถ ๋น์ค ๋ณํ ์ถ์ ",
|
| 261 |
+
"**ํ์จ**: ์์ถ ๋น์ค ๋์ ๊ธฐ์
์ ์ํ ์ฝ์ธ ์ ์์ถ ๊ฒฝ์๋ ฅโ, ์์ฌ๋ฃ ์์
๋น์ฉโ ๋์ ์ํฅ",
|
| 262 |
+
],
|
| 263 |
+
"ํ๊ณํจ์ ": [],
|
| 264 |
+
"topicํ์ธ": [],
|
| 265 |
+
},
|
| 266 |
+
"์ผ๋ฐ": {
|
| 267 |
+
"_meta": {"updated": "2026-03", "source": "์ผ๋ฐ ์ ์กฐ์
๊ธฐ์ค"},
|
| 268 |
+
"์งํ": {
|
| 269 |
+
"์์
์ด์ต๋ฅ ": {"good": 10, "normal_low": 5, "normal_high": 10, "unit": "%"},
|
| 270 |
+
"ROE": {"good": 12, "normal_low": 6, "normal_high": 12, "unit": "%"},
|
| 271 |
+
"๋ถ์ฑ๋น์จ": {"good": 100, "normal_low": 100, "normal_high": 200, "unit": "%", "invert": True},
|
| 272 |
+
"์ ๋๋น์จ": {"good": 150, "normal_low": 100, "normal_high": 150, "unit": "%"},
|
| 273 |
+
},
|
| 274 |
+
"๋ถ์ํฌ์ธํธ": [
|
| 275 |
+
"์
์ข
ํนํ ๋ฒค์น๋งํฌ๊ฐ ์์ผ๋ฏ๋ก ์ผ๋ฐ ์ ์กฐ์
๊ธฐ์ค ์ ์ฉ",
|
| 276 |
+
"์๊ฐ๊ตฌ์กฐ(costByNature)์ ๋ถ๋ฌธ๋ณ ์์ต์ฑ(segments)์ ์ง์ ์กฐํํ์ฌ ์
์ข
ํน์ฑ ํ์
๊ถ์ฅ",
|
| 277 |
+
],
|
| 278 |
+
"ํ๊ณํจ์ ": [],
|
| 279 |
+
"topicํ์ธ": [],
|
| 280 |
+
},
|
| 281 |
+
}
|
src/dartlab/ai/conversation/templates/benchmarks.py
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""์
์ข
๋ณ ๋ฒค์น๋งํฌ ๋ ๋๋ง + KRX ์
์ข
๋ช
๋งคํ.
|
| 2 |
+
|
| 3 |
+
๋ฐ์ดํฐ๋ benchmarkData.py (BENCHMARK_DATA dict)์ ๋ถ๋ฆฌ.
|
| 4 |
+
์ด ๋ชจ๋์ ๋ ๋๋ง๋ง ๋ด๋นํ๋ค.
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
from __future__ import annotations
|
| 8 |
+
|
| 9 |
+
from .benchmarkData import BENCHMARK_DATA
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
def render_benchmark(key: str) -> str:
|
| 13 |
+
"""BENCHMARK_DATA[key] โ ํ๋กฌํํธ์ฉ ๋งํฌ๋ค์ด ํ
์คํธ ๋ณํ."""
|
| 14 |
+
data = BENCHMARK_DATA.get(key)
|
| 15 |
+
if data is None:
|
| 16 |
+
return ""
|
| 17 |
+
|
| 18 |
+
display_name = key
|
| 19 |
+
lines: list[str] = [f"\n## {display_name} ์
์ข
๋ฒค์น๋งํฌ"]
|
| 20 |
+
|
| 21 |
+
# ์งํ ํ
์ด๋ธ
|
| 22 |
+
metrics = data.get("์งํ", {})
|
| 23 |
+
if metrics:
|
| 24 |
+
lines.append("| ์งํ | ์ฐ์ | ๋ณดํต | ์ฃผ์ |")
|
| 25 |
+
lines.append("|------|------|------|------|")
|
| 26 |
+
for name, spec in metrics.items():
|
| 27 |
+
unit = spec.get("unit", "")
|
| 28 |
+
inverted = spec.get("invert", False)
|
| 29 |
+
note = spec.get("note", "")
|
| 30 |
+
good = spec["good"]
|
| 31 |
+
low = spec["normal_low"]
|
| 32 |
+
high = spec["normal_high"]
|
| 33 |
+
|
| 34 |
+
if inverted:
|
| 35 |
+
good_str = f"< {good}{unit}"
|
| 36 |
+
normal_str = f"{low}-{high}{unit}"
|
| 37 |
+
bad_str = f"> {high}{unit}"
|
| 38 |
+
else:
|
| 39 |
+
good_str = f"> {good}{unit}"
|
| 40 |
+
normal_str = f"{low}-{high}{unit}"
|
| 41 |
+
bad_str = f"< {low}{unit}"
|
| 42 |
+
if note:
|
| 43 |
+
bad_str += f" ๋๋ {note}"
|
| 44 |
+
|
| 45 |
+
lines.append(f"| {name} | {good_str} | {normal_str} | {bad_str} |")
|
| 46 |
+
lines.append("")
|
| 47 |
+
|
| 48 |
+
# ๋ถ์ ํฌ์ธํธ
|
| 49 |
+
points = data.get("๋ถ์ํฌ์ธํธ", [])
|
| 50 |
+
if points:
|
| 51 |
+
lines.append(f"### {display_name} ํต์ฌ ๋ถ์ ํฌ์ธํธ")
|
| 52 |
+
for p in points:
|
| 53 |
+
lines.append(f"- {p}")
|
| 54 |
+
|
| 55 |
+
# ํ๊ณ ํจ์
|
| 56 |
+
traps = data.get("ํ๊ณํจ์ ", [])
|
| 57 |
+
if traps:
|
| 58 |
+
trap_label = "ํ๊ณ ํจ์ " if len(traps) > 1 else "ํ๊ณ ํจ์ "
|
| 59 |
+
lines.append(f"- **{trap_label}**: {traps[0]}")
|
| 60 |
+
for t in traps[1:]:
|
| 61 |
+
lines.append(f"- **ํ๊ณ ํจ์ **: {t}")
|
| 62 |
+
|
| 63 |
+
# topic ํ์ธ
|
| 64 |
+
topics = data.get("topicํ์ธ", [])
|
| 65 |
+
if topics:
|
| 66 |
+
lines.append(f"- **topic ํ์ธ**: {', '.join(topics)}")
|
| 67 |
+
|
| 68 |
+
return "\n".join(lines) + "\n"
|
| 69 |
+
|
| 70 |
+
|
| 71 |
+
# ๋ ๋๋ง ์บ์ โ ๊ธฐ์กด ์ฝ๋ ํธํ์ฉ
|
| 72 |
+
_INDUSTRY_BENCHMARKS: dict[str, str] = {key: render_benchmark(key) for key in BENCHMARK_DATA}
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
# KRX ์
์ข
๋ช
โ ๋ฒค์น๋งํฌ ํค ๋งคํ
|
| 76 |
+
_SECTOR_MAP: dict[str, str] = {
|
| 77 |
+
"๋ฐ๋์ฒด": "๋ฐ๋์ฒด",
|
| 78 |
+
"๋ฐ๋์ฒด์๋ฐ๋์ฒด์ฅ๋น": "๋ฐ๋์ฒด",
|
| 79 |
+
"๋์คํ๋ ์ด": "๋ฐ๋์ฒด",
|
| 80 |
+
"์ ์ฝ": "์ ์ฝ/๋ฐ์ด์ค",
|
| 81 |
+
"๋ฐ์ด์ค": "์ ์ฝ/๋ฐ์ด์ค",
|
| 82 |
+
"์์ฝํ": "์ ์ฝ/๋ฐ์ด์ค",
|
| 83 |
+
"์๋ฌผ๊ณตํ": "์ ์ฝ/๋ฐ์ด์ค",
|
| 84 |
+
"๊ฑด๊ฐ๊ด๋ฆฌ์ฅ๋น์์ฉํ": "์ ์ฝ/๋ฐ์ด์ค",
|
| 85 |
+
"์ํ": "๊ธ์ต/์ํ",
|
| 86 |
+
"์์ค์ํ": "๊ธ์ต/์ํ",
|
| 87 |
+
"์ง๋ฐฉ์ํ": "๊ธ์ต/์ํ",
|
| 88 |
+
"๋ณดํ": "๊ธ์ต/๋ณดํ",
|
| 89 |
+
"์๋ช
๋ณดํ": "๊ธ์ต/๋ณดํ",
|
| 90 |
+
"์ํด๋ณดํ": "๊ธ์ต/๋ณดํ",
|
| 91 |
+
"์ฆ๊ถ": "๊ธ์ต/์ฆ๊ถ",
|
| 92 |
+
"ํฌ์์ฆ๊ถ": "๊ธ์ต/์ฆ๊ถ",
|
| 93 |
+
"์๋ณธ์์ฅ": "๊ธ์ต/์ฆ๊ถ",
|
| 94 |
+
"์๋์ฐจ": "์๋์ฐจ",
|
| 95 |
+
"์๋์ฐจ๋ถํ": "์๋์ฐจ",
|
| 96 |
+
"ํํ": "ํํ",
|
| 97 |
+
"์์ ํํ": "ํํ",
|
| 98 |
+
"์ ์ ": "ํํ",
|
| 99 |
+
"์ฒ ๊ฐ": "์ฒ ๊ฐ",
|
| 100 |
+
"๋น์ฒ ๊ธ์": "์ฒ ๊ฐ",
|
| 101 |
+
"๊ธ์": "์ฒ ๊ฐ",
|
| 102 |
+
"๊ฑด์ค": "๊ฑด์ค",
|
| 103 |
+
"๊ฑด์ค์
": "๊ฑด์ค",
|
| 104 |
+
"์ฃผํ๊ฑด์ค": "๊ฑด์ค",
|
| 105 |
+
"์ ํต": "์ ํต",
|
| 106 |
+
"๋ฐฑํ์ ": "์ ํต",
|
| 107 |
+
"๋ํ๋งํธ": "์ ํต",
|
| 108 |
+
"ํธ์์ ": "์ ํต",
|
| 109 |
+
"์ํํธ์จ์ด": "IT/์ํํธ์จ์ด",
|
| 110 |
+
"IT์๋น์ค": "IT/์ํํธ์จ์ด",
|
| 111 |
+
"์ธํฐ๋ท": "IT/์ํํธ์จ์ด",
|
| 112 |
+
"๊ฒ์": "IT/์ํํธ์จ์ด",
|
| 113 |
+
"ํต์ ": "ํต์ ",
|
| 114 |
+
"๋ฌด์ ํต์ ": "ํต์ ",
|
| 115 |
+
"์ ์ ํต์ ": "ํต์ ",
|
| 116 |
+
"์ ๋ ฅ": "์ ๋ ฅ/์๋์ง",
|
| 117 |
+
"์๋์ง": "์ ๋ ฅ/์๋์ง",
|
| 118 |
+
"๊ฐ์ค": "์ ๋ ฅ/์๋์ง",
|
| 119 |
+
"์ํ": "์ํ",
|
| 120 |
+
"์๋ฃ": "์ํ",
|
| 121 |
+
"์๋ฃํ": "์ํ",
|
| 122 |
+
"์ฌ์ ": "์ฌ์ /์๋ฅ",
|
| 123 |
+
"์๋ฅ": "์ฌ์ /์๋ฅ",
|
| 124 |
+
"ํจ์
": "์ฌ์ /์๋ฅ",
|
| 125 |
+
}
|
src/dartlab/ai/conversation/templates/self_critique.py
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Self-Critique ํ๋กฌํํธ + Guided Generation ์คํค๋ง."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from typing import Any
|
| 6 |
+
|
| 7 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 8 |
+
# Self-Critique (2-pass ์๋ต ๊ฒํ )
|
| 9 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 10 |
+
|
| 11 |
+
SELF_CRITIQUE_PROMPT = """๋น์ ์ ์ฌ๋ฌด๋ถ์ ์๋ต์ ํ์ง ๊ฒํ ์์
๋๋ค.
|
| 12 |
+
์๋ ์๋ต์ ๋ค์ ๊ธฐ์ค์ผ๋ก ๊ฒํ ํ์ธ์.
|
| 13 |
+
|
| 14 |
+
## ๊ฒํ ๊ธฐ์ค
|
| 15 |
+
1. **๋ฐ์ดํฐ ์ ํฉ์ฑ**: ์ธ์ฉ๋ ์์น๊ฐ ์ ๊ณต๋ ๋ฐ์ดํฐ์ ์ผ์นํ๋๊ฐ?
|
| 16 |
+
2. **ํ
์ด๋ธ ์ฌ์ฉ**: ์์น 2๊ฐ ์ด์์ด๋ฉด ๋งํฌ๋ค์ด ํ
์ด๋ธ์ ์ฌ์ฉํ๋๊ฐ?
|
| 17 |
+
3. **ํด์ ์ ๊ณต**: ์ซ์๋ง ๋์ดํ์ง ์๊ณ "์?"์ "๊ทธ๋์?"๋ฅผ ์ค๋ช
ํ๋๊ฐ?
|
| 18 |
+
4. **์ถ์ฒ ๋ช
์**: ์์น ์ธ์ฉ ์ ํ
์ด๋ธ๋ช
๊ณผ ์ฐ๋๋ฅผ ํ๊ธฐํ๋๊ฐ?
|
| 19 |
+
5. **๊ฒฐ๋ก ์กด์ฌ**: ๋ช
ํํ ํ๋จ๊ณผ ๊ทผ๊ฑฐ ์์ฝ์ด ์๋๊ฐ?
|
| 20 |
+
|
| 21 |
+
## ์๋ต ํ์
|
| 22 |
+
๋ฌธ์ ๊ฐ ์์ผ๋ฉด "PASS"๋ง ์ถ๋ ฅํ์ธ์.
|
| 23 |
+
๋ฌธ์ ๊ฐ ์์ผ๋ฉด ์๋ ํ์์ผ๋ก ์์ ์ ์์ ์ถ๋ ฅํ์ธ์:
|
| 24 |
+
|
| 25 |
+
ISSUES:
|
| 26 |
+
- [๊ธฐ์ค๋ฒํธ] ๊ตฌ์ฒด์ ๋ฌธ์ ์ค๋ช
|
| 27 |
+
|
| 28 |
+
REVISED:
|
| 29 |
+
(์์ ๋ ์ ์ฒด ์๋ต)
|
| 30 |
+
"""
|
| 31 |
+
|
| 32 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 33 |
+
# Guided Generation โ JSON ๊ตฌ์กฐ ๊ฐ์ (Ollama)
|
| 34 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 35 |
+
|
| 36 |
+
GUIDED_SCHEMA: dict[str, Any] = {
|
| 37 |
+
"type": "object",
|
| 38 |
+
"properties": {
|
| 39 |
+
"summary": {
|
| 40 |
+
"type": "string",
|
| 41 |
+
"description": "ํต์ฌ ์์ฝ 1~2๋ฌธ์ฅ",
|
| 42 |
+
},
|
| 43 |
+
"metrics": {
|
| 44 |
+
"type": "array",
|
| 45 |
+
"description": "๋ถ์ ์งํ 3~8๊ฐ",
|
| 46 |
+
"items": {
|
| 47 |
+
"type": "object",
|
| 48 |
+
"properties": {
|
| 49 |
+
"name": {"type": "string", "description": "์งํ๋ช
"},
|
| 50 |
+
"value": {"type": "string", "description": "๊ฐ (์: 45.2%)"},
|
| 51 |
+
"year": {"type": "string", "description": "์ฐ๋"},
|
| 52 |
+
"trend": {"type": "string", "description": "ํ ๋จ์ด: ๊ฐ์ /์
ํ/์ ์ง/๊ธ๋ฑ/๊ธ๋ฝ"},
|
| 53 |
+
"assessment": {"type": "string", "description": "ํ ๋จ์ด: ์ํธ/์ฃผ์/์ํ/์ฐ์"},
|
| 54 |
+
},
|
| 55 |
+
"required": ["name", "value", "year", "trend", "assessment"],
|
| 56 |
+
},
|
| 57 |
+
},
|
| 58 |
+
"positives": {
|
| 59 |
+
"type": "array",
|
| 60 |
+
"description": "๊ธ์ ์ ํธ 1~3๊ฐ",
|
| 61 |
+
"items": {"type": "string"},
|
| 62 |
+
},
|
| 63 |
+
"risks": {
|
| 64 |
+
"type": "array",
|
| 65 |
+
"description": "๋ฆฌ์คํฌ 0~3๊ฐ",
|
| 66 |
+
"items": {
|
| 67 |
+
"type": "object",
|
| 68 |
+
"properties": {
|
| 69 |
+
"description": {"type": "string"},
|
| 70 |
+
"severity": {"type": "string", "description": "๋ฎ์/๋ณดํต/๋์"},
|
| 71 |
+
},
|
| 72 |
+
"required": ["description", "severity"],
|
| 73 |
+
},
|
| 74 |
+
},
|
| 75 |
+
"grade": {
|
| 76 |
+
"type": "string",
|
| 77 |
+
"description": "์ข
ํฉ ๋ฑ๊ธ (A+/A/B+/B/B-/C/D/F ๋๋ ์ํธ/๋ณดํต/์ฃผ์/์ํ)",
|
| 78 |
+
},
|
| 79 |
+
"conclusion": {
|
| 80 |
+
"type": "string",
|
| 81 |
+
"description": "๊ฒฐ๋ก 2~3๋ฌธ์ฅ, ๊ทผ๊ฑฐ ์์ฝ ํฌํจ",
|
| 82 |
+
},
|
| 83 |
+
},
|
| 84 |
+
"required": ["summary", "metrics", "positives", "risks", "grade", "conclusion"],
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 88 |
+
# ์๋ต ๋ฉํ๋ฐ์ดํฐ ์ถ์ถ ํจํด
|
| 89 |
+
# โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 90 |
+
|
| 91 |
+
SIGNAL_KEYWORDS = {
|
| 92 |
+
"positive": ["์ํธ", "์ฐ์", "์์ ", "๊ฐ์ ", "์ฑ์ฅ", "ํ์", "์ฆ๊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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""์์คํ
ํ๋กฌํํธ ๋ฒ ์ด์ค ํ
์คํธ (KR / EN / Compact)."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
SYSTEM_PROMPT_KR = """๋น์ ์ ํ๊ตญ ์์ฅ๊ธฐ์
์ฌ๋ฌด๋ถ์ ์ ๋ฌธ ์ ๋๋ฆฌ์คํธ์
๋๋ค.
|
| 6 |
+
DART(์ ์๊ณต์์์คํ
)์ ์ ๊ธฐ๋ณด๊ณ ์ยท์ฃผ์ยท๊ณต์ ๋ฐ์ดํฐ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๋ถ์ํฉ๋๋ค.
|
| 7 |
+
|
| 8 |
+
## ๋ฐ์ดํฐ ๊ตฌ์กฐ
|
| 9 |
+
|
| 10 |
+
์ด ๋ฐ์ดํฐ๋ DartLab์ด DART ์ ์๊ณต์์์ ์๋ ์ถ์ถํ K-IFRS ๊ธฐ์ค ๋ฐ์ดํฐ์
๋๋ค.
|
| 11 |
+
- ์ฌ๋ฌด์ ํ(BS/IS/CF)๋ `๊ณ์ ๋ช
` ์ปฌ๋ผ + ์ฐ๋๋ณ ๊ธ์ก ์ปฌ๋ผ ๊ตฌ์กฐ์
๋๋ค.
|
| 12 |
+
- ์ ๊ธฐ๋ณด๊ณ ์ ๋ฐ์ดํฐ๋ `year` ์ปฌ๋ผ + ์งํ ์ปฌ๋ผ ์๊ณ์ด ๊ตฌ์กฐ์
๋๋ค.
|
| 13 |
+
- ๋ชจ๋ ๊ธ์ก์ ๋ณ๋ ํ๊ธฐ ์์ผ๋ฉด **๋ฐฑ๋ง์** ๋จ์์
๋๋ค.
|
| 14 |
+
- ๋น์จ์ % ๋จ์์ด๋ฉฐ, "-"์ ๋ฐ์ดํฐ ์์ ๋๋ 0์
๋๋ค.
|
| 15 |
+
|
| 16 |
+
## ๋ฐ์ดํฐ ์ถ์ฒ ์ ๋ขฐ๋
|
| 17 |
+
|
| 18 |
+
์ด ๋ฐ์ดํฐ๋ DART/EDGAR ์๋ฌธ์์ ๊ธฐ๊ณ์ ์ผ๋ก ์ถ์ถยท์ ๊ทํํ ๊ฒ์
๋๋ค.
|
| 19 |
+
**์์ ๋ณด์ , ๋ฐ์ฌ๋ฆผ, ์ถ์ ๊ฐ์ด ํฌํจ๋์ด ์์ง ์์ต๋๋ค.**
|
| 20 |
+
|
| 21 |
+
| ์์ | ์์ค | ์ ๋ขฐ๋ | ์ค๋ช
|
|
| 22 |
+
|------|------|--------|------|
|
| 23 |
+
| 1 | finance | ์ต๊ณ | XBRL ๊ธฐ๋ฐ ์ ๊ทํ ์ฌ๋ฌด์ ํ. ์๋ณธ ์์น ๊ทธ๋๋ก |
|
| 24 |
+
| 2 | report | ๋์ | DART ์ ๊ธฐ๋ณด๊ณ ์ ์ ํ API (๋ฐฐ๋น, ์์, ๊ฐ์ฌ ๋ฑ) |
|
| 25 |
+
| 3 | explore/sections | ์์ ํ | ๊ณต์ ์๋ฌธ ํ
์คํธ. ์์น ํฌํจ ์ finance์ ๊ต์ฐจ๊ฒ์ฆ ํ์ |
|
| 26 |
+
| 4 | analyze | ํ์ | finance+explore ์์์ ๊ณ์ฐํ ๋ฑ๊ธ/์ ์. ๊ทผ๊ฑฐ ํ์ธ ๊ถ์ฅ |
|
| 27 |
+
| 5 | market | ์ธ๋ถ | Naver Finance ๋ฑ ์ธ๋ถ ์์ค. ์ค์๊ฐ ์๋, ์์ ์ฐจ์ด ๊ฐ๋ฅ |
|
| 28 |
+
|
| 29 |
+
**์์ถฉ ์**: finance ์์น โ explore ํ
์คํธ์ ์์น โ **finance๋ฅผ ์ ๋ขฐ**ํ์ธ์.
|
| 30 |
+
|
| 31 |
+
## K-IFRS ํน์ด์ฌํญ
|
| 32 |
+
- ๊ธฐ๋ณธ ๋ฐ์ดํฐ๋ **์ฐ๊ฒฐ์ฌ๋ฌด์ ํ** ๊ธฐ์ค. ์ง๋ฐฐ๊ธฐ์
๊ท์ ๋น๊ธฐ์์ด์ต์ด ROE ๋ถ์
|
| 33 |
+
- K-IFRS ์์
์ด์ต ์ ์๋ ๊ธฐ์
๋ง๋ค ๋ค๋ฅผ ์ ์์ (๊ธฐํ์์
์์ต/๋น์ฉ ํฌํจ ์ฌ๋ถ)
|
| 34 |
+
- IFRS 16(2019~): ์ด์ฉ๋ฆฌ์ค๊ฐ ์์ฐ/๋ถ์ฑ์ ์ธ์ โ ๋ถ์ฑ๋น์จ ๊ธ๋ฑ ๊ฐ๋ฅ
|
| 35 |
+
- ์์
CF > ์์ด์ต์ด๋ฉด ์ด์ต์ ์ง ์ํธ, ํฌ์CF ์(-)์ ์ ์(์ฑ์ฅ ํฌ์)
|
| 36 |
+
|
| 37 |
+
## ํต์ฌ ์ฌ๋ฌด๋น์จ ๋ฒค์น๋งํฌ
|
| 38 |
+
|
| 39 |
+
| ๋น์จ | ์ํธ | ์ฃผ์ | ์ํ |
|
| 40 |
+
|------|------|------|------|
|
| 41 |
+
| ๋ถ์ฑ๋น์จ (๋ถ์ฑ/์๋ณธ) | < 100% | 100-200% | > 200% |
|
| 42 |
+
| ์ ๋๋น์จ (์ ๋์์ฐ/์ ๋๋ถ์ฑ) | > 150% | 100-150% | < 100% |
|
| 43 |
+
| ์์
์ด์ต๋ฅ | ์
์ข
๋ณ ์์ด | ์ ๋
๋๋น ํ๋ฝ | ์ ์ ์ ํ |
|
| 44 |
+
| ROE | > 10% | 5-10% | < 5% |
|
| 45 |
+
| ์ด์๋ณด์๋ฐฐ์จ (์์
์ด์ต/์ด์๋น์ฉ) | > 5x | 1-5x | < 1x |
|
| 46 |
+
| ๋ฐฐ๋น์ฑํฅ | 30-50% | 50-80% | > 100% |
|
| 47 |
+
|
| 48 |
+
## ์ ๋ฌธ๊ฐ ๋ถ์ ํ๋ ์์ํฌ (7๋จ๊ณ)
|
| 49 |
+
|
| 50 |
+
**๋ชจ๋ ๋ถ์์ ๋ฐ๋์ ๋ค์ 7๋จ๊ณ๋ฅผ ๊ฑฐ์น์ธ์:**
|
| 51 |
+
|
| 52 |
+
1. **์์น ํ์ธ + ์ ๊ทํ** โ ํต์ฌ ์์น๋ฅผ ์ถ์ถํ๊ณ ์ถ์ฒ(ํ
์ด๋ธ๋ช
, ์ฐ๋)๋ฅผ ๊ธฐ๋ก. ๋ถ๋ถ์ฐ๋(~Q3) ๋ฐ์ดํฐ๋ ์ฐํ์ฐํ์ง ๋ง๊ณ ๋ช
์. ์ผํ์ฑ ํญ๋ชฉ(์์ฐ์ฒ๋ถ์ด์ต, ๋ณดํ๊ธ ๋ฑ)์ ๋ถ๋ฆฌํ์ฌ recurring ๊ธฐ์ค ํ๋จ.
|
| 53 |
+
2. **์ธ๊ณผ ๋ถํด** โ "๋งค์ถ ์ฆ๊ฐ"์ ๊ทธ์น์ง ๋ง๊ณ ๋ฐ๋์ ๋ถํด: ๋งค์ถ=๋ฌผ๋ร๋จ๊ฐร๋ฏน์ค(segments/productService ํ์ธ), ์ด์ต๋ฅ =์๊ฐ์จ(๋งค์ถ์๊ฐ/๋งค์ถ)+ํ๊ด๋น์จ(ํ๊ด๋น/๋งค์ถ) ๊ฐ๊ฐ ์ถ์ . **"์?"๋ฅผ ๋ฐ๋์ ๋ตํ์ธ์.**
|
| 54 |
+
3. **์ด์ต์ ์ง ๋ถ์** โ CF/NI ๋น์จ(โฅ100% ์ํธ, <50% ์ฃผ์)์ ๋ํด: Accrual Ratio=(์์ด์ต-์์
CF)/ํ๊ท ์์ฐ(>10%๋ฉด ๋ฐ์์ฃผ์ ๊ณผ๋ ์์ฌ), ์ด์ ์๋ณธ ์ฌ์ดํด(๋งค์ถ์ฑ๊ถ์ผ์+์ฌ๊ณ ์ผ์-๋งค์
์ฑ๋ฌด์ผ์) ์ถ์ด ํ์ธ.
|
| 55 |
+
4. **๊ต์ฐจ๊ฒ์ฆ + ์ ์์ ํธ** โ DuPont ๋ถํด(ROE=์์ด์ต๋ฅ ร์์ฐํ์ ์จร๋ ๋ฒ๋ฆฌ์ง)๋ก ROE ๋์ธ ์๋ณ. ๋ถ๋ฌธํฉ์ฐ vs ์ฐ๊ฒฐ ์ผ๊ด์ฑ ํ์ธ. ์๋ ์ ์ ์ ํธ ์ฒดํฌ๋ฆฌ์คํธ ์ ์ฉ.
|
| 56 |
+
5. **์ ๋ต์ ํฌ์ง์
๋** โ ๋ถ๋ฌธ๋ณ ์์ฅ์์น(segments), ๊ฒฝ์์ฐ์ ์งํ(R&D ๊ฐ๋, ๋ง์ง ํ๋ฆฌ๋ฏธ์, ๊ณ ๊ฐ์ง์ค๋), ์๋ณธ๋ฐฐ๋ถ ํจ์จ(CAPEX vs ๊ฐ๊ฐ์๊ฐ ๋น์จ).
|
| 57 |
+
6. **๊ฒฝ์์ง ํ์ง ์ ํธ** โ ์์ ๋ณด์ vs ์ค์ ๊ถค์ , ๊ฐ์ฌ์๊ฒฌ ๋ณํ, ๋ด๋ถํต์ ์ทจ์ฝ์ , ์ต๋์ฃผ์ฃผ ์ง๋ถ ๋ณ๋.
|
| 58 |
+
7. **์ข
ํฉ ํ๋จ + ์๊ธฐ๊ฒ์ฆ** โ ๊ฐ์ /์ฝ์ ์ ๋ฆฌ, Bull/Bear ๋
ผ๊ฑฐ ์ ์, ๋ชจ๋ํฐ๋ง ํฌ์ธํธ ๋ช
์. ์ธ์ฉ ์์น๋ฅผ ๋ฐ์ดํฐ์์ ์ฌํ์ธ.
|
| 59 |
+
|
| 60 |
+
## ์ ์ ์ ํธ ์ฒดํฌ๋ฆฌ์คํธ
|
| 61 |
+
|
| 62 |
+
๋ค์ ํจํด์ด ๋ฐ๊ฒฌ๋๋ฉด ๋ฐ๋์ โ ๏ธ ๊ฒฝ๊ณ ํ์ธ์:
|
| 63 |
+
- ๊ฐ์ฌ์ธ ๊ต์ฒด (ํนํ Big4 โ ์ค์)
|
| 64 |
+
- ํน์๊ด๊ณ์๊ฑฐ๋ ์ฆ๊ฐ์จ > ๋งค์ถ์ฆ๊ฐ์จ
|
| 65 |
+
- ์์
๊ถ/๋ฌดํ์์ฐ ๋น์ค ๊ธ์ฆ (์ธ์ ๋ฆฌ์คํฌ)
|
| 66 |
+
- R&D ์๋ณธํ ๋น์จ ์์น (๋น์ฉ ๊ณผ์ ํ์ ๊ฐ๋ฅ)
|
| 67 |
+
- ๋งค์ถ์ฑ๊ถ ์ฆ๊ฐ์จ >> ๋งค์ถ ์ฆ๊ฐ์จ (์ฑ๊ถ ๋ถ์คํ ์ ํธ)
|
| 68 |
+
- ์ฌ๊ณ ์์ฐ ์ฆ๊ฐ์จ >> ๋งค์ถ์๊ฐ ์ฆ๊ฐ์จ (์ฌ๊ณ ๋ถ์คํ ์ ํธ)
|
| 69 |
+
- 3๋
์ฐ์ ์์
CF < ์์ด์ต (๋ฐ์์ฃผ์ ์ด์ต ์์ฌ)
|
| 70 |
+
- ์ ๋๋น์จ < 100% + ๋จ๊ธฐ์ฐจ์
๊ธ ๊ธ์ฆ (์ ๋์ฑ ์๊ธฐ)
|
| 71 |
+
|
| 72 |
+
## ๋ถ์ ๊ท์น
|
| 73 |
+
|
| 74 |
+
1. ์ ๊ณต๋ ๋ฐ์ดํฐ์๋ง ๊ธฐ๋ฐํ์ฌ ๋ต๋ณํ์ธ์. ์ธ๋ถ ์ง์์ผ๋ก ๋ณด์ถฉํ์ง ๋ง์ธ์.
|
| 75 |
+
2. ์ซ์๋ฅผ ์ธ์ฉํ ๋ ๋ฐ๋์ ์ถ์ฒ ํ
์ด๋ธ๊ณผ ์ฐ๋๋ฅผ ๋ช
์ํ์ธ์. (์: "IS 2024: ๋งค์ถ์ก 1,234๋ฐฑ๋ง์")
|
| 76 |
+
3. ์ถ์ธ ๋ถ์ ์ ์ต๊ทผ 3~5๋
ํ๋ฆ์ ์์น์ ํจ๊ป ์ธ๊ธํ์ธ์.
|
| 77 |
+
4. ๊ธ์ /๋ถ์ ์ ํธ๋ฅผ ๋ชจ๋ ๊ท ํ ์๊ฒ ์ ์ํ์ธ์.
|
| 78 |
+
5. ์ด์ ์งํ(๊ธ๊ฒฉํ ๋ณ๋, ๋น์ ์ ํจํด)๊ฐ ์์ผ๋ฉด ๋ช
ํํ ์ง์ ํ์ธ์.
|
| 79 |
+
6. "์ฃผ์ ์งํ (์๋๊ณ์ฐ)" ์น์
์ด ์์ผ๋ฉด ํ์ฉํ๋, ์๋ณธ ํ
์ด๋ธ๋ก ์ง์ ๊ฒ์ฆํ์ธ์.
|
| 80 |
+
7. ์ ๊ณต๋์ง ์์ ๋ฐ์ดํฐ์ ๋ํด์๋ง "ํด๋น ๋ฐ์ดํฐ ๋ฏธํฌํจ"์ผ๋ก ํ์ํ์ธ์. ์ด๋ฏธ ํฌํจ๋ ๋ชจ๋์ด ์์ผ๋ฉด "๋ฐ์ดํฐ ์์"์ด๋ผ๊ณ ๋งํ์ง ๋ง์ธ์.
|
| 81 |
+
8. ๊ฒฐ๋ก ์์ ๊ทผ๊ฑฐ ๋ฐ์ดํฐ๋ฅผ ๋ฐ๋์ ์์ฝํ์ธ์.
|
| 82 |
+
9. **[ํ์] ํ๊ตญ์ด ์ง๋ฌธ์๋ ๋ฐ๋์ ํ๊ตญ์ด๋ก๋ง ๋ต๋ณํ์ธ์.** ๋๊ตฌ ๊ฒฐ๊ณผ๊ฐ ์์ด์ฌ๋ ๋ต๋ณ์ ํ๊ตญ์ด๋ก ์์ฑํ์ธ์. ์์ด ์ง๋ฌธ์ด๋ฉด ์์ด๋ก ๋ต๋ณ.
|
| 83 |
+
10. **ํ
์ด๋ธ ํ์**: ์์น๊ฐ 2๊ฐ ์ด์ ๋ฑ์ฅํ๋ฉด ๋ฐ๋์ ๋งํฌ๋ค์ด ํ
์ด๋ธ(|ํ)๋ก ์ ๋ฆฌํ์ธ์. ์๊ณ์ด, ๋น๊ต, ๋น์จ ๋ถ์์๋ ์์ธ ์์ด ํ
์ด๋ธ์ ์ฌ์ฉํ์ธ์.
|
| 84 |
+
11. **๋ฐ์ดํฐ ์ฐ๋ ๊ท์น**: "๋ฐ์ดํฐ ๊ธฐ์ค" ํค๋์ ์ปฌ๋ผ ํค๋๋ฅผ ํ์ธํ์ธ์. "(~Q3)" ๊ฐ์ ํ์๊ฐ ์์ผ๋ฉด ํด๋น ์ฐ๋๋ **๋ถ๋ถ ๋ฐ์ดํฐ**(ํด๋น ๋ถ๊ธฐ๊น์ง ๋์ )์
๋๋ค. ๋ถ๋ถ ์ฐ๋์ ์์ ์ฐ๋(4๋ถ๊ธฐ)๋ฅผ ์ง์ ๋น๊ตํ๋ฉด ์ ๋ฉ๋๋ค. ์: "2025(~Q3)" ๋งค์ถ 180์กฐ vs "2024" ๋งค์ถ 240์กฐ โ "-25%"๊ฐ ์๋๋ผ "3๋ถ๊ธฐ ๋์ ์ด๋ฏ๋ก ์ฐ๊ฐ ์ง์ ๋น๊ต ๋ถ๊ฐ"๋ก ๋ตํ์ธ์. ๋ฐ์ดํฐ์ ์๋ ์ฐ๋์ ์์น๋ฅผ ์ถ์ธกํ์ง ๋ง์ธ์.
|
| 85 |
+
12. "์ถ๊ฐ ์กฐํ ๊ฐ๋ฅํ ๋ฐ์ดํฐ" ์น์
์ ๋์ด๋ ๋ชจ๋์ด ๋ถ์์ ๋์์ด ๋๋ฉด, `finance(action='data', module='...')` ๋๊ตฌ๋ก ์ถ๊ฐ ์กฐํํ์ธ์.
|
| 86 |
+
13. **์๋ณธ ๋ณต์ฌ ๊ธ์ง, ๋ถ์ ํ
์ด๋ธ ๊ตฌ์ฑ ํ์.** ์๋ณธ ๋ฐ์ดํฐ๋ฅผ ๊ทธ๋๋ก ์ฎ๊ธฐ์ง ๋ง์ธ์ โ ์ฌ์ฉ์๋ ์ฐธ๊ณ ๋ฐ์ดํฐ ๋ฑ์ง๋ก ์๋ณธ์ ๋ณผ ์ ์์ต๋๋ค. ๋์ ํต์ฌ ์์น๋ฅผ ๋ฝ์์ "ํ๋จ", "์ ๋
๋น", "๋ฑ๊ธ", "์ถ์ธ" ๊ฐ์ **ํด์ ์ปฌ๋ผ์ ์ถ๊ฐํ ๋ถ์ ํ
์ด๋ธ**์ ์ง์ ๊ตฌ์ฑํ์ธ์. ํ
์คํธ๋ก ์์น๋ฅผ ๋์ดํ๋ ๊ฒ๋ณด๋ค ํ
์ด๋ธ์ด ํญ์ ์ฐ์ ํฉ๋๋ค.
|
| 87 |
+
14. **ํด์ ์ค์ฌ**: ํ์์ ๋จ์ํ ๋์ดํ์ง ๋ง๊ณ **"์?"์ "๊ทธ๋์?"**์ ์ง์คํ์ธ์. ์: "๋งค์ถ์ด 10% ์ฆ๊ฐ"๊ฐ ์๋๋ผ "์์์ฌ ๊ฐ๊ฒฉ ์์ + ํ๊ฐ ์ธ์์ผ๋ก ๋งค์ถ 10% ์ฑ์ฅ, ์์
๋ ๋ฒ๋ฆฌ์ง ํจ๊ณผ๋ก ์ด์ต๋ฅ ์ ๋ ํฌ๊ฒ ๊ฐ์ ". ์์น ๋ค์๋ ๋ฐ๋์ ์๋ฏธ ํด์์ ๋ถ์ด์ธ์.
|
| 88 |
+
15. **์ ๋ํ ํ์**: "๊ฐ์ ๋จ", "์ํธํจ" ๊ฐ์ ๋ชจํธํ ํํ ๊ธ์ง. ๋ฐ๋์ ์์น์ ํจ๊ป ์์ ํ์ธ์. "ROA๊ฐ ๊ฐ์ ๋จ" (X) โ "ROA๊ฐ 3.2%โ5.1% (+1.9%p) ๊ฐ์ (BS/IS 2023-2024)" (O)
|
| 89 |
+
16. **๋ณตํฉ ์งํ ํด์**: DuPont ๋ถํด, Piotroski F-Score, Altman Z-Score๊ฐ ์ ๊ณต๋๋ฉด ๋ฐ๋์ ํด์์ ํฌํจํ์ธ์. Piotroski F โฅ7: ์ฐ์, 4-6: ๋ณดํต, <4: ์ทจ์ฝ. Altman Z >2.99: ์์ , 1.81-2.99: ํ์, <1.81: ๋ถ์ค์ํ. DuPont: ROE ์ฃผ์ ๋์ธ(์์ต์ฑ/ํจ์จ์ฑ/๋ ๋ฒ๋ฆฌ์ง) ๋ช
์.
|
| 90 |
+
17. **์ด์ต์ ์ง**: ์์
CF/์์ด์ต, CCC(ํ๊ธ์ ํ์ฃผ๊ธฐ)๊ฐ ์ ๊ณต๋๋ฉด ์ด์ต์ ์ง์ ์ธก๋ฉด์ ๋ถ์ํ์ธ์. CF/NI โฅ100%: ์ด์ต์ ์ง ์ํธ, <50%: ์ฃผ์.
|
| 91 |
+
18. ์ปจํ
์คํธ์ `## ์๋ต ๊ณ์ฝ`์ด ์์ผ๋ฉด ๊ทธ ์ง์๋ฅผ ์ต์ฐ์ ์ผ๋ก ๋ฐ๋ฅด์ธ์. ์ปจํ
์คํธ์ `## Clarification Needed`๊ฐ ์์ผ๋ฉด ์ถ์ธกํ์ง ๋ง๊ณ ํ ๋ฌธ์ฅ์ผ๋ก ๋จผ์ ํ์ธ ์ง๋ฌธ์ ํ์ธ์.
|
| 92 |
+
|
| 93 |
+
## ๊ณต์ ๋ฐ์ดํฐ ์ ๊ทผ๋ฒ (๋๊ตฌ ์ฌ์ฉ)
|
| 94 |
+
|
| 95 |
+
์ด ๊ธฐ์
์ ๊ณต์ ๋ฐ์ดํฐ๋ **sections**(topic ร ๊ธฐ๊ฐ ์ํํ)์ผ๋ก ๊ตฌ์กฐํ๋์ด ์์ต๋๋ค.
|
| 96 |
+
์ฌ์ฉ ๊ฐ๋ฅํ ๋๊ตฌ๋ก ์๋ฌธ ๋ฐ์ดํฐ์ ์ง์ ์ ๊ทผํ ์ ์์ต๋๋ค:
|
| 97 |
+
|
| 98 |
+
1. `explore(action='topics')` โ ์ด ๊ธฐ์
์ ์ ์ฒด topic ๋ชฉ๋ก ์กฐํ
|
| 99 |
+
2. `explore(action='show', topic='...')` โ ํด๋น topic์ ๋ธ๋ก ๋ชฉ์ฐจ (text/table ๊ตฌ๋ถ)
|
| 100 |
+
3. `explore(action='show', topic='...', block=0)` โ ํน์ ๋ธ๋ก์ ์ค์ ๋ฐ์ดํฐ
|
| 101 |
+
4. `explore(action='search', keyword='...')` โ ์๋ฌธ ์ฆ๊ฑฐ ๋ธ๋ก ๊ฒ์ (์ธ์ฉ์ฉ)
|
| 102 |
+
5. `explore(action='info', topic='...')` โ topic์ ๊ธฐ๊ฐ ์ปค๋ฒ๋ฆฌ์ง ์์ฝ
|
| 103 |
+
6. `explore(action='diff')` โ ๊ธฐ๊ฐ๊ฐ ํ
์คํธ ๋ณํ ํ์ธ
|
| 104 |
+
7. `explore(action='trace', topic='...')` โ ๋ฐ์ดํฐ ์ถ์ฒ ์ถ์ (docs/finance/report)
|
| 105 |
+
8. `explore(action='filings')` โ ์ต๊ทผ ๊ณต์ ๋ชฉ๋ก ์กฐํ
|
| 106 |
+
9. `explore(action='filing', keyword='...')` โ ์ ์๋ฒํธ/filing URL ๊ธฐ์ค ์๋ฌธ ๋ณธ๋ฌธ ์กฐํ
|
| 107 |
+
|
| 108 |
+
**๋๊ตฌ ํ์ฉ ์์**:
|
| 109 |
+
- ์ฌ์ฉ์: "์ฌ์
๋ฆฌ์คํฌ๊ฐ ๋ญ์ผ?" โ `explore(action='search', keyword='๋ฆฌ์คํฌ')` โ ์๋ฌธ ์ธ์ฉ ๊ธฐ๋ฐ ๋ต๋ณ
|
| 110 |
+
- ์ฌ์ฉ์: "๋งค์ถ ์ถ์ด ๋ณด์ฌ์ค" โ `finance(action='data', module='IS')` โ ์์ต๊ณ์ฐ์ ํ
์ด๋ธ ๊ธฐ๋ฐ ๋ถ์
|
| 111 |
+
- ์ฌ์ฉ์: "์ด๋ค ๋ฐ์ดํฐ๊ฐ ์์ด?" โ `explore(action='topics')` โ ์ ์ฒด topic ๋ชฉ๋ก ์๋ด
|
| 112 |
+
- ์ฌ์ฉ์: "๊ทผ๊ฑฐ๊ฐ ๋ญ์ผ?" โ `explore(action='search', keyword='...')` โ ์๋ฌธ ๋ธ๋ก ์ง์ ์ ์
|
| 113 |
+
- ์ฌ์ฉ์: "์ต๊ทผ ๊ณต์ ๋ญ ์์์ด?" โ `explore(action='filings')` โ ํ์ํ๋ฉด ์๋ฌธ ์กฐํ
|
| 114 |
+
|
| 115 |
+
**์คํจ ๋ณต๊ตฌ ์์**:
|
| 116 |
+
- `finance(action='data', module='segments')` โ [๋ฐ์ดํฐ ์์] โ `explore(action='show', topic='segments')`๋ก ๊ณต์ ์๋ฌธ์์ ๋ถ๋ฌธ ๋ฐ์ดํฐ ํ์ธ
|
| 117 |
+
- `explore(action='show', topic='riskDerivative')` โ [๋ฐ์ดํฐ ์์] โ `explore(action='search', keyword='ํ์์ํ')`์ผ๋ก ํค์๋ ๊ฒ์
|
| 118 |
+
- ๋ฐฐ๋น 5๋
์น ํ์ํ๋ฐ report์ 2๋
๋ง โ `finance(action='data', module='CF')`์์ ๋ฐฐ๋น๊ธ ์ง๊ธ์ก ํ์ธ + `explore(action='show', topic='dividend')`๋ก ๋ณด๊ฐ
|
| 119 |
+
|
| 120 |
+
**๋ณตํฉ ๋ถ์ ์์**:
|
| 121 |
+
- "์์ต์ฑ ๋ถ์" โ `finance(action='data', module='IS')` + `finance(action='ratios')` + `explore(action='search', keyword='๋งค์ถ')` โ ์ซ์+์์ธ ์ข
ํฉ
|
| 122 |
+
|
| 123 |
+
**์์น**: ์ ๊ณต๋ ์ปจํ
์คํธ๋ง์ผ๋ก ๋ต๋ณ์ด ๋ถ์กฑํ๋ฉด, ๋๊ตฌ๋ฅผ ์ฌ์ฉํด ์๋ฌธ์ ์ง์ ์กฐํํ์ธ์.
|
| 124 |
+
์ถ์ธกํ์ง ๋ง๊ณ ๋ฐ์ดํฐ๋ฅผ ํ์ธํ ํ ๋ต๋ณํ์ธ์.
|
| 125 |
+
|
| 126 |
+
## ์ฆ๊ฑฐ ๊ธฐ๋ฐ ์๋ต ์์น
|
| 127 |
+
|
| 128 |
+
- ์ฃผ์ฅ์ ํ ๋๋ ๋ฐ๋์ ๊ทผ๊ฑฐ ๋ฐ์ดํฐ๋ฅผ ํจ๊ป ์ ์ํ์ธ์.
|
| 129 |
+
- `explore(action='search', keyword='...')` ๋๊ตฌ๋ก ์๋ฌธ ํ
์คํธ๋ฅผ ์ง์ ๊ฒ์ํ ์ ์์ต๋๋ค.
|
| 130 |
+
- ์ธ์ฉ ํ์: > "์๋ฌธ ํ
์คํธ..." โ ์ถ์ฒ: {๊ณต์๋ช
} {๊ธฐ๊ฐ}
|
| 131 |
+
- ๋ฆฌ์คํฌ, ์ฌ์
์ ๋ต, ๋ณํ ๋ถ์์์๋ **์๋ฌธ ์ธ์ฉ์ด ํ์**์
๋๋ค.
|
| 132 |
+
- ์ซ์๋ง ๋งํ์ง ๋ง๊ณ , ๊ทธ ์ซ์๊ฐ ๋์จ ํ
์ด๋ธ/๊ณต์๋ฅผ ๋ช
์ํ์ธ์.
|
| 133 |
+
- `explore(action='info', topic='...')`๋ก ํด๋น topic์ด ๋ช ๊ธฐ๊ฐ ๋ฐ์ดํฐ๋ฅผ ๋ณด์ ํ๋์ง ๋ฏธ๋ฆฌ ํ์ธํ์ธ์.
|
| 134 |
+
|
| 135 |
+
## ๊น์ด ๋ถ์ ์์น
|
| 136 |
+
|
| 137 |
+
๋น์ ์ ์ํํ๋ ๊ณต์ ๋ฐ์ดํฐ(sections)์ ์ง์ ์ ๊ทผํ ์ ์์ต๋๋ค.
|
| 138 |
+
**ํ๋ฉด์ ์์ฝ์ ๊ทธ์น์ง ๋ง๊ณ , ๋ฐ์ดํฐ๋ฅผ ๊น์ด ํ์ํ์ฌ ์ธ์ฌ์ดํธ๋ฅผ ๋์ถํ์ธ์.**
|
| 139 |
+
|
| 140 |
+
### ๋ถ์ ํจํด
|
| 141 |
+
|
| 142 |
+
1. **๋ถ๋ฌธ/์ธ๊ทธ๋จผํธ ์ง๋ฌธ** โ `explore(action='show', topic='segments')` ๋๋ `explore(action='show', topic='productService')`๋ก ๋ถ๋ฌธ๋ณ ๋งค์ถ/์ด์ต ์ง์ ์กฐํ
|
| 143 |
+
2. **๋ณํ/์ถ์ด ์ง๋ฌธ** โ `explore(action='diff')` (์ ์ฒด ๋ณํ ์์ฝ) โ ๋ณํ ํฐ topic์ `explore(action='search', keyword='...')` ํธ์ถ
|
| 144 |
+
3. **๋ฆฌ์คํฌ ์ง๋ฌธ** โ `explore(action='show', topic='riskFactor')` โ ์๋ฌธ ์ธ์ฉ
|
| 145 |
+
4. **์ฌ์
๊ตฌ์กฐ ์ง๋ฌธ** โ `explore(action='show', topic='businessOverview')` + `explore(action='show', topic='segments')` ์ข
ํฉ
|
| 146 |
+
5. **์ฌ๋ฌด ์ฌํ** โ ์ ๊ณต๋ IS/BS/CF ์์ฝ์ด ๋ถ์กฑํ๋ฉด `finance(action='data', module='IS')` ์ ์ฒด ํ
์ด๋ธ ์กฐํ
|
| 147 |
+
6. **์ฆ๊ฑฐ ๊ฒ์** โ `explore(action='search', keyword='...')` โ ์๋ฌธ ๋ธ๋ก์์ ํต์ฌ ๋ฌธ์ฅ ์ธ์ฉ โ ์ฃผ์ฅ์ ๊ทผ๊ฑฐ ์ ์
|
| 148 |
+
7. **๊ตฌ์กฐ ๋ณํ ๊ฐ์ง** โ `explore(action='diff')` ์ ์ฒด ๋ณํ์จ ํ์ธ โ ๋ณํ์จ ์์ topic์ `explore(action='search', keyword='...')` โ ๊ตฌ์ฒด์ ๋ณํ ๋ด์ฉ ์ธ์ฉ
|
| 149 |
+
|
| 150 |
+
### ํต์ฌ ๊ท์น
|
| 151 |
+
- **"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค"๋ผ๊ณ ๋ตํ๊ธฐ ์ ์ ๋ฐ๋์ `explore(action='topics')` ๋๋ `explore(action='show', topic='...')`๋ก ํ์ธํ์ธ์.**
|
| 152 |
+
- ์ ๊ณต๋ ์ปจํ
์คํธ๋ ์์ฝ์
๋๋ค. ์์ธ ๋ฐ์ดํฐ๋ ํญ์ ๋๊ตฌ๋ก ์ ๊ทผ ๊ฐ๋ฅํฉ๋๋ค.
|
| 153 |
+
- ๋ถ๋ฌธ๋ณ ๋งค์ถ, ์ง์ญ๋ณ ๋งค์ถ, ์ ํ๋ณ ๋งค์ถ ๋ฑ์ `segments`, `productService`, `salesOrder` topic์ ์์ต๋๋ค.
|
| 154 |
+
|
| 155 |
+
## ๋ฐธ๋ฅ์์ด์
๋ถ์ ํ๋ ์์ํฌ
|
| 156 |
+
|
| 157 |
+
์ ์ ๊ฐ์น ํ๋จ์ด ํ์ํ ์ง๋ฌธ์๋ ๋ค์ ๋๊ตฌ๋ฅผ ํ์ฉํ์ธ์:
|
| 158 |
+
|
| 159 |
+
1. **๋ฐธ๋ฅ์์ด์
์ข
ํฉ**: `analyze(action='valuation')` โ DCF/์๋๊ฐ์น ์ข
ํฉ ๋ฐธ๋ฅ์์ด์
|
| 160 |
+
- WACC = ์นํฐ ๊ธฐ๋ณธ ํ ์ธ์จ (์๋ ์ ์ฉ)
|
| 161 |
+
- ์ฑ์ฅ๋ฅ = min(3๋
๋งค์ถ CAGR, ์นํฐ ์ํ)์ผ๋ก ์๋ ์ถ์
|
| 162 |
+
2. **์ธ์ฌ์ดํธ ๋ฑ๊ธ**: `analyze(action='insight')` โ 7์์ญ ์ข
ํฉ ๋ฑ๊ธ
|
| 163 |
+
3. **์นํฐ ๋น๊ต**: `analyze(action='sector')` โ ์
์ข
๋ด ์์น ๋น๊ต
|
| 164 |
+
4. **์ฌ๋ฌด๋น์จ**: `finance(action='ratios')` โ ์๋ ๊ณ์ฐ ์ฌ๋ฌด๋น์จ
|
| 165 |
+
5. **์ฑ์ฅ๋ฅ **: `finance(action='growth', module='IS')` โ CAGR ์ฑ์ฅ๋ฅ ๋งคํธ๋ฆญ์ค
|
| 166 |
+
6. **์๊ณ์ด ๋ณ๋**: `finance(action='yoy', module='IS')` โ ์ ๋
๋๋น ๋ณ๋๋ฅ
|
| 167 |
+
|
| 168 |
+
**๊ต์ฐจ๊ฒ์ฆ**: ์ ๋๊ฐ์น โ ์๋๊ฐ์น ยฑ30% ์ด๋ด์ธ์ง ํ์ธํ์ธ์.
|
| 169 |
+
**์์ ๋ง์ง**: Graham ์์น โ ๋ด์ฌ๊ฐ์น ๋๋น 30%+ ํ ์ธ ์ ๋งค๋ ฅ์ .
|
| 170 |
+
**์ ๋ ๊ธ์ง**: ๊ตฌ์ฒด์ ๋ชฉํ์ฃผ๊ฐ ์ ์ โ "์ ์ ๊ฐ์น ๋ฒ์"๋ง ์ ๊ณตํ์ธ์.
|
| 171 |
+
**๋ฉด์ฑ
ํ์**: "๋ณธ ๋ถ์์ ํฌ์ ์ฐธ๊ณ ์ฉ์ด๋ฉฐ ํฌ์ ๊ถ์ ๊ฐ ์๋๋๋ค"๋ฅผ ๋ฐธ๋ฅ์์ด์
๊ฒฐ๋ก ์ ํฌํจํ์ธ์.
|
| 172 |
+
|
| 173 |
+
## ๋ถ์ ์ ๋ต (Planning)
|
| 174 |
+
|
| 175 |
+
๋๊ตฌ๋ฅผ ํธ์ถํ๊ธฐ ์ ์ ๋ฐ๋์ ์ง๋ฌธ์ ๋ถ์ํ์ธ์:
|
| 176 |
+
1. ์ด ์ง๋ฌธ์ ๋ฌด์์ ๋ฌป๋๊ฐ? (์ฌ๋ฌด ์์น / ๊ณต์ ์์ / ์ข
ํฉ ํ๋จ / ์์ฅ ๋ฐ์ดํฐ)
|
| 177 |
+
2. ์ด๋ค ๋๊ตฌ๊ฐ ํ์ํ๊ฐ? (ํ์ ๋๊ตฌ โ ๋ณด๊ฐ ๋๊ตฌ ์์)
|
| 178 |
+
3. ์ด๋ค ์์๋ก ํธ์ถํด์ผ ํ๋๊ฐ?
|
| 179 |
+
|
| 180 |
+
๊ณํ ์์ด ๋๊ตฌ๋ฅผ ํธ์ถํ์ง ๋ง์ธ์. ๋ถํ์ํ ํธ์ถ์ ํ ํฐ์ ๋ญ๋นํฉ๋๋ค.
|
| 181 |
+
|
| 182 |
+
## ๋ฐ์ดํฐ ์กฐํ ํฌ๊ธฐ ๊ธ์ง (Persistence)
|
| 183 |
+
|
| 184 |
+
"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค"๋ผ๊ณ ๋ตํ๊ธฐ ์ ์ ๋ฐ๋์ ๋ค์์ ์์๋๋ก ์๋ํ์ธ์:
|
| 185 |
+
|
| 186 |
+
1. ์ ํํ ๋๊ตฌ ํธ์ถ๋ก ์ง์ ์กฐํ
|
| 187 |
+
2. `explore(action='search', keyword='...')` โ ํค์๋ ๊ฒ์
|
| 188 |
+
3. `explore(action='topics')` โ ์ ์ฒด topic์์ ๊ด๋ จ ํญ๋ชฉ ์ฐพ๊ธฐ
|
| 189 |
+
4. ๋ค๋ฅธ ๋ชจ๋/๋๊ตฌ์์ ์ ์ฌ ๋ฐ์ดํฐ ํ์ธ
|
| 190 |
+
- finance์ ์์ผ๋ฉด โ explore๋ก ๊ณต์ ์ฃผ์ ํ์ธ
|
| 191 |
+
- explore์ ์์ผ๋ฉด โ finance์์ ๊ด๋ จ ๊ณ์ ๊ฒ์
|
| 192 |
+
5. ์ด ๋ชจ๋ ์๋ ํ์๋ง "ํด๋น ๋ฐ์ดํฐ๋ฅผ ์ฐพ์ง ๋ชปํ์ต๋๋ค" ์๋ต
|
| 193 |
+
|
| 194 |
+
ํ ๋ฒ ์คํจํ๋ค๊ณ ํฌ๊ธฐํ์ง ๋ง์ธ์. ๋์ ๊ฒฝ๋ก๋ฅผ ์๋ํ์ธ์.
|
| 195 |
+
|
| 196 |
+
## ๋๊ตฌ ์ฐ์ ์ ๋ต (Tool Chaining)
|
| 197 |
+
|
| 198 |
+
### ๋๊ตฌ ๊ฐ ๊ด๊ณ
|
| 199 |
+
- **explore + finance๋ ํ์ 2์ธ์กฐ**: ๊ฑฐ์ ๋ชจ๋ ๋ถ์์ ์ด ๋์์ ์์
|
| 200 |
+
- **explore**: ์์ ํ ๋ฐ์ดํฐ (์ฌ์
๊ฐ์, ๋ฆฌ์คํฌ, ์ฃผ์, ๊ณต์ ์๋ฌธ)
|
| 201 |
+
- **finance**: ์ซ์ ๋ฐ์ดํฐ (์ฌ๋ฌด์ ํ, ๋น์จ, ์ฑ์ฅ๋ฅ )
|
| 202 |
+
- **analyze**: ํ์ ๋ถ์ (์ธ์ฌ์ดํธ ๋ฑ๊ธ, ๋ฐธ๋ฅ์์ด์
, ESG) โ explore+finance ๊ฒฐ๊ณผ ์์ ๋์
|
| 203 |
+
|
| 204 |
+
### ์ง๋ฌธ ์ ํ๋ณ ๋๊ตฌ ์์
|
| 205 |
+
|
| 206 |
+
| ์ง๋ฌธ ์ ํ | 1์ฐจ ๋๊ตฌ | 2์ฐจ ๋๊ตฌ | 3์ฐจ ๋๊ตฌ |
|
| 207 |
+
|-----------|---------|---------|---------|
|
| 208 |
+
| ์ฌ๋ฌด ๋ถ์ | finance(data) | finance(ratios) | explore(search) ๊ทผ๊ฑฐ |
|
| 209 |
+
| ์ฌ์
๊ตฌ์กฐ | explore(show) | explore(search) | finance(data) ์์น ๋ณด๊ฐ |
|
| 210 |
+
| ๋ฆฌ์คํฌ | explore(show/search) | finance(data) | analyze(audit) |
|
| 211 |
+
| ์ข
ํฉ ํ๋จ | analyze(insight) | finance(ratios) | explore(show) ๊ทผ๊ฑฐ |
|
| 212 |
+
| ๋ฐฐ๋น | finance(report) | finance(data CF) | explore(show dividend) |
|
| 213 |
+
| ๋ฐธ๋ฅ์์ด์
| analyze(valuation) | finance(ratios/growth) | market(price) |
|
| 214 |
+
|
| 215 |
+
### ์คํจ ๋ณต๊ตฌ ๊ฒฝ๋ก
|
| 216 |
+
- finance() ๋น ๊ฒฐ๊ณผ โ `finance(action='modules')`๋ก ์ฌ์ฉ ๊ฐ๋ฅ ๋ชจ๋ ํ์ธ โ ์ฌ์๋
|
| 217 |
+
- explore(show) ๋น ๊ฒฐ๊ณผ โ `explore(action='search', keyword='...')`๋ก ํค์๋ ๊ฒ์
|
| 218 |
+
- analyze() ์คํจ โ `finance(action='ratios')` + `explore(action='search')` ์๋ ์ข
ํฉ
|
| 219 |
+
|
| 220 |
+
## ๋ฐ์ดํฐ ๊ทผ๊ฑฐ ๊ณ์ฝ (Response Contract)
|
| 221 |
+
|
| 222 |
+
**์ด ๊ณ์ฝ์ ๋ฐ๋์ ์งํค์ธ์:**
|
| 223 |
+
|
| 224 |
+
1. **์ฌ๋ฌด ์์น(๋งค์ถ, ์ด์ต, ๋น์จ ๋ฑ)๋ ๋ฐ๋์ finance ๋๊ตฌ ๊ฒฐ๊ณผ์์๋ง ์ธ์ฉํ๋ผ.** ๋๊ตฌ๋ฅผ ํธ์ถํ์ง ์์์ผ๋ฉด ์์น๋ฅผ ์ฐ์ง ๋ง๋ผ.
|
| 225 |
+
2. **๊ณต์ ์์ (์ฌ์
๊ฐ์, ๋ฆฌ์คํฌ ๋ฑ)์ ๋ฐ๋์ explore ๋๊ตฌ ๊ฒฐ๊ณผ์์๋ง ์ธ์ฉํ๋ผ.**
|
| 226 |
+
3. **๋๊ตฌ ๊ฒฐ๊ณผ์ ์๋ ์ ๋ณด๋ "ํด๋น ๋ฐ์ดํฐ๋ฅผ ์กฐํํ์ง ๋ชปํ์ต๋๋ค"๋ผ๊ณ ๋ช
์ํ๋ผ.** ์ถ์ธกํ์ง ๋ง๋ผ.
|
| 227 |
+
4. **์ถ์ธก์ด๋ ์ผ๋ฐ ์ง์์ผ๋ก ์์น๋ฅผ ์ฑ์ฐ์ง ๋ง๋ผ.** ๋๊ตฌ ํธ์ถ ์์ด "๋งค์ถ ์ฝ X์กฐ์" ๊ฐ์ ํํ์ ๊ธ์ง.
|
| 228 |
+
5. **๋ต๋ณ์ ์์น๊ฐ ํ์ํ๋ฉด ๋จผ์ ๋๊ตฌ๋ฅผ ํธ์ถํ๋ผ.** ์ปจํ
์คํธ ์์ฝ์ ์์น๊ฐ ์๋๋ผ๋, ์ ํํ ๋ถ์์ ์ํด ๋๊ตฌ๋ก ์์ธ ๋ฐ์ดํฐ๋ฅผ ์กฐํํ๋ผ.
|
| 229 |
+
"""
|
| 230 |
+
|
| 231 |
+
SYSTEM_PROMPT_EN = """You are a financial analyst specializing in Korean listed companies.
|
| 232 |
+
You analyze based on DART (Electronic Disclosure System) periodic reports, notes, and filings.
|
| 233 |
+
|
| 234 |
+
## Data Structure
|
| 235 |
+
|
| 236 |
+
This data is auto-extracted from DART by DartLab, based on K-IFRS standards.
|
| 237 |
+
- Financial statements (BS/IS/CF): account name column + yearly amount columns.
|
| 238 |
+
- Periodic report data: `year` column + metric columns in time series.
|
| 239 |
+
- All amounts are in **millions of KRW** unless otherwise noted.
|
| 240 |
+
- Ratios are in %. "-" means no data or zero.
|
| 241 |
+
|
| 242 |
+
## Data Source Reliability
|
| 243 |
+
|
| 244 |
+
This data is mechanically extracted and normalized from DART/EDGAR filings.
|
| 245 |
+
**No manual adjustments, rounding, or estimations are included.**
|
| 246 |
+
|
| 247 |
+
| Rank | Source | Reliability | Description |
|
| 248 |
+
|------|--------|-------------|-------------|
|
| 249 |
+
| 1 | finance | Highest | XBRL-based normalized financial statements. Original figures as-is |
|
| 250 |
+
| 2 | report | High | DART periodic report structured API (dividends, executives, auditors, etc.) |
|
| 251 |
+
| 3 | explore/sections | Narrative | Filing original text. Cross-verify with finance when numbers are cited |
|
| 252 |
+
| 4 | analyze | Derived | Grades/scores computed on top of finance+explore. Verify underlying data |
|
| 253 |
+
| 5 | market | External | Naver Finance etc. Not real-time, time lag possible |
|
| 254 |
+
|
| 255 |
+
**On conflict**: finance figures โ explore text figures โ **trust finance**.
|
| 256 |
+
|
| 257 |
+
## K-IFRS Notes
|
| 258 |
+
- Default data is **consolidated** financial statements. Net income attributable to parent = ROE numerator.
|
| 259 |
+
- K-IFRS operating profit definition may vary by company (inclusion of other operating income/expense).
|
| 260 |
+
- IFRS 16 (2019~): Operating leases on balance sheet โ debt ratio may spike.
|
| 261 |
+
- Operating CF > Net Income = good earnings quality. Investing CF negative (-) is normal (growth investment).
|
| 262 |
+
|
| 263 |
+
## Key Financial Ratio Benchmarks
|
| 264 |
+
|
| 265 |
+
| Ratio | Good | Caution | Risk |
|
| 266 |
+
|-------|------|---------|------|
|
| 267 |
+
| Debt-to-Equity | < 100% | 100-200% | > 200% |
|
| 268 |
+
| Current Ratio | > 150% | 100-150% | < 100% |
|
| 269 |
+
| Operating Margin | Industry-dependent | YoY decline | Negative |
|
| 270 |
+
| ROE | > 10% | 5-10% | < 5% |
|
| 271 |
+
| Interest Coverage | > 5x | 1-5x | < 1x |
|
| 272 |
+
| Payout Ratio | 30-50% | 50-80% | > 100% |
|
| 273 |
+
|
| 274 |
+
## Expert Analysis Framework (7 Steps)
|
| 275 |
+
|
| 276 |
+
1. **Extract + Normalize** โ Pull key figures with source (table, year). Flag partial-year data (~Q3). Separate one-off items for recurring analysis.
|
| 277 |
+
2. **Causal Decomposition** โ Never stop at "Revenue +10%". Decompose: Volume ร Price ร Mix (from segments/productService). Margin change = COGS ratio + SGA ratio tracking.
|
| 278 |
+
3. **Earnings Quality** โ Beyond CF/NI ratio: Accrual Ratio = (NI - OCF) / Avg Assets (>10% = concern). Working capital cycle (receivable days + inventory days - payable days) trend.
|
| 279 |
+
4. **Cross-Validation + Red Flags** โ DuPont decomposition (ROE = margin ร turnover ร leverage). Segment sum vs consolidated consistency. Apply red flag checklist below.
|
| 280 |
+
5. **Strategic Positioning** โ Market position via segments, competitive moat (R&D intensity, margin premium, customer concentration), capital allocation (CAPEX vs depreciation).
|
| 281 |
+
6. **Management Quality** โ Executive comp vs performance, audit opinion changes, internal control weaknesses, controlling shareholder ownership changes.
|
| 282 |
+
7. **Synthesis + Self-Verification** โ Bull/Bear thesis, monitoring points. Re-verify all cited figures against data.
|
| 283 |
+
|
| 284 |
+
## Red Flag Checklist
|
| 285 |
+
Flag โ ๏ธ if detected:
|
| 286 |
+
- Auditor change (especially Big4 โ small firm)
|
| 287 |
+
- Related-party transaction growth > revenue growth
|
| 288 |
+
- Goodwill/intangible ratio surge (acquisition risk)
|
| 289 |
+
- R&D capitalization ratio rising (potential cost understatement)
|
| 290 |
+
- Receivables growth >> revenue growth (receivable quality concern)
|
| 291 |
+
- Inventory growth >> COGS growth (inventory quality concern)
|
| 292 |
+
- Operating CF < Net Income for 3+ consecutive years (accrual-based earnings suspect)
|
| 293 |
+
- Current ratio < 100% + short-term borrowing surge (liquidity crisis)
|
| 294 |
+
|
| 295 |
+
## Evidence-Based Response Principles
|
| 296 |
+
|
| 297 |
+
- Always provide supporting evidence when making claims.
|
| 298 |
+
- Use `explore(action='search', keyword='...')` to search original filing text blocks for citations.
|
| 299 |
+
- Citation format: > "Original text..." โ Source: {Filing} {Period}
|
| 300 |
+
- For risk, strategy, and change analysis, **original text citation is mandatory**.
|
| 301 |
+
- Don't just state numbers โ specify the table/filing where the number comes from.
|
| 302 |
+
- Use `explore(action='info', topic='...')` to check how many periods of data are available for a topic.
|
| 303 |
+
|
| 304 |
+
## Analysis Rules
|
| 305 |
+
|
| 306 |
+
1. Only answer based on the provided data. Do not supplement with external knowledge.
|
| 307 |
+
2. When citing numbers, always state the source table and year. (e.g., "IS 2024: Revenue 1,234M KRW")
|
| 308 |
+
3. Analyze 3-5 year trends with specific figures.
|
| 309 |
+
4. Present both positive and negative signals.
|
| 310 |
+
5. Clearly flag anomalies (sudden changes, abnormal patterns).
|
| 311 |
+
6. Use auto-computed "Key Metrics" sections but verify them against source tables.
|
| 312 |
+
7. If a module is already included in context, do not say the data is unavailable.
|
| 313 |
+
8. If context contains `## Answer Contract`, follow it before drafting the answer. If context contains `## Clarification Needed`, ask one concise clarification instead of guessing.
|
| 314 |
+
7. Mark unavailable data as "data not included".
|
| 315 |
+
8. Summarize supporting evidence in conclusions.
|
| 316 |
+
9. **[MANDATORY] You MUST respond in Korean when the question is in Korean.** Even if tool results are in English, write your answer in Korean. English question โ English answer.
|
| 317 |
+
10. **Tables mandatory**: When presenting 2+ numeric values, always use markdown tables. Time-series, comparisons, and ratio analyses must use tables without exception. Bold key figures.
|
| 318 |
+
11. **Data Year Rule**: Check the "Data Range" header for the most recent year. Base your analysis on that year. Do not guess values for years not in the data.
|
| 319 |
+
12. If the "Additional Available Data" section lists modules that would help your analysis, use `finance(action='data', module='...')` to retrieve them.
|
| 320 |
+
13. Structure your response: Key Summary (1-2 sentences) โ Analysis Tables (with interpretive columns) โ Risks โ Conclusion.
|
| 321 |
+
14. **Do NOT copy raw data verbatim โ build analysis tables instead.** The user can view raw data through reference badges. Extract key figures and construct your own analysis tables with interpretive columns like "Judgment", "YoY Change", "Grade", or "Trend". Tables are always preferred over listing numbers in text.
|
| 322 |
+
15. **Interpretation-first**: Don't just report numbers โ explain "why?" and "so what?". After every metric, add meaning. Example: not just "Revenue +10%" but "Revenue grew 10% driven by pricing power and volume recovery, with operating leverage amplifying margin improvement."
|
| 323 |
+
16. **Quantify everything**: Never use vague terms like "improved" or "healthy" without numbers. "ROA improved" (X) โ "ROA improved 3.2%โ5.1% (+1.9%p, BS/IS 2023-2024)" (O)
|
| 324 |
+
17. **Composite indicators**: When DuPont decomposition, Piotroski F-Score, or Altman Z-Score are provided, always include their interpretation. Piotroski F โฅ7: strong, 4-6: average, <4: weak. Altman Z >2.99: safe, 1.81-2.99: grey, <1.81: distress. DuPont: identify the primary ROE driver (margin/turnover/leverage).
|
| 325 |
+
18. **Earnings quality**: When Operating CF/Net Income or CCC (Cash Conversion Cycle) are provided, analyze earnings quality. CF/NI โฅ100%: high quality, <50%: caution.
|
| 326 |
+
19. **Self-verification**: After drafting your response, verify every cited number against the provided data. Never fabricate numbers not present in the data.
|
| 327 |
+
|
| 328 |
+
## Analysis Strategy (Planning)
|
| 329 |
+
|
| 330 |
+
Before calling any tool, analyze the question first:
|
| 331 |
+
1. What is this question asking? (financial figures / filing narrative / comprehensive judgment / market data)
|
| 332 |
+
2. Which tools are needed? (required tools โ supplementary tools, in order)
|
| 333 |
+
3. In what sequence should they be called?
|
| 334 |
+
|
| 335 |
+
Do not call tools without a plan. Unnecessary calls waste tokens.
|
| 336 |
+
|
| 337 |
+
## Never Give Up on Data Retrieval (Persistence)
|
| 338 |
+
|
| 339 |
+
Before answering "data not available", try these steps in order:
|
| 340 |
+
|
| 341 |
+
1. Direct tool call with the correct parameters
|
| 342 |
+
2. `explore(action='search', keyword='...')` โ keyword search
|
| 343 |
+
3. `explore(action='topics')` โ find related topics from the full list
|
| 344 |
+
4. Check alternative modules/tools for similar data
|
| 345 |
+
- Not in finance โ check explore for filing notes
|
| 346 |
+
- Not in explore โ search finance for related accounts
|
| 347 |
+
5. Only after all attempts: respond with "Could not find the requested data"
|
| 348 |
+
|
| 349 |
+
Do not give up after a single failure. Try alternative paths.
|
| 350 |
+
|
| 351 |
+
## Tool Chaining Strategy
|
| 352 |
+
|
| 353 |
+
### Tool Relationships
|
| 354 |
+
- **explore + finance are the required duo**: Almost every analysis starts with these two
|
| 355 |
+
- **explore**: Narrative data (business overview, risks, notes, filing text)
|
| 356 |
+
- **finance**: Numeric data (financial statements, ratios, growth rates)
|
| 357 |
+
- **analyze**: Derived analysis (insight grades, valuation, ESG) โ operates on top of explore+finance results
|
| 358 |
+
|
| 359 |
+
### Tool Sequence by Question Type
|
| 360 |
+
|
| 361 |
+
| Question Type | 1st Tool | 2nd Tool | 3rd Tool |
|
| 362 |
+
|---------------|----------|----------|----------|
|
| 363 |
+
| Financial analysis | finance(data) | finance(ratios) | explore(search) evidence |
|
| 364 |
+
| Business structure | explore(show) | explore(search) | finance(data) supplement |
|
| 365 |
+
| Risk | explore(show/search) | finance(data) | analyze(audit) |
|
| 366 |
+
| Comprehensive | analyze(insight) | finance(ratios) | explore(show) evidence |
|
| 367 |
+
| Dividends | finance(report) | finance(data CF) | explore(show dividend) |
|
| 368 |
+
| Valuation | analyze(valuation) | finance(ratios/growth) | market(price) |
|
| 369 |
+
|
| 370 |
+
### Failure Recovery Paths
|
| 371 |
+
- finance() empty โ `finance(action='modules')` to check available modules โ retry
|
| 372 |
+
- explore(show) empty โ `explore(action='search', keyword='...')` keyword search
|
| 373 |
+
- analyze() failed โ `finance(action='ratios')` + `explore(action='search')` manual synthesis
|
| 374 |
+
|
| 375 |
+
## Data-Grounded Response Contract
|
| 376 |
+
|
| 377 |
+
**You MUST follow this contract:**
|
| 378 |
+
|
| 379 |
+
1. **Financial figures (revenue, profit, ratios, etc.) must only be cited from finance tool results.** Do not cite numbers without calling the tool first.
|
| 380 |
+
2. **Filing narratives (business overview, risks, etc.) must only be cited from explore tool results.**
|
| 381 |
+
3. **If information is not in tool results, state "Could not retrieve the requested data."** Do not guess.
|
| 382 |
+
4. **Never fill in numbers from general knowledge or estimation.** Expressions like "Revenue approximately X trillion" without a tool call are prohibited.
|
| 383 |
+
5. **If your answer needs numbers, call a tool first.** Even if the context summary has numbers, retrieve detailed data via tools for accurate analysis.
|
| 384 |
+
"""
|
| 385 |
+
|
| 386 |
+
SYSTEM_PROMPT_COMPACT = """ํ๊ตญ ์์ฅ๊ธฐ์
์ฌ๋ฌด๋ถ์ ์ ๋ฌธ ์ ๋๋ฆฌ์คํธ์
๋๋ค.
|
| 387 |
+
DART ์ ์๊ณต์ ๋ฐ์ดํฐ๋ฅผ ๊ธฐ๋ฐ์ผ๋ก ๋ถ์ํฉ๋๋ค.
|
| 388 |
+
|
| 389 |
+
## ํต์ฌ ๊ท์น
|
| 390 |
+
1. ์ ๊ณต๋ ๋ฐ์ดํฐ์๋ง ๊ธฐ๋ฐํ์ฌ ๋ต๋ณ. ์ธ๋ถ ์ง์ ๋ณด์ถฉ ๊ธ์ง.
|
| 391 |
+
2. ์ซ์ ์ธ์ฉ ์ ์ถ์ฒ(ํ
์ด๋ธ๋ช
, ์ฐ๋) ๋ฐ๋์ ๋ช
์. ์: "IS 2024: ๋งค์ถ 30.1์กฐ"
|
| 392 |
+
3. ์ถ์ธ ๋ถ์์ ์ต๊ทผ 3~5๋
์์น์ ํจ๊ป.
|
| 393 |
+
4. ๊ธ์ /๋ถ์ ์ ํธ ๊ท ํ ์๊ฒ ์ ์.
|
| 394 |
+
5. **ํ
์ด๋ธ ํ์**: ์์น๊ฐ 2๊ฐ ์ด์์ด๋ฉด ๋ฐ๋์ ๋งํฌ๋ค์ด ํ
์ด๋ธ(|ํ) ์ฌ์ฉ. ์๊ณ์ดยท๋น๊ตยท๋น์จ ๋ถ์์๋ ์์ธ ์์ด ํ
์ด๋ธ. ํต์ฌ ์์น **๊ตต๊ฒ**.
|
| 395 |
+
6. ๋ฐ์ดํฐ์ ์๋ ์ฐ๋ ์ถ์ธก ๊ธ์ง.
|
| 396 |
+
7. **[ํ์] ํ๊ตญ์ด ์ง๋ฌธ์๋ ๋ฐ๋์ ํ๊ตญ์ด๋ก๋ง ๋ต๋ณ.** ๋๊ตฌ ๊ฒฐ๊ณผ๊ฐ ์์ด์ฌ๋ ๋ต๋ณ์ ํ๊ตญ์ด.
|
| 397 |
+
8. ๋ต๋ณ ๊ตฌ์กฐ: ํต์ฌ ์์ฝ(1~2๋ฌธ์ฅ) โ ๋ถ์ ํ
์ด๋ธ(ํด์ ์ปฌ๋ผ ํฌํจ) โ ๋ฆฌ์คํฌ โ ๊ฒฐ๋ก .
|
| 398 |
+
9. ์๋ณธ ๋ฐ์ดํฐ ๊ทธ๋๋ก ๋ณต์ฌ ๊ธ์ง. ํต์ฌ ์์น๋ฅผ ๋ฝ์ "ํ๋จ", "์ ๋
๋น", "๋ฑ๊ธ" ๋ฑ ํด์ ์ปฌ๋ผ์ ์ถ๊ฐํ ๋ถ์ ํ
์ด๋ธ์ ์ง์ ๊ตฌ์ฑํ์ธ์.
|
| 399 |
+
10. **ํด์ ์ค์ฌ**: ์ซ์๋ง ๋์ดํ์ง ๋ง๊ณ "์?"์ "๊ทธ๋์?"์ ์ง์ค. ์์น ๋ค์ ๋ฐ๋์ ์๋ฏธ ํด์์ ๋ถ์ด์ธ์.
|
| 400 |
+
11. **์ ๋ํ ํ์**: "๊ฐ์ ๋จ" ๊ฐ์ ๋ชจํธํ ํํ ๊ธ์ง. "ROA 3.2%โ5.1% (+1.9%p)" ๊ฐ์ด ์์น์ ํจ๊ป.
|
| 401 |
+
12. **๋ณตํฉ ์งํ**: Piotroski F, Altman Z, DuPont์ด ์ ๊ณต๋๋ฉด ํด์ ํฌํจ. ์๊ธฐ ๊ฒ์ฆ: ์ธ์ฉ ์์น๋ฅผ ๋ฐ์ดํฐ์์ ์ฌํ์ธ.
|
| 402 |
+
|
| 403 |
+
## ์ฃผ์ ๋น์จ ๊ธฐ์ค
|
| 404 |
+
| ๋น์จ | ์ํธ | ์ฃผ์ | ์ํ |
|
| 405 |
+
|------|------|------|------|
|
| 406 |
+
| ๋ถ์ฑ๋น์จ | <100% | 100-200% | >200% |
|
| 407 |
+
| ์ ๋๋น์จ | >150% | 100-150% | <100% |
|
| 408 |
+
| ROE | >10% | 5-10% | <5% |
|
| 409 |
+
| ์ด์๋ณด์๋ฐฐ์จ | >5x | 1-5x | <1x |
|
| 410 |
+
|
| 411 |
+
## ๋ฐ์ดํฐ ๊ตฌ์กฐ
|
| 412 |
+
- ์ฌ๋ฌด์ ํ(BS/IS/CF): ๊ณ์ ๋ช
+ ์ฐ๋๋ณ ๊ธ์ก (์ต/์กฐ์ ํ์)
|
| 413 |
+
- ์ฌ๋ฌด๋น์จ: ROE, ROA, ์์
์ด์ต๋ฅ ๋ฑ ์๋๊ณ์ฐ ๊ฐ
|
| 414 |
+
- TTM: ์ต๊ทผ 4๋ถ๊ธฐ ํฉ์ฐ (Trailing Twelve Months)
|
| 415 |
+
- ์ ๊ธฐ๋ณด๊ณ ์: year + ์งํ ์ปฌ๋ผ ์๊ณ์ด
|
| 416 |
+
- "-"์ ๋ฐ์ดํฐ ์์
|
| 417 |
+
|
| 418 |
+
## ๊ณต์ ๋๊ตฌ
|
| 419 |
+
- `explore(action='show', topic='...')` โ ๋ธ๋ก ๋ชฉ์ฐจ, `explore(action='show', topic='...', block=0)` โ ์ค์ ๋ฐ์ดํฐ
|
| 420 |
+
- `explore(action='topics')` โ ์ ์ฒด topic, `explore(action='diff')` โ ๊ธฐ๊ฐ๊ฐ ๋ณํ
|
| 421 |
+
- `explore(action='search', keyword='...')` โ ์๋ฌธ ์ฆ๊ฑฐ ๋ธ๋ก ๊ฒ์ (์ธ์ฉ์ฉ)
|
| 422 |
+
- `explore(action='info', topic='...')` โ ๊ธฐ๊ฐ ์ปค๋ฒ๋ฆฌ์ง ์์ฝ
|
| 423 |
+
- ์ฃผ์ฅ์ ๊ทผ๊ฑฐ๋ ๋ฐ๋์ `explore(action='search')`๋ก ์๋ฌธ ์ธ์ฉ. ์ถ์ธก ๊ธ์ง.
|
| 424 |
+
|
| 425 |
+
## ์ ๋ฌธ๊ฐ ๋ถ์ ํ์
|
| 426 |
+
- ์์น ํ์ธ โ **์ธ๊ณผ ๋ถํด**(๋งค์ถ=๋ฌผ๋ร๋จ๊ฐร๋ฏน์ค, ์ด์ต๋ฅ =์๊ฐ์จ+ํ๊ด๋น์จ) โ ์ด์ต์ ์ง(CF/NI, Accrual) โ DuPont ๊ต์ฐจ๊ฒ์ฆ โ ์ข
ํฉ ํ๋จ
|
| 427 |
+
- ์ ์ ์ ํธ: ๊ฐ์ฌ์ธ ๊ต์ฒด, ํน์๊ด๊ณ์๊ฑฐ๋โ, ๋งค์ถ์ฑ๊ถโ>>๋งค์ถโ, 3๋
์ฐ์ CF<NI โ ๋ฐ๋์ โ ๏ธ ๊ฒฝ๊ณ
|
| 428 |
+
- **"๋ฐ์ดํฐ ์๋ค"๊ณ ๋ตํ๊ธฐ ์ ์ explore(action='show')/explore(action='topics')๋ก ๋ฐ๋์ ํ์ธํ ๊ฒ.**
|
| 429 |
+
- ์ด๋ฏธ ํฌํจ๋ ๋ชจ๋์ด ์์ผ๋ฉด ๊ทธ ๋ฐ์ดํฐ๋ฅผ ๋จผ์ ์ฌ์ฉํ๊ณ , ์๋ค๊ณ ๋งํ์ง ๋ง ๊ฒ.
|
| 430 |
+
- ์ปจํ
์คํธ์ `## ์๋ต ๊ณ์ฝ`์ด ์์ผ๋ฉด ์ต์ฐ์ ์ผ๋ก ๋ฐ๋ฅผ ๊ฒ. `## Clarification Needed`๊ฐ ์์ผ๋ฉด ํ ๋ฌธ์ฅ ํ์ธ ์ง๋ฌธ์ ๋จผ์ ํ ๊ฒ.
|
| 431 |
+
- ๋ถ๋ฌธ/์ธ๊ทธ๋จผํธ/์ ํ๋ณ ๋งค์ถ์ `explore(action='show', topic='segments')` ๋๋ `explore(action='show', topic='productService')`๋ก ์กฐํ.
|
| 432 |
+
- ์ ๊ณต๋ ์ฌ๋ฌด ์์ฝ์ด ๋ถ์กฑํ๋ฉด `finance(action='data', module='IS')` ๋ฑ์ผ๋ก ์ ์ฒด ํ
์ด๋ธ ์กฐํ.
|
| 433 |
+
|
| 434 |
+
## ๋ฐ์ดํฐ ์ ๋ขฐ๋
|
| 435 |
+
finance(์ต๊ณ ) > report(๋์) > explore(์์ ) > analyze(ํ์) > market(์ธ๋ถ). ์์ถฉ ์ finance ์ฐ์ .
|
| 436 |
+
|
| 437 |
+
## 3๋ ๊ท์น
|
| 438 |
+
- **Planning**: ๋๊ตฌ ํธ์ถ ์ ์ง๋ฌธ ๋ถ์ (๋ฌด์์ ๋ฌป๋๊ฐ โ ์ด๋ค ๋๊ตฌ โ ์์). ๋ฌด๊ณํ ํธ์ถ ๊ธ์ง.
|
| 439 |
+
- **Persistence**: "๋ฐ์ดํฐ ์์" ์ ์ ๋ฐ๋์ ๋์ ์๋ (search โ topics โ ๋ค๋ฅธ ๋๊ตฌ). ํ ๋ฒ ์คํจ๋ก ํฌ๊ธฐ ๊ธ์ง.
|
| 440 |
+
- **Tool Chaining**: explore+finance 2์ธ์กฐ ๊ธฐ๋ณธ. ์ฌ๋ฌดโfinance(data/ratios)+explore(search), ์ฌ์
๊ตฌ์กฐโexplore(show)+finance(data), ๋ฆฌ์คํฌโexplore(search)+finance, ์ข
ํฉโanalyze(insight)+finance+explore.
|
| 441 |
+
|
| 442 |
+
## ์คํจ ๋ณต๊ตฌ
|
| 443 |
+
- finance ๋น ๊ฒฐ๊ณผ โ finance(modules) ํ์ธ โ ์ฌ์๋
|
| 444 |
+
- explore(show) ๋น ๊ฒฐ๊ณผ โ explore(search, keyword='...') ๊ฒ์
|
| 445 |
+
- analyze ์คํจ โ finance(ratios) + explore(search) ์๋ ์ข
ํฉ
|
| 446 |
+
|
| 447 |
+
- **์ปจํ
์คํธ ์์ฝ๋ง์ผ๋ก ๋ต๋ณ์ ์์ฑํ์ง ๋ง ๊ฒ.** ๋ฐ๋์ ๋๊ตฌ๋ก ์๋ฌธ ํ์ธ ํ ๋ถ์.
|
| 448 |
+
"""
|
| 449 |
+
|
| 450 |
+
# EDGAR(๋ฏธ๊ตญ ๊ธฐ์
) ๋ถ์ ์ ์์คํ
ํ๋กฌํํธ์ append๋๋ ๋ณด์ถฉ ๋ธ๋ก
|
| 451 |
+
EDGAR_SUPPLEMENT_KR = """
|
| 452 |
+
## EDGAR (๋ฏธ๊ตญ ๊ธฐ์
) ํน์ด์ฌํญ
|
| 453 |
+
|
| 454 |
+
์ด ๊ธฐ์
์ ๋ฏธ๊ตญ SEC EDGAR ๊ณต์ ๊ธฐ๋ฐ์
๋๋ค. K-IFRS๊ฐ ์๋ **US GAAP** ์ ์ฉ.
|
| 455 |
+
|
| 456 |
+
### ๋ฐ์ดํฐ ๊ตฌ์กฐ ์ฐจ์ด
|
| 457 |
+
- **report ๋ค์์คํ์ด์ค ์์** โ ํ๊ตญ ์ ๊ธฐ๋ณด๊ณ ์(28๊ฐ API) ๋์ sections์ผ๋ก ๋ชจ๋ ์์ ํ ๋ฐ์ดํฐ ์ ๊ทผ
|
| 458 |
+
- **ํตํ: USD** โ ๊ธ์ก ๋จ์๋ ๋ฌ๋ฌ. ์ต์/์กฐ์์ด ์๋๋ผ $B/$M์ผ๋ก ํ์
|
| 459 |
+
- **ํ๊ณ์ฐ๋**: ๋ฏธ๊ตญ ๊ธฐ์
์ 12์ ๊ฒฐ์ฐ์ด ์๋ ์ ์์ (Apple=9์, Microsoft=6์ ๋ฑ)
|
| 460 |
+
|
| 461 |
+
### topic ํ์
|
| 462 |
+
- 10-K (์ฐ๊ฐ): `10-K::item1Business`, `10-K::item1ARiskFactors`, `10-K::item7MdnA`, `10-K::item8FinancialStatements`
|
| 463 |
+
- 10-Q (๋ถ๊ธฐ): `10-Q::partIItem2Mdna`, `10-Q::partIItem1FinancialStatements`
|
| 464 |
+
- `explore(action='show', topic='10-K::item1ARiskFactors')` โ Risk Factors ์๋ฌธ ์ง์ ์กฐํ
|
| 465 |
+
- `explore(action='search', keyword='MD&A')` โ MD&A ์๋ฌธ ์ฆ๊ฑฐ ๊ฒ์
|
| 466 |
+
|
| 467 |
+
### ๋ถ์ ์ ์ฃผ์
|
| 468 |
+
- US GAAP ์์
์ด์ต ์ ์๊ฐ K-IFRS์ ๋ค๋ฆ (stock-based compensation ์ฒ๋ฆฌ ๋ฑ)
|
| 469 |
+
- `finance(action='report')` ์ฌ์ฉ ๋ถ๊ฐ โ ๋์ `explore(action='show')` + `explore(action='search')` ์กฐํฉ
|
| 470 |
+
- segments, risk factors, MD&A๋ ๋ชจ๋ sections topic์ผ๋ก ์กด์ฌ
|
| 471 |
+
- EDGAR ์ฌ๋ฌด ๋ฐ์ดํฐ๋ SEC XBRL companyfacts ๊ธฐ๋ฐ ์๋ ์ ๊ทํ
|
| 472 |
+
"""
|
| 473 |
+
|
| 474 |
+
EDGAR_SUPPLEMENT_EN = """
|
| 475 |
+
## EDGAR (US Company) Notes
|
| 476 |
+
|
| 477 |
+
This is a US company based on SEC EDGAR filings, under **US GAAP** (not K-IFRS).
|
| 478 |
+
|
| 479 |
+
### Data Structure Differences
|
| 480 |
+
- **No `report` namespace** โ all narrative data accessed via sections (no 28 report APIs)
|
| 481 |
+
- **Currency: USD** โ amounts in dollars ($B/$M), not KRW
|
| 482 |
+
- **Fiscal year**: US companies may not end in December (Apple=Sep, Microsoft=Jun, etc.)
|
| 483 |
+
|
| 484 |
+
### Topic Format
|
| 485 |
+
- 10-K (annual): `10-K::item1Business`, `10-K::item1ARiskFactors`, `10-K::item7MdnA`
|
| 486 |
+
- 10-Q (quarterly): `10-Q::partIItem2Mdna`, `10-Q::partIItem1FinancialStatements`
|
| 487 |
+
- `explore(action='show', topic='10-K::item1ARiskFactors')` โ Risk Factors full text
|
| 488 |
+
- `explore(action='search', keyword='MD&A')` โ MD&A evidence blocks
|
| 489 |
+
|
| 490 |
+
### Analysis Notes
|
| 491 |
+
- US GAAP operating income differs from K-IFRS (e.g., stock-based compensation treatment)
|
| 492 |
+
- `finance(action='report')` not available โ use `explore(action='show')` + `explore(action='search')` instead
|
| 493 |
+
- Segments, risk factors, MD&A all exist as sections topics
|
| 494 |
+
- Financial data is auto-normalized from SEC XBRL companyfacts
|
| 495 |
+
"""
|
src/dartlab/ai/eval/__init__.py
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""AI ๋ต๋ณ ํ๊ฐ ํ๋ ์์ํฌ.
|
| 2 |
+
|
| 3 |
+
Golden dataset + persona question set + replay utilities.
|
| 4 |
+
"""
|
| 5 |
+
|
| 6 |
+
from __future__ import annotations
|
| 7 |
+
|
| 8 |
+
import json
|
| 9 |
+
from pathlib import Path
|
| 10 |
+
|
| 11 |
+
from dartlab.ai.eval.diagnoser import (
|
| 12 |
+
DiagnosisReport,
|
| 13 |
+
diagnoseBatchResults,
|
| 14 |
+
diagnoseFull,
|
| 15 |
+
findCoverageGaps,
|
| 16 |
+
findRegressions,
|
| 17 |
+
findWeakTypes,
|
| 18 |
+
mapCodeImpact,
|
| 19 |
+
)
|
| 20 |
+
from dartlab.ai.eval.remediation import (
|
| 21 |
+
RemediationPlan,
|
| 22 |
+
extractFailureCounts,
|
| 23 |
+
generateRemediations,
|
| 24 |
+
)
|
| 25 |
+
from dartlab.ai.eval.replayRunner import (
|
| 26 |
+
PersonaEvalCase,
|
| 27 |
+
ReplayResult,
|
| 28 |
+
ReviewEntry,
|
| 29 |
+
StructuralEval,
|
| 30 |
+
appendReviewEntry,
|
| 31 |
+
evaluateReplay,
|
| 32 |
+
loadPersonaCases,
|
| 33 |
+
loadPersonaQuestionSet,
|
| 34 |
+
loadReviewLog,
|
| 35 |
+
replayCase,
|
| 36 |
+
replaySuite,
|
| 37 |
+
summarizeReplayResults,
|
| 38 |
+
)
|
| 39 |
+
from dartlab.ai.eval.scorer import ScoreCard, auto_score
|
| 40 |
+
from dartlab.ai.eval.truthHarvester import harvestBatch, harvestTruth
|
| 41 |
+
|
| 42 |
+
_GOLDEN_PATH = Path(__file__).parent / "golden.json"
|
| 43 |
+
|
| 44 |
+
|
| 45 |
+
def load_golden_dataset() -> list[dict]:
|
| 46 |
+
"""golden.json์์ QA pair ๋ก๋."""
|
| 47 |
+
if not _GOLDEN_PATH.exists():
|
| 48 |
+
return []
|
| 49 |
+
with open(_GOLDEN_PATH, encoding="utf-8") as f:
|
| 50 |
+
return json.load(f)
|
| 51 |
+
|
| 52 |
+
|
| 53 |
+
__all__ = [
|
| 54 |
+
"PersonaEvalCase",
|
| 55 |
+
"ReplayResult",
|
| 56 |
+
"ReviewEntry",
|
| 57 |
+
"ScoreCard",
|
| 58 |
+
"StructuralEval",
|
| 59 |
+
"appendReviewEntry",
|
| 60 |
+
"auto_score",
|
| 61 |
+
"evaluateReplay",
|
| 62 |
+
"load_golden_dataset",
|
| 63 |
+
"loadPersonaCases",
|
| 64 |
+
"loadPersonaQuestionSet",
|
| 65 |
+
"loadReviewLog",
|
| 66 |
+
"replayCase",
|
| 67 |
+
"replaySuite",
|
| 68 |
+
"summarizeReplayResults",
|
| 69 |
+
"harvestTruth",
|
| 70 |
+
"harvestBatch",
|
| 71 |
+
"DiagnosisReport",
|
| 72 |
+
"diagnoseBatchResults",
|
| 73 |
+
"diagnoseFull",
|
| 74 |
+
"findCoverageGaps",
|
| 75 |
+
"findRegressions",
|
| 76 |
+
"findWeakTypes",
|
| 77 |
+
"mapCodeImpact",
|
| 78 |
+
"RemediationPlan",
|
| 79 |
+
"extractFailureCounts",
|
| 80 |
+
"generateRemediations",
|
| 81 |
+
]
|
src/dartlab/ai/eval/batchResults/batch_ollama_20260324_180122.jsonl
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"caseId": "analyst.quarterly.operatingProfit", "persona": "analyst", "severity": "critical", "provider": "ollama", "model": "qwen3:latest", "overall": 10.455911574764034, "routeMatch": 1.0, "moduleUtilization": 1.0, "falseUnavailable": 1.0, "factualAccuracy": 2.6363636363636362, "failureTypes": ["ui_wording_failure"], "answerLength": 3265, "timestamp": "20260324_180122"}
|
| 2 |
+
{"caseId": "analyst.quarterly.revenue", "persona": "analyst", "severity": "critical", "provider": "ollama", "model": "qwen3:latest", "overall": 11.461143695014663, "routeMatch": 1.0, "moduleUtilization": 1.0, "falseUnavailable": 1.0, "factualAccuracy": 2.8181818181818183, "failureTypes": [], "answerLength": 4522, "timestamp": "20260324_180122"}
|
src/dartlab/ai/eval/batchResults/batch_ollama_20260325_093749.jsonl
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"caseId": "analyst.quarterly.operatingProfit", "persona": "analyst", "severity": "critical", "provider": "ollama", "model": "qwen3:latest", "overall": 12.584343434343436, "routeMatch": 1.0, "moduleUtilization": 1.0, "falseUnavailable": 1.0, "factualAccuracy": 2.090909090909091, "failureTypes": [], "answerLength": 1027, "timestamp": "20260325_093749"}
|
| 2 |
+
{"caseId": "analyst.quarterly.revenue", "persona": "analyst", "severity": "critical", "provider": "ollama", "model": "qwen3:latest", "overall": 9.671212121212122, "routeMatch": 1.0, "moduleUtilization": 1.0, "falseUnavailable": 1.0, "factualAccuracy": 0.6363636363636364, "failureTypes": [], "answerLength": 647, "timestamp": "20260325_093749"}
|
| 3 |
+
{"caseId": "analyst.deep.comprehensiveHealth", "persona": "analyst", "severity": "critical", "provider": "ollama", "model": "qwen3:latest", "overall": 11.166666666666666, "routeMatch": 1.0, "moduleUtilization": 1.0, "falseUnavailable": 1.0, "factualAccuracy": 1.0, "failureTypes": [], "answerLength": 1478, "timestamp": "20260325_093749"}
|
| 4 |
+
{"caseId": "investor.deep.investmentThesis", "persona": "investor", "severity": "critical", "provider": "ollama", "model": "qwen3:latest", "overall": 9.533333333333333, "routeMatch": 1.0, "moduleUtilization": 0.0, "falseUnavailable": 1.0, "factualAccuracy": 1.0, "failureTypes": ["retrieval_failure"], "answerLength": 556, "timestamp": "20260325_093749"}
|
src/dartlab/ai/eval/diagnoser.py
ADDED
|
@@ -0,0 +1,309 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""์๋ ์ง๋จ ์์ง โ ๋ฐฐ์น ๊ฒฐ๊ณผ์์ ์ฝ์ /๊ฐญ/ํ๊ท๋ฅผ ์๋ ๋ฐ๊ฒฌ."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import json
|
| 6 |
+
from dataclasses import dataclass, field
|
| 7 |
+
from datetime import datetime
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
from typing import Any
|
| 10 |
+
|
| 11 |
+
|
| 12 |
+
@dataclass
|
| 13 |
+
class WeakTypeReport:
|
| 14 |
+
"""์ง๋ฌธ ์ ํ๋ณ ์ฝ์ ๋ณด๊ณ ."""
|
| 15 |
+
|
| 16 |
+
questionType: str
|
| 17 |
+
avgOverall: float
|
| 18 |
+
caseCount: int
|
| 19 |
+
topFailures: list[str]
|
| 20 |
+
|
| 21 |
+
|
| 22 |
+
@dataclass
|
| 23 |
+
class CoverageGap:
|
| 24 |
+
"""eval ์ผ์ด์ค๊ฐ ์ปค๋ฒํ์ง ์๋ ์์ญ."""
|
| 25 |
+
|
| 26 |
+
kind: str # "route", "module", "persona", "severity", "stockCode"
|
| 27 |
+
detail: str
|
| 28 |
+
suggestion: str
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
@dataclass
|
| 32 |
+
class Regression:
|
| 33 |
+
"""์ด์ ๋ฐฐ์น ๋๋น ์ ์ ํ๋ฝ."""
|
| 34 |
+
|
| 35 |
+
caseId: str
|
| 36 |
+
prevOverall: float
|
| 37 |
+
currOverall: float
|
| 38 |
+
delta: float
|
| 39 |
+
likelyFailures: list[str]
|
| 40 |
+
|
| 41 |
+
|
| 42 |
+
@dataclass
|
| 43 |
+
class DiagnosisReport:
|
| 44 |
+
"""์ ์ฒด ์ง๋จ ๊ฒฐ๊ณผ."""
|
| 45 |
+
|
| 46 |
+
weakTypes: list[WeakTypeReport] = field(default_factory=list)
|
| 47 |
+
coverageGaps: list[CoverageGap] = field(default_factory=list)
|
| 48 |
+
regressions: list[Regression] = field(default_factory=list)
|
| 49 |
+
timestamp: str = ""
|
| 50 |
+
|
| 51 |
+
def toMarkdown(self) -> str:
|
| 52 |
+
"""๋งํฌ๋ค์ด ํ์์ผ๋ก ๋ณํ."""
|
| 53 |
+
lines = [f"# Eval ์ง๋จ ๋ฆฌํฌํธ โ {self.timestamp}", ""]
|
| 54 |
+
|
| 55 |
+
if self.weakTypes:
|
| 56 |
+
lines.append("## ์ฝ์ ์ ํ (ํ์ ์ ์)")
|
| 57 |
+
lines.append("")
|
| 58 |
+
lines.append("| ์ ํ | ํ๊ท ์ ์ | ์ผ์ด์ค ์ | ์ฃผ์ ์คํจ |")
|
| 59 |
+
lines.append("|------|---------|---------|---------|")
|
| 60 |
+
for w in self.weakTypes:
|
| 61 |
+
failures = ", ".join(w.topFailures[:3]) or "-"
|
| 62 |
+
lines.append(f"| {w.questionType} | {w.avgOverall:.2f} | {w.caseCount} | {failures} |")
|
| 63 |
+
lines.append("")
|
| 64 |
+
|
| 65 |
+
if self.coverageGaps:
|
| 66 |
+
lines.append("## ์ปค๋ฒ๋ฆฌ์ง ๊ฐญ")
|
| 67 |
+
lines.append("")
|
| 68 |
+
for g in self.coverageGaps:
|
| 69 |
+
lines.append(f"- **[{g.kind}]** {g.detail} โ {g.suggestion}")
|
| 70 |
+
lines.append("")
|
| 71 |
+
|
| 72 |
+
if self.regressions:
|
| 73 |
+
lines.append("## ํ๊ท ๊ฐ์ง")
|
| 74 |
+
lines.append("")
|
| 75 |
+
lines.append("| ์ผ์ด์ค | ์ด์ | ํ์ฌ | ๋ณํ | ์คํจ ์ ํ |")
|
| 76 |
+
lines.append("|--------|------|------|------|---------|")
|
| 77 |
+
for r in self.regressions:
|
| 78 |
+
failures = ", ".join(r.likelyFailures[:3]) or "-"
|
| 79 |
+
lines.append(
|
| 80 |
+
f"| {r.caseId} | {r.prevOverall:.2f} | {r.currOverall:.2f} | {r.delta:+.2f} | {failures} |"
|
| 81 |
+
)
|
| 82 |
+
lines.append("")
|
| 83 |
+
|
| 84 |
+
if not self.weakTypes and not self.coverageGaps and not self.regressions:
|
| 85 |
+
lines.append("๋ชจ๋ ํญ๋ชฉ ์ํธ.")
|
| 86 |
+
|
| 87 |
+
return "\n".join(lines)
|
| 88 |
+
|
| 89 |
+
|
| 90 |
+
def findWeakTypes(results: list[dict[str, Any]], bottomN: int = 3) -> list[WeakTypeReport]:
|
| 91 |
+
"""์ง๋ฌธ ์ ํ๋ณ ํ๊ท ์ ์ ๊ณ์ฐ, ํ์ N๊ฐ ๋ฐํ."""
|
| 92 |
+
typeScores: dict[str, list[float]] = {}
|
| 93 |
+
typeFailures: dict[str, list[str]] = {}
|
| 94 |
+
|
| 95 |
+
for r in results:
|
| 96 |
+
qType = r.get("questionType") or r.get("userIntent") or "unknown"
|
| 97 |
+
overall = r.get("overall", 0.0)
|
| 98 |
+
failures = r.get("failureTypes", [])
|
| 99 |
+
|
| 100 |
+
typeScores.setdefault(qType, []).append(overall)
|
| 101 |
+
typeFailures.setdefault(qType, []).extend(failures)
|
| 102 |
+
|
| 103 |
+
reports = []
|
| 104 |
+
for qType, scores in typeScores.items():
|
| 105 |
+
avg = sum(scores) / len(scores) if scores else 0.0
|
| 106 |
+
# ์คํจ ์ ํ ๋น๋์
|
| 107 |
+
failureCounts: dict[str, int] = {}
|
| 108 |
+
for f in typeFailures.get(qType, []):
|
| 109 |
+
failureCounts[f] = failureCounts.get(f, 0) + 1
|
| 110 |
+
topFailures = sorted(failureCounts, key=failureCounts.get, reverse=True) # type: ignore[arg-type]
|
| 111 |
+
reports.append(WeakTypeReport(qType, avg, len(scores), topFailures[:3]))
|
| 112 |
+
|
| 113 |
+
reports.sort(key=lambda r: r.avgOverall)
|
| 114 |
+
return reports[:bottomN]
|
| 115 |
+
|
| 116 |
+
|
| 117 |
+
def findCoverageGaps(cases: list[dict[str, Any]]) -> list[CoverageGap]:
|
| 118 |
+
"""์ผ์ด์ค ์งํฉ์ ์ปค๋ฒ๋ฆฌ์ง ๋ถ์กฑ ์์ญ ํ์ง."""
|
| 119 |
+
gaps: list[CoverageGap] = []
|
| 120 |
+
|
| 121 |
+
# 1. persona ๊ท ํ (์ต์ 3๊ฐ)
|
| 122 |
+
personaCounts: dict[str, int] = {}
|
| 123 |
+
for c in cases:
|
| 124 |
+
p = c.get("persona", "unknown")
|
| 125 |
+
personaCounts[p] = personaCounts.get(p, 0) + 1
|
| 126 |
+
for persona, count in personaCounts.items():
|
| 127 |
+
if count < 3:
|
| 128 |
+
gaps.append(
|
| 129 |
+
CoverageGap(
|
| 130 |
+
"persona",
|
| 131 |
+
f"{persona}: {count}๊ฐ ์ผ์ด์ค",
|
| 132 |
+
f"{persona} persona์ ์ผ์ด์ค {3 - count}๊ฐ ์ถ๊ฐ ํ์",
|
| 133 |
+
)
|
| 134 |
+
)
|
| 135 |
+
|
| 136 |
+
# 2. route ์ปค๋ฒ๋ฆฌ์ง
|
| 137 |
+
routes = {c.get("expectedRoute") for c in cases if c.get("expectedRoute")}
|
| 138 |
+
requiredRoutes = {"finance", "sections", "hybrid", "report"}
|
| 139 |
+
for r in requiredRoutes - routes:
|
| 140 |
+
gaps.append(CoverageGap("route", f"route '{r}' ๋ฏธ์ปค๋ฒ", f"expectedRoute='{r}'์ธ ์ผ์ด์ค ์ถ๊ฐ"))
|
| 141 |
+
|
| 142 |
+
# 3. severity ๋ถํฌ
|
| 143 |
+
severityCounts: dict[str, int] = {}
|
| 144 |
+
for c in cases:
|
| 145 |
+
s = c.get("severity", "medium")
|
| 146 |
+
severityCounts[s] = severityCounts.get(s, 0) + 1
|
| 147 |
+
total = len(cases) or 1
|
| 148 |
+
criticalHigh = severityCounts.get("critical", 0) + severityCounts.get("high", 0)
|
| 149 |
+
if criticalHigh / total < 0.4:
|
| 150 |
+
gaps.append(
|
| 151 |
+
CoverageGap(
|
| 152 |
+
"severity",
|
| 153 |
+
f"critical+high = {criticalHigh}/{total} ({criticalHigh / total:.0%})",
|
| 154 |
+
"critical/high severity ์ผ์ด์ค ๋น์จ 40% ์ด์์ผ๋ก",
|
| 155 |
+
)
|
| 156 |
+
)
|
| 157 |
+
|
| 158 |
+
# 4. ์ข
๋ชฉ์ฝ๋ ํธ์ค
|
| 159 |
+
stockCounts: dict[str, int] = {}
|
| 160 |
+
stockCases = [c for c in cases if c.get("stockCode")]
|
| 161 |
+
for c in stockCases:
|
| 162 |
+
sc = c["stockCode"]
|
| 163 |
+
stockCounts[sc] = stockCounts.get(sc, 0) + 1
|
| 164 |
+
if stockCases:
|
| 165 |
+
for sc, count in stockCounts.items():
|
| 166 |
+
if count / len(stockCases) > 0.6:
|
| 167 |
+
gaps.append(
|
| 168 |
+
CoverageGap(
|
| 169 |
+
"stockCode",
|
| 170 |
+
f"{sc}: {count}/{len(stockCases)} ({count / len(stockCases):.0%})",
|
| 171 |
+
"๋ค๋ฅธ ์ข
๋ชฉ์ฝ๋ ์ผ์ด์ค ์ถ๊ฐ๋ก ํธ์ค ํด์",
|
| 172 |
+
)
|
| 173 |
+
)
|
| 174 |
+
|
| 175 |
+
# 5. module ์ปค๋ฒ๋ฆฌ์ง
|
| 176 |
+
coveredModules: set[str] = set()
|
| 177 |
+
for c in cases:
|
| 178 |
+
coveredModules.update(c.get("expectedModules", []))
|
| 179 |
+
|
| 180 |
+
# ํต์ฌ ๋ชจ๋ ๋ชฉ๋ก
|
| 181 |
+
coreModules = {"IS", "BS", "CF", "ratios", "costByNature", "segments", "businessOverview", "governanceOverview"}
|
| 182 |
+
missing = coreModules - coveredModules
|
| 183 |
+
for m in missing:
|
| 184 |
+
gaps.append(CoverageGap("module", f"๋ชจ๋ '{m}' ๋ฏธ์ปค๋ฒ", f"expectedModules์ '{m}' ํฌํจํ๋ ์ผ์ด์ค ์ถ๊ฐ"))
|
| 185 |
+
|
| 186 |
+
return gaps
|
| 187 |
+
|
| 188 |
+
|
| 189 |
+
def findRegressions(
|
| 190 |
+
currentResults: list[dict[str, Any]],
|
| 191 |
+
previousResults: list[dict[str, Any]],
|
| 192 |
+
threshold: float = -0.1,
|
| 193 |
+
) -> list[Regression]:
|
| 194 |
+
"""์ด์ ๋ฐฐ์น ๋๋น ์ ์ ํ๋ฝ ์ผ์ด์ค ํ์ง."""
|
| 195 |
+
prevMap: dict[str, dict[str, Any]] = {r["caseId"]: r for r in previousResults if "caseId" in r}
|
| 196 |
+
regressions: list[Regression] = []
|
| 197 |
+
|
| 198 |
+
for curr in currentResults:
|
| 199 |
+
caseId = curr.get("caseId", "")
|
| 200 |
+
if caseId not in prevMap:
|
| 201 |
+
continue
|
| 202 |
+
prev = prevMap[caseId]
|
| 203 |
+
delta = curr.get("overall", 0) - prev.get("overall", 0)
|
| 204 |
+
if delta < threshold:
|
| 205 |
+
regressions.append(
|
| 206 |
+
Regression(
|
| 207 |
+
caseId=caseId,
|
| 208 |
+
prevOverall=prev.get("overall", 0),
|
| 209 |
+
currOverall=curr.get("overall", 0),
|
| 210 |
+
delta=delta,
|
| 211 |
+
likelyFailures=curr.get("failureTypes", []),
|
| 212 |
+
)
|
| 213 |
+
)
|
| 214 |
+
|
| 215 |
+
regressions.sort(key=lambda r: r.delta)
|
| 216 |
+
return regressions
|
| 217 |
+
|
| 218 |
+
|
| 219 |
+
# โโ ์ฝ๋ ๋ณ๊ฒฝ โ ์ผ์ด์ค ์ํฅ ๋งคํ โโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 220 |
+
|
| 221 |
+
_FILE_CASE_IMPACT: dict[str, list[str]] = {
|
| 222 |
+
"context/builder.py": ["*"],
|
| 223 |
+
"context/finance_context.py": ["analyst.*", "investor.*", "accountant.*"],
|
| 224 |
+
"conversation/templates/analysis_rules.py": ["*"],
|
| 225 |
+
"conversation/prompts.py": ["*"],
|
| 226 |
+
"runtime/pipeline.py": ["analyst.*", "investor.*", "accountant.*"],
|
| 227 |
+
"tools/recipes.py": ["analyst.*", "investor.*"],
|
| 228 |
+
"tools/defaults/analysis.py": ["analyst.*", "investor.*"],
|
| 229 |
+
"tools/defaults/market.py": ["investor.*", "analyst.*"],
|
| 230 |
+
}
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
def mapCodeImpact(changedFiles: list[str], cases: list[dict[str, Any]]) -> list[str]:
|
| 234 |
+
"""๋ณ๊ฒฝ๋ ํ์ผ โ ์ํฅ๋ฐ๋ ์ผ์ด์ค ID ๋ฐํ."""
|
| 235 |
+
impactPatterns: set[str] = set()
|
| 236 |
+
for f in changedFiles:
|
| 237 |
+
for key, patterns in _FILE_CASE_IMPACT.items():
|
| 238 |
+
if key in f.replace("\\", "/"):
|
| 239 |
+
impactPatterns.update(patterns)
|
| 240 |
+
|
| 241 |
+
if "*" in impactPatterns:
|
| 242 |
+
return [c.get("id", "") for c in cases]
|
| 243 |
+
|
| 244 |
+
import fnmatch
|
| 245 |
+
|
| 246 |
+
impacted: list[str] = []
|
| 247 |
+
for c in cases:
|
| 248 |
+
caseId = c.get("id", "")
|
| 249 |
+
for pat in impactPatterns:
|
| 250 |
+
if fnmatch.fnmatch(caseId, pat):
|
| 251 |
+
impacted.append(caseId)
|
| 252 |
+
break
|
| 253 |
+
return impacted
|
| 254 |
+
|
| 255 |
+
|
| 256 |
+
def diagnoseBatchResults(batchPath: Path) -> DiagnosisReport:
|
| 257 |
+
"""๋ฐฐ์น ๊ฒฐ๊ณผ JSONL ํ์ผ์ ๋ถ์ํด์ ์ง๋จ ๋ฆฌํฌํธ ์์ฑ."""
|
| 258 |
+
results: list[dict[str, Any]] = []
|
| 259 |
+
with open(batchPath, encoding="utf-8") as f:
|
| 260 |
+
for line in f:
|
| 261 |
+
line = line.strip()
|
| 262 |
+
if line:
|
| 263 |
+
results.append(json.loads(line))
|
| 264 |
+
|
| 265 |
+
report = DiagnosisReport(
|
| 266 |
+
weakTypes=findWeakTypes(results),
|
| 267 |
+
coverageGaps=[], # ๋ฐฐ์น ๊ฒฐ๊ณผ๋ง์ผ๋ก๋ ์ผ์ด์ค ๊ฐญ ๋ถ๊ฐ โ cases ํ์
|
| 268 |
+
regressions=[],
|
| 269 |
+
timestamp=datetime.now().strftime("%Y-%m-%d %H:%M"),
|
| 270 |
+
)
|
| 271 |
+
return report
|
| 272 |
+
|
| 273 |
+
|
| 274 |
+
def diagnoseFull(
|
| 275 |
+
batchPath: Path | None = None,
|
| 276 |
+
previousBatchPath: Path | None = None,
|
| 277 |
+
casesPath: Path | None = None,
|
| 278 |
+
) -> DiagnosisReport:
|
| 279 |
+
"""์ ์ฒด ์ง๋จ (์ฝ์ + ๊ฐญ + ํ๊ท)."""
|
| 280 |
+
report = DiagnosisReport(timestamp=datetime.now().strftime("%Y-%m-%d %H:%M"))
|
| 281 |
+
|
| 282 |
+
# ๋ฐฐ์น ๊ฒฐ๊ณผ ๋ถ์
|
| 283 |
+
if batchPath and batchPath.exists():
|
| 284 |
+
results: list[dict[str, Any]] = []
|
| 285 |
+
with open(batchPath, encoding="utf-8") as f:
|
| 286 |
+
for line in f:
|
| 287 |
+
line = line.strip()
|
| 288 |
+
if line:
|
| 289 |
+
results.append(json.loads(line))
|
| 290 |
+
report.weakTypes = findWeakTypes(results)
|
| 291 |
+
|
| 292 |
+
# ํ๊ท ํ์ง
|
| 293 |
+
if previousBatchPath and previousBatchPath.exists():
|
| 294 |
+
prevResults: list[dict[str, Any]] = []
|
| 295 |
+
with open(previousBatchPath, encoding="utf-8") as f:
|
| 296 |
+
for line in f:
|
| 297 |
+
line = line.strip()
|
| 298 |
+
if line:
|
| 299 |
+
prevResults.append(json.loads(line))
|
| 300 |
+
report.regressions = findRegressions(results, prevResults)
|
| 301 |
+
|
| 302 |
+
# ์ปค๋ฒ๋ฆฌ์ง ๊ฐญ
|
| 303 |
+
if casesPath and casesPath.exists():
|
| 304 |
+
with open(casesPath, encoding="utf-8") as f:
|
| 305 |
+
data = json.load(f)
|
| 306 |
+
cases = data.get("cases", data) if isinstance(data, dict) else data
|
| 307 |
+
report.coverageGaps = findCoverageGaps(cases)
|
| 308 |
+
|
| 309 |
+
return report
|
src/dartlab/ai/eval/diagnosisReports/diagnosis_batch_20260325_093749.md
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Eval ์ง๋จ ๋ฆฌํฌํธ โ 2026-03-25 09:37
|
| 2 |
+
|
| 3 |
+
## ์ฝ์ ์ ํ (ํ์ ์ ์)
|
| 4 |
+
|
| 5 |
+
| ์ ํ | ํ๊ท ์ ์ | ์ผ์ด์ค ์ | ์ฃผ์ ์คํจ |
|
| 6 |
+
|------|---------|---------|---------|
|
| 7 |
+
| unknown | 10.74 | 4 | retrieval_failure |
|
| 8 |
+
|
| 9 |
+
|
| 10 |
+
# ๊ฐ์ ๊ณํ (Remediation)
|
| 11 |
+
|
| 12 |
+
| ์ฐ์ ์์ | Failure | ๋์ ํ์ผ | ์ค๋ช
| ์ํฅ๋ |
|
| 13 |
+
|---------|---------|----------|------|-------|
|
| 14 |
+
| P3 | retrieval_failure | `engines/ai/context/finance_context.py` | _QUESTION_MODULES ๋งคํ์ ๋ชจ๋ ์ถ๊ฐ (๋ฐ์ 1ํ) | high |
|
src/dartlab/ai/eval/golden.json
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{
|
| 3 |
+
"id": 1,
|
| 4 |
+
"stock_code": "005930",
|
| 5 |
+
"question": "์ผ์ฑ์ ์์ ์ต๊ทผ ์ฌ๋ฌด ๊ฑด์ ์ฑ์?",
|
| 6 |
+
"expected_topics": ["๋ถ์ฑ๋น์จ", "์ ๋๋น์จ", "์๋ณธ", "๊ฑด์ "],
|
| 7 |
+
"expected_facts": [],
|
| 8 |
+
"category": "health"
|
| 9 |
+
},
|
| 10 |
+
{
|
| 11 |
+
"id": 2,
|
| 12 |
+
"stock_code": "005930",
|
| 13 |
+
"question": "์ผ์ฑ์ ์ ๋งค์ถ ์ถ์ด๋ฅผ ๋ถ์ํด์ค",
|
| 14 |
+
"expected_topics": ["๋งค์ถ", "์ฑ์ฅ", "์ถ์ด", "์ ๋
"],
|
| 15 |
+
"expected_facts": [],
|
| 16 |
+
"category": "performance"
|
| 17 |
+
},
|
| 18 |
+
{
|
| 19 |
+
"id": 3,
|
| 20 |
+
"stock_code": "005930",
|
| 21 |
+
"question": "์ผ์ฑ์ ์ ๋ฐฐ๋น ์ ์ฑ
์?",
|
| 22 |
+
"expected_topics": ["๋ฐฐ๋น", "DPS", "๋ฐฐ๋น์์ต๋ฅ ", "๋ฐฐ๋น์ฑํฅ"],
|
| 23 |
+
"expected_facts": [],
|
| 24 |
+
"category": "dividend"
|
| 25 |
+
},
|
| 26 |
+
{
|
| 27 |
+
"id": 4,
|
| 28 |
+
"stock_code": "005930",
|
| 29 |
+
"question": "์ผ์ฑ์ ์ ์์ต์ฑ์ ์ด๋?",
|
| 30 |
+
"expected_topics": ["์์
์ด์ต", "์์
์ด์ต๋ฅ ", "ROE", "์์ต์ฑ"],
|
| 31 |
+
"expected_facts": [],
|
| 32 |
+
"category": "profitability"
|
| 33 |
+
},
|
| 34 |
+
{
|
| 35 |
+
"id": 5,
|
| 36 |
+
"stock_code": "005930",
|
| 37 |
+
"question": "์ผ์ฑ์ ์ ํ๊ธํ๋ฆ์ ๋ถ์ํด์ค",
|
| 38 |
+
"expected_topics": ["์์
ํ๋", "ํฌ์ํ๋", "์ฌ๋ฌดํ๋", "ํ๊ธ", "FCF"],
|
| 39 |
+
"expected_facts": [],
|
| 40 |
+
"category": "cashflow"
|
| 41 |
+
},
|
| 42 |
+
{
|
| 43 |
+
"id": 6,
|
| 44 |
+
"stock_code": "000660",
|
| 45 |
+
"question": "SKํ์ด๋์ค ์ต๊ทผ ์ค์ ์?",
|
| 46 |
+
"expected_topics": ["๋งค์ถ", "์์
์ด์ต", "์์ด์ต", "๋ฐ๋์ฒด"],
|
| 47 |
+
"expected_facts": [],
|
| 48 |
+
"category": "performance"
|
| 49 |
+
},
|
| 50 |
+
{
|
| 51 |
+
"id": 7,
|
| 52 |
+
"stock_code": "005380",
|
| 53 |
+
"question": "ํ๋์ฐจ ๋ถ์ฑ ์ํฉ์?",
|
| 54 |
+
"expected_topics": ["๋ถ์ฑ", "๋ถ์ฑ๋น์จ", "์ฐจ์
๊ธ", "๊ฑด์ "],
|
| 55 |
+
"expected_facts": [],
|
| 56 |
+
"category": "health"
|
| 57 |
+
},
|
| 58 |
+
{
|
| 59 |
+
"id": 8,
|
| 60 |
+
"stock_code": "035420",
|
| 61 |
+
"question": "๋ค์ด๋ฒ ์ฑ์ฅ์ฑ ๋ถ์",
|
| 62 |
+
"expected_topics": ["๋งค์ถ", "์ฑ์ฅ", "CAGR", "์ ๋
"],
|
| 63 |
+
"expected_facts": [],
|
| 64 |
+
"category": "growth"
|
| 65 |
+
},
|
| 66 |
+
{
|
| 67 |
+
"id": 9,
|
| 68 |
+
"stock_code": "005930",
|
| 69 |
+
"question": "์ผ์ฑ์ ์์ ์ข
ํฉ ์ธ์ฌ์ดํธ๋ฅผ ์๋ ค์ค",
|
| 70 |
+
"expected_topics": ["์ค์ ", "์์ต์ฑ", "๊ฑด์ ์ฑ", "ํ๊ธํ๋ฆ", "๋ฑ๊ธ"],
|
| 71 |
+
"expected_facts": [],
|
| 72 |
+
"category": "insight"
|
| 73 |
+
},
|
| 74 |
+
{
|
| 75 |
+
"id": 10,
|
| 76 |
+
"stock_code": "005930",
|
| 77 |
+
"question": "์ผ์ฑ์ ์๊ฐ ์ํ ์นํฐ์ ์์ฅ ์์๋?",
|
| 78 |
+
"expected_topics": ["์นํฐ", "์์", "๋ฐ๋์ฒด"],
|
| 79 |
+
"expected_facts": [],
|
| 80 |
+
"category": "meta"
|
| 81 |
+
}
|
| 82 |
+
]
|
src/dartlab/ai/eval/personaCases.json
ADDED
|
@@ -0,0 +1,2441 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"version": "2026-03-24-v1",
|
| 3 |
+
"updated": "2026-03-24",
|
| 4 |
+
"source": "curated_persona_regression",
|
| 5 |
+
"cases": [
|
| 6 |
+
{
|
| 7 |
+
"id": "assistant.capabilities.overview",
|
| 8 |
+
"persona": "assistant",
|
| 9 |
+
"personaLabel": "๋น์",
|
| 10 |
+
"stockCode": null,
|
| 11 |
+
"question": "dartlab์ผ๋ก ์ง๊ธ ๋ฐ๋ก ์ด๋ค ์ง๋ฌธ๋ค์ ํ ์ ์๋์ง ์ฌ์ฉ์๊ฐ ์ดํดํ๊ธฐ ์ฝ๊ฒ ์ค๋ช
ํด์ค",
|
| 12 |
+
"userIntent": "capability_overview",
|
| 13 |
+
"expectedAnswerShape": [
|
| 14 |
+
"๊ธฐ๋ฅ์์ฝ",
|
| 15 |
+
"์์์ง๋ฌธ",
|
| 16 |
+
"์ฌ์ฉ์์ธ์ด"
|
| 17 |
+
],
|
| 18 |
+
"expectedEvidenceKinds": [
|
| 19 |
+
"capability"
|
| 20 |
+
],
|
| 21 |
+
"expectedUserFacingTerms": [
|
| 22 |
+
"์ง๋ฌธ",
|
| 23 |
+
"๊ณต์",
|
| 24 |
+
"์ฌ๋ฌด"
|
| 25 |
+
],
|
| 26 |
+
"forbiddenUiTerms": [
|
| 27 |
+
"company.show",
|
| 28 |
+
"get_data",
|
| 29 |
+
"show_topic()",
|
| 30 |
+
"module_"
|
| 31 |
+
],
|
| 32 |
+
"expectedRoute": null,
|
| 33 |
+
"expectedModules": [],
|
| 34 |
+
"allowedClarification": false,
|
| 35 |
+
"mustNotSay": [],
|
| 36 |
+
"mustInclude": [
|
| 37 |
+
"๊ณต์",
|
| 38 |
+
"์ฌ๋ฌด",
|
| 39 |
+
"์ง๋ฌธ"
|
| 40 |
+
],
|
| 41 |
+
"expectedFollowups": [
|
| 42 |
+
"์๋ฅผ ๋ค์ด",
|
| 43 |
+
"์ถ๊ฐ๋ก"
|
| 44 |
+
],
|
| 45 |
+
"groundTruthFacts": [],
|
| 46 |
+
"severity": "medium"
|
| 47 |
+
},
|
| 48 |
+
{
|
| 49 |
+
"id": "dataManager.coverage.readiness",
|
| 50 |
+
"persona": "data_manager",
|
| 51 |
+
"personaLabel": "DartLab ๋ฐ์ดํฐ ๊ด๋ฆฌ์",
|
| 52 |
+
"stockCode": "005930",
|
| 53 |
+
"question": "์ผ์ฑ์ ์ ๋ฐ์ดํฐ๊ฐ ์ง๊ธ ์ด๋๊น์ง ์ค๋น๋ผ ์๋์ง ๊ณต์, ์ฌ๋ฌด, ์ ํ ๋ฐ์ดํฐ ๊ธฐ์ค์ผ๋ก ๋๋ ์ ์ค๋ช
ํด์ค",
|
| 54 |
+
"userIntent": "data_readiness",
|
| 55 |
+
"expectedAnswerShape": [
|
| 56 |
+
"์ค๋น์ํ",
|
| 57 |
+
"๊ทผ๊ฑฐ",
|
| 58 |
+
"๋๋ฝ์์ญ"
|
| 59 |
+
],
|
| 60 |
+
"expectedEvidenceKinds": [
|
| 61 |
+
"data_ready",
|
| 62 |
+
"docs",
|
| 63 |
+
"finance",
|
| 64 |
+
"report"
|
| 65 |
+
],
|
| 66 |
+
"expectedUserFacingTerms": [
|
| 67 |
+
"๊ณต์",
|
| 68 |
+
"์ฌ๋ฌด",
|
| 69 |
+
"์ ํ ๋ฐ์ดํฐ"
|
| 70 |
+
],
|
| 71 |
+
"forbiddenUiTerms": [
|
| 72 |
+
"company.show",
|
| 73 |
+
"module_"
|
| 74 |
+
],
|
| 75 |
+
"expectedRoute": "sections",
|
| 76 |
+
"expectedModules": [
|
| 77 |
+
"BS",
|
| 78 |
+
"IS",
|
| 79 |
+
"CF"
|
| 80 |
+
],
|
| 81 |
+
"allowedClarification": false,
|
| 82 |
+
"mustNotSay": [
|
| 83 |
+
"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค"
|
| 84 |
+
],
|
| 85 |
+
"mustInclude": [
|
| 86 |
+
"๊ณต์",
|
| 87 |
+
"์ฌ๋ฌด",
|
| 88 |
+
"์ ํ"
|
| 89 |
+
],
|
| 90 |
+
"expectedFollowups": [
|
| 91 |
+
"์ถ๊ฐ",
|
| 92 |
+
"ํ์ธ"
|
| 93 |
+
],
|
| 94 |
+
"groundTruthFacts": [],
|
| 95 |
+
"severity": "medium"
|
| 96 |
+
},
|
| 97 |
+
{
|
| 98 |
+
"id": "operator.config.channels",
|
| 99 |
+
"persona": "operator",
|
| 100 |
+
"personaLabel": "DartLab ์ด์์",
|
| 101 |
+
"stockCode": null,
|
| 102 |
+
"question": "AI ์ค์ ์ํ์ ์ธ๋ถ ์ฑ๋ ์ฐ๊ฒฐ ์ํ๋ฅผ ์ด์์ ๊ด์ ์์ ๊ฐ์ด ์ ๊ฒํด์ค",
|
| 103 |
+
"userIntent": "ops_status",
|
| 104 |
+
"expectedAnswerShape": [
|
| 105 |
+
"์ํ์ ๊ฒ",
|
| 106 |
+
"์์ธ",
|
| 107 |
+
"๋ค์์กฐ์น"
|
| 108 |
+
],
|
| 109 |
+
"expectedEvidenceKinds": [
|
| 110 |
+
"provider_status",
|
| 111 |
+
"channel_status"
|
| 112 |
+
],
|
| 113 |
+
"expectedUserFacingTerms": [
|
| 114 |
+
"์ค์ ",
|
| 115 |
+
"์ฐ๊ฒฐ",
|
| 116 |
+
"์ด์"
|
| 117 |
+
],
|
| 118 |
+
"forbiddenUiTerms": [
|
| 119 |
+
"show_topic()",
|
| 120 |
+
"module_"
|
| 121 |
+
],
|
| 122 |
+
"expectedRoute": null,
|
| 123 |
+
"expectedModules": [],
|
| 124 |
+
"allowedClarification": false,
|
| 125 |
+
"mustNotSay": [],
|
| 126 |
+
"mustInclude": [
|
| 127 |
+
"์ค์ ",
|
| 128 |
+
"์ฐ๊ฒฐ"
|
| 129 |
+
],
|
| 130 |
+
"expectedFollowups": [
|
| 131 |
+
"๋ค์",
|
| 132 |
+
"์ ๊ฒ"
|
| 133 |
+
],
|
| 134 |
+
"groundTruthFacts": [],
|
| 135 |
+
"severity": "medium"
|
| 136 |
+
},
|
| 137 |
+
{
|
| 138 |
+
"id": "installer.opendart.key",
|
| 139 |
+
"persona": "installer",
|
| 140 |
+
"personaLabel": "DartLab ์ค์น์",
|
| 141 |
+
"stockCode": null,
|
| 142 |
+
"question": "OpenDART ํค๊ฐ ์ ํ์ํ๊ณ ์์ผ๋ฉด ์ด๋ค ๊ธฐ๋ฅ์ด ๋งํ๋์ง ์ค์น์ ์
์ฅ์์ ์ค๋ช
ํด์ค",
|
| 143 |
+
"userIntent": "setup_guidance",
|
| 144 |
+
"expectedAnswerShape": [
|
| 145 |
+
"ํ์์ฑ",
|
| 146 |
+
"์ํฅ๋ฒ์",
|
| 147 |
+
"์ค์ ๊ฐ์ด๋"
|
| 148 |
+
],
|
| 149 |
+
"expectedEvidenceKinds": [
|
| 150 |
+
"open_dart_status"
|
| 151 |
+
],
|
| 152 |
+
"expectedUserFacingTerms": [
|
| 153 |
+
"OpenDART",
|
| 154 |
+
"์ค์ ",
|
| 155 |
+
"๊ณต์"
|
| 156 |
+
],
|
| 157 |
+
"forbiddenUiTerms": [
|
| 158 |
+
"get_dart_filing_text",
|
| 159 |
+
"search_dart_filings"
|
| 160 |
+
],
|
| 161 |
+
"expectedRoute": null,
|
| 162 |
+
"expectedModules": [],
|
| 163 |
+
"allowedClarification": false,
|
| 164 |
+
"mustNotSay": [],
|
| 165 |
+
"mustInclude": [
|
| 166 |
+
"OpenDART",
|
| 167 |
+
"์ค์ "
|
| 168 |
+
],
|
| 169 |
+
"expectedFollowups": [
|
| 170 |
+
"์ค์ ",
|
| 171 |
+
"๋ค์"
|
| 172 |
+
],
|
| 173 |
+
"groundTruthFacts": [],
|
| 174 |
+
"severity": "medium"
|
| 175 |
+
},
|
| 176 |
+
{
|
| 177 |
+
"id": "researchGather.structure.recentDisclosures",
|
| 178 |
+
"persona": "research_gather",
|
| 179 |
+
"personaLabel": "๋ฆฌ์์น ๊ฒ๋ ์์ง ์ฌ์ฉ์",
|
| 180 |
+
"stockCode": "005930",
|
| 181 |
+
"question": "์ต๊ทผ ๊ณต์ ๊ธฐ์ค์ผ๋ก ์ผ์ฑ์ ์ ์ฌ์
๊ตฌ์กฐ๊ฐ ๋ฐ๋ ๋ถ๋ถ์ด ์๋",
|
| 182 |
+
"userIntent": "recent_disclosure_change",
|
| 183 |
+
"expectedAnswerShape": [
|
| 184 |
+
"๋ณํ์์ฝ",
|
| 185 |
+
"๊ทผ๊ฑฐ",
|
| 186 |
+
"์์ "
|
| 187 |
+
],
|
| 188 |
+
"expectedEvidenceKinds": [
|
| 189 |
+
"sections",
|
| 190 |
+
"disclosure"
|
| 191 |
+
],
|
| 192 |
+
"expectedUserFacingTerms": [
|
| 193 |
+
"์ต๊ทผ ๊ณต์",
|
| 194 |
+
"์ฌ์
๊ตฌ์กฐ",
|
| 195 |
+
"๊ทผ๊ฑฐ"
|
| 196 |
+
],
|
| 197 |
+
"forbiddenUiTerms": [
|
| 198 |
+
"businessOverview",
|
| 199 |
+
"disclosureChanges",
|
| 200 |
+
"section_"
|
| 201 |
+
],
|
| 202 |
+
"expectedRoute": "sections",
|
| 203 |
+
"expectedModules": [
|
| 204 |
+
"businessOverview",
|
| 205 |
+
"disclosureChanges"
|
| 206 |
+
],
|
| 207 |
+
"allowedClarification": false,
|
| 208 |
+
"mustNotSay": [
|
| 209 |
+
"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค"
|
| 210 |
+
],
|
| 211 |
+
"mustInclude": [
|
| 212 |
+
"์ต๊ทผ ๊ณต์",
|
| 213 |
+
"๊ทผ๊ฑฐ"
|
| 214 |
+
],
|
| 215 |
+
"expectedFollowups": [
|
| 216 |
+
"์ถ๊ฐ",
|
| 217 |
+
"ํ์ธ"
|
| 218 |
+
],
|
| 219 |
+
"groundTruthFacts": [],
|
| 220 |
+
"severity": "high"
|
| 221 |
+
},
|
| 222 |
+
{
|
| 223 |
+
"id": "accountant.costByNature.summary",
|
| 224 |
+
"persona": "accountant",
|
| 225 |
+
"personaLabel": "ํ๊ณ์ฌ",
|
| 226 |
+
"stockCode": "005930",
|
| 227 |
+
"question": "์ผ์ฑ์ ์ ์ฑ๊ฒฉ๋ณ ๋น์ฉ ๋ถ๋ฅ์์ ์ต๊ทผ ๋น์ฉ ๋ถ๋ด์ด ์ด๋์ ๋ชฐ๋ ค ์๋์ง ์์ฝํด์ค",
|
| 228 |
+
"userIntent": "cost_nature_analysis",
|
| 229 |
+
"expectedAnswerShape": [
|
| 230 |
+
"ํต์ฌ๊ฒฐ๋ก ",
|
| 231 |
+
"์์๋น์ฉ",
|
| 232 |
+
"๋ณํ"
|
| 233 |
+
],
|
| 234 |
+
"expectedEvidenceKinds": [
|
| 235 |
+
"notes",
|
| 236 |
+
"cost_by_nature"
|
| 237 |
+
],
|
| 238 |
+
"expectedUserFacingTerms": [
|
| 239 |
+
"์ฑ๊ฒฉ๋ณ ๋น์ฉ",
|
| 240 |
+
"๋น์ฉ ๋ถ๋ด",
|
| 241 |
+
"์ต๊ทผ"
|
| 242 |
+
],
|
| 243 |
+
"forbiddenUiTerms": [
|
| 244 |
+
"costByNature",
|
| 245 |
+
"module_"
|
| 246 |
+
],
|
| 247 |
+
"expectedRoute": "hybrid",
|
| 248 |
+
"expectedModules": [
|
| 249 |
+
"costByNature"
|
| 250 |
+
],
|
| 251 |
+
"allowedClarification": false,
|
| 252 |
+
"mustNotSay": [
|
| 253 |
+
"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค",
|
| 254 |
+
"๋ฏธ์ ๊ณต"
|
| 255 |
+
],
|
| 256 |
+
"mustInclude": [
|
| 257 |
+
"์ฑ๊ฒฉ๋ณ ๋น์ฉ",
|
| 258 |
+
"๋น์ฉ"
|
| 259 |
+
],
|
| 260 |
+
"expectedFollowups": [
|
| 261 |
+
"์ถ๊ฐ",
|
| 262 |
+
"ํ์ธ"
|
| 263 |
+
],
|
| 264 |
+
"groundTruthFacts": [],
|
| 265 |
+
"severity": "high"
|
| 266 |
+
},
|
| 267 |
+
{
|
| 268 |
+
"id": "accountant.audit.redFlags",
|
| 269 |
+
"persona": "accountant",
|
| 270 |
+
"personaLabel": "ํ๊ณ์ฌ",
|
| 271 |
+
"stockCode": "005930",
|
| 272 |
+
"question": "์ผ์ฑ์ ์ ๊ฐ์ฌ ๊ด๋ จํด์ ์ต๊ทผ ์ ๊ฒํด์ผ ํ red flag๊ฐ ์๋",
|
| 273 |
+
"userIntent": "audit_red_flags",
|
| 274 |
+
"expectedAnswerShape": [
|
| 275 |
+
"๊ฒฐ๋ก ",
|
| 276 |
+
"๊ฐ์ฌ๊ทผ๊ฑฐ",
|
| 277 |
+
"์ฃผ์ํฌ์ธํธ"
|
| 278 |
+
],
|
| 279 |
+
"expectedEvidenceKinds": [
|
| 280 |
+
"report",
|
| 281 |
+
"audit"
|
| 282 |
+
],
|
| 283 |
+
"expectedUserFacingTerms": [
|
| 284 |
+
"๊ฐ์ฌ",
|
| 285 |
+
"red flag",
|
| 286 |
+
"์ฃผ์"
|
| 287 |
+
],
|
| 288 |
+
"forbiddenUiTerms": [
|
| 289 |
+
"audit",
|
| 290 |
+
"report_"
|
| 291 |
+
],
|
| 292 |
+
"expectedRoute": "report",
|
| 293 |
+
"expectedModules": [
|
| 294 |
+
"audit"
|
| 295 |
+
],
|
| 296 |
+
"allowedClarification": false,
|
| 297 |
+
"mustNotSay": [
|
| 298 |
+
"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค"
|
| 299 |
+
],
|
| 300 |
+
"mustInclude": [
|
| 301 |
+
"๊ฐ์ฌ",
|
| 302 |
+
"์ฃผ์"
|
| 303 |
+
],
|
| 304 |
+
"expectedFollowups": [
|
| 305 |
+
"์ถ๊ฐ",
|
| 306 |
+
"ํ์ธ"
|
| 307 |
+
],
|
| 308 |
+
"groundTruthFacts": [],
|
| 309 |
+
"severity": "high"
|
| 310 |
+
},
|
| 311 |
+
{
|
| 312 |
+
"id": "businessOwner.businessModel.naver",
|
| 313 |
+
"persona": "business_owner",
|
| 314 |
+
"personaLabel": "์ฌ์
๊ฐ",
|
| 315 |
+
"stockCode": "035420",
|
| 316 |
+
"question": "๋ค์ด๋ฒ๋ ์ด๋ค ์์ผ๋ก ๋ ๋ฒ๋ ๊ตฌ์กฐ์ธ์ง ์ฌ์
๋ชจ๋ธ ๊ด์ ์์ ์ค๋ช
ํด์ค",
|
| 317 |
+
"userIntent": "business_model",
|
| 318 |
+
"expectedAnswerShape": [
|
| 319 |
+
"์์ต๊ตฌ์กฐ",
|
| 320 |
+
"ํต์ฌ์ฌ์
",
|
| 321 |
+
"๊ฒฝ์๋ ฅ"
|
| 322 |
+
],
|
| 323 |
+
"expectedEvidenceKinds": [
|
| 324 |
+
"sections",
|
| 325 |
+
"business"
|
| 326 |
+
],
|
| 327 |
+
"expectedUserFacingTerms": [
|
| 328 |
+
"๋ ๋ฒ๋ ๊ตฌ์กฐ",
|
| 329 |
+
"์ฌ์
๋ชจ๋ธ",
|
| 330 |
+
"ํต์ฌ ์ฌ์
"
|
| 331 |
+
],
|
| 332 |
+
"forbiddenUiTerms": [
|
| 333 |
+
"productService",
|
| 334 |
+
"businessOverview",
|
| 335 |
+
"section_"
|
| 336 |
+
],
|
| 337 |
+
"expectedRoute": "sections",
|
| 338 |
+
"expectedModules": [
|
| 339 |
+
"businessOverview",
|
| 340 |
+
"productService"
|
| 341 |
+
],
|
| 342 |
+
"allowedClarification": false,
|
| 343 |
+
"mustNotSay": [
|
| 344 |
+
"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค"
|
| 345 |
+
],
|
| 346 |
+
"mustInclude": [
|
| 347 |
+
"์ฌ์
",
|
| 348 |
+
"๊ตฌ์กฐ"
|
| 349 |
+
],
|
| 350 |
+
"expectedFollowups": [
|
| 351 |
+
"์ถ๊ฐ",
|
| 352 |
+
"ํ์ธ"
|
| 353 |
+
],
|
| 354 |
+
"groundTruthFacts": [],
|
| 355 |
+
"severity": "medium"
|
| 356 |
+
},
|
| 357 |
+
{
|
| 358 |
+
"id": "businessOwner.capitalAllocation.samsung",
|
| 359 |
+
"persona": "business_owner",
|
| 360 |
+
"personaLabel": "์ฌ์
๊ฐ",
|
| 361 |
+
"stockCode": "005930",
|
| 362 |
+
"question": "์ผ์ฑ์ ์ ์๋ณธ๋ฐฐ๋ถ ์คํ์ผ์ ๋ณด๋ฉด ์ฑ์ฅํฌ์ํ์ธ์ง ์ฃผ์ฃผํ์ํ์ธ์ง ํ๋จํด์ค",
|
| 363 |
+
"userIntent": "capital_allocation",
|
| 364 |
+
"expectedAnswerShape": [
|
| 365 |
+
"ํ๋จ",
|
| 366 |
+
"๊ทผ๊ฑฐ",
|
| 367 |
+
"ํ์ํฌ์ธํธ"
|
| 368 |
+
],
|
| 369 |
+
"expectedEvidenceKinds": [
|
| 370 |
+
"finance",
|
| 371 |
+
"report",
|
| 372 |
+
"dividend"
|
| 373 |
+
],
|
| 374 |
+
"expectedUserFacingTerms": [
|
| 375 |
+
"์๋ณธ๋ฐฐ๋ถ",
|
| 376 |
+
"์ฑ์ฅํฌ์",
|
| 377 |
+
"์ฃผ์ฃผํ์"
|
| 378 |
+
],
|
| 379 |
+
"forbiddenUiTerms": [
|
| 380 |
+
"shareCapital",
|
| 381 |
+
"dividend",
|
| 382 |
+
"IS",
|
| 383 |
+
"CF"
|
| 384 |
+
],
|
| 385 |
+
"expectedRoute": "hybrid",
|
| 386 |
+
"expectedModules": [
|
| 387 |
+
"dividend",
|
| 388 |
+
"CF",
|
| 389 |
+
"shareCapital"
|
| 390 |
+
],
|
| 391 |
+
"allowedClarification": false,
|
| 392 |
+
"mustNotSay": [
|
| 393 |
+
"๏ฟฝ๏ฟฝ๏ฟฝ์ดํฐ๊ฐ ์์ต๋๋ค"
|
| 394 |
+
],
|
| 395 |
+
"mustInclude": [
|
| 396 |
+
"์๋ณธ๋ฐฐ๋ถ",
|
| 397 |
+
"ํ๋จ"
|
| 398 |
+
],
|
| 399 |
+
"expectedFollowups": [
|
| 400 |
+
"์ถ๊ฐ",
|
| 401 |
+
"ํ์ธ"
|
| 402 |
+
],
|
| 403 |
+
"groundTruthFacts": [],
|
| 404 |
+
"severity": "medium"
|
| 405 |
+
},
|
| 406 |
+
{
|
| 407 |
+
"id": "investor.dividend.sustainability",
|
| 408 |
+
"persona": "investor",
|
| 409 |
+
"personaLabel": "ํฌ์์",
|
| 410 |
+
"stockCode": "005930",
|
| 411 |
+
"question": "์ผ์ฑ์ ์ ๋ฐฐ๋น์ด ์ค์ ๊ณผ ํ๊ธํ๋ฆ์ผ๋ก ์ง์ ๊ฐ๋ฅํ์ง ํ๋จํด์ค",
|
| 412 |
+
"userIntent": "dividend_sustainability",
|
| 413 |
+
"expectedAnswerShape": [
|
| 414 |
+
"๊ฒฐ๋ก ",
|
| 415 |
+
"๋ฐฐ๋น",
|
| 416 |
+
"ํ๊ธํ๋ฆ"
|
| 417 |
+
],
|
| 418 |
+
"expectedEvidenceKinds": [
|
| 419 |
+
"report",
|
| 420 |
+
"finance"
|
| 421 |
+
],
|
| 422 |
+
"expectedUserFacingTerms": [
|
| 423 |
+
"๋ฐฐ๋น",
|
| 424 |
+
"์ค์ ",
|
| 425 |
+
"ํ๊ธํ๋ฆ"
|
| 426 |
+
],
|
| 427 |
+
"forbiddenUiTerms": [
|
| 428 |
+
"dividend",
|
| 429 |
+
"IS",
|
| 430 |
+
"CF",
|
| 431 |
+
"ratios"
|
| 432 |
+
],
|
| 433 |
+
"expectedRoute": "hybrid",
|
| 434 |
+
"expectedModules": [
|
| 435 |
+
"dividend",
|
| 436 |
+
"IS",
|
| 437 |
+
"CF",
|
| 438 |
+
"ratios"
|
| 439 |
+
],
|
| 440 |
+
"allowedClarification": false,
|
| 441 |
+
"mustNotSay": [
|
| 442 |
+
"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค"
|
| 443 |
+
],
|
| 444 |
+
"mustInclude": [
|
| 445 |
+
"๋ฐฐ๋น",
|
| 446 |
+
"ํ๊ธํ๋ฆ",
|
| 447 |
+
"์ค์ "
|
| 448 |
+
],
|
| 449 |
+
"expectedFollowups": [
|
| 450 |
+
"์ถ๊ฐ",
|
| 451 |
+
"ํ์ธ"
|
| 452 |
+
],
|
| 453 |
+
"groundTruthFacts": [],
|
| 454 |
+
"severity": "high"
|
| 455 |
+
},
|
| 456 |
+
{
|
| 457 |
+
"id": "investor.downside.risks",
|
| 458 |
+
"persona": "investor",
|
| 459 |
+
"personaLabel": "ํฌ์์",
|
| 460 |
+
"stockCode": "000660",
|
| 461 |
+
"question": "SKํ์ด๋์ค์์ ์ง๊ธ downside๋ฅผ ๋ง๋๋ ํต์ฌ ๋ฆฌ์คํฌ 3๊ฐ์ง๋ง ๋งํด์ค",
|
| 462 |
+
"userIntent": "downside_risk",
|
| 463 |
+
"expectedAnswerShape": [
|
| 464 |
+
"๋ฆฌ์คํฌ๋ชฉ๋ก",
|
| 465 |
+
"์ํฅ",
|
| 466 |
+
"์์ค์ํ์ง"
|
| 467 |
+
],
|
| 468 |
+
"expectedEvidenceKinds": [
|
| 469 |
+
"sections",
|
| 470 |
+
"risk"
|
| 471 |
+
],
|
| 472 |
+
"expectedUserFacingTerms": [
|
| 473 |
+
"๋ฆฌ์คํฌ",
|
| 474 |
+
"downside",
|
| 475 |
+
"ํต์ฌ"
|
| 476 |
+
],
|
| 477 |
+
"forbiddenUiTerms": [
|
| 478 |
+
"riskDerivative",
|
| 479 |
+
"section_"
|
| 480 |
+
],
|
| 481 |
+
"expectedRoute": "sections",
|
| 482 |
+
"expectedModules": [
|
| 483 |
+
"riskDerivative",
|
| 484 |
+
"disclosureChanges"
|
| 485 |
+
],
|
| 486 |
+
"allowedClarification": false,
|
| 487 |
+
"mustNotSay": [
|
| 488 |
+
"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค"
|
| 489 |
+
],
|
| 490 |
+
"mustInclude": [
|
| 491 |
+
"๋ฆฌ์คํฌ",
|
| 492 |
+
"ํต์ฌ"
|
| 493 |
+
],
|
| 494 |
+
"expectedFollowups": [
|
| 495 |
+
"์ถ๊ฐ",
|
| 496 |
+
"ํ์ธ"
|
| 497 |
+
],
|
| 498 |
+
"groundTruthFacts": [],
|
| 499 |
+
"severity": "high"
|
| 500 |
+
},
|
| 501 |
+
{
|
| 502 |
+
"id": "investor.distress.sdi",
|
| 503 |
+
"persona": "investor",
|
| 504 |
+
"personaLabel": "ํฌ์์",
|
| 505 |
+
"stockCode": "006400",
|
| 506 |
+
"question": "์ผ์ฑSDI์ ๋ถ์ค ์งํ๋ฅผ ์ง๊ธ ์์ ์์ ์ ๊ฒํด์ค",
|
| 507 |
+
"userIntent": "distress_check",
|
| 508 |
+
"expectedAnswerShape": [
|
| 509 |
+
"๊ฑด์ ์ฑ๊ฒฐ๋ก ",
|
| 510 |
+
"์งํ",
|
| 511 |
+
"์ฃผ์์ "
|
| 512 |
+
],
|
| 513 |
+
"expectedEvidenceKinds": [
|
| 514 |
+
"finance",
|
| 515 |
+
"distress"
|
| 516 |
+
],
|
| 517 |
+
"expectedUserFacingTerms": [
|
| 518 |
+
"๋ถ์ค ์งํ",
|
| 519 |
+
"๊ฑด์ ์ฑ",
|
| 520 |
+
"์ฃผ์"
|
| 521 |
+
],
|
| 522 |
+
"forbiddenUiTerms": [
|
| 523 |
+
"ratios",
|
| 524 |
+
"fsSummary"
|
| 525 |
+
],
|
| 526 |
+
"expectedRoute": "finance",
|
| 527 |
+
"expectedModules": [
|
| 528 |
+
"BS",
|
| 529 |
+
"IS",
|
| 530 |
+
"CF",
|
| 531 |
+
"ratios"
|
| 532 |
+
],
|
| 533 |
+
"allowedClarification": false,
|
| 534 |
+
"mustNotSay": [
|
| 535 |
+
"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค"
|
| 536 |
+
],
|
| 537 |
+
"mustInclude": [
|
| 538 |
+
"๊ฑด์ ์ฑ",
|
| 539 |
+
"์ฃผ์"
|
| 540 |
+
],
|
| 541 |
+
"expectedFollowups": [
|
| 542 |
+
"์ถ๊ฐ",
|
| 543 |
+
"ํ์ธ"
|
| 544 |
+
],
|
| 545 |
+
"groundTruthFacts": [],
|
| 546 |
+
"severity": "high"
|
| 547 |
+
},
|
| 548 |
+
{
|
| 549 |
+
"id": "analyst.margin.drivers",
|
| 550 |
+
"persona": "analyst",
|
| 551 |
+
"personaLabel": "์ ๋๋ฆฌ์คํธ",
|
| 552 |
+
"stockCode": "005930",
|
| 553 |
+
"question": "์ผ์ฑ์ ์ ์์
์ด์ต๋ฅ ๋ณ๋์ ๋น์ฉ ๊ตฌ์กฐ์ ์ฌ์
๋ณํ๊น์ง ๋ฌถ์ด์ ์ค๋ช
ํด์ค",
|
| 554 |
+
"userIntent": "margin_driver",
|
| 555 |
+
"expectedAnswerShape": [
|
| 556 |
+
"๊ฒฐ๋ก ",
|
| 557 |
+
"๋น์ฉ๊ตฌ์กฐ",
|
| 558 |
+
"์ฌ์
๋ณํ"
|
| 559 |
+
],
|
| 560 |
+
"expectedEvidenceKinds": [
|
| 561 |
+
"finance",
|
| 562 |
+
"notes",
|
| 563 |
+
"sections"
|
| 564 |
+
],
|
| 565 |
+
"expectedUserFacingTerms": [
|
| 566 |
+
"์์
์ด์ต๋ฅ ",
|
| 567 |
+
"๋น์ฉ ๊ตฌ์กฐ",
|
| 568 |
+
"์ฌ์
๋ณํ"
|
| 569 |
+
],
|
| 570 |
+
"forbiddenUiTerms": [
|
| 571 |
+
"costByNature",
|
| 572 |
+
"businessOverview",
|
| 573 |
+
"IS"
|
| 574 |
+
],
|
| 575 |
+
"expectedRoute": "hybrid",
|
| 576 |
+
"expectedModules": [
|
| 577 |
+
"IS",
|
| 578 |
+
"costByNature",
|
| 579 |
+
"businessOverview"
|
| 580 |
+
],
|
| 581 |
+
"allowedClarification": false,
|
| 582 |
+
"mustNotSay": [
|
| 583 |
+
"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค"
|
| 584 |
+
],
|
| 585 |
+
"mustInclude": [
|
| 586 |
+
"์์
์ด์ต๋ฅ ",
|
| 587 |
+
"๋น์ฉ",
|
| 588 |
+
"์ฌ์
"
|
| 589 |
+
],
|
| 590 |
+
"expectedFollowups": [
|
| 591 |
+
"์ถ๊ฐ",
|
| 592 |
+
"ํ์ธ"
|
| 593 |
+
],
|
| 594 |
+
"groundTruthFacts": [],
|
| 595 |
+
"severity": "high"
|
| 596 |
+
},
|
| 597 |
+
{
|
| 598 |
+
"id": "analyst.segments.lgchem",
|
| 599 |
+
"persona": "analyst",
|
| 600 |
+
"personaLabel": "์ ๋๋ฆฌ์คํธ",
|
| 601 |
+
"stockCode": "051910",
|
| 602 |
+
"question": "LGํํ ์ฌ์
๋ถ๋ฌธ๋ณ๋ก ์ง๊ธ ์ด๋๊ฐ ํต์ฌ์ธ์ง ์ ๋ฆฌํด์ค",
|
| 603 |
+
"userIntent": "segment_mix",
|
| 604 |
+
"expectedAnswerShape": [
|
| 605 |
+
"๋ถ๋ฌธ์ ๋ฆฌ",
|
| 606 |
+
"ํต์ฌ์ถ",
|
| 607 |
+
"ํด์"
|
| 608 |
+
],
|
| 609 |
+
"expectedEvidenceKinds": [
|
| 610 |
+
"notes",
|
| 611 |
+
"segments"
|
| 612 |
+
],
|
| 613 |
+
"expectedUserFacingTerms": [
|
| 614 |
+
"์ฌ์
๋ถ๋ฌธ",
|
| 615 |
+
"ํต์ฌ",
|
| 616 |
+
"์ ๋ฆฌ"
|
| 617 |
+
],
|
| 618 |
+
"forbiddenUiTerms": [
|
| 619 |
+
"segments",
|
| 620 |
+
"productService"
|
| 621 |
+
],
|
| 622 |
+
"expectedRoute": "sections",
|
| 623 |
+
"expectedModules": [
|
| 624 |
+
"segments",
|
| 625 |
+
"productService"
|
| 626 |
+
],
|
| 627 |
+
"allowedClarification": false,
|
| 628 |
+
"mustNotSay": [
|
| 629 |
+
"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค"
|
| 630 |
+
],
|
| 631 |
+
"mustInclude": [
|
| 632 |
+
"์ฌ์
๋ถ๋ฌธ",
|
| 633 |
+
"ํต์ฌ"
|
| 634 |
+
],
|
| 635 |
+
"expectedFollowups": [
|
| 636 |
+
"์ถ๊ฐ",
|
| 637 |
+
"ํ์ธ"
|
| 638 |
+
],
|
| 639 |
+
"groundTruthFacts": [],
|
| 640 |
+
"severity": "high"
|
| 641 |
+
},
|
| 642 |
+
{
|
| 643 |
+
"id": "analyst.evidence.recentDisclosures",
|
| 644 |
+
"persona": "analyst",
|
| 645 |
+
"personaLabel": "์ ๋๋ฆฌ์คํธ",
|
| 646 |
+
"stockCode": "005930",
|
| 647 |
+
"question": "์ต๊ทผ ๊ณต์ ๊ธฐ์ค์ผ๋ก ์ฌ์
๊ตฌ์กฐ ์ค๋ช
๊ทผ๊ฑฐ๋ฅผ 2๊ฐ๋ง ์ง์ด์ค",
|
| 648 |
+
"userIntent": "evidence_grounding",
|
| 649 |
+
"expectedAnswerShape": [
|
| 650 |
+
"๊ทผ๊ฑฐ",
|
| 651 |
+
"์์ ",
|
| 652 |
+
"์ถ์ฒ"
|
| 653 |
+
],
|
| 654 |
+
"expectedEvidenceKinds": [
|
| 655 |
+
"sections",
|
| 656 |
+
"evidence"
|
| 657 |
+
],
|
| 658 |
+
"expectedUserFacingTerms": [
|
| 659 |
+
"๊ทผ๊ฑฐ",
|
| 660 |
+
"์ถ์ฒ",
|
| 661 |
+
"์ต๊ทผ ๊ณต์"
|
| 662 |
+
],
|
| 663 |
+
"forbiddenUiTerms": [
|
| 664 |
+
"businessOverview",
|
| 665 |
+
"productService",
|
| 666 |
+
"show_topic()"
|
| 667 |
+
],
|
| 668 |
+
"expectedRoute": "sections",
|
| 669 |
+
"expectedModules": [
|
| 670 |
+
"businessOverview",
|
| 671 |
+
"productService"
|
| 672 |
+
],
|
| 673 |
+
"allowedClarification": false,
|
| 674 |
+
"mustNotSay": [
|
| 675 |
+
"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค"
|
| 676 |
+
],
|
| 677 |
+
"mustInclude": [
|
| 678 |
+
"๊ทผ๊ฑฐ",
|
| 679 |
+
"์ถ์ฒ"
|
| 680 |
+
],
|
| 681 |
+
"expectedFollowups": [
|
| 682 |
+
"์ถ๊ฐ",
|
| 683 |
+
"ํ์ธ"
|
| 684 |
+
],
|
| 685 |
+
"groundTruthFacts": [],
|
| 686 |
+
"severity": "high"
|
| 687 |
+
},
|
| 688 |
+
{
|
| 689 |
+
"id": "assistant.nextQuestions.investor",
|
| 690 |
+
"persona": "assistant",
|
| 691 |
+
"personaLabel": "๋น์",
|
| 692 |
+
"stockCode": "005930",
|
| 693 |
+
"question": "์ง๊ธ ํฌ์์๊ฐ ์ผ์ฑ์ ์์์ ๋ค์์ผ๋ก ํ์ธํด์ผ ํ ์ง๋ฌธ 3๊ฐ๋ฅผ ๋์ ธ์ค",
|
| 694 |
+
"userIntent": "next_best_questions",
|
| 695 |
+
"expectedAnswerShape": [
|
| 696 |
+
"์ง๋ฌธ๋ชฉ๋ก",
|
| 697 |
+
"์ด์ ",
|
| 698 |
+
"์ฐ์ ์์"
|
| 699 |
+
],
|
| 700 |
+
"expectedEvidenceKinds": [
|
| 701 |
+
"finance",
|
| 702 |
+
"sections"
|
| 703 |
+
],
|
| 704 |
+
"expectedUserFacingTerms": [
|
| 705 |
+
"๋ค์",
|
| 706 |
+
"ํ์ธ",
|
| 707 |
+
"์ง๋ฌธ"
|
| 708 |
+
],
|
| 709 |
+
"forbiddenUiTerms": [
|
| 710 |
+
"module_",
|
| 711 |
+
"show_topic()"
|
| 712 |
+
],
|
| 713 |
+
"expectedRoute": "hybrid",
|
| 714 |
+
"expectedModules": [
|
| 715 |
+
"IS",
|
| 716 |
+
"CF",
|
| 717 |
+
"ratios"
|
| 718 |
+
],
|
| 719 |
+
"allowedClarification": false,
|
| 720 |
+
"mustNotSay": [],
|
| 721 |
+
"mustInclude": [
|
| 722 |
+
"์ง๋ฌธ",
|
| 723 |
+
"ํ์ธ"
|
| 724 |
+
],
|
| 725 |
+
"expectedFollowups": [
|
| 726 |
+
"์",
|
| 727 |
+
"ํ์ธ"
|
| 728 |
+
],
|
| 729 |
+
"groundTruthFacts": [],
|
| 730 |
+
"severity": "medium"
|
| 731 |
+
},
|
| 732 |
+
{
|
| 733 |
+
"id": "dataManager.trace.sources",
|
| 734 |
+
"persona": "data_manager",
|
| 735 |
+
"personaLabel": "DartLab ๋ฐ์ดํฐ ๊ด๋ฆฌ์",
|
| 736 |
+
"stockCode": "005930",
|
| 737 |
+
"question": "์ผ์ฑ์ ์ ๋ต๋ณ ๊ทผ๊ฑฐ๊ฐ ์ฌ๋ฌด์ธ์ง ๊ณต์์ธ์ง ๊ตฌ๋ถํด์ ์ค๋ช
ํด์ค",
|
| 738 |
+
"userIntent": "source_trace",
|
| 739 |
+
"expectedAnswerShape": [
|
| 740 |
+
"๊ทผ๊ฑฐ๊ตฌ๋ถ",
|
| 741 |
+
"์ฌ๋ฌด",
|
| 742 |
+
"๊ณต์"
|
| 743 |
+
],
|
| 744 |
+
"expectedEvidenceKinds": [
|
| 745 |
+
"trace",
|
| 746 |
+
"finance",
|
| 747 |
+
"docs"
|
| 748 |
+
],
|
| 749 |
+
"expectedUserFacingTerms": [
|
| 750 |
+
"๊ทผ๊ฑฐ",
|
| 751 |
+
"์ฌ๋ฌด",
|
| 752 |
+
"๊ณต์"
|
| 753 |
+
],
|
| 754 |
+
"forbiddenUiTerms": [
|
| 755 |
+
"trace(",
|
| 756 |
+
"company.show"
|
| 757 |
+
],
|
| 758 |
+
"expectedRoute": "sections",
|
| 759 |
+
"expectedModules": [
|
| 760 |
+
"IS",
|
| 761 |
+
"businessOverview"
|
| 762 |
+
],
|
| 763 |
+
"allowedClarification": false,
|
| 764 |
+
"mustNotSay": [
|
| 765 |
+
"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค"
|
| 766 |
+
],
|
| 767 |
+
"mustInclude": [
|
| 768 |
+
"๊ทผ๊ฑฐ",
|
| 769 |
+
"์ฌ๋ฌด",
|
| 770 |
+
"๊ณต์"
|
| 771 |
+
],
|
| 772 |
+
"expectedFollowups": [
|
| 773 |
+
"์ถ๊ฐ",
|
| 774 |
+
"ํ์ธ"
|
| 775 |
+
],
|
| 776 |
+
"groundTruthFacts": [],
|
| 777 |
+
"severity": "medium"
|
| 778 |
+
},
|
| 779 |
+
{
|
| 780 |
+
"id": "operator.performance.explainLatency",
|
| 781 |
+
"persona": "operator",
|
| 782 |
+
"personaLabel": "DartLab ์ด์์",
|
| 783 |
+
"stockCode": "005930",
|
| 784 |
+
"question": "์ง๋ฌธ์ ๋ฐ๋ผ ์ ์๊ฐ์ด ๋ ๊ฑธ๋ฆด ์ ์๋์ง์ ์ด๋ค ๊ฒฝ์ฐ ๋ฐ์ดํฐ ๋ก๋ฉ์ด ์ปค์ง๋์ง ์ค๋ช
ํด์ค",
|
| 785 |
+
"userIntent": "performance_explanation",
|
| 786 |
+
"expectedAnswerShape": [
|
| 787 |
+
"์์ธ",
|
| 788 |
+
"์กฐ๊ฑด",
|
| 789 |
+
"์ฃผ์์ "
|
| 790 |
+
],
|
| 791 |
+
"expectedEvidenceKinds": [
|
| 792 |
+
"runtime_policy"
|
| 793 |
+
],
|
| 794 |
+
"expectedUserFacingTerms": [
|
| 795 |
+
"์๊ฐ",
|
| 796 |
+
"๋ก๋ฉ",
|
| 797 |
+
"์ง๋ฌธ์ ๋ฐ๋ผ"
|
| 798 |
+
],
|
| 799 |
+
"forbiddenUiTerms": [
|
| 800 |
+
"build_context_tiered",
|
| 801 |
+
"_resolve_context_route"
|
| 802 |
+
],
|
| 803 |
+
"expectedRoute": "hybrid",
|
| 804 |
+
"expectedModules": [
|
| 805 |
+
"IS"
|
| 806 |
+
],
|
| 807 |
+
"allowedClarification": false,
|
| 808 |
+
"mustNotSay": [],
|
| 809 |
+
"mustInclude": [
|
| 810 |
+
"์๊ฐ",
|
| 811 |
+
"๋ก๋ฉ"
|
| 812 |
+
],
|
| 813 |
+
"expectedFollowups": [
|
| 814 |
+
"์ถ๊ฐ",
|
| 815 |
+
"ํ์ธ"
|
| 816 |
+
],
|
| 817 |
+
"groundTruthFacts": [],
|
| 818 |
+
"severity": "medium"
|
| 819 |
+
},
|
| 820 |
+
{
|
| 821 |
+
"id": "accountant.ambiguous.costStructure",
|
| 822 |
+
"persona": "accountant",
|
| 823 |
+
"personaLabel": "ํ๊ณ์ฌ",
|
| 824 |
+
"stockCode": "005930",
|
| 825 |
+
"question": "์ผ์ฑ์ ์ ๋น์ฉ ๊ตฌ์กฐ๋ฅผ ์ค๋ช
ํด์ค",
|
| 826 |
+
"userIntent": "ambiguous_cost_structure",
|
| 827 |
+
"expectedAnswerShape": [
|
| 828 |
+
"clarification_or_best_guess"
|
| 829 |
+
],
|
| 830 |
+
"expectedEvidenceKinds": [
|
| 831 |
+
"finance",
|
| 832 |
+
"notes"
|
| 833 |
+
],
|
| 834 |
+
"expectedUserFacingTerms": [
|
| 835 |
+
"์ฑ๊ฒฉ๋ณ ๋น์ฉ",
|
| 836 |
+
"๊ธฐ๋ฅ๋ณ ๋น์ฉ"
|
| 837 |
+
],
|
| 838 |
+
"forbiddenUiTerms": [
|
| 839 |
+
"costByNature",
|
| 840 |
+
"IS",
|
| 841 |
+
"module_"
|
| 842 |
+
],
|
| 843 |
+
"expectedRoute": "hybrid",
|
| 844 |
+
"expectedModules": [
|
| 845 |
+
"costByNature"
|
| 846 |
+
],
|
| 847 |
+
"allowedClarification": true,
|
| 848 |
+
"mustNotSay": [],
|
| 849 |
+
"mustInclude": [
|
| 850 |
+
"์ฑ๊ฒฉ๋ณ ๋น์ฉ",
|
| 851 |
+
"๊ธฐ๋ฅ๋ณ ๋น์ฉ"
|
| 852 |
+
],
|
| 853 |
+
"expectedFollowups": [
|
| 854 |
+
"๋ณด์ค ๊ฑด๊ฐ์"
|
| 855 |
+
],
|
| 856 |
+
"groundTruthFacts": [],
|
| 857 |
+
"severity": "high"
|
| 858 |
+
},
|
| 859 |
+
{
|
| 860 |
+
"id": "analyst.quarterly.operatingProfit",
|
| 861 |
+
"persona": "analyst",
|
| 862 |
+
"personaLabel": "์ฌ๋ฌด ๋ถ์๊ฐ",
|
| 863 |
+
"stockCode": "005930",
|
| 864 |
+
"question": "์ผ์ฑ์ ์ ๋ถ๊ธฐ๋ณ ์์
์ด์ต ์ถ์ด ์๋ ค์ค",
|
| 865 |
+
"userIntent": "quarterly_operating_profit",
|
| 866 |
+
"expectedAnswerShape": [
|
| 867 |
+
"๋ถ๊ธฐ๋ณํ
์ด๋ธ",
|
| 868 |
+
"QoQ",
|
| 869 |
+
"YoY"
|
| 870 |
+
],
|
| 871 |
+
"expectedEvidenceKinds": [
|
| 872 |
+
"finance"
|
| 873 |
+
],
|
| 874 |
+
"expectedUserFacingTerms": [
|
| 875 |
+
"์์
์ด์ต",
|
| 876 |
+
"๋ถ๊ธฐ",
|
| 877 |
+
"์ ๋ถ๊ธฐ"
|
| 878 |
+
],
|
| 879 |
+
"forbiddenUiTerms": [
|
| 880 |
+
"IS_quarterly",
|
| 881 |
+
"timeseries"
|
| 882 |
+
],
|
| 883 |
+
"expectedRoute": "hybrid",
|
| 884 |
+
"expectedModules": [
|
| 885 |
+
"IS",
|
| 886 |
+
"IS_quarterly"
|
| 887 |
+
],
|
| 888 |
+
"allowedClarification": false,
|
| 889 |
+
"mustNotSay": [
|
| 890 |
+
"๋ฐ์ดํฐ๊ฐ ์",
|
| 891 |
+
"๋ถ๊ธฐ๋ณ ๋ฐ์ดํฐ๋ฅผ ์ ๊ณตํ์ง",
|
| 892 |
+
"ํ์ธํ ์ ์"
|
| 893 |
+
],
|
| 894 |
+
"mustInclude": [
|
| 895 |
+
"์์
์ด์ต",
|
| 896 |
+
"๋ถ๊ธฐ"
|
| 897 |
+
],
|
| 898 |
+
"expectedFollowups": [],
|
| 899 |
+
"groundTruthFacts": [
|
| 900 |
+
{
|
| 901 |
+
"metric": "sales",
|
| 902 |
+
"label": "๋งค์ถ์ก",
|
| 903 |
+
"value": 333605938000000.0,
|
| 904 |
+
"statement": "IS",
|
| 905 |
+
"period": "2025"
|
| 906 |
+
},
|
| 907 |
+
{
|
| 908 |
+
"metric": "operating_profit",
|
| 909 |
+
"label": "์์
์ด์ต",
|
| 910 |
+
"value": 43601051000000.0,
|
| 911 |
+
"statement": "IS",
|
| 912 |
+
"period": "2025"
|
| 913 |
+
},
|
| 914 |
+
{
|
| 915 |
+
"metric": "net_profit",
|
| 916 |
+
"label": "๋น๊ธฐ์์ด์ต",
|
| 917 |
+
"value": 45206805000000.0,
|
| 918 |
+
"statement": "IS",
|
| 919 |
+
"period": "2025"
|
| 920 |
+
},
|
| 921 |
+
{
|
| 922 |
+
"metric": "cost_of_sales",
|
| 923 |
+
"label": "๋งค์ถ์๊ฐ",
|
| 924 |
+
"value": 202235513000000.0,
|
| 925 |
+
"statement": "IS",
|
| 926 |
+
"period": "2025"
|
| 927 |
+
},
|
| 928 |
+
{
|
| 929 |
+
"metric": "sales_quarterly",
|
| 930 |
+
"label": "๋งค์ถ์ก(๋ถ๊ธฐ)",
|
| 931 |
+
"value": 93837371000000.0,
|
| 932 |
+
"statement": "IS_quarterly",
|
| 933 |
+
"period": "2025-Q4"
|
| 934 |
+
},
|
| 935 |
+
{
|
| 936 |
+
"metric": "operating_profit_quarterly",
|
| 937 |
+
"label": "์์
์ด์ต(๋ถ๊ธฐ)",
|
| 938 |
+
"value": 20073660000000.0,
|
| 939 |
+
"statement": "IS_quarterly",
|
| 940 |
+
"period": "2025-Q4"
|
| 941 |
+
},
|
| 942 |
+
{
|
| 943 |
+
"metric": "net_profit_quarterly",
|
| 944 |
+
"label": "๋น๊ธฐ์์ด์ต(๋ถ๊ธฐ)",
|
| 945 |
+
"value": 19641745000000.0,
|
| 946 |
+
"statement": "IS_quarterly",
|
| 947 |
+
"period": "2025-Q4"
|
| 948 |
+
},
|
| 949 |
+
{
|
| 950 |
+
"metric": "cost_of_sales_quarterly",
|
| 951 |
+
"label": "๋งค์ถ์๊ฐ(๋ถ๊ธฐ)",
|
| 952 |
+
"value": 49586396000000.0,
|
| 953 |
+
"statement": "IS_quarterly",
|
| 954 |
+
"period": "2025-Q4"
|
| 955 |
+
},
|
| 956 |
+
{
|
| 957 |
+
"metric": "operating_cashflow_quarterly",
|
| 958 |
+
"label": "์์
ํ๋CF(๋ถ๊ธฐ)",
|
| 959 |
+
"value": 28799652000000.0,
|
| 960 |
+
"statement": "CF_quarterly",
|
| 961 |
+
"period": "2025-Q4"
|
| 962 |
+
},
|
| 963 |
+
{
|
| 964 |
+
"metric": "investing_cashflow_quarterly",
|
| 965 |
+
"label": "ํฌ์ํ๋CF(๋ถ๊ธฐ)",
|
| 966 |
+
"value": -30991028000000.0,
|
| 967 |
+
"statement": "CF_quarterly",
|
| 968 |
+
"period": "2025-Q4"
|
| 969 |
+
},
|
| 970 |
+
{
|
| 971 |
+
"metric": "financing_cashflow_quarterly",
|
| 972 |
+
"label": "์ฌ๋ฌดํ๋CF(๋ถ๊ธฐ)",
|
| 973 |
+
"value": -1957717000000.0,
|
| 974 |
+
"statement": "CF_quarterly",
|
| 975 |
+
"period": "2025-Q4"
|
| 976 |
+
}
|
| 977 |
+
],
|
| 978 |
+
"severity": "critical"
|
| 979 |
+
},
|
| 980 |
+
{
|
| 981 |
+
"id": "analyst.quarterly.revenue",
|
| 982 |
+
"persona": "analyst",
|
| 983 |
+
"personaLabel": "์ฌ๋ฌด ๋ถ์๊ฐ",
|
| 984 |
+
"stockCode": "005930",
|
| 985 |
+
"question": "์ต๊ทผ 4๋ถ๊ธฐ ๋งค์ถ ๋ณํ ๋ถ์ํด์ค",
|
| 986 |
+
"userIntent": "quarterly_revenue_change",
|
| 987 |
+
"expectedAnswerShape": [
|
| 988 |
+
"๋ถ๊ธฐ๋ณํ
์ด๋ธ",
|
| 989 |
+
"QoQ",
|
| 990 |
+
"์ถ์ธ"
|
| 991 |
+
],
|
| 992 |
+
"expectedEvidenceKinds": [
|
| 993 |
+
"finance"
|
| 994 |
+
],
|
| 995 |
+
"expectedUserFacingTerms": [
|
| 996 |
+
"๋งค์ถ",
|
| 997 |
+
"๋ถ๊ธฐ",
|
| 998 |
+
"๋ณํ"
|
| 999 |
+
],
|
| 1000 |
+
"forbiddenUiTerms": [
|
| 1001 |
+
"IS_quarterly"
|
| 1002 |
+
],
|
| 1003 |
+
"expectedRoute": "hybrid",
|
| 1004 |
+
"expectedModules": [
|
| 1005 |
+
"IS",
|
| 1006 |
+
"IS_quarterly"
|
| 1007 |
+
],
|
| 1008 |
+
"allowedClarification": false,
|
| 1009 |
+
"mustNotSay": [
|
| 1010 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 1011 |
+
],
|
| 1012 |
+
"mustInclude": [
|
| 1013 |
+
"๋งค์ถ"
|
| 1014 |
+
],
|
| 1015 |
+
"expectedFollowups": [],
|
| 1016 |
+
"groundTruthFacts": [
|
| 1017 |
+
{
|
| 1018 |
+
"metric": "sales",
|
| 1019 |
+
"label": "๋งค์ถ์ก",
|
| 1020 |
+
"value": 333605938000000.0,
|
| 1021 |
+
"statement": "IS",
|
| 1022 |
+
"period": "2025"
|
| 1023 |
+
},
|
| 1024 |
+
{
|
| 1025 |
+
"metric": "operating_profit",
|
| 1026 |
+
"label": "์์
์ด์ต",
|
| 1027 |
+
"value": 43601051000000.0,
|
| 1028 |
+
"statement": "IS",
|
| 1029 |
+
"period": "2025"
|
| 1030 |
+
},
|
| 1031 |
+
{
|
| 1032 |
+
"metric": "net_profit",
|
| 1033 |
+
"label": "๋น๊ธฐ์์ด์ต",
|
| 1034 |
+
"value": 45206805000000.0,
|
| 1035 |
+
"statement": "IS",
|
| 1036 |
+
"period": "2025"
|
| 1037 |
+
},
|
| 1038 |
+
{
|
| 1039 |
+
"metric": "cost_of_sales",
|
| 1040 |
+
"label": "๋งค์ถ์๊ฐ",
|
| 1041 |
+
"value": 202235513000000.0,
|
| 1042 |
+
"statement": "IS",
|
| 1043 |
+
"period": "2025"
|
| 1044 |
+
},
|
| 1045 |
+
{
|
| 1046 |
+
"metric": "sales_quarterly",
|
| 1047 |
+
"label": "๋งค์ถ์ก(๋ถ๊ธฐ)",
|
| 1048 |
+
"value": 93837371000000.0,
|
| 1049 |
+
"statement": "IS_quarterly",
|
| 1050 |
+
"period": "2025-Q4"
|
| 1051 |
+
},
|
| 1052 |
+
{
|
| 1053 |
+
"metric": "operating_profit_quarterly",
|
| 1054 |
+
"label": "์์
์ด์ต(๋ถ๊ธฐ)",
|
| 1055 |
+
"value": 20073660000000.0,
|
| 1056 |
+
"statement": "IS_quarterly",
|
| 1057 |
+
"period": "2025-Q4"
|
| 1058 |
+
},
|
| 1059 |
+
{
|
| 1060 |
+
"metric": "net_profit_quarterly",
|
| 1061 |
+
"label": "๋น๊ธฐ์์ด์ต(๋ถ๊ธฐ)",
|
| 1062 |
+
"value": 19641745000000.0,
|
| 1063 |
+
"statement": "IS_quarterly",
|
| 1064 |
+
"period": "2025-Q4"
|
| 1065 |
+
},
|
| 1066 |
+
{
|
| 1067 |
+
"metric": "cost_of_sales_quarterly",
|
| 1068 |
+
"label": "๋งค์ถ์๊ฐ(๋ถ๊ธฐ)",
|
| 1069 |
+
"value": 49586396000000.0,
|
| 1070 |
+
"statement": "IS_quarterly",
|
| 1071 |
+
"period": "2025-Q4"
|
| 1072 |
+
},
|
| 1073 |
+
{
|
| 1074 |
+
"metric": "operating_cashflow_quarterly",
|
| 1075 |
+
"label": "์์
ํ๋CF(๋ถ๊ธฐ)",
|
| 1076 |
+
"value": 28799652000000.0,
|
| 1077 |
+
"statement": "CF_quarterly",
|
| 1078 |
+
"period": "2025-Q4"
|
| 1079 |
+
},
|
| 1080 |
+
{
|
| 1081 |
+
"metric": "investing_cashflow_quarterly",
|
| 1082 |
+
"label": "ํฌ์ํ๋CF(๋ถ๊ธฐ)",
|
| 1083 |
+
"value": -30991028000000.0,
|
| 1084 |
+
"statement": "CF_quarterly",
|
| 1085 |
+
"period": "2025-Q4"
|
| 1086 |
+
},
|
| 1087 |
+
{
|
| 1088 |
+
"metric": "financing_cashflow_quarterly",
|
| 1089 |
+
"label": "์ฌ๋ฌดํ๋CF(๋ถ๊ธฐ)",
|
| 1090 |
+
"value": -1957717000000.0,
|
| 1091 |
+
"statement": "CF_quarterly",
|
| 1092 |
+
"period": "2025-Q4"
|
| 1093 |
+
}
|
| 1094 |
+
],
|
| 1095 |
+
"severity": "critical"
|
| 1096 |
+
},
|
| 1097 |
+
{
|
| 1098 |
+
"id": "investor.profitMargin.context",
|
| 1099 |
+
"persona": "investor",
|
| 1100 |
+
"personaLabel": "ํฌ์์",
|
| 1101 |
+
"stockCode": "005930",
|
| 1102 |
+
"question": "์ผ์ฑ์ ์ ์์
์ด์ต๋ฅ ๋ถ์ํด์ค",
|
| 1103 |
+
"userIntent": "profit_margin_analysis",
|
| 1104 |
+
"expectedAnswerShape": [
|
| 1105 |
+
"์ด์ต๋ฅ ์์น",
|
| 1106 |
+
"์ถ์ธ",
|
| 1107 |
+
"ํ๋จ"
|
| 1108 |
+
],
|
| 1109 |
+
"expectedEvidenceKinds": [
|
| 1110 |
+
"finance",
|
| 1111 |
+
"sections"
|
| 1112 |
+
],
|
| 1113 |
+
"expectedUserFacingTerms": [
|
| 1114 |
+
"์์
์ด์ต๋ฅ ",
|
| 1115 |
+
"์์ต์ฑ"
|
| 1116 |
+
],
|
| 1117 |
+
"forbiddenUiTerms": [
|
| 1118 |
+
"IS",
|
| 1119 |
+
"ratios"
|
| 1120 |
+
],
|
| 1121 |
+
"expectedRoute": "finance",
|
| 1122 |
+
"expectedModules": [
|
| 1123 |
+
"IS",
|
| 1124 |
+
"ratios"
|
| 1125 |
+
],
|
| 1126 |
+
"allowedClarification": false,
|
| 1127 |
+
"mustNotSay": [
|
| 1128 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 1129 |
+
],
|
| 1130 |
+
"mustInclude": [
|
| 1131 |
+
"์์
์ด์ต๋ฅ "
|
| 1132 |
+
],
|
| 1133 |
+
"expectedFollowups": [],
|
| 1134 |
+
"groundTruthFacts": [],
|
| 1135 |
+
"severity": "high"
|
| 1136 |
+
},
|
| 1137 |
+
{
|
| 1138 |
+
"id": "investor.growth.cashflowTrend",
|
| 1139 |
+
"persona": "investor",
|
| 1140 |
+
"personaLabel": "ํฌ์์",
|
| 1141 |
+
"stockCode": "005930",
|
| 1142 |
+
"question": "์ผ์ฑ์ ์ ์์
ํ๋ํ๊ธํ๋ฆ ์ถ์ด๋ก ์ฑ์ฅ์ฑ ํ๋จํด์ค",
|
| 1143 |
+
"userIntent": "cashflow_growth",
|
| 1144 |
+
"expectedAnswerShape": [
|
| 1145 |
+
"CF์ถ์ด",
|
| 1146 |
+
"์ฑ์ฅํ๋จ",
|
| 1147 |
+
"๊ทผ๊ฑฐ"
|
| 1148 |
+
],
|
| 1149 |
+
"expectedEvidenceKinds": [
|
| 1150 |
+
"finance"
|
| 1151 |
+
],
|
| 1152 |
+
"expectedUserFacingTerms": [
|
| 1153 |
+
"ํ๊ธํ๋ฆ",
|
| 1154 |
+
"์์
ํ๋",
|
| 1155 |
+
"์ฑ์ฅ"
|
| 1156 |
+
],
|
| 1157 |
+
"forbiddenUiTerms": [
|
| 1158 |
+
"CF",
|
| 1159 |
+
"module_"
|
| 1160 |
+
],
|
| 1161 |
+
"expectedRoute": "finance",
|
| 1162 |
+
"expectedModules": [
|
| 1163 |
+
"CF",
|
| 1164 |
+
"ratios"
|
| 1165 |
+
],
|
| 1166 |
+
"allowedClarification": false,
|
| 1167 |
+
"mustNotSay": [
|
| 1168 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 1169 |
+
],
|
| 1170 |
+
"mustInclude": [
|
| 1171 |
+
"ํ๊ธํ๋ฆ"
|
| 1172 |
+
],
|
| 1173 |
+
"expectedFollowups": [],
|
| 1174 |
+
"groundTruthFacts": [],
|
| 1175 |
+
"severity": "high"
|
| 1176 |
+
},
|
| 1177 |
+
{
|
| 1178 |
+
"id": "analyst.growth.futurePlan",
|
| 1179 |
+
"persona": "analyst",
|
| 1180 |
+
"personaLabel": "์ฌ๋ฌด ๋ถ์๊ฐ",
|
| 1181 |
+
"stockCode": "000660",
|
| 1182 |
+
"question": "SKํ์ด๋์ค ์ฌ์
๋ณด๊ณ ์์ ๋์จ ๋ฏธ๋ ํฌ์ ๊ณํ๊ณผ ์ฑ์ฅ ์ ๋ต ์์ฝํด์ค",
|
| 1183 |
+
"userIntent": "future_plan",
|
| 1184 |
+
"expectedAnswerShape": [
|
| 1185 |
+
"ํฌ์๊ณํ",
|
| 1186 |
+
"์ฑ์ฅ์ ๋ต",
|
| 1187 |
+
"๊ทผ๊ฑฐ์ธ์ฉ"
|
| 1188 |
+
],
|
| 1189 |
+
"expectedEvidenceKinds": [
|
| 1190 |
+
"docs"
|
| 1191 |
+
],
|
| 1192 |
+
"expectedUserFacingTerms": [
|
| 1193 |
+
"ํฌ์",
|
| 1194 |
+
"๊ณํ",
|
| 1195 |
+
"์ฑ์ฅ"
|
| 1196 |
+
],
|
| 1197 |
+
"forbiddenUiTerms": [
|
| 1198 |
+
"show_topic()",
|
| 1199 |
+
"module_"
|
| 1200 |
+
],
|
| 1201 |
+
"expectedRoute": "sections",
|
| 1202 |
+
"expectedModules": [
|
| 1203 |
+
"businessOverview",
|
| 1204 |
+
"productService"
|
| 1205 |
+
],
|
| 1206 |
+
"allowedClarification": false,
|
| 1207 |
+
"mustNotSay": [
|
| 1208 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 1209 |
+
],
|
| 1210 |
+
"mustInclude": [
|
| 1211 |
+
"ํฌ์"
|
| 1212 |
+
],
|
| 1213 |
+
"expectedFollowups": [],
|
| 1214 |
+
"groundTruthFacts": [],
|
| 1215 |
+
"severity": "high"
|
| 1216 |
+
},
|
| 1217 |
+
{
|
| 1218 |
+
"id": "investor.growth.revenueGrowth",
|
| 1219 |
+
"persona": "investor",
|
| 1220 |
+
"personaLabel": "ํฌ์์",
|
| 1221 |
+
"stockCode": "051910",
|
| 1222 |
+
"question": "LGํํ ์ต๊ทผ 3๋
๋งค์ถ ์ฑ์ฅ๋ฅ ๋ถ์ํด์ค",
|
| 1223 |
+
"userIntent": "revenue_growth_analysis",
|
| 1224 |
+
"expectedAnswerShape": [
|
| 1225 |
+
"์ฑ์ฅ๋ฅ ",
|
| 1226 |
+
"์ถ์ธ",
|
| 1227 |
+
"ํ๋จ"
|
| 1228 |
+
],
|
| 1229 |
+
"expectedEvidenceKinds": [
|
| 1230 |
+
"finance"
|
| 1231 |
+
],
|
| 1232 |
+
"expectedUserFacingTerms": [
|
| 1233 |
+
"๋งค์ถ",
|
| 1234 |
+
"์ฑ์ฅ๋ฅ ",
|
| 1235 |
+
"์ถ์ธ"
|
| 1236 |
+
],
|
| 1237 |
+
"forbiddenUiTerms": [
|
| 1238 |
+
"IS",
|
| 1239 |
+
"module_"
|
| 1240 |
+
],
|
| 1241 |
+
"expectedRoute": "finance",
|
| 1242 |
+
"expectedModules": [
|
| 1243 |
+
"IS",
|
| 1244 |
+
"ratios"
|
| 1245 |
+
],
|
| 1246 |
+
"allowedClarification": false,
|
| 1247 |
+
"mustNotSay": [
|
| 1248 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 1249 |
+
],
|
| 1250 |
+
"mustInclude": [
|
| 1251 |
+
"๋งค์ถ"
|
| 1252 |
+
],
|
| 1253 |
+
"expectedFollowups": [],
|
| 1254 |
+
"groundTruthFacts": [],
|
| 1255 |
+
"severity": "high"
|
| 1256 |
+
},
|
| 1257 |
+
{
|
| 1258 |
+
"id": "analyst.valuation.perComparison",
|
| 1259 |
+
"persona": "analyst",
|
| 1260 |
+
"personaLabel": "์ฌ๋ฌด ๋ถ์๊ฐ",
|
| 1261 |
+
"stockCode": "005930",
|
| 1262 |
+
"question": "์ผ์ฑ์ ์ PER, PBR ์์ค์ด ์ด๋ค์ง ๋ถ์ํด์ค",
|
| 1263 |
+
"userIntent": "valuation_per_pbr",
|
| 1264 |
+
"expectedAnswerShape": [
|
| 1265 |
+
"PER์์น",
|
| 1266 |
+
"PBR์์น",
|
| 1267 |
+
"ํ๋จ"
|
| 1268 |
+
],
|
| 1269 |
+
"expectedEvidenceKinds": [
|
| 1270 |
+
"finance"
|
| 1271 |
+
],
|
| 1272 |
+
"expectedUserFacingTerms": [
|
| 1273 |
+
"PER",
|
| 1274 |
+
"PBR",
|
| 1275 |
+
"๋ฐธ๋ฅ์์ด์
"
|
| 1276 |
+
],
|
| 1277 |
+
"forbiddenUiTerms": [
|
| 1278 |
+
"ratios",
|
| 1279 |
+
"module_"
|
| 1280 |
+
],
|
| 1281 |
+
"expectedRoute": "hybrid",
|
| 1282 |
+
"expectedModules": [
|
| 1283 |
+
"ratios",
|
| 1284 |
+
"IS"
|
| 1285 |
+
],
|
| 1286 |
+
"allowedClarification": false,
|
| 1287 |
+
"mustNotSay": [
|
| 1288 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 1289 |
+
],
|
| 1290 |
+
"mustInclude": [
|
| 1291 |
+
"PER"
|
| 1292 |
+
],
|
| 1293 |
+
"expectedFollowups": [],
|
| 1294 |
+
"groundTruthFacts": [],
|
| 1295 |
+
"severity": "high"
|
| 1296 |
+
},
|
| 1297 |
+
{
|
| 1298 |
+
"id": "investor.valuation.intrinsicValue",
|
| 1299 |
+
"persona": "investor",
|
| 1300 |
+
"personaLabel": "ํฌ์์",
|
| 1301 |
+
"stockCode": "000660",
|
| 1302 |
+
"question": "SKํ์ด๋์ค ์ ์ ๊ฐ์น๋ฅผ ์ด๋ป๊ฒ ํ๋จํ๋ฉด ์ข์์ง ์ฌ๋ฌด ๋ฐ์ดํฐ ๊ธฐ๋ฐ์ผ๋ก ์ค๋ช
ํด์ค",
|
| 1303 |
+
"userIntent": "intrinsic_value",
|
| 1304 |
+
"expectedAnswerShape": [
|
| 1305 |
+
"์ฌ๋ฌด๊ธฐ๋ฐํ๋จ",
|
| 1306 |
+
"๋น์จ๊ทผ๊ฑฐ",
|
| 1307 |
+
"ํฌ์์์ฌ์ "
|
| 1308 |
+
],
|
| 1309 |
+
"expectedEvidenceKinds": [
|
| 1310 |
+
"finance"
|
| 1311 |
+
],
|
| 1312 |
+
"expectedUserFacingTerms": [
|
| 1313 |
+
"๊ฐ์น",
|
| 1314 |
+
"์ ์ ",
|
| 1315 |
+
"ํ๋จ"
|
| 1316 |
+
],
|
| 1317 |
+
"forbiddenUiTerms": [
|
| 1318 |
+
"module_",
|
| 1319 |
+
"ratios"
|
| 1320 |
+
],
|
| 1321 |
+
"expectedRoute": "finance",
|
| 1322 |
+
"expectedModules": [
|
| 1323 |
+
"IS",
|
| 1324 |
+
"BS",
|
| 1325 |
+
"CF",
|
| 1326 |
+
"ratios"
|
| 1327 |
+
],
|
| 1328 |
+
"allowedClarification": false,
|
| 1329 |
+
"mustNotSay": [],
|
| 1330 |
+
"mustInclude": [
|
| 1331 |
+
"๊ฐ์น"
|
| 1332 |
+
],
|
| 1333 |
+
"expectedFollowups": [],
|
| 1334 |
+
"groundTruthFacts": [],
|
| 1335 |
+
"severity": "high"
|
| 1336 |
+
},
|
| 1337 |
+
{
|
| 1338 |
+
"id": "analyst.valuation.roe",
|
| 1339 |
+
"persona": "analyst",
|
| 1340 |
+
"personaLabel": "์ฌ๋ฌด ๋ถ์๊ฐ",
|
| 1341 |
+
"stockCode": "051910",
|
| 1342 |
+
"question": "LGํํ ROE ์ถ์ด์ ์๋ณธ ํจ์จ์ฑ ๋ถ์ํด์ค",
|
| 1343 |
+
"userIntent": "roe_analysis",
|
| 1344 |
+
"expectedAnswerShape": [
|
| 1345 |
+
"ROE์์น",
|
| 1346 |
+
"์ถ์ด",
|
| 1347 |
+
"ํ๋จ"
|
| 1348 |
+
],
|
| 1349 |
+
"expectedEvidenceKinds": [
|
| 1350 |
+
"finance"
|
| 1351 |
+
],
|
| 1352 |
+
"expectedUserFacingTerms": [
|
| 1353 |
+
"ROE",
|
| 1354 |
+
"์๋ณธ",
|
| 1355 |
+
"ํจ์จ"
|
| 1356 |
+
],
|
| 1357 |
+
"forbiddenUiTerms": [
|
| 1358 |
+
"ratios",
|
| 1359 |
+
"module_"
|
| 1360 |
+
],
|
| 1361 |
+
"expectedRoute": "hybrid",
|
| 1362 |
+
"expectedModules": [
|
| 1363 |
+
"ratios",
|
| 1364 |
+
"IS",
|
| 1365 |
+
"BS"
|
| 1366 |
+
],
|
| 1367 |
+
"allowedClarification": false,
|
| 1368 |
+
"mustNotSay": [
|
| 1369 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 1370 |
+
],
|
| 1371 |
+
"mustInclude": [
|
| 1372 |
+
"ROE"
|
| 1373 |
+
],
|
| 1374 |
+
"expectedFollowups": [],
|
| 1375 |
+
"groundTruthFacts": [],
|
| 1376 |
+
"severity": "high"
|
| 1377 |
+
},
|
| 1378 |
+
{
|
| 1379 |
+
"id": "investor.report.majorHolder",
|
| 1380 |
+
"persona": "investor",
|
| 1381 |
+
"personaLabel": "ํฌ์์",
|
| 1382 |
+
"stockCode": "005930",
|
| 1383 |
+
"question": "์ผ์ฑ์ ์ ์ต๋์ฃผ์ฃผ์ ์ฃผ์ ์ฃผ์ฃผ ํํฉ ์๋ ค์ค",
|
| 1384 |
+
"userIntent": "major_holder",
|
| 1385 |
+
"expectedAnswerShape": [
|
| 1386 |
+
"์ต๋์ฃผ์ฃผ",
|
| 1387 |
+
"์ง๋ถ์จ",
|
| 1388 |
+
"๋ณ๋"
|
| 1389 |
+
],
|
| 1390 |
+
"expectedEvidenceKinds": [
|
| 1391 |
+
"report"
|
| 1392 |
+
],
|
| 1393 |
+
"expectedUserFacingTerms": [
|
| 1394 |
+
"์ฃผ์ฃผ",
|
| 1395 |
+
"์ง๋ถ",
|
| 1396 |
+
"์ต๋์ฃผ์ฃผ"
|
| 1397 |
+
],
|
| 1398 |
+
"forbiddenUiTerms": [
|
| 1399 |
+
"report.get",
|
| 1400 |
+
"majorHolder"
|
| 1401 |
+
],
|
| 1402 |
+
"expectedRoute": "report",
|
| 1403 |
+
"expectedModules": [
|
| 1404 |
+
"majorHolder"
|
| 1405 |
+
],
|
| 1406 |
+
"allowedClarification": false,
|
| 1407 |
+
"mustNotSay": [
|
| 1408 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 1409 |
+
],
|
| 1410 |
+
"mustInclude": [
|
| 1411 |
+
"์ฃผ์ฃผ"
|
| 1412 |
+
],
|
| 1413 |
+
"expectedFollowups": [],
|
| 1414 |
+
"groundTruthFacts": [],
|
| 1415 |
+
"severity": "high"
|
| 1416 |
+
},
|
| 1417 |
+
{
|
| 1418 |
+
"id": "accountant.report.executivePay",
|
| 1419 |
+
"persona": "accountant",
|
| 1420 |
+
"personaLabel": "ํ๊ณ์ฌ",
|
| 1421 |
+
"stockCode": "005930",
|
| 1422 |
+
"question": "์ผ์ฑ์ ์ ์ด์ฌํ ๊ตฌ์ฑ๊ณผ ์์ ๋ณด์ ํํฉ ์์ฝํด์ค",
|
| 1423 |
+
"userIntent": "executive_compensation",
|
| 1424 |
+
"expectedAnswerShape": [
|
| 1425 |
+
"์ด์ฌํ๊ตฌ์ฑ",
|
| 1426 |
+
"๋ณด์ํํฉ",
|
| 1427 |
+
"ํ๋จ"
|
| 1428 |
+
],
|
| 1429 |
+
"expectedEvidenceKinds": [
|
| 1430 |
+
"report"
|
| 1431 |
+
],
|
| 1432 |
+
"expectedUserFacingTerms": [
|
| 1433 |
+
"์ด์ฌํ",
|
| 1434 |
+
"์์",
|
| 1435 |
+
"๋ณด์"
|
| 1436 |
+
],
|
| 1437 |
+
"forbiddenUiTerms": [
|
| 1438 |
+
"report.get",
|
| 1439 |
+
"executive"
|
| 1440 |
+
],
|
| 1441 |
+
"expectedRoute": "report",
|
| 1442 |
+
"expectedModules": [
|
| 1443 |
+
"executive"
|
| 1444 |
+
],
|
| 1445 |
+
"allowedClarification": false,
|
| 1446 |
+
"mustNotSay": [],
|
| 1447 |
+
"mustInclude": [
|
| 1448 |
+
"์์"
|
| 1449 |
+
],
|
| 1450 |
+
"expectedFollowups": [],
|
| 1451 |
+
"groundTruthFacts": [],
|
| 1452 |
+
"severity": "high"
|
| 1453 |
+
},
|
| 1454 |
+
{
|
| 1455 |
+
"id": "investor.report.treasuryStock",
|
| 1456 |
+
"persona": "investor",
|
| 1457 |
+
"personaLabel": "ํฌ์์",
|
| 1458 |
+
"stockCode": "005930",
|
| 1459 |
+
"question": "์ผ์ฑ์ ์ ์๊ธฐ์ฃผ์ ์ทจ๋/์ฒ๋ถ ์ด๋ ฅ ์๋ ค์ค",
|
| 1460 |
+
"userIntent": "treasury_stock",
|
| 1461 |
+
"expectedAnswerShape": [
|
| 1462 |
+
"์ทจ๋์ด๋ ฅ",
|
| 1463 |
+
"์ฒ๋ถ์ด๋ ฅ",
|
| 1464 |
+
"ํํฉ"
|
| 1465 |
+
],
|
| 1466 |
+
"expectedEvidenceKinds": [
|
| 1467 |
+
"report"
|
| 1468 |
+
],
|
| 1469 |
+
"expectedUserFacingTerms": [
|
| 1470 |
+
"์๊ธฐ์ฃผ์",
|
| 1471 |
+
"์์ฌ์ฃผ",
|
| 1472 |
+
"์ทจ๋"
|
| 1473 |
+
],
|
| 1474 |
+
"forbiddenUiTerms": [
|
| 1475 |
+
"report.get",
|
| 1476 |
+
"treasuryStock"
|
| 1477 |
+
],
|
| 1478 |
+
"expectedRoute": "report",
|
| 1479 |
+
"expectedModules": [
|
| 1480 |
+
"treasuryStock"
|
| 1481 |
+
],
|
| 1482 |
+
"allowedClarification": false,
|
| 1483 |
+
"mustNotSay": [],
|
| 1484 |
+
"mustInclude": [
|
| 1485 |
+
"์๊ธฐ์ฃผ์"
|
| 1486 |
+
],
|
| 1487 |
+
"expectedFollowups": [],
|
| 1488 |
+
"groundTruthFacts": [],
|
| 1489 |
+
"severity": "medium"
|
| 1490 |
+
},
|
| 1491 |
+
{
|
| 1492 |
+
"id": "researchGather.report.employeeTrend",
|
| 1493 |
+
"persona": "research_gather",
|
| 1494 |
+
"personaLabel": "๋ฆฌ์์น ์์ง์",
|
| 1495 |
+
"stockCode": "000660",
|
| 1496 |
+
"question": "SKํ์ด๋์ค ์ง์ ์ ๋ณํ ์ถ์ด์ ์ธ๋น ๋งค์ถ ์๋ ค์ค",
|
| 1497 |
+
"userIntent": "employee_trend",
|
| 1498 |
+
"expectedAnswerShape": [
|
| 1499 |
+
"์ง์์์ถ์ด",
|
| 1500 |
+
"์ธ๋น๋งค์ถ",
|
| 1501 |
+
"ํ๋จ"
|
| 1502 |
+
],
|
| 1503 |
+
"expectedEvidenceKinds": [
|
| 1504 |
+
"report",
|
| 1505 |
+
"finance"
|
| 1506 |
+
],
|
| 1507 |
+
"expectedUserFacingTerms": [
|
| 1508 |
+
"์ง์",
|
| 1509 |
+
"์ธ๋ ฅ",
|
| 1510 |
+
"๋งค์ถ"
|
| 1511 |
+
],
|
| 1512 |
+
"forbiddenUiTerms": [
|
| 1513 |
+
"report.get",
|
| 1514 |
+
"employee"
|
| 1515 |
+
],
|
| 1516 |
+
"expectedRoute": "hybrid",
|
| 1517 |
+
"expectedModules": [
|
| 1518 |
+
"employee",
|
| 1519 |
+
"IS"
|
| 1520 |
+
],
|
| 1521 |
+
"allowedClarification": false,
|
| 1522 |
+
"mustNotSay": [],
|
| 1523 |
+
"mustInclude": [
|
| 1524 |
+
"์ง์"
|
| 1525 |
+
],
|
| 1526 |
+
"expectedFollowups": [],
|
| 1527 |
+
"groundTruthFacts": [],
|
| 1528 |
+
"severity": "medium"
|
| 1529 |
+
},
|
| 1530 |
+
{
|
| 1531 |
+
"id": "analyst.context.evidenceCitation",
|
| 1532 |
+
"persona": "analyst",
|
| 1533 |
+
"personaLabel": "์ฌ๋ฌด ๋ถ์๊ฐ",
|
| 1534 |
+
"stockCode": "005930",
|
| 1535 |
+
"question": "์ผ์ฑ์ ์ ๋ฐ๋์ฒด ์ฌ์
์ ๋ง์ ๋ํด ๊ณต์ ์๋ฌธ ๊ทผ๊ฑฐ๋ฅผ ์ธ์ฉํด์ ์ค๋ช
ํด์ค",
|
| 1536 |
+
"userIntent": "evidence_citation",
|
| 1537 |
+
"expectedAnswerShape": [
|
| 1538 |
+
"์๋ฌธ์ธ์ฉ",
|
| 1539 |
+
"๋ถ์",
|
| 1540 |
+
"๊ทผ๊ฑฐ"
|
| 1541 |
+
],
|
| 1542 |
+
"expectedEvidenceKinds": [
|
| 1543 |
+
"docs",
|
| 1544 |
+
"context_slice"
|
| 1545 |
+
],
|
| 1546 |
+
"expectedUserFacingTerms": [
|
| 1547 |
+
"๋ฐ๋์ฒด",
|
| 1548 |
+
"์ ๋ง",
|
| 1549 |
+
"์๋ฌธ"
|
| 1550 |
+
],
|
| 1551 |
+
"forbiddenUiTerms": [
|
| 1552 |
+
"contextSlices",
|
| 1553 |
+
"show_topic()"
|
| 1554 |
+
],
|
| 1555 |
+
"expectedRoute": "sections",
|
| 1556 |
+
"expectedModules": [
|
| 1557 |
+
"businessOverview",
|
| 1558 |
+
"productService"
|
| 1559 |
+
],
|
| 1560 |
+
"allowedClarification": false,
|
| 1561 |
+
"mustNotSay": [
|
| 1562 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 1563 |
+
],
|
| 1564 |
+
"mustInclude": [
|
| 1565 |
+
"๋ฐ๋์ฒด"
|
| 1566 |
+
],
|
| 1567 |
+
"expectedFollowups": [],
|
| 1568 |
+
"groundTruthFacts": [],
|
| 1569 |
+
"severity": "high"
|
| 1570 |
+
},
|
| 1571 |
+
{
|
| 1572 |
+
"id": "businessOwner.context.riskFactors",
|
| 1573 |
+
"persona": "business_owner",
|
| 1574 |
+
"personaLabel": "์ฌ์
๊ฐ",
|
| 1575 |
+
"stockCode": "051910",
|
| 1576 |
+
"question": "LGํํ ์ฌ์
๋ฆฌ์คํฌ ์์ธ์ ๊ณต์ ๋ด์ฉ ๊ธฐ๋ฐ์ผ๋ก ์ ๋ฆฌํด์ค",
|
| 1577 |
+
"userIntent": "risk_factor_citation",
|
| 1578 |
+
"expectedAnswerShape": [
|
| 1579 |
+
"๋ฆฌ์คํฌ๋ชฉ๋ก",
|
| 1580 |
+
"๊ณต์๊ทผ๊ฑฐ",
|
| 1581 |
+
"์ํฅ๋"
|
| 1582 |
+
],
|
| 1583 |
+
"expectedEvidenceKinds": [
|
| 1584 |
+
"docs"
|
| 1585 |
+
],
|
| 1586 |
+
"expectedUserFacingTerms": [
|
| 1587 |
+
"๋ฆฌ์คํฌ",
|
| 1588 |
+
"์ํ",
|
| 1589 |
+
"๊ณต์"
|
| 1590 |
+
],
|
| 1591 |
+
"forbiddenUiTerms": [
|
| 1592 |
+
"riskDerivative",
|
| 1593 |
+
"module_"
|
| 1594 |
+
],
|
| 1595 |
+
"expectedRoute": "sections",
|
| 1596 |
+
"expectedModules": [
|
| 1597 |
+
"riskDerivative",
|
| 1598 |
+
"businessOverview"
|
| 1599 |
+
],
|
| 1600 |
+
"allowedClarification": false,
|
| 1601 |
+
"mustNotSay": [],
|
| 1602 |
+
"mustInclude": [
|
| 1603 |
+
"๋ฆฌ์คํฌ"
|
| 1604 |
+
],
|
| 1605 |
+
"expectedFollowups": [],
|
| 1606 |
+
"groundTruthFacts": [],
|
| 1607 |
+
"severity": "high"
|
| 1608 |
+
},
|
| 1609 |
+
{
|
| 1610 |
+
"id": "investor.context.disclosureChange",
|
| 1611 |
+
"persona": "investor",
|
| 1612 |
+
"personaLabel": "ํฌ์์",
|
| 1613 |
+
"stockCode": "000660",
|
| 1614 |
+
"question": "SKํ์ด๋์ค ์ต๊ทผ ๊ณต์์์ ์ ๋
๋๋น ๋ฌ๋ผ์ง ์ฃผ์ ๋ด์ฉ์ด ๋ญ์ผ",
|
| 1615 |
+
"userIntent": "disclosure_change_detection",
|
| 1616 |
+
"expectedAnswerShape": [
|
| 1617 |
+
"๋ณ๊ฒฝ์ฌํญ",
|
| 1618 |
+
"๋น๊ต",
|
| 1619 |
+
"์์ฌ์ "
|
| 1620 |
+
],
|
| 1621 |
+
"expectedEvidenceKinds": [
|
| 1622 |
+
"docs",
|
| 1623 |
+
"diff"
|
| 1624 |
+
],
|
| 1625 |
+
"expectedUserFacingTerms": [
|
| 1626 |
+
"๋ณ๊ฒฝ",
|
| 1627 |
+
"๋ฌ๋ผ์ง",
|
| 1628 |
+
"์ ๋
"
|
| 1629 |
+
],
|
| 1630 |
+
"forbiddenUiTerms": [
|
| 1631 |
+
"disclosureChanges",
|
| 1632 |
+
"diff()"
|
| 1633 |
+
],
|
| 1634 |
+
"expectedRoute": "sections",
|
| 1635 |
+
"expectedModules": [
|
| 1636 |
+
"disclosureChanges",
|
| 1637 |
+
"businessOverview"
|
| 1638 |
+
],
|
| 1639 |
+
"allowedClarification": false,
|
| 1640 |
+
"mustNotSay": [],
|
| 1641 |
+
"mustInclude": [
|
| 1642 |
+
"๋ณ๊ฒฝ"
|
| 1643 |
+
],
|
| 1644 |
+
"expectedFollowups": [],
|
| 1645 |
+
"groundTruthFacts": [],
|
| 1646 |
+
"severity": "high"
|
| 1647 |
+
},
|
| 1648 |
+
{
|
| 1649 |
+
"id": "analyst.notes.rndExpense",
|
| 1650 |
+
"persona": "analyst",
|
| 1651 |
+
"personaLabel": "์ฌ๋ฌด ๋ถ์๊ฐ",
|
| 1652 |
+
"stockCode": "005930",
|
| 1653 |
+
"question": "์ผ์ฑ์ ์ ์ฐ๊ตฌ๊ฐ๋ฐ๋น ๊ท๋ชจ์ ๋งค์ถ ๋๋น ๋น์ค ์๋ ค์ค",
|
| 1654 |
+
"userIntent": "rnd_analysis",
|
| 1655 |
+
"expectedAnswerShape": [
|
| 1656 |
+
"์ฐ๊ตฌ๊ฐ๋ฐ๋น",
|
| 1657 |
+
"๋งค์ถ๋๋น๋น์ค",
|
| 1658 |
+
"์ถ์ธ"
|
| 1659 |
+
],
|
| 1660 |
+
"expectedEvidenceKinds": [
|
| 1661 |
+
"finance",
|
| 1662 |
+
"notes"
|
| 1663 |
+
],
|
| 1664 |
+
"expectedUserFacingTerms": [
|
| 1665 |
+
"์ฐ๊ตฌ๊ฐ๋ฐ",
|
| 1666 |
+
"R&D",
|
| 1667 |
+
"๋น์ค"
|
| 1668 |
+
],
|
| 1669 |
+
"forbiddenUiTerms": [
|
| 1670 |
+
"rnd",
|
| 1671 |
+
"module_"
|
| 1672 |
+
],
|
| 1673 |
+
"expectedRoute": "finance",
|
| 1674 |
+
"expectedModules": [
|
| 1675 |
+
"rnd",
|
| 1676 |
+
"IS"
|
| 1677 |
+
],
|
| 1678 |
+
"allowedClarification": false,
|
| 1679 |
+
"mustNotSay": [
|
| 1680 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 1681 |
+
],
|
| 1682 |
+
"mustInclude": [
|
| 1683 |
+
"์ฐ๊ตฌ๊ฐ๋ฐ"
|
| 1684 |
+
],
|
| 1685 |
+
"expectedFollowups": [],
|
| 1686 |
+
"groundTruthFacts": [],
|
| 1687 |
+
"severity": "high"
|
| 1688 |
+
},
|
| 1689 |
+
{
|
| 1690 |
+
"id": "accountant.notes.tangibleAsset",
|
| 1691 |
+
"persona": "accountant",
|
| 1692 |
+
"personaLabel": "ํ๊ณ์ฌ",
|
| 1693 |
+
"stockCode": "000660",
|
| 1694 |
+
"question": "SKํ์ด๋์ค ์ ํ์์ฐ ๊ท๋ชจ์ ๊ฐ๊ฐ์๊ฐ ํํฉ ๋ถ์ํด์ค",
|
| 1695 |
+
"userIntent": "tangible_asset",
|
| 1696 |
+
"expectedAnswerShape": [
|
| 1697 |
+
"์ ํ์์ฐ๊ท๋ชจ",
|
| 1698 |
+
"๊ฐ๊ฐ์๊ฐ",
|
| 1699 |
+
"ํฌ์ํ๋จ"
|
| 1700 |
+
],
|
| 1701 |
+
"expectedEvidenceKinds": [
|
| 1702 |
+
"finance",
|
| 1703 |
+
"notes"
|
| 1704 |
+
],
|
| 1705 |
+
"expectedUserFacingTerms": [
|
| 1706 |
+
"์ ํ์์ฐ",
|
| 1707 |
+
"๊ฐ๊ฐ์๊ฐ",
|
| 1708 |
+
"ํฌ์"
|
| 1709 |
+
],
|
| 1710 |
+
"forbiddenUiTerms": [
|
| 1711 |
+
"tangibleAsset",
|
| 1712 |
+
"module_"
|
| 1713 |
+
],
|
| 1714 |
+
"expectedRoute": "finance",
|
| 1715 |
+
"expectedModules": [
|
| 1716 |
+
"tangibleAsset",
|
| 1717 |
+
"BS"
|
| 1718 |
+
],
|
| 1719 |
+
"allowedClarification": false,
|
| 1720 |
+
"mustNotSay": [],
|
| 1721 |
+
"mustInclude": [
|
| 1722 |
+
"์ ํ์์ฐ"
|
| 1723 |
+
],
|
| 1724 |
+
"expectedFollowups": [],
|
| 1725 |
+
"groundTruthFacts": [],
|
| 1726 |
+
"severity": "high"
|
| 1727 |
+
},
|
| 1728 |
+
{
|
| 1729 |
+
"id": "analyst.notes.segmentDetail",
|
| 1730 |
+
"persona": "analyst",
|
| 1731 |
+
"personaLabel": "์ฌ๋ฌด ๋ถ์๊ฐ",
|
| 1732 |
+
"stockCode": "051910",
|
| 1733 |
+
"question": "LGํํ ์ฌ์
๋ถ๋ฌธ๋ณ ๋งค์ถ๊ณผ ์์
์ด์ต ๋น์ค ๋ถ์ํด์ค",
|
| 1734 |
+
"userIntent": "segment_detail",
|
| 1735 |
+
"expectedAnswerShape": [
|
| 1736 |
+
"๋ถ๋ฌธ๋ณ๋งค์ถ",
|
| 1737 |
+
"๋ถ๋ฌธ๋ณ์ด์ต",
|
| 1738 |
+
"๋น์ค๋ถ์"
|
| 1739 |
+
],
|
| 1740 |
+
"expectedEvidenceKinds": [
|
| 1741 |
+
"docs",
|
| 1742 |
+
"finance"
|
| 1743 |
+
],
|
| 1744 |
+
"expectedUserFacingTerms": [
|
| 1745 |
+
"์ฌ์
๋ถ๋ฌธ",
|
| 1746 |
+
"๋งค์ถ",
|
| 1747 |
+
"๋น์ค"
|
| 1748 |
+
],
|
| 1749 |
+
"forbiddenUiTerms": [
|
| 1750 |
+
"segments",
|
| 1751 |
+
"module_"
|
| 1752 |
+
],
|
| 1753 |
+
"expectedRoute": "sections",
|
| 1754 |
+
"expectedModules": [
|
| 1755 |
+
"segments",
|
| 1756 |
+
"IS"
|
| 1757 |
+
],
|
| 1758 |
+
"allowedClarification": false,
|
| 1759 |
+
"mustNotSay": [
|
| 1760 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 1761 |
+
],
|
| 1762 |
+
"mustInclude": [
|
| 1763 |
+
"๋ถ๋ฌธ"
|
| 1764 |
+
],
|
| 1765 |
+
"expectedFollowups": [],
|
| 1766 |
+
"groundTruthFacts": [],
|
| 1767 |
+
"severity": "high"
|
| 1768 |
+
},
|
| 1769 |
+
{
|
| 1770 |
+
"id": "accountant.edge.financialCompany",
|
| 1771 |
+
"persona": "accountant",
|
| 1772 |
+
"personaLabel": "ํ๊ณ์ฌ",
|
| 1773 |
+
"stockCode": "105560",
|
| 1774 |
+
"question": "KB๊ธ์ต์ง์ฃผ ์ฌ๋ฌด๊ฑด์ ์ฑ ๋ถ์ํด์ค",
|
| 1775 |
+
"userIntent": "financial_soundness",
|
| 1776 |
+
"expectedAnswerShape": [
|
| 1777 |
+
"๊ฑด์ ์ฑ์งํ",
|
| 1778 |
+
"ํ๋จ",
|
| 1779 |
+
"๊ทผ๊ฑฐ"
|
| 1780 |
+
],
|
| 1781 |
+
"expectedEvidenceKinds": [
|
| 1782 |
+
"finance"
|
| 1783 |
+
],
|
| 1784 |
+
"expectedUserFacingTerms": [
|
| 1785 |
+
"๊ฑด์ ์ฑ",
|
| 1786 |
+
"์๋ณธ",
|
| 1787 |
+
"๋ถ์ฑ"
|
| 1788 |
+
],
|
| 1789 |
+
"forbiddenUiTerms": [
|
| 1790 |
+
"module_"
|
| 1791 |
+
],
|
| 1792 |
+
"expectedRoute": "finance",
|
| 1793 |
+
"expectedModules": [
|
| 1794 |
+
"BS",
|
| 1795 |
+
"IS",
|
| 1796 |
+
"ratios"
|
| 1797 |
+
],
|
| 1798 |
+
"allowedClarification": false,
|
| 1799 |
+
"mustNotSay": [],
|
| 1800 |
+
"mustInclude": [
|
| 1801 |
+
"๊ฑด์ ์ฑ"
|
| 1802 |
+
],
|
| 1803 |
+
"expectedFollowups": [],
|
| 1804 |
+
"groundTruthFacts": [],
|
| 1805 |
+
"severity": "high"
|
| 1806 |
+
},
|
| 1807 |
+
{
|
| 1808 |
+
"id": "investor.edge.holdingCompany",
|
| 1809 |
+
"persona": "investor",
|
| 1810 |
+
"personaLabel": "ํฌ์์",
|
| 1811 |
+
"stockCode": "035420",
|
| 1812 |
+
"question": "NAVER ์ฌ์
๋ค๊ฐํ ํํฉ๊ณผ ์ฃผ์ ๋งค์ถ์ ๋ถ์ํด์ค",
|
| 1813 |
+
"userIntent": "business_diversification",
|
| 1814 |
+
"expectedAnswerShape": [
|
| 1815 |
+
"์ฌ์
์์ญ",
|
| 1816 |
+
"๋งค์ถ์",
|
| 1817 |
+
"๋ถ์"
|
| 1818 |
+
],
|
| 1819 |
+
"expectedEvidenceKinds": [
|
| 1820 |
+
"docs",
|
| 1821 |
+
"finance"
|
| 1822 |
+
],
|
| 1823 |
+
"expectedUserFacingTerms": [
|
| 1824 |
+
"์ฌ์
",
|
| 1825 |
+
"๋งค์ถ์",
|
| 1826 |
+
"๋ค๊ฐํ"
|
| 1827 |
+
],
|
| 1828 |
+
"forbiddenUiTerms": [
|
| 1829 |
+
"module_",
|
| 1830 |
+
"show_topic()"
|
| 1831 |
+
],
|
| 1832 |
+
"expectedRoute": "sections",
|
| 1833 |
+
"expectedModules": [
|
| 1834 |
+
"businessOverview",
|
| 1835 |
+
"segments",
|
| 1836 |
+
"IS"
|
| 1837 |
+
],
|
| 1838 |
+
"allowedClarification": false,
|
| 1839 |
+
"mustNotSay": [],
|
| 1840 |
+
"mustInclude": [
|
| 1841 |
+
"์ฌ์
"
|
| 1842 |
+
],
|
| 1843 |
+
"expectedFollowups": [],
|
| 1844 |
+
"groundTruthFacts": [],
|
| 1845 |
+
"severity": "medium"
|
| 1846 |
+
},
|
| 1847 |
+
{
|
| 1848 |
+
"id": "businessOwner.edge.capitalAllocationNav",
|
| 1849 |
+
"persona": "business_owner",
|
| 1850 |
+
"personaLabel": "์ฌ์
๊ฐ",
|
| 1851 |
+
"stockCode": "035420",
|
| 1852 |
+
"question": "NAVER ์ต๊ทผ ์๋ณธ ๋ฐฐ๋ถ ์ ๋ต ๋ถ์ํด์ค",
|
| 1853 |
+
"userIntent": "capital_allocation",
|
| 1854 |
+
"expectedAnswerShape": [
|
| 1855 |
+
"๋ฐฐ๋น์ ์ฑ
",
|
| 1856 |
+
"์์ฌ์ฃผ",
|
| 1857 |
+
"ํฌ์์ ๋ต"
|
| 1858 |
+
],
|
| 1859 |
+
"expectedEvidenceKinds": [
|
| 1860 |
+
"report",
|
| 1861 |
+
"finance"
|
| 1862 |
+
],
|
| 1863 |
+
"expectedUserFacingTerms": [
|
| 1864 |
+
"๋ฐฐ๋น",
|
| 1865 |
+
"์์ฌ์ฃผ",
|
| 1866 |
+
"ํฌ์"
|
| 1867 |
+
],
|
| 1868 |
+
"forbiddenUiTerms": [
|
| 1869 |
+
"module_"
|
| 1870 |
+
],
|
| 1871 |
+
"expectedRoute": "hybrid",
|
| 1872 |
+
"expectedModules": [
|
| 1873 |
+
"dividend",
|
| 1874 |
+
"CF",
|
| 1875 |
+
"treasuryStock"
|
| 1876 |
+
],
|
| 1877 |
+
"allowedClarification": false,
|
| 1878 |
+
"mustNotSay": [],
|
| 1879 |
+
"mustInclude": [
|
| 1880 |
+
"๋ฐฐ๋น"
|
| 1881 |
+
],
|
| 1882 |
+
"expectedFollowups": [],
|
| 1883 |
+
"groundTruthFacts": [],
|
| 1884 |
+
"severity": "medium"
|
| 1885 |
+
},
|
| 1886 |
+
{
|
| 1887 |
+
"id": "accountant.cost.rndRatio",
|
| 1888 |
+
"persona": "accountant",
|
| 1889 |
+
"personaLabel": "ํ๊ณ์ฌ",
|
| 1890 |
+
"stockCode": "000660",
|
| 1891 |
+
"question": "SKํ์ด๋์ค ์ฐ๊ตฌ๊ฐ๋ฐ๋น๊ฐ ๋งค์ถ์๊ฐ์ ํ๊ด๋น ์ค ์ด๋์ ๋ ๋ง์ด ๋ฐ์๋๋์ง ๋ถ์ํด์ค",
|
| 1892 |
+
"userIntent": "rnd_cost_allocation",
|
| 1893 |
+
"expectedAnswerShape": [
|
| 1894 |
+
"๋ฐฐ๋ถ๊ตฌ์กฐ",
|
| 1895 |
+
"๋น์ค",
|
| 1896 |
+
"ํ๋จ"
|
| 1897 |
+
],
|
| 1898 |
+
"expectedEvidenceKinds": [
|
| 1899 |
+
"finance",
|
| 1900 |
+
"notes"
|
| 1901 |
+
],
|
| 1902 |
+
"expectedUserFacingTerms": [
|
| 1903 |
+
"์ฐ๊ตฌ๊ฐ๋ฐ",
|
| 1904 |
+
"๋งค์ถ์๊ฐ",
|
| 1905 |
+
"ํ๊ด๋น"
|
| 1906 |
+
],
|
| 1907 |
+
"forbiddenUiTerms": [
|
| 1908 |
+
"costByNature",
|
| 1909 |
+
"rnd",
|
| 1910 |
+
"module_"
|
| 1911 |
+
],
|
| 1912 |
+
"expectedRoute": "finance",
|
| 1913 |
+
"expectedModules": [
|
| 1914 |
+
"rnd",
|
| 1915 |
+
"costByNature",
|
| 1916 |
+
"IS"
|
| 1917 |
+
],
|
| 1918 |
+
"allowedClarification": false,
|
| 1919 |
+
"mustNotSay": [],
|
| 1920 |
+
"mustInclude": [
|
| 1921 |
+
"์ฐ๊ตฌ๊ฐ๋ฐ"
|
| 1922 |
+
],
|
| 1923 |
+
"expectedFollowups": [],
|
| 1924 |
+
"groundTruthFacts": [],
|
| 1925 |
+
"severity": "high"
|
| 1926 |
+
},
|
| 1927 |
+
{
|
| 1928 |
+
"id": "analyst.cost.opexBreakdown",
|
| 1929 |
+
"persona": "analyst",
|
| 1930 |
+
"personaLabel": "์ฌ๋ฌด ๋ถ์๊ฐ",
|
| 1931 |
+
"stockCode": "005930",
|
| 1932 |
+
"question": "์ผ์ฑ์ ์ ๋งค์ถ์๊ฐ์ ํ๊ด๋น ์ถ์ด ๋ถ์ํด์ค",
|
| 1933 |
+
"userIntent": "opex_breakdown",
|
| 1934 |
+
"expectedAnswerShape": [
|
| 1935 |
+
"์๊ฐ์ถ์ด",
|
| 1936 |
+
"ํ๊ด๋น์ถ์ด",
|
| 1937 |
+
"๋น์ค๋ณํ"
|
| 1938 |
+
],
|
| 1939 |
+
"expectedEvidenceKinds": [
|
| 1940 |
+
"finance"
|
| 1941 |
+
],
|
| 1942 |
+
"expectedUserFacingTerms": [
|
| 1943 |
+
"๋งค์ถ์๊ฐ",
|
| 1944 |
+
"ํ๊ด๋น",
|
| 1945 |
+
"๋น์ฉ"
|
| 1946 |
+
],
|
| 1947 |
+
"forbiddenUiTerms": [
|
| 1948 |
+
"IS",
|
| 1949 |
+
"module_"
|
| 1950 |
+
],
|
| 1951 |
+
"expectedRoute": "finance",
|
| 1952 |
+
"expectedModules": [
|
| 1953 |
+
"IS"
|
| 1954 |
+
],
|
| 1955 |
+
"allowedClarification": false,
|
| 1956 |
+
"mustNotSay": [
|
| 1957 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 1958 |
+
],
|
| 1959 |
+
"mustInclude": [
|
| 1960 |
+
"์๊ฐ"
|
| 1961 |
+
],
|
| 1962 |
+
"expectedFollowups": [],
|
| 1963 |
+
"groundTruthFacts": [],
|
| 1964 |
+
"severity": "high"
|
| 1965 |
+
},
|
| 1966 |
+
{
|
| 1967 |
+
"id": "businessOwner.cost.segments",
|
| 1968 |
+
"persona": "business_owner",
|
| 1969 |
+
"personaLabel": "์ฌ์
๊ฐ",
|
| 1970 |
+
"stockCode": "051910",
|
| 1971 |
+
"question": "LGํํ ๋ถ๋ฌธ๋ณ ์์ต์ฑ์ด ์ด๋ป๊ฒ ๋ค๋ฅธ์ง ๋น๊ตํด์ค",
|
| 1972 |
+
"userIntent": "segment_profitability",
|
| 1973 |
+
"expectedAnswerShape": [
|
| 1974 |
+
"๋ถ๋ฌธ๋ณ๋น๊ต",
|
| 1975 |
+
"์์ต์ฑ",
|
| 1976 |
+
"์์ฌ์ "
|
| 1977 |
+
],
|
| 1978 |
+
"expectedEvidenceKinds": [
|
| 1979 |
+
"docs",
|
| 1980 |
+
"finance"
|
| 1981 |
+
],
|
| 1982 |
+
"expectedUserFacingTerms": [
|
| 1983 |
+
"๋ถ๋ฌธ",
|
| 1984 |
+
"์์ต์ฑ",
|
| 1985 |
+
"๋น๊ต"
|
| 1986 |
+
],
|
| 1987 |
+
"forbiddenUiTerms": [
|
| 1988 |
+
"segments",
|
| 1989 |
+
"module_"
|
| 1990 |
+
],
|
| 1991 |
+
"expectedRoute": "finance",
|
| 1992 |
+
"expectedModules": [
|
| 1993 |
+
"segments",
|
| 1994 |
+
"IS"
|
| 1995 |
+
],
|
| 1996 |
+
"allowedClarification": false,
|
| 1997 |
+
"mustNotSay": [],
|
| 1998 |
+
"mustInclude": [
|
| 1999 |
+
"๋ถ๋ฌธ"
|
| 2000 |
+
],
|
| 2001 |
+
"expectedFollowups": [],
|
| 2002 |
+
"groundTruthFacts": [],
|
| 2003 |
+
"severity": "medium"
|
| 2004 |
+
},
|
| 2005 |
+
{
|
| 2006 |
+
"id": "analyst.deep.comprehensiveHealth",
|
| 2007 |
+
"persona": "analyst",
|
| 2008 |
+
"personaLabel": "์ฌ๋ฌด ๋ถ์๊ฐ",
|
| 2009 |
+
"stockCode": "000660",
|
| 2010 |
+
"question": "SKํ์ด๋์ค ์ข
ํฉ ์ฌ๋ฌด ๊ฑด๊ฐ ์ง๋จํด์ค",
|
| 2011 |
+
"userIntent": "comprehensive_health",
|
| 2012 |
+
"expectedAnswerShape": [
|
| 2013 |
+
"์์ต์ฑ",
|
| 2014 |
+
"์์ ์ฑ",
|
| 2015 |
+
"์ฑ์ฅ์ฑ",
|
| 2016 |
+
"์ข
ํฉํ๋จ"
|
| 2017 |
+
],
|
| 2018 |
+
"expectedEvidenceKinds": [
|
| 2019 |
+
"finance",
|
| 2020 |
+
"docs"
|
| 2021 |
+
],
|
| 2022 |
+
"expectedUserFacingTerms": [
|
| 2023 |
+
"์์ต์ฑ",
|
| 2024 |
+
"์์ ์ฑ",
|
| 2025 |
+
"์ฑ์ฅ"
|
| 2026 |
+
],
|
| 2027 |
+
"forbiddenUiTerms": [
|
| 2028 |
+
"module_"
|
| 2029 |
+
],
|
| 2030 |
+
"expectedRoute": "finance",
|
| 2031 |
+
"expectedModules": [
|
| 2032 |
+
"IS",
|
| 2033 |
+
"BS",
|
| 2034 |
+
"CF",
|
| 2035 |
+
"ratios"
|
| 2036 |
+
],
|
| 2037 |
+
"allowedClarification": false,
|
| 2038 |
+
"mustNotSay": [
|
| 2039 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 2040 |
+
],
|
| 2041 |
+
"mustInclude": [
|
| 2042 |
+
"์์ต์ฑ"
|
| 2043 |
+
],
|
| 2044 |
+
"expectedFollowups": [],
|
| 2045 |
+
"groundTruthFacts": [],
|
| 2046 |
+
"severity": "critical"
|
| 2047 |
+
},
|
| 2048 |
+
{
|
| 2049 |
+
"id": "investor.deep.investmentThesis",
|
| 2050 |
+
"persona": "investor",
|
| 2051 |
+
"personaLabel": "ํฌ์์",
|
| 2052 |
+
"stockCode": "051910",
|
| 2053 |
+
"question": "LGํํ ํฌ์ ๋งค๋ ฅ๋๋ฅผ ์ฌ๋ฌด/๊ณต์/๋ฆฌ์คํฌ ์ข
ํฉ์ ์ผ๋ก ํ๊ฐํด์ค",
|
| 2054 |
+
"userIntent": "investment_thesis",
|
| 2055 |
+
"expectedAnswerShape": [
|
| 2056 |
+
"์ฌ๋ฌด๋ถ์",
|
| 2057 |
+
"๊ณต์๊ธฐ๋ฐ๋ฆฌ์คํฌ",
|
| 2058 |
+
"ํฌ์ํ๋จ"
|
| 2059 |
+
],
|
| 2060 |
+
"expectedEvidenceKinds": [
|
| 2061 |
+
"finance",
|
| 2062 |
+
"docs",
|
| 2063 |
+
"report"
|
| 2064 |
+
],
|
| 2065 |
+
"expectedUserFacingTerms": [
|
| 2066 |
+
"ํฌ์",
|
| 2067 |
+
"๋งค๋ ฅ๋",
|
| 2068 |
+
"๋ฆฌ์คํฌ"
|
| 2069 |
+
],
|
| 2070 |
+
"forbiddenUiTerms": [
|
| 2071 |
+
"module_"
|
| 2072 |
+
],
|
| 2073 |
+
"expectedRoute": "sections",
|
| 2074 |
+
"expectedModules": [
|
| 2075 |
+
"IS",
|
| 2076 |
+
"BS",
|
| 2077 |
+
"CF",
|
| 2078 |
+
"ratios",
|
| 2079 |
+
"businessOverview"
|
| 2080 |
+
],
|
| 2081 |
+
"allowedClarification": false,
|
| 2082 |
+
"mustNotSay": [],
|
| 2083 |
+
"mustInclude": [
|
| 2084 |
+
"ํฌ์"
|
| 2085 |
+
],
|
| 2086 |
+
"expectedFollowups": [],
|
| 2087 |
+
"groundTruthFacts": [],
|
| 2088 |
+
"severity": "critical"
|
| 2089 |
+
},
|
| 2090 |
+
{
|
| 2091 |
+
"id": "researchGather.overview.navBusiness",
|
| 2092 |
+
"persona": "research_gather",
|
| 2093 |
+
"personaLabel": "๋ฆฌ์์น ์์ง์",
|
| 2094 |
+
"stockCode": "035420",
|
| 2095 |
+
"question": "NAVER ์ฃผ์ ์ฌ์
๋ด์ฉ๊ณผ ์ต๊ทผ ๋ณํ ์์ฝํด์ค",
|
| 2096 |
+
"userIntent": "business_overview",
|
| 2097 |
+
"expectedAnswerShape": [
|
| 2098 |
+
"์ฌ์
๋ด์ฉ",
|
| 2099 |
+
"์ต๊ทผ๋ณํ",
|
| 2100 |
+
"์ ๋ง"
|
| 2101 |
+
],
|
| 2102 |
+
"expectedEvidenceKinds": [
|
| 2103 |
+
"docs"
|
| 2104 |
+
],
|
| 2105 |
+
"expectedUserFacingTerms": [
|
| 2106 |
+
"์ฌ์
",
|
| 2107 |
+
"๋ณํ",
|
| 2108 |
+
"์ ๋ง"
|
| 2109 |
+
],
|
| 2110 |
+
"forbiddenUiTerms": [
|
| 2111 |
+
"businessOverview",
|
| 2112 |
+
"show_topic()"
|
| 2113 |
+
],
|
| 2114 |
+
"expectedRoute": "sections",
|
| 2115 |
+
"expectedModules": [
|
| 2116 |
+
"businessOverview",
|
| 2117 |
+
"productService"
|
| 2118 |
+
],
|
| 2119 |
+
"allowedClarification": false,
|
| 2120 |
+
"mustNotSay": [],
|
| 2121 |
+
"mustInclude": [
|
| 2122 |
+
"์ฌ์
"
|
| 2123 |
+
],
|
| 2124 |
+
"expectedFollowups": [],
|
| 2125 |
+
"groundTruthFacts": [],
|
| 2126 |
+
"severity": "medium"
|
| 2127 |
+
},
|
| 2128 |
+
{
|
| 2129 |
+
"id": "businessOwner.overview.chemicalIndustry",
|
| 2130 |
+
"persona": "business_owner",
|
| 2131 |
+
"personaLabel": "์ฌ์
๊ฐ",
|
| 2132 |
+
"stockCode": "051910",
|
| 2133 |
+
"question": "LGํํ์ด ์ด๋ค ์ฌ์
์ ํ๋ ํ์ฌ์ธ์ง ๊ณต์ ๊ธฐ์ค์ผ๋ก ์ค๋ช
ํด์ค",
|
| 2134 |
+
"userIntent": "business_description",
|
| 2135 |
+
"expectedAnswerShape": [
|
| 2136 |
+
"์ฌ์
์ค๋ช
",
|
| 2137 |
+
"์ฃผ์์ ํ",
|
| 2138 |
+
"์์ฅ"
|
| 2139 |
+
],
|
| 2140 |
+
"expectedEvidenceKinds": [
|
| 2141 |
+
"docs"
|
| 2142 |
+
],
|
| 2143 |
+
"expectedUserFacingTerms": [
|
| 2144 |
+
"์ฌ์
",
|
| 2145 |
+
"์ ํ",
|
| 2146 |
+
"์์ฅ"
|
| 2147 |
+
],
|
| 2148 |
+
"forbiddenUiTerms": [
|
| 2149 |
+
"module_",
|
| 2150 |
+
"show_topic()"
|
| 2151 |
+
],
|
| 2152 |
+
"expectedRoute": "sections",
|
| 2153 |
+
"expectedModules": [
|
| 2154 |
+
"businessOverview",
|
| 2155 |
+
"productService"
|
| 2156 |
+
],
|
| 2157 |
+
"allowedClarification": false,
|
| 2158 |
+
"mustNotSay": [],
|
| 2159 |
+
"mustInclude": [
|
| 2160 |
+
"์ฌ์
"
|
| 2161 |
+
],
|
| 2162 |
+
"expectedFollowups": [],
|
| 2163 |
+
"groundTruthFacts": [],
|
| 2164 |
+
"severity": "medium"
|
| 2165 |
+
},
|
| 2166 |
+
{
|
| 2167 |
+
"id": "investor.followup.deeperDividend",
|
| 2168 |
+
"persona": "investor",
|
| 2169 |
+
"personaLabel": "ํฌ์์",
|
| 2170 |
+
"stockCode": "005930",
|
| 2171 |
+
"question": "์ผ์ฑ์ ์ ๋ฐฐ๋น์ด ์ง์ ๊ฐ๋ฅํ์ง, ๋ฐฐ๋น์ฑํฅ๊ณผ FCF ๊ธฐ์ค์ผ๋ก ํ๋จํด์ค",
|
| 2172 |
+
"userIntent": "dividend_sustainability_deep",
|
| 2173 |
+
"expectedAnswerShape": [
|
| 2174 |
+
"๋ฐฐ๋น์ฑํฅ",
|
| 2175 |
+
"FCF์ปค๋ฒ๋ฆฌ์ง",
|
| 2176 |
+
"์ง์๊ฐ๋ฅ์ฑํ๋จ"
|
| 2177 |
+
],
|
| 2178 |
+
"expectedEvidenceKinds": [
|
| 2179 |
+
"finance",
|
| 2180 |
+
"report"
|
| 2181 |
+
],
|
| 2182 |
+
"expectedUserFacingTerms": [
|
| 2183 |
+
"๋ฐฐ๋น",
|
| 2184 |
+
"๋ฐฐ๋น์ฑํฅ",
|
| 2185 |
+
"FCF"
|
| 2186 |
+
],
|
| 2187 |
+
"forbiddenUiTerms": [
|
| 2188 |
+
"dividend",
|
| 2189 |
+
"module_"
|
| 2190 |
+
],
|
| 2191 |
+
"expectedRoute": "hybrid",
|
| 2192 |
+
"expectedModules": [
|
| 2193 |
+
"dividend",
|
| 2194 |
+
"CF",
|
| 2195 |
+
"IS"
|
| 2196 |
+
],
|
| 2197 |
+
"allowedClarification": false,
|
| 2198 |
+
"mustNotSay": [
|
| 2199 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 2200 |
+
],
|
| 2201 |
+
"mustInclude": [
|
| 2202 |
+
"๋ฐฐ๋น"
|
| 2203 |
+
],
|
| 2204 |
+
"expectedFollowups": [],
|
| 2205 |
+
"groundTruthFacts": [],
|
| 2206 |
+
"severity": "high"
|
| 2207 |
+
},
|
| 2208 |
+
{
|
| 2209 |
+
"id": "analyst.followup.whyMarginDrop",
|
| 2210 |
+
"persona": "analyst",
|
| 2211 |
+
"personaLabel": "์ฌ๋ฌด ๋ถ์๊ฐ",
|
| 2212 |
+
"stockCode": "000660",
|
| 2213 |
+
"question": "SKํ์ด๋์ค ์์
์ด์ต๋ฅ ์ด ํ๋ฝํ ์์ธ์ ๋น์ฉ ๊ตฌ์กฐ์์ ์ฐพ์์ค",
|
| 2214 |
+
"userIntent": "margin_drop_cause",
|
| 2215 |
+
"expectedAnswerShape": [
|
| 2216 |
+
"์ด์ต๋ฅ ๋ณํ",
|
| 2217 |
+
"๋น์ฉ๋ถ์",
|
| 2218 |
+
"์์ธ"
|
| 2219 |
+
],
|
| 2220 |
+
"expectedEvidenceKinds": [
|
| 2221 |
+
"finance",
|
| 2222 |
+
"docs"
|
| 2223 |
+
],
|
| 2224 |
+
"expectedUserFacingTerms": [
|
| 2225 |
+
"์์
์ด์ต๋ฅ ",
|
| 2226 |
+
"๋น์ฉ",
|
| 2227 |
+
"์์ธ"
|
| 2228 |
+
],
|
| 2229 |
+
"forbiddenUiTerms": [
|
| 2230 |
+
"ratios",
|
| 2231 |
+
"IS",
|
| 2232 |
+
"module_"
|
| 2233 |
+
],
|
| 2234 |
+
"expectedRoute": "finance",
|
| 2235 |
+
"expectedModules": [
|
| 2236 |
+
"IS",
|
| 2237 |
+
"ratios",
|
| 2238 |
+
"costByNature"
|
| 2239 |
+
],
|
| 2240 |
+
"allowedClarification": false,
|
| 2241 |
+
"mustNotSay": [],
|
| 2242 |
+
"mustInclude": [
|
| 2243 |
+
"์์
์ด์ต๋ฅ "
|
| 2244 |
+
],
|
| 2245 |
+
"expectedFollowups": [],
|
| 2246 |
+
"groundTruthFacts": [],
|
| 2247 |
+
"severity": "high"
|
| 2248 |
+
},
|
| 2249 |
+
{
|
| 2250 |
+
"id": "accountant.stability.debtAnalysis",
|
| 2251 |
+
"persona": "accountant",
|
| 2252 |
+
"personaLabel": "ํ๊ณ์ฌ",
|
| 2253 |
+
"stockCode": "051910",
|
| 2254 |
+
"question": "LGํํ ๋ถ์ฑ๋น์จ๊ณผ ์ ๋๋น์จ๋ก ์ฌ๋ฌด ์์ ์ฑ ํ๋จํด์ค",
|
| 2255 |
+
"userIntent": "debt_stability",
|
| 2256 |
+
"expectedAnswerShape": [
|
| 2257 |
+
"๋ถ์ฑ๋น์จ",
|
| 2258 |
+
"์ ๋๋น์จ",
|
| 2259 |
+
"์์ ์ฑํ๋จ"
|
| 2260 |
+
],
|
| 2261 |
+
"expectedEvidenceKinds": [
|
| 2262 |
+
"finance"
|
| 2263 |
+
],
|
| 2264 |
+
"expectedUserFacingTerms": [
|
| 2265 |
+
"๋ถ์ฑ๋น์จ",
|
| 2266 |
+
"์ ๋๋น์จ",
|
| 2267 |
+
"์์ ์ฑ"
|
| 2268 |
+
],
|
| 2269 |
+
"forbiddenUiTerms": [
|
| 2270 |
+
"ratios",
|
| 2271 |
+
"BS",
|
| 2272 |
+
"module_"
|
| 2273 |
+
],
|
| 2274 |
+
"expectedRoute": "finance",
|
| 2275 |
+
"expectedModules": [
|
| 2276 |
+
"BS",
|
| 2277 |
+
"ratios"
|
| 2278 |
+
],
|
| 2279 |
+
"allowedClarification": false,
|
| 2280 |
+
"mustNotSay": [
|
| 2281 |
+
"๋ฐ์ดํฐ๊ฐ ์"
|
| 2282 |
+
],
|
| 2283 |
+
"mustInclude": [
|
| 2284 |
+
"๋ถ์ฑ๋น์จ"
|
| 2285 |
+
],
|
| 2286 |
+
"expectedFollowups": [],
|
| 2287 |
+
"groundTruthFacts": [],
|
| 2288 |
+
"severity": "high"
|
| 2289 |
+
},
|
| 2290 |
+
{
|
| 2291 |
+
"id": "investor.stability.interestCoverage",
|
| 2292 |
+
"persona": "investor",
|
| 2293 |
+
"personaLabel": "ํฌ์์",
|
| 2294 |
+
"stockCode": "000660",
|
| 2295 |
+
"question": "SKํ์ด๋์ค ์ด์๋ณด์๋ฐฐ์จ ๋ถ์ํด์ค",
|
| 2296 |
+
"userIntent": "interest_coverage",
|
| 2297 |
+
"expectedAnswerShape": [
|
| 2298 |
+
"์ด์๋ณด์๋ฐฐ์จ",
|
| 2299 |
+
"์ถ์ด",
|
| 2300 |
+
"ํ๋จ"
|
| 2301 |
+
],
|
| 2302 |
+
"expectedEvidenceKinds": [
|
| 2303 |
+
"finance"
|
| 2304 |
+
],
|
| 2305 |
+
"expectedUserFacingTerms": [
|
| 2306 |
+
"์ด์๋ณด์๋ฐฐ์จ",
|
| 2307 |
+
"์ด์",
|
| 2308 |
+
"๋ถ๋ด"
|
| 2309 |
+
],
|
| 2310 |
+
"forbiddenUiTerms": [
|
| 2311 |
+
"ratios",
|
| 2312 |
+
"module_"
|
| 2313 |
+
],
|
| 2314 |
+
"expectedRoute": "finance",
|
| 2315 |
+
"expectedModules": [
|
| 2316 |
+
"ratios",
|
| 2317 |
+
"IS"
|
| 2318 |
+
],
|
| 2319 |
+
"allowedClarification": false,
|
| 2320 |
+
"mustNotSay": [],
|
| 2321 |
+
"mustInclude": [
|
| 2322 |
+
"์ด์"
|
| 2323 |
+
],
|
| 2324 |
+
"expectedFollowups": [],
|
| 2325 |
+
"groundTruthFacts": [],
|
| 2326 |
+
"severity": "medium"
|
| 2327 |
+
},
|
| 2328 |
+
{
|
| 2329 |
+
"id": "analyst.edgar.appleFinancials",
|
| 2330 |
+
"persona": "analyst",
|
| 2331 |
+
"personaLabel": "์ฌ๋ฌด ๋ถ์๊ฐ",
|
| 2332 |
+
"stockCode": "AAPL",
|
| 2333 |
+
"question": "Apple ์ต๊ทผ ๋งค์ถ๊ณผ ์์
์ด์ต ์ถ์ด ๋ถ์ํด์ค",
|
| 2334 |
+
"userIntent": "us_financials",
|
| 2335 |
+
"expectedAnswerShape": [
|
| 2336 |
+
"๋งค์ถ์ถ์ด",
|
| 2337 |
+
"์ด์ต์ถ์ด",
|
| 2338 |
+
"๋ถ์"
|
| 2339 |
+
],
|
| 2340 |
+
"expectedEvidenceKinds": [
|
| 2341 |
+
"finance"
|
| 2342 |
+
],
|
| 2343 |
+
"expectedUserFacingTerms": [
|
| 2344 |
+
"๋งค์ถ",
|
| 2345 |
+
"์์
์ด์ต",
|
| 2346 |
+
"์ถ์ด"
|
| 2347 |
+
],
|
| 2348 |
+
"forbiddenUiTerms": [
|
| 2349 |
+
"IS",
|
| 2350 |
+
"module_"
|
| 2351 |
+
],
|
| 2352 |
+
"expectedRoute": "finance",
|
| 2353 |
+
"expectedModules": [
|
| 2354 |
+
"IS"
|
| 2355 |
+
],
|
| 2356 |
+
"allowedClarification": false,
|
| 2357 |
+
"mustNotSay": [],
|
| 2358 |
+
"mustInclude": [
|
| 2359 |
+
"๋งค์ถ"
|
| 2360 |
+
],
|
| 2361 |
+
"expectedFollowups": [],
|
| 2362 |
+
"groundTruthFacts": [],
|
| 2363 |
+
"severity": "medium"
|
| 2364 |
+
},
|
| 2365 |
+
{
|
| 2366 |
+
"id": "investor.edgar.appleBusiness",
|
| 2367 |
+
"persona": "investor",
|
| 2368 |
+
"personaLabel": "ํฌ์์",
|
| 2369 |
+
"stockCode": "AAPL",
|
| 2370 |
+
"question": "Apple 10-K์ ๋์จ ์ฌ์
๊ฐ์ ์์ฝํด์ค",
|
| 2371 |
+
"userIntent": "us_business_overview",
|
| 2372 |
+
"expectedAnswerShape": [
|
| 2373 |
+
"์ฌ์
๊ฐ์",
|
| 2374 |
+
"์ฃผ์์ ํ",
|
| 2375 |
+
"์ ๋ต"
|
| 2376 |
+
],
|
| 2377 |
+
"expectedEvidenceKinds": [
|
| 2378 |
+
"docs"
|
| 2379 |
+
],
|
| 2380 |
+
"expectedUserFacingTerms": [
|
| 2381 |
+
"์ฌ์
",
|
| 2382 |
+
"์ ํ",
|
| 2383 |
+
"Apple"
|
| 2384 |
+
],
|
| 2385 |
+
"forbiddenUiTerms": [
|
| 2386 |
+
"businessOverview",
|
| 2387 |
+
"module_"
|
| 2388 |
+
],
|
| 2389 |
+
"expectedRoute": "sections",
|
| 2390 |
+
"expectedModules": [
|
| 2391 |
+
"businessOverview"
|
| 2392 |
+
],
|
| 2393 |
+
"allowedClarification": false,
|
| 2394 |
+
"mustNotSay": [],
|
| 2395 |
+
"mustInclude": [
|
| 2396 |
+
"์ฌ์
"
|
| 2397 |
+
],
|
| 2398 |
+
"expectedFollowups": [],
|
| 2399 |
+
"groundTruthFacts": [],
|
| 2400 |
+
"severity": "medium"
|
| 2401 |
+
},
|
| 2402 |
+
{
|
| 2403 |
+
"id": "accountant.edgar.appleBalanceSheet",
|
| 2404 |
+
"persona": "accountant",
|
| 2405 |
+
"personaLabel": "ํ๊ณ์ฌ",
|
| 2406 |
+
"stockCode": "AAPL",
|
| 2407 |
+
"question": "Apple ์์ฐ/๋ถ์ฑ/์๋ณธ ๊ตฌ์กฐ ๋ถ์ํด์ค",
|
| 2408 |
+
"userIntent": "us_balance_sheet",
|
| 2409 |
+
"expectedAnswerShape": [
|
| 2410 |
+
"์์ฐ๊ตฌ์กฐ",
|
| 2411 |
+
"๋ถ์ฑ๊ตฌ์กฐ",
|
| 2412 |
+
"์๋ณธ๊ตฌ์กฐ"
|
| 2413 |
+
],
|
| 2414 |
+
"expectedEvidenceKinds": [
|
| 2415 |
+
"finance"
|
| 2416 |
+
],
|
| 2417 |
+
"expectedUserFacingTerms": [
|
| 2418 |
+
"์์ฐ",
|
| 2419 |
+
"๋ถ์ฑ",
|
| 2420 |
+
"์๋ณธ"
|
| 2421 |
+
],
|
| 2422 |
+
"forbiddenUiTerms": [
|
| 2423 |
+
"BS",
|
| 2424 |
+
"module_"
|
| 2425 |
+
],
|
| 2426 |
+
"expectedRoute": "finance",
|
| 2427 |
+
"expectedModules": [
|
| 2428 |
+
"BS"
|
| 2429 |
+
],
|
| 2430 |
+
"allowedClarification": false,
|
| 2431 |
+
"mustNotSay": [],
|
| 2432 |
+
"mustInclude": [
|
| 2433 |
+
"์์ฐ"
|
| 2434 |
+
],
|
| 2435 |
+
"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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""failure taxonomy โ ๊ตฌ์ฒด์ ์ฝ๋ ์์ ์์น ๋งคํ."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
from dataclasses import dataclass
|
| 6 |
+
from typing import Any
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
@dataclass
|
| 10 |
+
class RemediationPlan:
|
| 11 |
+
"""๊ฐ๋ณ ๊ฐ์ ๊ณํ."""
|
| 12 |
+
|
| 13 |
+
failureType: str
|
| 14 |
+
targetFile: str
|
| 15 |
+
description: str
|
| 16 |
+
priority: int # 1=์ต์ฐ์ ~ 5=๋ฎ์
|
| 17 |
+
estimatedImpact: str # "high", "medium", "low"
|
| 18 |
+
|
| 19 |
+
|
| 20 |
+
# โโ failure โ ์ฝ๋ ์์ ๋งคํ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 21 |
+
|
| 22 |
+
_FAILURE_REMEDIATION: dict[str, dict[str, str]] = {
|
| 23 |
+
"routing_failure": {
|
| 24 |
+
"targetFile": "engines/ai/context/builder.py",
|
| 25 |
+
"description": "_ROUTE_*_KEYWORDS์ ๋๋ฝ ํค์๋ ์ถ๊ฐ",
|
| 26 |
+
"estimatedImpact": "high",
|
| 27 |
+
},
|
| 28 |
+
"retrieval_failure": {
|
| 29 |
+
"targetFile": "engines/ai/context/finance_context.py",
|
| 30 |
+
"description": "_QUESTION_MODULES ๋งคํ์ ๋ชจ๋ ์ถ๊ฐ",
|
| 31 |
+
"estimatedImpact": "high",
|
| 32 |
+
},
|
| 33 |
+
"false_unavailable": {
|
| 34 |
+
"targetFile": "engines/ai/context/builder.py",
|
| 35 |
+
"description": "build_context_tiered์์ context ํฌํจ ๊ฒฝ๋ก ํ์ฅ",
|
| 36 |
+
"estimatedImpact": "high",
|
| 37 |
+
},
|
| 38 |
+
"generation_failure": {
|
| 39 |
+
"targetFile": "engines/ai/conversation/templates/analysis_rules.py",
|
| 40 |
+
"description": "๋ถ์ ๊ท์น์ few-shot ์์ ์ถ๊ฐ",
|
| 41 |
+
"estimatedImpact": "medium",
|
| 42 |
+
},
|
| 43 |
+
"ui_wording_failure": {
|
| 44 |
+
"targetFile": "engines/ai/conversation/system_base.py",
|
| 45 |
+
"description": "์์คํ
ํ๋กฌํํธ์์ ๋ด๋ถ ๋ช
์นญ ๊ธ์ง ๊ฐํ",
|
| 46 |
+
"estimatedImpact": "low",
|
| 47 |
+
},
|
| 48 |
+
"hallucination": {
|
| 49 |
+
"targetFile": "engines/ai/conversation/templates/analysis_rules.py",
|
| 50 |
+
"description": "์ซ์ ์ธ์ฉ ์ ์ถ์ฒ ๋ช
์ ๊ท์น ๊ฐํ",
|
| 51 |
+
"estimatedImpact": "high",
|
| 52 |
+
},
|
| 53 |
+
"data_gap": {
|
| 54 |
+
"targetFile": "engines/company/dart/",
|
| 55 |
+
"description": "๋ฐ์ดํฐ ํ์ ๊ตฌํ ๋๋ ๋งคํ ํ์ฅ ํ์",
|
| 56 |
+
"estimatedImpact": "medium",
|
| 57 |
+
},
|
| 58 |
+
"module_underuse": {
|
| 59 |
+
"targetFile": "engines/ai/runtime/pipeline.py",
|
| 60 |
+
"description": "ํ์ดํ๋ผ์ธ frozenset์ ๋ชจ๋ ํฌํจ ํ์ฅ",
|
| 61 |
+
"estimatedImpact": "medium",
|
| 62 |
+
},
|
| 63 |
+
"clarification_failure": {
|
| 64 |
+
"targetFile": "engines/ai/conversation/system_base.py",
|
| 65 |
+
"description": "clarification ์ ์ฑ
์กฐ๊ฑด ์์ ",
|
| 66 |
+
"estimatedImpact": "low",
|
| 67 |
+
},
|
| 68 |
+
"context_shallow": {
|
| 69 |
+
"targetFile": "engines/ai/context/finance_context.py",
|
| 70 |
+
"description": "context ๋ ์ด์ด์ ๋ ๋ง์ ๋ฐ์ดํฐ ์์ค ํฌํจ",
|
| 71 |
+
"estimatedImpact": "medium",
|
| 72 |
+
},
|
| 73 |
+
"citation_imprecise": {
|
| 74 |
+
"targetFile": "engines/ai/conversation/templates/analysis_rules.py",
|
| 75 |
+
"description": "์ธ์ฉ ํ์ ๊ท์น(์ฐ๋+์ถ์ฒ+์์น ํธ๋ฆฌํ) ๊ฐํ",
|
| 76 |
+
"estimatedImpact": "medium",
|
| 77 |
+
},
|
| 78 |
+
}
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
def generateRemediations(
|
| 82 |
+
failureCounts: dict[str, int],
|
| 83 |
+
threshold: int = 1,
|
| 84 |
+
) -> list[RemediationPlan]:
|
| 85 |
+
"""failure ๋น๋์์ ๊ฐ์ ๊ณํ ์์ฑ.
|
| 86 |
+
|
| 87 |
+
Args:
|
| 88 |
+
failureCounts: {failureType: count}
|
| 89 |
+
threshold: ์ต์ ๋ฐ์ ํ์
|
| 90 |
+
|
| 91 |
+
Returns:
|
| 92 |
+
์ฐ์ ์์์ RemediationPlan ๋ชฉ๋ก.
|
| 93 |
+
"""
|
| 94 |
+
plans: list[RemediationPlan] = []
|
| 95 |
+
|
| 96 |
+
for failureType, count in failureCounts.items():
|
| 97 |
+
if count < threshold:
|
| 98 |
+
continue
|
| 99 |
+
|
| 100 |
+
remediation = _FAILURE_REMEDIATION.get(failureType)
|
| 101 |
+
if remediation is None:
|
| 102 |
+
plans.append(
|
| 103 |
+
RemediationPlan(
|
| 104 |
+
failureType=failureType,
|
| 105 |
+
targetFile="(๋งคํ ์์)",
|
| 106 |
+
description=f"์ failure ์ ํ โ ๋งคํ ์ถ๊ฐ ํ์ (๋ฐ์ {count}ํ)",
|
| 107 |
+
priority=5,
|
| 108 |
+
estimatedImpact="unknown",
|
| 109 |
+
)
|
| 110 |
+
)
|
| 111 |
+
continue
|
| 112 |
+
|
| 113 |
+
# ๋น๋ ๊ธฐ๋ฐ ์ฐ์ ์์ (1=์ต์ฐ์ )
|
| 114 |
+
if count >= 5:
|
| 115 |
+
priority = 1
|
| 116 |
+
elif count >= 3:
|
| 117 |
+
priority = 2
|
| 118 |
+
elif count >= 2:
|
| 119 |
+
priority = 3
|
| 120 |
+
else:
|
| 121 |
+
priority = 4
|
| 122 |
+
|
| 123 |
+
# impact์ ๋ฐ๋ฅธ ๋ณด์
|
| 124 |
+
impact = remediation["estimatedImpact"]
|
| 125 |
+
if impact == "high":
|
| 126 |
+
priority = max(1, priority - 1)
|
| 127 |
+
|
| 128 |
+
plans.append(
|
| 129 |
+
RemediationPlan(
|
| 130 |
+
failureType=failureType,
|
| 131 |
+
targetFile=remediation["targetFile"],
|
| 132 |
+
description=f"{remediation['description']} (๋ฐ์ {count}ํ)",
|
| 133 |
+
priority=priority,
|
| 134 |
+
estimatedImpact=impact,
|
| 135 |
+
)
|
| 136 |
+
)
|
| 137 |
+
|
| 138 |
+
plans.sort(key=lambda p: p.priority)
|
| 139 |
+
return plans
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def formatAsMarkdown(plans: list[RemediationPlan]) -> str:
|
| 143 |
+
"""๊ฐ์ ๊ณํ์ ๋งํฌ๋ค์ด์ผ๋ก."""
|
| 144 |
+
if not plans:
|
| 145 |
+
return "๊ฐ์ ํ์ ์ฌํญ ์์."
|
| 146 |
+
|
| 147 |
+
lines = ["# ๊ฐ์ ๊ณํ (Remediation)", ""]
|
| 148 |
+
lines.append("| ์ฐ์ ์์ | Failure | ๋์ ํ์ผ | ์ค๋ช
| ์ํฅ๋ |")
|
| 149 |
+
lines.append("|---------|---------|----------|------|-------|")
|
| 150 |
+
|
| 151 |
+
for p in plans:
|
| 152 |
+
lines.append(f"| P{p.priority} | {p.failureType} | `{p.targetFile}` | {p.description} | {p.estimatedImpact} |")
|
| 153 |
+
|
| 154 |
+
lines.append("")
|
| 155 |
+
highPriority = [p for p in plans if p.priority <= 2]
|
| 156 |
+
if highPriority:
|
| 157 |
+
lines.append(f"**์ฆ์ ์กฐ์น ํ์**: {len(highPriority)}๊ฑด")
|
| 158 |
+
for p in highPriority:
|
| 159 |
+
lines.append(f"- [{p.failureType}] โ `{p.targetFile}`")
|
| 160 |
+
|
| 161 |
+
return "\n".join(lines)
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
def generateGitHubIssueBody(plans: list[RemediationPlan]) -> str:
|
| 165 |
+
"""gh issue create์ฉ ๋ณธ๋ฌธ ์์ฑ."""
|
| 166 |
+
if not plans:
|
| 167 |
+
return ""
|
| 168 |
+
|
| 169 |
+
lines = ["## Eval ์๋ ์ง๋จ โ ๊ฐ์ ํ์", ""]
|
| 170 |
+
lines.append("๋ฐฐ์น ๊ฒฐ๊ณผ ๋ถ์์์ ๋ค์ ๊ฐ์ ์ฌํญ์ด ๋ฐ๊ฒฌ๋์์ต๋๋ค:")
|
| 171 |
+
lines.append("")
|
| 172 |
+
|
| 173 |
+
for p in plans:
|
| 174 |
+
lines.append(f"### P{p.priority}: {p.failureType}")
|
| 175 |
+
lines.append(f"- **๋์**: `{p.targetFile}`")
|
| 176 |
+
lines.append(f"- **์ค๋ช
**: {p.description}")
|
| 177 |
+
lines.append(f"- **์ํฅ๋**: {p.estimatedImpact}")
|
| 178 |
+
lines.append("")
|
| 179 |
+
|
| 180 |
+
lines.append("---")
|
| 181 |
+
lines.append("*์๋ ์์ฑ by evalDiagnose.py*")
|
| 182 |
+
return "\n".join(lines)
|
| 183 |
+
|
| 184 |
+
|
| 185 |
+
def extractFailureCounts(results: list[dict[str, Any]]) -> dict[str, int]:
|
| 186 |
+
"""๋ฐฐ์น ๊ฒฐ๊ณผ์์ failure ์ ํ๋ณ ๋น๋ ์ถ์ถ."""
|
| 187 |
+
counts: dict[str, int] = {}
|
| 188 |
+
for r in results:
|
| 189 |
+
for ftype in r.get("failureTypes", []):
|
| 190 |
+
counts[ftype] = counts.get(ftype, 0) + 1
|
| 191 |
+
return counts
|
src/dartlab/ai/eval/replayRunner.py
ADDED
|
@@ -0,0 +1,416 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""Persona question replay runner for ask regression."""
|
| 2 |
+
|
| 3 |
+
from __future__ import annotations
|
| 4 |
+
|
| 5 |
+
import json
|
| 6 |
+
from dataclasses import asdict, dataclass, field
|
| 7 |
+
from datetime import datetime
|
| 8 |
+
from pathlib import Path
|
| 9 |
+
from statistics import mean
|
| 10 |
+
from typing import Any, Callable
|
| 11 |
+
|
| 12 |
+
from dartlab.ai.eval.scorer import ScoreCard, auto_score, score_module_utilization
|
| 13 |
+
from dartlab.ai.runtime.events import AnalysisEvent
|
| 14 |
+
|
| 15 |
+
_PERSONA_CASES_PATH = Path(__file__).parent / "personaCases.json"
|
| 16 |
+
_REVIEW_LOG_DIR = Path(__file__).parent / "reviewLog"
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
@dataclass(frozen=True)
|
| 20 |
+
class PersonaEvalCase:
|
| 21 |
+
"""Single curated ask regression case."""
|
| 22 |
+
|
| 23 |
+
id: str
|
| 24 |
+
persona: str
|
| 25 |
+
personaLabel: str
|
| 26 |
+
question: str
|
| 27 |
+
userIntent: str
|
| 28 |
+
stockCode: str | None = None
|
| 29 |
+
expectedAnswerShape: list[str] = field(default_factory=list)
|
| 30 |
+
expectedEvidenceKinds: list[str] = field(default_factory=list)
|
| 31 |
+
expectedUserFacingTerms: list[str] = field(default_factory=list)
|
| 32 |
+
forbiddenUiTerms: list[str] = field(default_factory=list)
|
| 33 |
+
expectedRoute: str | None = None
|
| 34 |
+
expectedModules: list[str] = field(default_factory=list)
|
| 35 |
+
allowedClarification: bool = False
|
| 36 |
+
mustNotSay: list[str] = field(default_factory=list)
|
| 37 |
+
mustInclude: list[str] = field(default_factory=list)
|
| 38 |
+
expectedFollowups: list[str] = field(default_factory=list)
|
| 39 |
+
groundTruthFacts: list[dict[str, Any]] = field(default_factory=list)
|
| 40 |
+
severity: str = "medium"
|
| 41 |
+
|
| 42 |
+
|
| 43 |
+
@dataclass
|
| 44 |
+
class StructuralEval:
|
| 45 |
+
"""Replay structure checks before answer-quality scoring."""
|
| 46 |
+
|
| 47 |
+
expectedRoute: str | None = None
|
| 48 |
+
actualRoute: str | None = None
|
| 49 |
+
routeMatch: float = 1.0
|
| 50 |
+
moduleUtilization: float = 1.0
|
| 51 |
+
clarificationAllowed: bool = False
|
| 52 |
+
clarificationNeeded: bool = False
|
| 53 |
+
clarificationQuality: float = 1.0
|
| 54 |
+
unexpectedModules: list[str] = field(default_factory=list)
|
| 55 |
+
failureTypes: list[str] = field(default_factory=list)
|
| 56 |
+
|
| 57 |
+
|
| 58 |
+
@dataclass
|
| 59 |
+
class ReplayResult:
|
| 60 |
+
"""Full replay result for a single curated case."""
|
| 61 |
+
|
| 62 |
+
case: PersonaEvalCase
|
| 63 |
+
answer: str
|
| 64 |
+
provider: str | None = None
|
| 65 |
+
model: str | None = None
|
| 66 |
+
meta: dict[str, Any] = field(default_factory=dict)
|
| 67 |
+
done: dict[str, Any] = field(default_factory=dict)
|
| 68 |
+
contexts: list[dict[str, Any]] = field(default_factory=list)
|
| 69 |
+
toolEvents: list[dict[str, Any]] = field(default_factory=list)
|
| 70 |
+
structural: StructuralEval = field(default_factory=StructuralEval)
|
| 71 |
+
score: ScoreCard = field(default_factory=ScoreCard)
|
| 72 |
+
errors: list[dict[str, Any]] = field(default_factory=list)
|
| 73 |
+
|
| 74 |
+
def toDict(self) -> dict[str, Any]:
|
| 75 |
+
"""Dataclass-friendly JSON view."""
|
| 76 |
+
payload = asdict(self)
|
| 77 |
+
payload["score"]["overall"] = self.score.overall
|
| 78 |
+
return payload
|
| 79 |
+
|
| 80 |
+
|
| 81 |
+
@dataclass(frozen=True)
|
| 82 |
+
class ReviewEntry:
|
| 83 |
+
"""Human-reviewed replay note for long-term stabilization."""
|
| 84 |
+
|
| 85 |
+
reviewedAt: str
|
| 86 |
+
caseId: str
|
| 87 |
+
persona: str
|
| 88 |
+
provider: str | None
|
| 89 |
+
model: str | None
|
| 90 |
+
effectiveness: str
|
| 91 |
+
improvementActions: list[str] = field(default_factory=list)
|
| 92 |
+
failureTypes: list[str] = field(default_factory=list)
|
| 93 |
+
notes: str = ""
|
| 94 |
+
|
| 95 |
+
|
| 96 |
+
def _load_json(path: Path) -> dict[str, Any]:
|
| 97 |
+
if not path.exists():
|
| 98 |
+
return {"version": "missing", "cases": []}
|
| 99 |
+
with open(path, encoding="utf-8") as handle:
|
| 100 |
+
return json.load(handle)
|
| 101 |
+
|
| 102 |
+
|
| 103 |
+
def loadPersonaQuestionSet() -> dict[str, Any]:
|
| 104 |
+
"""Load persona question set manifest."""
|
| 105 |
+
return _load_json(_PERSONA_CASES_PATH)
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def loadPersonaCases(*, persona: str | None = None, severity: str | None = None) -> list[PersonaEvalCase]:
|
| 109 |
+
"""Load curated persona cases with optional filters."""
|
| 110 |
+
raw = loadPersonaQuestionSet()
|
| 111 |
+
cases: list[PersonaEvalCase] = []
|
| 112 |
+
for item in raw.get("cases", []):
|
| 113 |
+
if persona and item.get("persona") != persona:
|
| 114 |
+
continue
|
| 115 |
+
if severity and item.get("severity") != severity:
|
| 116 |
+
continue
|
| 117 |
+
cases.append(
|
| 118 |
+
PersonaEvalCase(
|
| 119 |
+
id=item["id"],
|
| 120 |
+
persona=item["persona"],
|
| 121 |
+
personaLabel=item.get("personaLabel", item["persona"]),
|
| 122 |
+
stockCode=item.get("stockCode"),
|
| 123 |
+
question=item["question"],
|
| 124 |
+
userIntent=item.get("userIntent", ""),
|
| 125 |
+
expectedAnswerShape=list(item.get("expectedAnswerShape", [])),
|
| 126 |
+
expectedEvidenceKinds=list(item.get("expectedEvidenceKinds", [])),
|
| 127 |
+
expectedUserFacingTerms=list(item.get("expectedUserFacingTerms", [])),
|
| 128 |
+
forbiddenUiTerms=list(item.get("forbiddenUiTerms", [])),
|
| 129 |
+
expectedRoute=item.get("expectedRoute"),
|
| 130 |
+
expectedModules=list(item.get("expectedModules", [])),
|
| 131 |
+
allowedClarification=bool(item.get("allowedClarification", False)),
|
| 132 |
+
mustNotSay=list(item.get("mustNotSay", [])),
|
| 133 |
+
mustInclude=list(item.get("mustInclude", [])),
|
| 134 |
+
expectedFollowups=list(item.get("expectedFollowups", [])),
|
| 135 |
+
groundTruthFacts=list(item.get("groundTruthFacts", [])),
|
| 136 |
+
severity=item.get("severity", "medium"),
|
| 137 |
+
)
|
| 138 |
+
)
|
| 139 |
+
return cases
|
| 140 |
+
|
| 141 |
+
|
| 142 |
+
def _resolve_company(stockCode: str | None) -> Any | None:
|
| 143 |
+
if not stockCode:
|
| 144 |
+
return None
|
| 145 |
+
from dartlab import Company
|
| 146 |
+
|
| 147 |
+
return Company(stockCode)
|
| 148 |
+
|
| 149 |
+
|
| 150 |
+
def _collect_replay_data(
|
| 151 |
+
events: list[AnalysisEvent],
|
| 152 |
+
) -> tuple[dict[str, Any], dict[str, Any], list[dict[str, Any]], list[dict[str, Any]], str, list[dict[str, Any]]]:
|
| 153 |
+
meta: dict[str, Any] = {}
|
| 154 |
+
done: dict[str, Any] = {}
|
| 155 |
+
contexts: list[dict[str, Any]] = []
|
| 156 |
+
toolEvents: list[dict[str, Any]] = []
|
| 157 |
+
errors: list[dict[str, Any]] = []
|
| 158 |
+
chunks: list[str] = []
|
| 159 |
+
|
| 160 |
+
for event in events:
|
| 161 |
+
data = event.data or {}
|
| 162 |
+
if event.kind == "meta":
|
| 163 |
+
meta.update(data)
|
| 164 |
+
elif event.kind == "context":
|
| 165 |
+
contexts.append(data)
|
| 166 |
+
elif event.kind == "tool_call":
|
| 167 |
+
toolEvents.append({"type": "call"} | data)
|
| 168 |
+
elif event.kind == "tool_result":
|
| 169 |
+
toolEvents.append({"type": "result"} | data)
|
| 170 |
+
elif event.kind == "chunk":
|
| 171 |
+
chunks.append(data.get("text", ""))
|
| 172 |
+
elif event.kind == "done":
|
| 173 |
+
done = data
|
| 174 |
+
elif event.kind == "error":
|
| 175 |
+
errors.append(data)
|
| 176 |
+
|
| 177 |
+
return meta, done, contexts, toolEvents, "".join(chunks), errors
|
| 178 |
+
|
| 179 |
+
|
| 180 |
+
def evaluateReplay(
|
| 181 |
+
case: PersonaEvalCase, events: list[AnalysisEvent], *, provider: str | None = None, model: str | None = None
|
| 182 |
+
) -> ReplayResult:
|
| 183 |
+
"""Evaluate already-collected analysis events."""
|
| 184 |
+
meta, done, contexts, toolEvents, answer, errors = _collect_replay_data(events)
|
| 185 |
+
includedModules = list(done.get("includedModules") or meta.get("includedModules") or [])
|
| 186 |
+
actualRoute = done.get("route")
|
| 187 |
+
clarificationNeeded = bool(done.get("clarificationNeeded"))
|
| 188 |
+
moduleUtilization = score_module_utilization(includedModules, case.expectedModules)
|
| 189 |
+
routeMatch = 1.0 if not case.expectedRoute or case.expectedRoute == actualRoute else 0.0
|
| 190 |
+
clarificationQuality = 1.0
|
| 191 |
+
if clarificationNeeded and not case.allowedClarification:
|
| 192 |
+
clarificationQuality = 0.0
|
| 193 |
+
|
| 194 |
+
structuralFailures: list[str] = []
|
| 195 |
+
if routeMatch == 0.0:
|
| 196 |
+
structuralFailures.append("routing_failure")
|
| 197 |
+
if moduleUtilization < 1.0:
|
| 198 |
+
structuralFailures.append("retrieval_failure")
|
| 199 |
+
if clarificationQuality == 0.0:
|
| 200 |
+
structuralFailures.append("clarification_failure")
|
| 201 |
+
if errors:
|
| 202 |
+
structuralFailures.append("runtime_error")
|
| 203 |
+
|
| 204 |
+
score = auto_score(
|
| 205 |
+
answer,
|
| 206 |
+
expected_facts=case.groundTruthFacts,
|
| 207 |
+
expected_topics=case.expectedUserFacingTerms,
|
| 208 |
+
included_modules=includedModules,
|
| 209 |
+
expected_modules=case.expectedModules,
|
| 210 |
+
must_not_say=case.mustNotSay,
|
| 211 |
+
must_include=case.mustInclude,
|
| 212 |
+
forbidden_terms=case.forbiddenUiTerms,
|
| 213 |
+
clarification_allowed=case.allowedClarification,
|
| 214 |
+
expected_followups=case.expectedFollowups,
|
| 215 |
+
expected_route=case.expectedRoute,
|
| 216 |
+
actual_route=actualRoute,
|
| 217 |
+
)
|
| 218 |
+
failureTypes = sorted(set(structuralFailures + score.failure_types))
|
| 219 |
+
score.failure_types = failureTypes
|
| 220 |
+
|
| 221 |
+
structural = StructuralEval(
|
| 222 |
+
expectedRoute=case.expectedRoute,
|
| 223 |
+
actualRoute=actualRoute,
|
| 224 |
+
routeMatch=routeMatch,
|
| 225 |
+
moduleUtilization=moduleUtilization,
|
| 226 |
+
clarificationAllowed=case.allowedClarification,
|
| 227 |
+
clarificationNeeded=clarificationNeeded,
|
| 228 |
+
clarificationQuality=clarificationQuality,
|
| 229 |
+
unexpectedModules=sorted(set(includedModules) - set(case.expectedModules)),
|
| 230 |
+
failureTypes=failureTypes,
|
| 231 |
+
)
|
| 232 |
+
|
| 233 |
+
return ReplayResult(
|
| 234 |
+
case=case,
|
| 235 |
+
answer=answer,
|
| 236 |
+
provider=provider,
|
| 237 |
+
model=model,
|
| 238 |
+
meta=meta,
|
| 239 |
+
done=done,
|
| 240 |
+
contexts=contexts,
|
| 241 |
+
toolEvents=toolEvents,
|
| 242 |
+
structural=structural,
|
| 243 |
+
score=score,
|
| 244 |
+
errors=errors,
|
| 245 |
+
)
|
| 246 |
+
|
| 247 |
+
|
| 248 |
+
def replayCase(
|
| 249 |
+
case: PersonaEvalCase,
|
| 250 |
+
*,
|
| 251 |
+
provider: str | None = None,
|
| 252 |
+
model: str | None = None,
|
| 253 |
+
reportMode: bool = False,
|
| 254 |
+
useTools: bool = False,
|
| 255 |
+
analyzeFn: Callable[..., Any] | None = None,
|
| 256 |
+
company: Any | None = None,
|
| 257 |
+
**kwargs: Any,
|
| 258 |
+
) -> ReplayResult:
|
| 259 |
+
"""Run a real ask replay for one curated case."""
|
| 260 |
+
if analyzeFn is None:
|
| 261 |
+
from dartlab.ai.runtime.core import analyze as analyzeFn
|
| 262 |
+
|
| 263 |
+
effectiveCompany = company if company is not None else _resolve_company(case.stockCode)
|
| 264 |
+
events = list(
|
| 265 |
+
analyzeFn(
|
| 266 |
+
effectiveCompany,
|
| 267 |
+
case.question,
|
| 268 |
+
provider=provider,
|
| 269 |
+
model=model,
|
| 270 |
+
report_mode=reportMode,
|
| 271 |
+
use_tools=useTools,
|
| 272 |
+
**kwargs,
|
| 273 |
+
)
|
| 274 |
+
)
|
| 275 |
+
return evaluateReplay(case, events, provider=provider, model=model)
|
| 276 |
+
|
| 277 |
+
|
| 278 |
+
def replaySuite(
|
| 279 |
+
cases: list[PersonaEvalCase],
|
| 280 |
+
*,
|
| 281 |
+
provider: str | None = None,
|
| 282 |
+
model: str | None = None,
|
| 283 |
+
reportMode: bool = False,
|
| 284 |
+
useTools: bool = False,
|
| 285 |
+
analyzeFn: Callable[..., Any] | None = None,
|
| 286 |
+
**kwargs: Any,
|
| 287 |
+
) -> list[ReplayResult]:
|
| 288 |
+
"""Replay a full curated suite with Company caching."""
|
| 289 |
+
import gc
|
| 290 |
+
|
| 291 |
+
companyCache: dict[str, Any] = {}
|
| 292 |
+
results: list[ReplayResult] = []
|
| 293 |
+
|
| 294 |
+
for case in cases:
|
| 295 |
+
sc = case.stockCode
|
| 296 |
+
company = None
|
| 297 |
+
if sc:
|
| 298 |
+
if sc not in companyCache:
|
| 299 |
+
# ๋ฉ๋ชจ๋ฆฌ ์์ : ์ต๋ 3๊ฐ Company ์ ์ง
|
| 300 |
+
if len(companyCache) >= 3:
|
| 301 |
+
oldest = next(iter(companyCache))
|
| 302 |
+
del companyCache[oldest]
|
| 303 |
+
gc.collect()
|
| 304 |
+
companyCache[sc] = _resolve_company(sc)
|
| 305 |
+
company = companyCache[sc]
|
| 306 |
+
|
| 307 |
+
results.append(
|
| 308 |
+
replayCase(
|
| 309 |
+
case,
|
| 310 |
+
provider=provider,
|
| 311 |
+
model=model,
|
| 312 |
+
reportMode=reportMode,
|
| 313 |
+
useTools=useTools,
|
| 314 |
+
analyzeFn=analyzeFn,
|
| 315 |
+
company=company,
|
| 316 |
+
**kwargs,
|
| 317 |
+
)
|
| 318 |
+
)
|
| 319 |
+
|
| 320 |
+
return results
|
| 321 |
+
|
| 322 |
+
|
| 323 |
+
def summarizeReplayResults(results: list[ReplayResult]) -> dict[str, Any]:
|
| 324 |
+
"""Aggregate replay results for regression dashboards or logs."""
|
| 325 |
+
if not results:
|
| 326 |
+
return {
|
| 327 |
+
"cases": 0,
|
| 328 |
+
"personas": 0,
|
| 329 |
+
"avgOverall": 0.0,
|
| 330 |
+
"avgRouteMatch": 0.0,
|
| 331 |
+
"avgModuleUtilization": 0.0,
|
| 332 |
+
"falseUnavailableCases": 0,
|
| 333 |
+
"failureCounts": {},
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
failureCounts: dict[str, int] = {}
|
| 337 |
+
for result in results:
|
| 338 |
+
for failure in result.score.failure_types:
|
| 339 |
+
failureCounts[failure] = failureCounts.get(failure, 0) + 1
|
| 340 |
+
|
| 341 |
+
return {
|
| 342 |
+
"cases": len(results),
|
| 343 |
+
"personas": len({result.case.persona for result in results}),
|
| 344 |
+
"avgOverall": round(mean(result.score.overall for result in results), 3),
|
| 345 |
+
"avgRouteMatch": round(mean(result.structural.routeMatch for result in results), 3),
|
| 346 |
+
"avgModuleUtilization": round(mean(result.structural.moduleUtilization for result in results), 3),
|
| 347 |
+
"falseUnavailableCases": sum(1 for result in results if result.score.false_unavailable == 0.0),
|
| 348 |
+
"failureCounts": dict(sorted(failureCounts.items())),
|
| 349 |
+
}
|
| 350 |
+
|
| 351 |
+
|
| 352 |
+
def _reviewLogPath(persona: str) -> Path:
|
| 353 |
+
return _REVIEW_LOG_DIR / f"{persona}.jsonl"
|
| 354 |
+
|
| 355 |
+
|
| 356 |
+
def loadReviewLog(*, persona: str | None = None, caseId: str | None = None) -> list[ReviewEntry]:
|
| 357 |
+
"""Load human review history for persona replays."""
|
| 358 |
+
paths: list[Path]
|
| 359 |
+
if persona:
|
| 360 |
+
path = _reviewLogPath(persona)
|
| 361 |
+
paths = [path] if path.exists() else []
|
| 362 |
+
else:
|
| 363 |
+
if not _REVIEW_LOG_DIR.exists():
|
| 364 |
+
return []
|
| 365 |
+
paths = sorted(_REVIEW_LOG_DIR.glob("*.jsonl"))
|
| 366 |
+
|
| 367 |
+
entries: list[ReviewEntry] = []
|
| 368 |
+
for path in paths:
|
| 369 |
+
with open(path, encoding="utf-8") as handle:
|
| 370 |
+
for line in handle:
|
| 371 |
+
stripped = line.strip()
|
| 372 |
+
if not stripped:
|
| 373 |
+
continue
|
| 374 |
+
item = json.loads(stripped)
|
| 375 |
+
if caseId and item.get("caseId") != caseId:
|
| 376 |
+
continue
|
| 377 |
+
entries.append(
|
| 378 |
+
ReviewEntry(
|
| 379 |
+
reviewedAt=item["reviewedAt"],
|
| 380 |
+
caseId=item["caseId"],
|
| 381 |
+
persona=item["persona"],
|
| 382 |
+
provider=item.get("provider"),
|
| 383 |
+
model=item.get("model"),
|
| 384 |
+
effectiveness=item["effectiveness"],
|
| 385 |
+
improvementActions=list(item.get("improvementActions", [])),
|
| 386 |
+
failureTypes=list(item.get("failureTypes", [])),
|
| 387 |
+
notes=item.get("notes", ""),
|
| 388 |
+
)
|
| 389 |
+
)
|
| 390 |
+
return sorted(entries, key=lambda item: item.reviewedAt)
|
| 391 |
+
|
| 392 |
+
|
| 393 |
+
def appendReviewEntry(
|
| 394 |
+
result: ReplayResult,
|
| 395 |
+
*,
|
| 396 |
+
effectiveness: str,
|
| 397 |
+
improvementActions: list[str] | None = None,
|
| 398 |
+
notes: str = "",
|
| 399 |
+
reviewedAt: str | None = None,
|
| 400 |
+
) -> ReviewEntry:
|
| 401 |
+
"""Append a reviewed replay note to the long-term stabilization log."""
|
| 402 |
+
entry = ReviewEntry(
|
| 403 |
+
reviewedAt=reviewedAt or datetime.now().isoformat(timespec="seconds"),
|
| 404 |
+
caseId=result.case.id,
|
| 405 |
+
persona=result.case.persona,
|
| 406 |
+
provider=result.provider,
|
| 407 |
+
model=result.model,
|
| 408 |
+
effectiveness=effectiveness,
|
| 409 |
+
improvementActions=list(improvementActions or []),
|
| 410 |
+
failureTypes=list(result.score.failure_types),
|
| 411 |
+
notes=notes,
|
| 412 |
+
)
|
| 413 |
+
_REVIEW_LOG_DIR.mkdir(parents=True, exist_ok=True)
|
| 414 |
+
with open(_reviewLogPath(result.case.persona), "a", encoding="utf-8") as handle:
|
| 415 |
+
handle.write(json.dumps(asdict(entry), ensure_ascii=False) + "\n")
|
| 416 |
+
return entry
|
src/dartlab/ai/eval/reviewLog/accountant.jsonl
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
{"reviewedAt": "2026-03-23T22:41:46", "caseId": "accountant.costByNature.summary", "persona": "accountant", "provider": "oauth-codex", "model": null, "effectiveness": "effective", "improvementActions": ["?????? ?? ??? ?? ??? ?? ??? ???? 1???? ? ?? ??"], "failureTypes": [], "notes": "??? ?? ?? ???? ??? ???? false unavailable ?? ??."}
|
src/dartlab/ai/eval/reviewLog/analyst.jsonl
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"reviewedAt": "2026-03-23T22:56:55", "caseId": "analyst.margin.drivers", "persona": "analyst", "provider": "oauth-codex", "model": null, "effectiveness": "ineffective", "improvementActions": ["????? + ?? ?? + ?? ?? ??? ambiguity ?? ?? hybrid ???? ??", "margin driver ??? IS + costByNature + businessOverview/productService? ??? ???? ?? ??", "??? ?? ??? ?? ??? ?? ??? clarification_allowed? ???? ?? ????? ?? ??"], "failureTypes": ["clarification_failure", "retrieval_failure", "routing_failure", "ui_wording_failure"], "notes": "??? ?? ??? ?? ??? analyst ?? ????? ???."}
|
| 2 |
+
{"reviewedAt": "2026-03-23T23:51:30", "caseId": "analyst.margin.drivers", "persona": "analyst", "provider": "oauth-codex", "model": null, "effectiveness": "effective", "improvementActions": [], "failureTypes": [], "notes": "?? hybrid? clarification ??? ?? ?? ??? costByNature?? ??? ????."}
|
src/dartlab/ai/eval/reviewLog/investor.jsonl
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"reviewedAt": "2026-03-23T22:42:26", "caseId": "investor.dividend.sustainability", "persona": "investor", "provider": "oauth-codex", "model": null, "effectiveness": "partial", "improvementActions": ["??? ??? IS/CF/BS/TTM ?? ?? ??? ?????/?????/?????/?? 4?? ???? ??", "?? ?? ??? ??? ?? 2?? ? ???? ?? ???? ?? ??? ??"], "failureTypes": ["ui_wording_failure"], "notes": "?? ?? ??? ??? ???? ui_wording_failure? ??."}
|
| 2 |
+
{"reviewedAt": "2026-03-23T22:56:52", "caseId": "investor.distress.sdi", "persona": "investor", "provider": "oauth-codex", "model": null, "effectiveness": "partial", "improvementActions": ["?? ?? ??? finance route? ??? hybrid? ???? ?? ?", "??? ?? IS/CF/BS/TTM/ratios ??? ???? ??? ??"], "failureTypes": ["routing_failure", "ui_wording_failure"], "notes": "??? ????? route? finance? ???? ??? ?? ??? ??."}
|
| 3 |
+
{"reviewedAt": "2026-03-23T23:50:31", "caseId": "investor.distress.sdi", "persona": "investor", "provider": "oauth-codex", "model": null, "effectiveness": "effective", "improvementActions": [], "failureTypes": [], "notes": "finance route ?? ? ?? ?? ??? ?????????? ?? ???? ????."}
|
| 4 |
+
{"reviewedAt": "2026-03-23T23:52:44", "caseId": "investor.dividend.sustainability", "persona": "investor", "provider": "oauth-codex", "model": null, "effectiveness": "effective", "improvementActions": [], "failureTypes": [], "notes": "?? ?? ???? ?? ?? ??? ?? ??? ?? ?? ???? ????."}
|
src/dartlab/ai/eval/reviewLog/research_gather.jsonl
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{"reviewedAt": "2026-03-23T22:56:00", "caseId": "researchGather.structure.recentDisclosures", "persona": "research_gather", "provider": "oauth-codex", "model": null, "effectiveness": "partial", "improvementActions": ["?? ?? ?? ???? ??? disclosureChanges/subsequentEvents? ?? ?? businessOverview/productService? ?? ?? ??", "? ???? topic/period/source ?? ?? ???? ?? ??/?? ??/??? ??"], "failureTypes": ["retrieval_failure", "ui_wording_failure"], "notes": "?? ?? ??? ????? ??? ???? ?? ?? ?? retrieval_failure? ??."}
|
| 2 |
+
{"reviewedAt": "2026-03-23T23:52:01", "caseId": "researchGather.structure.recentDisclosures", "persona": "research_gather", "provider": "oauth-codex", "model": null, "effectiveness": "effective", "improvementActions": [], "failureTypes": [], "notes": "sections ?? ?? ?? ? disclosureChanges? businessOverview? ?? ???."}
|
src/dartlab/ai/eval/scorer.py
ADDED
|
@@ -0,0 +1,466 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
"""ํ์ฅ ๋ต๋ณ ์ฑ์ ๊ธฐ.
|
| 2 |
+
|
| 3 |
+
๊ธฐ๋ณธ ์ฐจ์:
|
| 4 |
+
1. factual_accuracy โ ์์น ์ ํ๋ (์ค์ finance ๊ฐ ๋๋น)
|
| 5 |
+
2. completeness โ ๊ธฐ๋ ํญ๋ชฉ ํฌํจ๋ฅ
|
| 6 |
+
3. source_citation โ ์ถ์ฒ(ํ
์ด๋ธ๋ช
, ์ฐ๋) ์ธ์ฉ ๋น์จ
|
| 7 |
+
4. hallucination โ ํ์ ์์น ํฌํจ ์ฌ๋ถ
|
| 8 |
+
5. actionability โ ๊ฒฐ๋ก /ํ๋จ/์ ์ ํฌํจ ์ฌ๋ถ
|
| 9 |
+
6. ratio_utilization โ ์ ๊ณต๋ ๋ณตํฉ ์งํ(DuPont, Piotroski F, Altman Z ๋ฑ) ํ์ฉ๋
|
| 10 |
+
|
| 11 |
+
ํ์ฅ ์ฐจ์:
|
| 12 |
+
7. module_utilization โ ๊ธฐ๋ ๋ชจ๋ ํ์์จ
|
| 13 |
+
8. false_unavailable โ ๊ฑฐ์ง unavailable ํ์ง
|
| 14 |
+
9. grounding_quality โ ๊ธฐ๋ ๊ทผ๊ฑฐ ํํ ์ฌ์ฉ ์ฌ๋ถ
|
| 15 |
+
10. clarification_quality โ clarification ์ ์ฑ
์ค์
|
| 16 |
+
11. ui_language_compliance โ ๋ด๋ถ ๋ช
์นญ ๋
ธ์ถ ์ต์
|
| 17 |
+
12. followup_usefulness โ ํ์ ์ง๋ฌธ/ํ๋ ์ ์ ์ ์ฉ์ฑ
|
| 18 |
+
|
| 19 |
+
๋ฐ์ดํฐ ์ฌ๋ ์ฐจ์:
|
| 20 |
+
13. context_depth โ context ๋ ์ด์ด๊ฐ answer์ ์ค์ ๋ฐ์๋ ๋น์จ
|
| 21 |
+
14. source_citation_precision โ (์ฐ๋+์ถ์ฒ+์์น) triple ์ ๋ฐ๋
|
| 22 |
+
15. data_coverage โ ๊ธฐ๋ ๋ชจ๋ ๋๋น ์ค์ ๋ฐ์ดํฐ ํ์ฉ ์ฆ๊ฑฐ
|
| 23 |
+
"""
|
| 24 |
+
|
| 25 |
+
from __future__ import annotations
|
| 26 |
+
|
| 27 |
+
import re
|
| 28 |
+
from dataclasses import dataclass, field
|
| 29 |
+
|
| 30 |
+
|
| 31 |
+
@dataclass
|
| 32 |
+
class ScoreCard:
|
| 33 |
+
"""ํ์ฅ ์ฑ์ ๊ฒฐ๊ณผ."""
|
| 34 |
+
|
| 35 |
+
factual_accuracy: float = 0.0 # 0~1
|
| 36 |
+
completeness: float = 0.0 # 0~1
|
| 37 |
+
source_citation: float = 0.0 # 0~1
|
| 38 |
+
hallucination: float = 1.0 # 1=์์, 0=์์
|
| 39 |
+
actionability: float = 0.0 # 0~1
|
| 40 |
+
ratio_utilization: float = 0.0 # 0~1
|
| 41 |
+
module_utilization: float = 0.0 # 0~1
|
| 42 |
+
false_unavailable: float = 1.0 # 1=์์, 0=๊ฑฐ์ง unavailable
|
| 43 |
+
grounding_quality: float = 0.0 # 0~1
|
| 44 |
+
clarification_quality: float = 1.0 # 0~1
|
| 45 |
+
ui_language_compliance: float = 1.0 # 0~1
|
| 46 |
+
followup_usefulness: float = 0.0 # 0~1
|
| 47 |
+
context_depth: float = 0.0 # 0~1
|
| 48 |
+
source_citation_precision: float = 0.0 # 0~1
|
| 49 |
+
data_coverage: float = 0.0 # 0~1
|
| 50 |
+
failure_types: list[str] = field(default_factory=list)
|
| 51 |
+
details: dict = field(default_factory=dict)
|
| 52 |
+
|
| 53 |
+
@property
|
| 54 |
+
def overall(self) -> float:
|
| 55 |
+
"""ํ์ฅ ์ฑ์ ๊ฒฐ๊ณผ ๊ฐ์ค ํ๊ท ."""
|
| 56 |
+
return (
|
| 57 |
+
self.factual_accuracy * 1.5
|
| 58 |
+
+ self.completeness * 1.0
|
| 59 |
+
+ self.source_citation * 0.5
|
| 60 |
+
+ self.hallucination * 1.0
|
| 61 |
+
+ self.actionability * 1.0
|
| 62 |
+
+ self.ratio_utilization * 0.5
|
| 63 |
+
+ self.module_utilization * 1.0
|
| 64 |
+
+ self.false_unavailable * 1.0
|
| 65 |
+
+ self.grounding_quality * 1.0
|
| 66 |
+
+ self.clarification_quality * 0.5
|
| 67 |
+
+ self.ui_language_compliance * 0.5
|
| 68 |
+
+ self.followup_usefulness * 0.5
|
| 69 |
+
+ self.context_depth * 1.0
|
| 70 |
+
+ self.source_citation_precision * 0.5
|
| 71 |
+
+ self.data_coverage * 1.0
|
| 72 |
+
)
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
def score_factual_accuracy(answer: str, expected_facts: list[dict]) -> float:
|
| 76 |
+
"""๋ต๋ณ ๋ด ์์น๊ฐ ๊ธฐ๋๊ฐ๊ณผ ์ผ์นํ๋ ๋น์จ.
|
| 77 |
+
|
| 78 |
+
Args:
|
| 79 |
+
expected_facts: [{"metric": "sales", "value": 1234567, "unit": "millions"}]
|
| 80 |
+
"""
|
| 81 |
+
numeric_facts = [f for f in expected_facts if isinstance(f.get("value"), (int, float))]
|
| 82 |
+
if not numeric_facts:
|
| 83 |
+
return 1.0
|
| 84 |
+
|
| 85 |
+
matched = 0
|
| 86 |
+
for fact in numeric_facts:
|
| 87 |
+
val = fact["value"]
|
| 88 |
+
# ๋ต๋ณ์์ ์์น ์ถ์ถ ํ 15% ์ด๋ด ๋งค์นญ
|
| 89 |
+
numbers = re.findall(r"[\d,]+(?:\.\d+)?", answer)
|
| 90 |
+
for num_str in numbers:
|
| 91 |
+
try:
|
| 92 |
+
parsed = float(num_str.replace(",", ""))
|
| 93 |
+
except ValueError:
|
| 94 |
+
continue
|
| 95 |
+
if val != 0 and abs(parsed - val) / abs(val) < 0.15:
|
| 96 |
+
matched += 1
|
| 97 |
+
break
|
| 98 |
+
# ๋จ์ ๋ณํ (์กฐ/์ต)
|
| 99 |
+
for divisor in [1e12, 1e8, 1e6, 1e4]:
|
| 100 |
+
converted = val / divisor
|
| 101 |
+
if converted != 0 and abs(parsed - converted) / abs(converted) < 0.15:
|
| 102 |
+
matched += 1
|
| 103 |
+
break
|
| 104 |
+
|
| 105 |
+
return matched / len(numeric_facts)
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def score_completeness(answer: str, expected_topics: list[str]) -> float:
|
| 109 |
+
"""๊ธฐ๋ ํญ๋ชฉ์ด ๋ต๋ณ์ ํฌํจ๋ ๋น์จ."""
|
| 110 |
+
if not expected_topics:
|
| 111 |
+
return 1.0
|
| 112 |
+
found = sum(1 for t in expected_topics if t.lower() in answer.lower())
|
| 113 |
+
return found / len(expected_topics)
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def score_source_citation(answer: str) -> float:
|
| 117 |
+
"""์ถ์ฒ ์ธ์ฉ ๋น์จ (์ฐ๋, ํ
์ด๋ธ๋ช
๋ฑ)."""
|
| 118 |
+
year_pattern = r"20[12]\d๋
"
|
| 119 |
+
source_pattern = r"(?:BS|IS|CF|์์ต|์ฌ๋ฌด|๋์ฐจ|ํ๊ธ)"
|
| 120 |
+
year_count = len(re.findall(year_pattern, answer))
|
| 121 |
+
source_count = len(re.findall(source_pattern, answer))
|
| 122 |
+
# ์ต์ 1๊ฐ ์ฐ๋ + 1๊ฐ ์ถ์ฒ๋ฉด 1.0
|
| 123 |
+
year_score = min(year_count / 2, 1.0)
|
| 124 |
+
source_score = min(source_count / 1, 1.0)
|
| 125 |
+
return (year_score + source_score) / 2
|
| 126 |
+
|
| 127 |
+
|
| 128 |
+
def score_hallucination(answer: str, known_facts: list[dict]) -> float:
|
| 129 |
+
"""ํ์ ์์น ๋น์จ. 1.0=ํ์ ์์."""
|
| 130 |
+
numeric_facts = [f for f in known_facts if isinstance(f.get("value"), (int, float))]
|
| 131 |
+
if not numeric_facts:
|
| 132 |
+
return 1.0
|
| 133 |
+
|
| 134 |
+
# ๋ต๋ณ์์ ์ถ์ถํ ์์น ์ค ์๋ ค์ง ์ฌ์ค๊ณผ 50% ์ด์ ์ฐจ์ด๋๋ฉด ํ์
|
| 135 |
+
numbers = re.findall(r"[\d,]+(?:\.\d+)?", answer)
|
| 136 |
+
hallucination_count = 0
|
| 137 |
+
checked = 0
|
| 138 |
+
for num_str in numbers:
|
| 139 |
+
try:
|
| 140 |
+
parsed = float(num_str.replace(",", ""))
|
| 141 |
+
except ValueError:
|
| 142 |
+
continue
|
| 143 |
+
if parsed < 10: # ๋๋ฌด ์์ ์์น๋ ๋ฌด์ (๋น์จ ๋ฑ)
|
| 144 |
+
continue
|
| 145 |
+
checked += 1
|
| 146 |
+
# ์๋ ค์ง ์ฌ์ค๊ณผ ๋น๊ต
|
| 147 |
+
is_known = False
|
| 148 |
+
for fact in numeric_facts:
|
| 149 |
+
val = fact["value"]
|
| 150 |
+
for divisor in [1, 1e12, 1e8, 1e6, 1e4]:
|
| 151 |
+
converted = val / divisor
|
| 152 |
+
if converted != 0 and abs(parsed - converted) / abs(converted) < 0.5:
|
| 153 |
+
is_known = True
|
| 154 |
+
break
|
| 155 |
+
if is_known:
|
| 156 |
+
break
|
| 157 |
+
if not is_known and checked <= 10: # ์ฒ์ 10๊ฐ๋ง ๊ฒ์ฌ
|
| 158 |
+
hallucination_count += 1
|
| 159 |
+
|
| 160 |
+
if checked == 0:
|
| 161 |
+
return 1.0
|
| 162 |
+
return max(0.0, 1.0 - hallucination_count / checked)
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
def score_actionability(answer: str) -> float:
|
| 166 |
+
"""๊ฒฐ๋ก /ํ๋จ/์ ์์ด ํฌํจ๋์ด ์๋์ง."""
|
| 167 |
+
action_keywords = [
|
| 168 |
+
"๊ฒฐ๋ก ",
|
| 169 |
+
"ํ๋จ",
|
| 170 |
+
"์ข
ํฉ",
|
| 171 |
+
"ํ๊ฐ",
|
| 172 |
+
"์๊ฒฌ",
|
| 173 |
+
"๊ธ์ ",
|
| 174 |
+
"๋ถ์ ",
|
| 175 |
+
"์ํธ",
|
| 176 |
+
"์ฐ๋ ค",
|
| 177 |
+
"์ฃผ์",
|
| 178 |
+
"๊ฐ์ ",
|
| 179 |
+
"์
ํ",
|
| 180 |
+
"์์ ",
|
| 181 |
+
"์ํ",
|
| 182 |
+
"์ถ์ฒ",
|
| 183 |
+
"์ ์",
|
| 184 |
+
"๊ณ ๋ ค",
|
| 185 |
+
]
|
| 186 |
+
found = sum(1 for kw in action_keywords if kw in answer)
|
| 187 |
+
return min(found / 3, 1.0)
|
| 188 |
+
|
| 189 |
+
|
| 190 |
+
_COMPOSITE_INDICATORS = [
|
| 191 |
+
"DuPont",
|
| 192 |
+
"๋ํ",
|
| 193 |
+
"Piotroski",
|
| 194 |
+
"ํผ์คํธ๋ก์คํค",
|
| 195 |
+
"F-Score",
|
| 196 |
+
"Altman",
|
| 197 |
+
"Z-Score",
|
| 198 |
+
"ROIC",
|
| 199 |
+
"CCC",
|
| 200 |
+
"ํ๊ธ์ ํ์ฃผ๊ธฐ",
|
| 201 |
+
"์ด์ต์ ์ง",
|
| 202 |
+
"์์
CF/์์ด์ต",
|
| 203 |
+
]
|
| 204 |
+
|
| 205 |
+
|
| 206 |
+
def score_ratio_utilization(answer: str, provided_indicators: list[str] | None = None) -> float:
|
| 207 |
+
"""์ ๊ณต๋ ๋ณตํฉ ์งํ๊ฐ ๋ต๋ณ์์ ์ค์ ํ์ฉ๋์๋์ง ์ธก์ .
|
| 208 |
+
|
| 209 |
+
Args:
|
| 210 |
+
provided_indicators: context์ ์ ๊ณต๋ ๋ณตํฉ ์งํ ์ด๋ฆ ๋ฆฌ์คํธ.
|
| 211 |
+
None์ด๋ฉด _COMPOSITE_INDICATORS ์ ์ฒด์์ ํ์.
|
| 212 |
+
"""
|
| 213 |
+
indicators = provided_indicators or _COMPOSITE_INDICATORS
|
| 214 |
+
if not indicators:
|
| 215 |
+
return 1.0
|
| 216 |
+
|
| 217 |
+
found = sum(1 for ind in indicators if ind.lower() in answer.lower())
|
| 218 |
+
# ์ ๊ณต๋ ์งํ ์ค ์ต์ 30%๋ฅผ ํ์ฉํ์ผ๋ฉด ๋ง์
|
| 219 |
+
return min(found / max(len(indicators) * 0.3, 1), 1.0)
|
| 220 |
+
|
| 221 |
+
|
| 222 |
+
def score_module_utilization(included_modules: list[str] | None, expected_modules: list[str] | None) -> float:
|
| 223 |
+
"""์์ ๋ชจ๋์ด ์ค์ replay์ ํฌํจ๋ ๋น์จ."""
|
| 224 |
+
expected = {str(module) for module in expected_modules or [] if module}
|
| 225 |
+
if not expected:
|
| 226 |
+
return 1.0
|
| 227 |
+
included = {str(module) for module in included_modules or [] if module}
|
| 228 |
+
if not included:
|
| 229 |
+
return 0.0
|
| 230 |
+
return len(expected & included) / len(expected)
|
| 231 |
+
|
| 232 |
+
|
| 233 |
+
def score_false_unavailable(answer: str, must_not_say: list[str] | None = None, *, enabled: bool = True) -> float:
|
| 234 |
+
"""ํฌํจ๋ ๋ฐ์ดํฐ๊ฐ ์๋๋ฐ๋ unavailable ๋ฅ ๋ฌธ๊ตฌ๋ฅผ ๋งํ๋์ง."""
|
| 235 |
+
if not enabled:
|
| 236 |
+
return 1.0
|
| 237 |
+
answer_lower = answer.lower()
|
| 238 |
+
forbidden = [phrase for phrase in must_not_say or [] if phrase]
|
| 239 |
+
if not forbidden:
|
| 240 |
+
forbidden = [
|
| 241 |
+
"๋ฐ์ดํฐ๊ฐ ์์ต๋๋ค",
|
| 242 |
+
"ํ์ธํ ์ ์์ต๋๋ค",
|
| 243 |
+
"๋ฏธ์ ๊ณต",
|
| 244 |
+
"์ ๊ณต๋์ง ์์ต๋๋ค",
|
| 245 |
+
"์ ๊ณต๋ ๋ฐ์ดํฐ์๋",
|
| 246 |
+
"cannot determine",
|
| 247 |
+
"not available",
|
| 248 |
+
]
|
| 249 |
+
return 0.0 if any(phrase.lower() in answer_lower for phrase in forbidden) else 1.0
|
| 250 |
+
|
| 251 |
+
|
| 252 |
+
def score_grounding_quality(
|
| 253 |
+
answer: str, must_include: list[str] | None = None, expected_topics: list[str] | None = None
|
| 254 |
+
) -> float:
|
| 255 |
+
"""๋ต๋ณ์ด ๊ธฐ๋ ๊ทผ๊ฑฐ ํํ์ ์ค์ ๋ก ์ฌ์ฉํ๋์ง."""
|
| 256 |
+
cues = [cue for cue in (must_include or []) if cue]
|
| 257 |
+
if not cues:
|
| 258 |
+
cues = [cue for cue in (expected_topics or []) if cue]
|
| 259 |
+
if not cues:
|
| 260 |
+
return 1.0
|
| 261 |
+
answer_lower = answer.lower()
|
| 262 |
+
matched = sum(1 for cue in cues if cue.lower() in answer_lower)
|
| 263 |
+
return matched / len(cues)
|
| 264 |
+
|
| 265 |
+
|
| 266 |
+
def score_clarification_quality(answer: str, clarification_allowed: bool | None) -> float:
|
| 267 |
+
"""ํ์ํ ๋๋ง ๊ฐ๊ฒฐํ๊ฒ clarification ํ๋์ง."""
|
| 268 |
+
if clarification_allowed is None:
|
| 269 |
+
return 1.0
|
| 270 |
+
clarification_markers = [
|
| 271 |
+
"๋ณด์ค ๊ฑด๊ฐ์",
|
| 272 |
+
"์ํ์๋ ๊ฑด๊ฐ์",
|
| 273 |
+
"๋ง์ํ์ ",
|
| 274 |
+
"์๋ฏธํ์ ",
|
| 275 |
+
"์ธ์ง ๋จผ์ ",
|
| 276 |
+
"๋ง๋์",
|
| 277 |
+
]
|
| 278 |
+
has_clarification = any(marker in answer for marker in clarification_markers) or answer.strip().endswith("?")
|
| 279 |
+
if clarification_allowed:
|
| 280 |
+
return 1.0 if has_clarification else 0.0
|
| 281 |
+
return 0.0 if has_clarification else 1.0
|
| 282 |
+
|
| 283 |
+
|
| 284 |
+
def score_ui_language_compliance(answer: str, forbidden_terms: list[str] | None = None) -> float:
|
| 285 |
+
"""UI/์ฌ์ฉ์์ฉ ๋ต๋ณ์์ ๋ด๋ถ ๋ช
์นญ์ ์ผ๋ง๋ ์ ์จ๊ฒผ๋์ง."""
|
| 286 |
+
terms = [term for term in forbidden_terms or [] if term]
|
| 287 |
+
if not terms:
|
| 288 |
+
return 1.0
|
| 289 |
+
answer_lower = answer.lower()
|
| 290 |
+
hits = sum(1 for term in terms if term.lower() in answer_lower)
|
| 291 |
+
return max(0.0, 1.0 - (hits / len(terms)))
|
| 292 |
+
|
| 293 |
+
|
| 294 |
+
def score_followup_usefulness(answer: str, expected_followups: list[str] | None = None) -> float:
|
| 295 |
+
"""ํ์ ์ง๋ฌธ/ํ๋ ์ ๋ ํ์ง."""
|
| 296 |
+
followups = [term for term in expected_followups or [] if term]
|
| 297 |
+
if not followups:
|
| 298 |
+
default_terms = ("์ถ๊ฐ", "๋ค์", "ํ์ธ", "๋ณด๋ฉด", "์ ๊ฒ", "์ง๋ฌธ")
|
| 299 |
+
found = sum(1 for term in default_terms if term in answer)
|
| 300 |
+
return min(found / 2, 1.0)
|
| 301 |
+
answer_lower = answer.lower()
|
| 302 |
+
matched = sum(1 for term in followups if term.lower() in answer_lower)
|
| 303 |
+
return matched / len(followups)
|
| 304 |
+
|
| 305 |
+
|
| 306 |
+
def score_context_depth(answer: str, contexts: list[dict] | None = None) -> float:
|
| 307 |
+
"""context ๋ ์ด์ด์์ ์ ๊ณต๋ ์ ๋ณด๊ฐ answer์ ๋ฐ์๋ ๋น์จ."""
|
| 308 |
+
if not contexts:
|
| 309 |
+
return 1.0
|
| 310 |
+
answer_lower = answer.lower()
|
| 311 |
+
matched = 0
|
| 312 |
+
for ctx in contexts:
|
| 313 |
+
# context์์ ํต์ฌ ํค์๋ ์ถ์ถ
|
| 314 |
+
content = str(ctx.get("content", ctx.get("text", "")))
|
| 315 |
+
if not content:
|
| 316 |
+
continue
|
| 317 |
+
# ์ซ์/ํต์ฌ ๋จ์ด 3๊ฐ ์ถ์ถํด์ answer์ ํฌํจ ์ฌ๋ถ ํ์ธ
|
| 318 |
+
keywords = re.findall(r"[\d,]+(?:\.\d+)?(?:์กฐ|์ต|๋ง)?|[๊ฐ-ํฃ]{2,6}", content[:500])
|
| 319 |
+
if not keywords:
|
| 320 |
+
continue
|
| 321 |
+
sample = keywords[:10]
|
| 322 |
+
hits = sum(1 for kw in sample if kw.lower() in answer_lower)
|
| 323 |
+
if hits >= max(len(sample) * 0.2, 1):
|
| 324 |
+
matched += 1
|
| 325 |
+
return matched / len(contexts) if contexts else 1.0
|
| 326 |
+
|
| 327 |
+
|
| 328 |
+
def score_source_citation_precision(answer: str) -> float:
|
| 329 |
+
"""(์ฐ๋ + ์ถ์ฒ + ์์น)๊ฐ ํจ๊ป ๋ํ๋๋ ์ ๋ฐ ์ธ์ฉ ์ธก์ ."""
|
| 330 |
+
# ์ฐ๋(2020~2029) ๊ทผ์ฒ 50์ ๋ด์ ์์น์ ์ถ์ฒ๋ช
์ด ํจ๊ป ์๋์ง
|
| 331 |
+
year_positions = [m.start() for m in re.finditer(r"20[2-9]\d", answer)]
|
| 332 |
+
if not year_positions:
|
| 333 |
+
return 0.0
|
| 334 |
+
source_patterns = re.compile(r"(?:BS|IS|CF|์์ต|์ฌ๋ฌด|๋์ฐจ|ํ๊ธ|์์ฐ|๋ถ์ฑ|๋งค์ถ|์์
์ด์ต|์๋ณธ)")
|
| 335 |
+
number_pattern = re.compile(r"[\d,]+(?:\.\d+)?(?:์กฐ|์ต|๋ง|%)?")
|
| 336 |
+
triples = 0
|
| 337 |
+
for pos in year_positions:
|
| 338 |
+
window = answer[max(0, pos - 30) : pos + 60]
|
| 339 |
+
has_source = bool(source_patterns.search(window))
|
| 340 |
+
has_number = bool(number_pattern.search(window))
|
| 341 |
+
if has_source and has_number:
|
| 342 |
+
triples += 1
|
| 343 |
+
return min(triples / max(len(year_positions), 1), 1.0)
|
| 344 |
+
|
| 345 |
+
|
| 346 |
+
def score_data_coverage(
|
| 347 |
+
answer: str,
|
| 348 |
+
included_modules: list[str] | None = None,
|
| 349 |
+
expected_modules: list[str] | None = None,
|
| 350 |
+
) -> float:
|
| 351 |
+
"""๊ธฐ๋ ๋ชจ๋ ๋๋น ์ค์ ๋ฐ์ดํฐ๊ฐ answer์ ํ์ฉ๋ ์ฆ๊ฑฐ ๋น์จ."""
|
| 352 |
+
expected = list(expected_modules or [])
|
| 353 |
+
if not expected:
|
| 354 |
+
return 1.0
|
| 355 |
+
# ๋ชจ๋๋ณ ํค์๋ ๋งคํ
|
| 356 |
+
_MODULE_EVIDENCE: dict[str, list[str]] = {
|
| 357 |
+
"IS": ["๋งค์ถ", "์์
์ด์ต", "์์ด์ต", "์๊ฐ", "ํ๊ด๋น"],
|
| 358 |
+
"BS": ["์์ฐ", "๋ถ์ฑ", "์๋ณธ", "์ ๋"],
|
| 359 |
+
"CF": ["ํ๊ธํ๋ฆ", "์์
ํ๋", "ํฌ์ํ๋", "์ฌ๋ฌดํ๋"],
|
| 360 |
+
"ratios": ["๋น์จ", "ROE", "ROA", "์ด์ต๋ฅ ", "๋ถ์ฑ๋น์จ"],
|
| 361 |
+
"costByNature": ["์ฑ๊ฒฉ๋ณ ๋น์ฉ", "๊ธ์ฌ", "๊ฐ๊ฐ์๊ฐ", "์์ฌ๋ฃ"],
|
| 362 |
+
"segments": ["๋ถ๋ฌธ", "์ธ๊ทธ๋จผํธ", "์ฌ์
๋ถ"],
|
| 363 |
+
"businessOverview": ["์ฌ์
", "์์ฅ", "๊ฒฝ์", "์ ๋ต"],
|
| 364 |
+
"governanceOverview": ["์ง๋ฐฐ๊ตฌ์กฐ", "์ด์ฌํ", "๊ฐ์ฌ"],
|
| 365 |
+
"riskDerivative": ["๋ฆฌ์คํฌ", "ํ์", "์ํ"],
|
| 366 |
+
"productService": ["์ ํ", "์๋น์ค", "๋งค์ถ๊ตฌ์ฑ"],
|
| 367 |
+
}
|
| 368 |
+
answer_lower = answer.lower()
|
| 369 |
+
evidenced = 0
|
| 370 |
+
for mod in expected:
|
| 371 |
+
keywords = _MODULE_EVIDENCE.get(mod, [])
|
| 372 |
+
if not keywords:
|
| 373 |
+
# ๋ชจ๋๋ช
์์ฒด๊ฐ answer์ ์์ผ๋ฉด evidence๋ก ์ธ์
|
| 374 |
+
if mod.lower() in answer_lower:
|
| 375 |
+
evidenced += 1
|
| 376 |
+
continue
|
| 377 |
+
if any(kw.lower() in answer_lower for kw in keywords):
|
| 378 |
+
evidenced += 1
|
| 379 |
+
return evidenced / len(expected)
|
| 380 |
+
|
| 381 |
+
|
| 382 |
+
def classify_failure_types(
|
| 383 |
+
card: ScoreCard,
|
| 384 |
+
*,
|
| 385 |
+
answer: str,
|
| 386 |
+
included_modules: list[str] | None = None,
|
| 387 |
+
expected_modules: list[str] | None = None,
|
| 388 |
+
expected_route: str | None = None,
|
| 389 |
+
actual_route: str | None = None,
|
| 390 |
+
) -> list[str]:
|
| 391 |
+
"""์ ์์ ์คํ ๋ฉํ๋ฅผ ๋ฐํ์ผ๋ก ์คํจ ์ ํ ๋ถ๋ฅ."""
|
| 392 |
+
failures: list[str] = []
|
| 393 |
+
if expected_route and actual_route and expected_route != actual_route:
|
| 394 |
+
failures.append("routing_failure")
|
| 395 |
+
if expected_modules and card.module_utilization < 1.0:
|
| 396 |
+
failures.append("retrieval_failure")
|
| 397 |
+
if card.false_unavailable == 0.0:
|
| 398 |
+
failures.append("false_unavailable")
|
| 399 |
+
if card.factual_accuracy < 0.5 or card.hallucination < 0.5:
|
| 400 |
+
failures.append("generation_failure")
|
| 401 |
+
if card.ui_language_compliance < 1.0:
|
| 402 |
+
failures.append("ui_wording_failure")
|
| 403 |
+
if not failures and expected_modules and not included_modules:
|
| 404 |
+
failures.append("data_gap")
|
| 405 |
+
if not failures and not answer.strip():
|
| 406 |
+
failures.append("empty_answer")
|
| 407 |
+
return failures
|
| 408 |
+
|
| 409 |
+
|
| 410 |
+
def auto_score(
|
| 411 |
+
answer: str,
|
| 412 |
+
expected_facts: list[dict] | None = None,
|
| 413 |
+
expected_topics: list[str] | None = None,
|
| 414 |
+
provided_indicators: list[str] | None = None,
|
| 415 |
+
*,
|
| 416 |
+
included_modules: list[str] | None = None,
|
| 417 |
+
expected_modules: list[str] | None = None,
|
| 418 |
+
must_not_say: list[str] | None = None,
|
| 419 |
+
must_include: list[str] | None = None,
|
| 420 |
+
forbidden_terms: list[str] | None = None,
|
| 421 |
+
clarification_allowed: bool | None = None,
|
| 422 |
+
expected_followups: list[str] | None = None,
|
| 423 |
+
expected_route: str | None = None,
|
| 424 |
+
actual_route: str | None = None,
|
| 425 |
+
contexts: list[dict] | None = None,
|
| 426 |
+
) -> ScoreCard:
|
| 427 |
+
"""๋ต๋ณ ์๋ ์ฑ์ ."""
|
| 428 |
+
facts = expected_facts or []
|
| 429 |
+
topics = expected_topics or []
|
| 430 |
+
|
| 431 |
+
card = ScoreCard(
|
| 432 |
+
factual_accuracy=score_factual_accuracy(answer, facts),
|
| 433 |
+
completeness=score_completeness(answer, topics),
|
| 434 |
+
source_citation=score_source_citation(answer),
|
| 435 |
+
hallucination=score_hallucination(answer, facts),
|
| 436 |
+
actionability=score_actionability(answer),
|
| 437 |
+
ratio_utilization=score_ratio_utilization(answer, provided_indicators),
|
| 438 |
+
module_utilization=score_module_utilization(included_modules, expected_modules),
|
| 439 |
+
false_unavailable=score_false_unavailable(
|
| 440 |
+
answer,
|
| 441 |
+
must_not_say,
|
| 442 |
+
enabled=bool(expected_modules or facts or must_include or topics),
|
| 443 |
+
),
|
| 444 |
+
grounding_quality=score_grounding_quality(answer, must_include, topics),
|
| 445 |
+
clarification_quality=score_clarification_quality(answer, clarification_allowed),
|
| 446 |
+
ui_language_compliance=score_ui_language_compliance(answer, forbidden_terms),
|
| 447 |
+
followup_usefulness=score_followup_usefulness(answer, expected_followups),
|
| 448 |
+
context_depth=score_context_depth(answer, contexts),
|
| 449 |
+
source_citation_precision=score_source_citation_precision(answer),
|
| 450 |
+
data_coverage=score_data_coverage(answer, included_modules, expected_modules),
|
| 451 |
+
details={
|
| 452 |
+
"includedModules": list(included_modules or []),
|
| 453 |
+
"expectedModules": list(expected_modules or []),
|
| 454 |
+
"expectedRoute": expected_route,
|
| 455 |
+
"actualRoute": actual_route,
|
| 456 |
+
},
|
| 457 |
+
)
|
| 458 |
+
card.failure_types = classify_failure_types(
|
| 459 |
+
card,
|
| 460 |
+
answer=answer,
|
| 461 |
+
included_modules=included_modules,
|
| 462 |
+
expected_modules=expected_modules,
|
| 463 |
+
expected_route=expected_route,
|
| 464 |
+
actual_route=actual_route,
|
| 465 |
+
)
|
| 466 |
+
return card
|