Spaces:
Configuration error
Configuration error
Upload 5 files
Browse files- .gitignore +50 -0
- .python-version +1 -0
- README.md +89 -7
- app.py +1935 -0
- requirements.txt +10 -0
.gitignore
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Python
|
| 2 |
+
__pycache__/
|
| 3 |
+
*.py[cod]
|
| 4 |
+
*$py.class
|
| 5 |
+
*.so
|
| 6 |
+
.Python
|
| 7 |
+
build/
|
| 8 |
+
develop-eggs/
|
| 9 |
+
dist/
|
| 10 |
+
downloads/
|
| 11 |
+
eggs/
|
| 12 |
+
.eggs/
|
| 13 |
+
lib/
|
| 14 |
+
lib64/
|
| 15 |
+
parts/
|
| 16 |
+
sdist/
|
| 17 |
+
var/
|
| 18 |
+
wheels/
|
| 19 |
+
*.egg-info/
|
| 20 |
+
.installed.cfg
|
| 21 |
+
*.egg
|
| 22 |
+
|
| 23 |
+
# Virtual Environment
|
| 24 |
+
venv/
|
| 25 |
+
ENV/
|
| 26 |
+
env/
|
| 27 |
+
.venv
|
| 28 |
+
|
| 29 |
+
# IDE
|
| 30 |
+
.vscode/
|
| 31 |
+
.idea/
|
| 32 |
+
*.swp
|
| 33 |
+
*.swo
|
| 34 |
+
*~
|
| 35 |
+
|
| 36 |
+
# OS
|
| 37 |
+
.DS_Store
|
| 38 |
+
Thumbs.db
|
| 39 |
+
|
| 40 |
+
# Secrets
|
| 41 |
+
.env
|
| 42 |
+
*.pem
|
| 43 |
+
*.key
|
| 44 |
+
|
| 45 |
+
# Gradio
|
| 46 |
+
gradio_cached_examples/
|
| 47 |
+
flagged/
|
| 48 |
+
|
| 49 |
+
# Logs
|
| 50 |
+
*.log
|
.python-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
3.10
|
README.md
CHANGED
|
@@ -1,14 +1,96 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
-
emoji:
|
| 4 |
-
colorFrom:
|
| 5 |
-
colorTo:
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version:
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
| 11 |
-
short_description: compositeAI
|
| 12 |
---
|
| 13 |
|
| 14 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: POSCO DX MRO Composite AI
|
| 3 |
+
emoji: ๐ญ
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: 4.44.1
|
| 8 |
app_file: app.py
|
| 9 |
pinned: false
|
| 10 |
license: mit
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# ๐ญ POSCO DX - MRO Composite AI
|
| 14 |
+
|
| 15 |
+
## ์
๋ฌด ํ๋ก์ธ์ค ์๋ํ + AI ์์ฌ๊ฒฐ์ ์ง์ ์์คํ
|
| 16 |
+
|
| 17 |
+
์ด ์ ํ๋ฆฌ์ผ์ด์
์ POSCO์ MRO(Maintenance, Repair, Operations) ํ๋ก์ธ์ค๋ฅผ ์๋ํํ๊ณ ์ต์ ํํ๋ 3-Agent Collaboration ์์คํ
์
๋๋ค.
|
| 18 |
+
|
| 19 |
+
### ๐ฏ ์ฃผ์ ๊ธฐ๋ฅ
|
| 20 |
+
|
| 21 |
+
1. **MRO ์ด์ ์๋ํ**
|
| 22 |
+
- ์ค๋น-๋ถํ ์๋ ๋งค์นญ
|
| 23 |
+
- ์ ์ฌ ์ฌ๊ณ ์ค์๊ฐ ์กฐํ
|
| 24 |
+
- ๋ฐ์ฃผ ํ์์ฑ ์๋ ํ๋จ
|
| 25 |
+
|
| 26 |
+
2. **๊ตฌ๋งค/์กฐ๋ฌ ์ต์ ํ**
|
| 27 |
+
- ๊ณต๊ธ์
์ฒด ์๋ ๋น๊ต
|
| 28 |
+
- Neuro-Symbolic AI ๊ท์ ๊ฒ์ฆ
|
| 29 |
+
- Linear Programming ์ต์ ํ
|
| 30 |
+
|
| 31 |
+
3. **๊ฒฝ์์ง ์์ฌ๊ฒฐ์ ์ง์**
|
| 32 |
+
- ์ค์๊ฐ KPI ๋์๋ณด๋
|
| 33 |
+
- Action Items ์๋ ์์ฑ
|
| 34 |
+
- ๊ฐ์ฌ ์ถ์ (Audit Trail)
|
| 35 |
+
|
| 36 |
+
### ๐ ์ฌ์ฉ ๋ฐฉ๋ฒ
|
| 37 |
+
|
| 38 |
+
#### 1. ๊ธฐ๋ณธ ์ฌ์ฉ (Demo Mode)
|
| 39 |
+
|
| 40 |
+
API ํค ์์ด๋ ๋ฐ๋ชจ ๋ฐ์ดํฐ๋ก ์์คํ
์ ๋ชจ๋ ๊ธฐ๋ฅ์ ์ฒดํํ ์ ์์ต๋๋ค:
|
| 41 |
+
|
| 42 |
+
1. ์๋๋ฆฌ์ค ์ ํ (๊ธด๊ธ ๊ณ ์ฅ ๋์ / ์ ๊ธฐ ๋ฐ์ฃผ ๊ณํ / ๊ท์ ์ค์ ๊ฒ์ฆ)
|
| 43 |
+
2. ํ๋ผ๋ฏธํฐ ํ์ธ (์ค๋น ID, ํ๋ชฉ ID, ์๋)
|
| 44 |
+
3. "๐ Composite AI ๋ถ์ ์คํ" ๋ฒํผ ํด๋ฆญ
|
| 45 |
+
4. ๊ฐ ํญ์์ ๊ฒฐ๊ณผ ํ์ธ
|
| 46 |
+
|
| 47 |
+
#### 2. OpenAI ๊ธฐ๋ฅ ํ์ฑํ
|
| 48 |
+
|
| 49 |
+
LLM ๊ธฐ๋ฐ AI ๋ถ์์ ์ฌ์ฉํ๋ ค๋ฉด:
|
| 50 |
+
|
| 51 |
+
1. **Space Settings**๋ก ์ด๋
|
| 52 |
+
2. **Secrets** ์น์
์์ ์ Secret ์ถ๊ฐ:
|
| 53 |
+
- Name: `OPENAI_API_KEY`
|
| 54 |
+
- Value: `sk-...` (๊ทํ์ OpenAI API ํค)
|
| 55 |
+
3. Space๋ฅผ ์ฌ์์ํ๋ฉด ์๋์ผ๋ก API ํค๊ฐ ๋ก๋๋ฉ๋๋ค
|
| 56 |
+
|
| 57 |
+
### ๐ ๊ธฐ๋ ํจ๊ณผ
|
| 58 |
+
|
| 59 |
+
- โฑ๏ธ **์ฒ๋ฆฌ ์๊ฐ**: ๊ธฐ์กด 3-5์ผ โ **1์๊ฐ ์ด๋ด**
|
| 60 |
+
- ๐ฐ **๋น์ฉ ์ ๊ฐ**: ํ๊ท **15-25%** ๊ตฌ๋งค ๋น์ฉ ์ ๊ฐ
|
| 61 |
+
- โ๏ธ **์ปดํ๋ผ์ด์ธ์ค**: **100%** ๊ท์ ์ค์
|
| 62 |
+
- ๐ **ํจ์จ์ฑ**: ๋ด๋น์ ์
๋ฌด ์๊ฐ **60%** ๋จ์ถ
|
| 63 |
+
|
| 64 |
+
### ๐ ๏ธ ๊ธฐ์ ์คํ
|
| 65 |
+
|
| 66 |
+
- **Frontend**: Gradio 4.0+
|
| 67 |
+
- **Data Processing**: Pandas, NumPy
|
| 68 |
+
- **Visualization**: Plotly
|
| 69 |
+
- **Optimization**: PuLP (Linear Programming)
|
| 70 |
+
- **AI/LLM**: OpenAI GPT-4o-mini (optional)
|
| 71 |
+
- **Workflow**: LangGraph
|
| 72 |
+
|
| 73 |
+
### ๐ฆ ์ค์น ๋ฐฉ๋ฒ (๋ก์ปฌ)
|
| 74 |
+
|
| 75 |
+
```bash
|
| 76 |
+
pip install -r requirements.txt
|
| 77 |
+
python app.py
|
| 78 |
+
```
|
| 79 |
+
|
| 80 |
+
### ๐ ๋ณด์ ์ฐธ๊ณ ์ฌํญ
|
| 81 |
+
|
| 82 |
+
- API ํค๋ ์ ๋ ์ฝ๋์ ํ๋์ฝ๋ฉํ์ง ๋ง์ธ์
|
| 83 |
+
- Hugging Face Spaces์ Secrets ๊ธฐ๋ฅ์ ์ฌ์ฉํ์ธ์
|
| 84 |
+
- ํ๋ก๋์
ํ๊ฒฝ์์๋ ์ ์ ํ ์ ๊ทผ ์ ์ด๋ฅผ ๊ตฌํํ์ธ์
|
| 85 |
+
|
| 86 |
+
### ๐ ๋ผ์ด์ ์ค
|
| 87 |
+
|
| 88 |
+
์ด ํ๋ก์ ํธ๋ ๋ฐ๋ชจ ๋ชฉ์ ์ผ๋ก ์ ๊ณต๋ฉ๋๋ค.
|
| 89 |
+
|
| 90 |
+
### ๐ค ๋ฌธ์
|
| 91 |
+
|
| 92 |
+
ํ๋ก์ ํธ ๊ด๋ จ ๋ฌธ์์ฌํญ์ ์ด์๋ฅผ ํตํด ๋จ๊ฒจ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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# =========================================================
|
| 2 |
+
# POSCO DX - MRO Composite AI - PROCESS GUIDE ENHANCED
|
| 3 |
+
# ์
๋ฌด ํ๋ก์ธ์ค ๊ฐ์ด๋ ํตํฉ ๋ฒ์ - Hugging Face Spaces ๋ฐฐํฌ์ฉ
|
| 4 |
+
# =========================================================
|
| 5 |
+
|
| 6 |
+
import os
|
| 7 |
+
import json
|
| 8 |
+
import time
|
| 9 |
+
import random
|
| 10 |
+
import traceback
|
| 11 |
+
from dataclasses import dataclass
|
| 12 |
+
from typing import Dict, Any, List, Optional, Tuple, TypedDict
|
| 13 |
+
from datetime import datetime, timedelta
|
| 14 |
+
|
| 15 |
+
import numpy as np
|
| 16 |
+
import pandas as pd
|
| 17 |
+
import networkx as nx
|
| 18 |
+
|
| 19 |
+
# โ
Plotly imports
|
| 20 |
+
import plotly
|
| 21 |
+
import plotly.graph_objects as go
|
| 22 |
+
import plotly.express as px
|
| 23 |
+
from plotly.subplots import make_subplots
|
| 24 |
+
|
| 25 |
+
print(f"โ
NumPy: {np.__version__}")
|
| 26 |
+
print(f"โ
Pandas: {pd.__version__}")
|
| 27 |
+
print(f"โ
Plotly: {plotly.__version__}")
|
| 28 |
+
|
| 29 |
+
try:
|
| 30 |
+
from pulp import LpProblem, LpMinimize, LpVariable, lpSum, LpStatus
|
| 31 |
+
PULP_AVAILABLE = True
|
| 32 |
+
print("โ
PuLP available")
|
| 33 |
+
except ImportError:
|
| 34 |
+
print("โ ๏ธ PuLP not available")
|
| 35 |
+
PULP_AVAILABLE = False
|
| 36 |
+
|
| 37 |
+
import gradio as gr
|
| 38 |
+
print(f"โ
Gradio: {gr.__version__}")
|
| 39 |
+
|
| 40 |
+
try:
|
| 41 |
+
from langgraph.graph import StateGraph, END
|
| 42 |
+
LANGGRAPH_AVAILABLE = True
|
| 43 |
+
print("โ
LangGraph available")
|
| 44 |
+
except ImportError:
|
| 45 |
+
print("โ ๏ธ LangGraph not available")
|
| 46 |
+
LANGGRAPH_AVAILABLE = False
|
| 47 |
+
|
| 48 |
+
try:
|
| 49 |
+
from openai import OpenAI
|
| 50 |
+
OPENAI_AVAILABLE = True
|
| 51 |
+
print("โ
OpenAI available")
|
| 52 |
+
except ImportError:
|
| 53 |
+
print("โ ๏ธ OpenAI not available")
|
| 54 |
+
OPENAI_AVAILABLE = False
|
| 55 |
+
|
| 56 |
+
# =========================================================
|
| 57 |
+
# API Key Configuration for Hugging Face Spaces
|
| 58 |
+
# =========================================================
|
| 59 |
+
# Hugging Face Spaces์์ ํ๊ฒฝ ๋ณ์๋ก API ํค ๋ก๋
|
| 60 |
+
OPENAI_API_KEY = os.environ.get('OPENAI_API_KEY', '').strip()
|
| 61 |
+
|
| 62 |
+
if OPENAI_API_KEY:
|
| 63 |
+
os.environ['OPENAI_API_KEY'] = OPENAI_API_KEY
|
| 64 |
+
print("โ
OpenAI API Key loaded from environment")
|
| 65 |
+
else:
|
| 66 |
+
print("โ ๏ธ DEMO MODE - No API Key found")
|
| 67 |
+
print("๐ก To use OpenAI features, add OPENAI_API_KEY to your Hugging Face Space Secrets")
|
| 68 |
+
|
| 69 |
+
print("\n" + "=" * 60)
|
| 70 |
+
print("โ
ํ๋ก์ธ์ค ๊ฐ์ด๋ ํตํฉ ๋ฒ์ ์ด๊ธฐํ ์๋ฃ!")
|
| 71 |
+
print("=" * 60 + "\n")
|
| 72 |
+
|
| 73 |
+
# =========================================================
|
| 74 |
+
# Process Guide Configuration
|
| 75 |
+
# =========================================================
|
| 76 |
+
PROCESS_WORKFLOWS = {
|
| 77 |
+
"mro": {
|
| 78 |
+
"title": "๐ง MRO ์ด์ ํ๋ก์ธ์ค",
|
| 79 |
+
"steps": [
|
| 80 |
+
{
|
| 81 |
+
"id": "1",
|
| 82 |
+
"name": "๊ณ ์ฅ/์ ๋น ์์ฒญ ์ ์",
|
| 83 |
+
"description": "์ค๋น ๊ณ ์ฅ ๋๋ ์๋ฐฉ์ ๋น ์์ฒญ์ ์ ์ํฉ๋๋ค",
|
| 84 |
+
"input": "์ค๋น ID, ๊ณ ์ฅ ์ ํ, ์ฐ์ ์์",
|
| 85 |
+
"output": "์์ฒญ ๋ฒํธ, ์ค๋น ์์ธ์ ๋ณด",
|
| 86 |
+
"owner": "ํ์ฅ ๋ด๋น์ โ MROํ",
|
| 87 |
+
"duration": "5๋ถ"
|
| 88 |
+
},
|
| 89 |
+
{
|
| 90 |
+
"id": "2",
|
| 91 |
+
"name": "์ค๋น ์ ๋ณด ์กฐํ",
|
| 92 |
+
"description": "Knowledge Graph์์ ์ค๋น ์์ธ ์ ๋ณด๋ฅผ ์กฐํํฉ๋๋ค",
|
| 93 |
+
"input": "์ค๋น ID",
|
| 94 |
+
"output": "์ค๋น๋ช
, ์์น, ์ค์๋, ์ ๋น์ด๋ ฅ",
|
| 95 |
+
"owner": "MROํ (AI ์๋)",
|
| 96 |
+
"duration": "1๋ถ"
|
| 97 |
+
},
|
| 98 |
+
{
|
| 99 |
+
"id": "3",
|
| 100 |
+
"name": "ํธํ ๋ถํ ์๋ ๋งค์นญ",
|
| 101 |
+
"description": "์ค๋น์ ํธํ๋๋ ๋ชจ๋ ๋ถํ์ ์๋์ผ๋ก ์กฐํํฉ๋๋ค",
|
| 102 |
+
"input": "์ค๋น ID, ์ค๋น ํ์
",
|
| 103 |
+
"output": "ํธํ ๋ถํ ๋ฆฌ์คํธ, ํ์/์ ํ ๊ตฌ๋ถ",
|
| 104 |
+
"owner": "MROํ (AI ์๋)",
|
| 105 |
+
"duration": "2๋ถ"
|
| 106 |
+
},
|
| 107 |
+
{
|
| 108 |
+
"id": "4",
|
| 109 |
+
"name": "์ ์ฌ ์ฌ๊ณ ํํฉ ํ์ธ",
|
| 110 |
+
"description": "๋ณธ์ฌ ๋ฐ ๊ฐ ์ ์ฒ ์์ ์ฌ๊ณ ํํฉ์ ์ค์๊ฐ ํ์ธํฉ๋๋ค",
|
| 111 |
+
"input": "ํ๋ชฉ ID",
|
| 112 |
+
"output": "์ฐฝ๊ณ ๋ณ ์ฌ๊ณ ๋, ์์ ์ฌ๊ณ , ์์ฝ์๋",
|
| 113 |
+
"owner": "MROํ (AI ์๋)",
|
| 114 |
+
"duration": "1๋ถ"
|
| 115 |
+
},
|
| 116 |
+
{
|
| 117 |
+
"id": "5",
|
| 118 |
+
"name": "๋ฐ์ฃผ ํ์์ฑ ํ๋จ",
|
| 119 |
+
"description": "์ฌ๊ณ ๋ถ์กฑ ์ ๋ฐ์ฃผ ์์ฒญ์ ์์ฑํฉ๋๋ค",
|
| 120 |
+
"input": "ํ์ฌ๊ณ , ์์ ์ฌ๊ณ , ์์๋",
|
| 121 |
+
"output": "๋ฐ์ฃผ ํ์ ์ฌ๋ถ, ๋ฐ์ฃผ ์๋",
|
| 122 |
+
"owner": "MROํ",
|
| 123 |
+
"duration": "3๋ถ"
|
| 124 |
+
},
|
| 125 |
+
{
|
| 126 |
+
"id": "6",
|
| 127 |
+
"name": "๊ตฌ๋งคํ ๋ฐ์ฃผ ์์ฒญ",
|
| 128 |
+
"description": "๊ตฌ๋งคํ์ ๋ฐ์ฃผ ์์ฒญ์๋ฅผ ์ ๋ฌํฉ๋๋ค",
|
| 129 |
+
"input": "ํ๋ชฉ ์ ๋ณด, ์๋, ๋ฉ๊ธฐ ์๊ตฌ์ฌํญ",
|
| 130 |
+
"output": "๋ฐ์ฃผ ์์ฒญ ๋ฒํธ",
|
| 131 |
+
"owner": "MROํ โ ๊ตฌ๋งคํ",
|
| 132 |
+
"duration": "2๋ถ"
|
| 133 |
+
}
|
| 134 |
+
],
|
| 135 |
+
"total_duration": "์ฝ 15๋ถ",
|
| 136 |
+
"success_criteria": [
|
| 137 |
+
"โ ์ค๋น ์ ๋ณด ์ ํ๏ฟฝ๏ฟฝ ์๋ณ",
|
| 138 |
+
"โ ํธํ ๋ถํ 100% ๋งค์นญ",
|
| 139 |
+
"โ ์ฌ๊ณ ํํฉ ์ค์๊ฐ ๋ฐ์",
|
| 140 |
+
"โ ๋ฐ์ฃผ ์๋ ์ต์ ํ"
|
| 141 |
+
]
|
| 142 |
+
},
|
| 143 |
+
"procurement": {
|
| 144 |
+
"title": "๐ฐ ๊ตฌ๋งค/์กฐ๋ฌ ํ๋ก์ธ์ค",
|
| 145 |
+
"steps": [
|
| 146 |
+
{
|
| 147 |
+
"id": "1",
|
| 148 |
+
"name": "๋ฐ์ฃผ ์์ฒญ ์ ์",
|
| 149 |
+
"description": "MROํ์ผ๋ก๋ถํฐ ๋ฐ์ฃผ ์์ฒญ์ ์ ์ํฉ๋๋ค",
|
| 150 |
+
"input": "๋ฐ์ฃผ ์์ฒญ์, ํ๋ชฉ, ์๋, ๋ฉ๊ธฐ",
|
| 151 |
+
"output": "๊ตฌ๋งค ์์
๋ฒํธ",
|
| 152 |
+
"owner": "๊ตฌ๋งคํ",
|
| 153 |
+
"duration": "3๋ถ"
|
| 154 |
+
},
|
| 155 |
+
{
|
| 156 |
+
"id": "2",
|
| 157 |
+
"name": "๊ณต๊ธ์
์ฒด ์ ๋ณด ์กฐํ",
|
| 158 |
+
"description": "ํ๋ชฉ๋ณ ๋ฑ๋ก๋ ๋ชจ๋ ๊ณต๊ธ์
์ฒด๋ฅผ ์กฐํํฉ๋๋ค",
|
| 159 |
+
"input": "ํ๋ชฉ ID",
|
| 160 |
+
"output": "๊ณต๊ธ์
์ฒด ๋ฆฌ์คํธ, ๋จ๊ฐ, ๋ฉ๊ธฐ, ESG๋ฑ๊ธ",
|
| 161 |
+
"owner": "๊ตฌ๋งคํ (AI ์๋)",
|
| 162 |
+
"duration": "2๋ถ"
|
| 163 |
+
},
|
| 164 |
+
{
|
| 165 |
+
"id": "3",
|
| 166 |
+
"name": "๊ท์ ์ค์ ๊ฒ์ฆ",
|
| 167 |
+
"description": "Neuro-Symbolic AI๋ก ๊ตฌ๋งค ๊ท์ ์ ์๋ ๊ฒ์ฆํฉ๋๋ค",
|
| 168 |
+
"input": "ํ๋ชฉ ์์ฑ, ๊ณต๊ธ์
์ฒด ์ ๋ณด",
|
| 169 |
+
"output": "๊ท์ ์๋ฐ ์ฌ๋ถ, ์ฐจ๋จ/๊ฒฝ๊ณ ๋ฆฌ์คํธ",
|
| 170 |
+
"owner": "๊ตฌ๋งคํ (AI ์๋)",
|
| 171 |
+
"duration": "1๋ถ"
|
| 172 |
+
},
|
| 173 |
+
{
|
| 174 |
+
"id": "4",
|
| 175 |
+
"name": "์ต์ ๋ฐฐ๋ถ ๊ณ์ฐ",
|
| 176 |
+
"description": "Linear Programming์ผ๋ก ์ต์ ๋ฐ์ฃผ ๊ณํ์ ์๋ฆฝํฉ๋๋ค",
|
| 177 |
+
"input": "๊ณต๊ธ์
์ฒด ์คํผ, ์์๋, ์ ์ฝ์กฐ๊ฑด",
|
| 178 |
+
"output": "์
์ฒด๋ณ ๋ฐ์ฃผ๋, ์ด ๋น์ฉ, ์์ ๋ฉ๊ธฐ",
|
| 179 |
+
"owner": "๊ตฌ๋งคํ (AI ์๋)",
|
| 180 |
+
"duration": "2๋ถ"
|
| 181 |
+
},
|
| 182 |
+
{
|
| 183 |
+
"id": "5",
|
| 184 |
+
"name": "๋ฐ์ฃผ ์ ๋ต ์๋ฆฝ",
|
| 185 |
+
"description": "LLM์ด ์ต์ ํ ๊ฒฐ๊ณผ๋ฅผ ๋ฐํ์ผ๋ก ๊ตฌ๋งค ์ ๋ต์ ์ ์ํฉ๋๋ค",
|
| 186 |
+
"input": "์ต์ ํ ๊ฒฐ๊ณผ, ์์ฅ ์ํฉ",
|
| 187 |
+
"output": "๋ฐ์ฃผ ์ ๋ต, ๋ฆฌ์คํฌ ๋ถ์, ๋์",
|
| 188 |
+
"owner": "๊ตฌ๋งคํ (AI ์ง์)",
|
| 189 |
+
"duration": "5๋ถ"
|
| 190 |
+
},
|
| 191 |
+
{
|
| 192 |
+
"id": "6",
|
| 193 |
+
"name": "๊ฒฝ์์ง ์น์ธ ์์ฒญ",
|
| 194 |
+
"description": "๋ฐ์ฃผ ๊ณํ์ ๊ฒฝ์์ง์๊ฒ ์น์ธ ์์ฒญํฉ๋๋ค",
|
| 195 |
+
"input": "๋ฐ์ฃผ ๊ณํ์, ๋น์ฉ ๋ถ์",
|
| 196 |
+
"output": "์น์ธ ์์ฒญ ๋ฒํธ",
|
| 197 |
+
"owner": "๊ตฌ๋งคํ โ ๊ฒฝ์์ง",
|
| 198 |
+
"duration": "3๋ถ"
|
| 199 |
+
},
|
| 200 |
+
{
|
| 201 |
+
"id": "7",
|
| 202 |
+
"name": "PO ๋ฐํ (์น์ธ ํ)",
|
| 203 |
+
"description": "์น์ธ ํ ๊ณต๊ธ์
์ฒด์ ์ ์ ๋ฐ์ฃผ์๋ฅผ ๋ฐํํฉ๋๋ค",
|
| 204 |
+
"input": "์น์ธ๋ ๋ฐ์ฃผ ๊ณํ",
|
| 205 |
+
"output": "PO ๋ฒํธ, ๊ณ์ฝ์",
|
| 206 |
+
"owner": "๊ตฌ๋งคํ",
|
| 207 |
+
"duration": "10๋ถ"
|
| 208 |
+
}
|
| 209 |
+
],
|
| 210 |
+
"total_duration": "์ฝ 25๋ถ (์น์ธ ๋๊ธฐ ์ ์ธ)",
|
| 211 |
+
"success_criteria": [
|
| 212 |
+
"โ ๊ท์ 100% ์ค์",
|
| 213 |
+
"โ ๋น์ฉ ์ต์ ํ ๋ฌ์ฑ",
|
| 214 |
+
"โ ๋ฉ๊ธฐ ์๊ตฌ์ฌํญ ์ถฉ์กฑ",
|
| 215 |
+
"โ ESG ๋ฑ๊ธ ๊ธฐ์ค ๋ง์กฑ"
|
| 216 |
+
]
|
| 217 |
+
},
|
| 218 |
+
"executive": {
|
| 219 |
+
"title": "๐ ๊ฒฝ์์ง ์์ฌ๊ฒฐ์ ํ๋ก์ธ์ค",
|
| 220 |
+
"steps": [
|
| 221 |
+
{
|
| 222 |
+
"id": "1",
|
| 223 |
+
"name": "์น์ธ ์์ฒญ ์๋ฆผ",
|
| 224 |
+
"description": "๋ฐ์ฃผ ์น์ธ ์์ฒญ ์๋ฆผ์ ์์ ํฉ๋๋ค",
|
| 225 |
+
"input": "์น์ธ ์์ฒญ ๋ฒํธ, ์์ฝ ์ ๋ณด",
|
| 226 |
+
"output": "์๋ฆผ ํ์ธ",
|
| 227 |
+
"owner": "์์คํ
โ ๊ฒฝ์์ง",
|
| 228 |
+
"duration": "์ฆ์"
|
| 229 |
+
},
|
| 230 |
+
{
|
| 231 |
+
"id": "2",
|
| 232 |
+
"name": "KPI ๋์๋ณด๋ ํ์ธ",
|
| 233 |
+
"description": "์ค์๊ฐ KPI ๋์๋ณด๋๋ฅผ ํตํด ์ ๋ฐ์ ํํฉ์ ํ์
ํฉ๋๋ค",
|
| 234 |
+
"input": "์์",
|
| 235 |
+
"output": "๋น์ฉ์ ๊ฐ๋ฅ , ์ปดํ๋ผ์ด์ธ์ค, ESG์ ์ ๋ฑ",
|
| 236 |
+
"owner": "๊ฒฝ์์ง",
|
| 237 |
+
"duration": "2๋ถ"
|
| 238 |
+
},
|
| 239 |
+
{
|
| 240 |
+
"id": "3",
|
| 241 |
+
"name": "Action Items ๊ฒํ ",
|
| 242 |
+
"description": "์ฐ์ ์์๋ณ ์กฐ์น ํญ๋ชฉ์ ๊ฒํ ํฉ๋๋ค",
|
| 243 |
+
"input": "Action Items ๋ฆฌ์คํธ",
|
| 244 |
+
"output": "๊ฒํ ์๊ฒฌ",
|
| 245 |
+
"owner": "๊ฒฝ์์ง",
|
| 246 |
+
"duration": "5๋ถ"
|
| 247 |
+
},
|
| 248 |
+
{
|
| 249 |
+
"id": "4",
|
| 250 |
+
"name": "๋ฐ์ฃผ ์์ธ ๋ถ์",
|
| 251 |
+
"description": "๋ฐ์ฃผ ๊ณํ์ ํ๋น์ฑ์ ๋ฉด๋ฐํ ๊ฒํ ํฉ๋๋ค",
|
| 252 |
+
"input": "๋ฐ์ฃผ ๊ณํ์, ์ต์ ํ ๊ฒฐ๊ณผ, ๊ท์ ๊ฒ์ฆ",
|
| 253 |
+
"output": "๋ถ์ ์๊ฒฌ",
|
| 254 |
+
"owner": "๊ฒฝ์์ง",
|
| 255 |
+
"duration": "10๋ถ"
|
| 256 |
+
},
|
| 257 |
+
{
|
| 258 |
+
"id": "5",
|
| 259 |
+
"name": "์์ฌ๊ฒฐ์ ",
|
| 260 |
+
"description": "์น์ธ/๋ฐ๋ ค/์กฐ๊ฑด๋ถ์น์ธ์ ๊ฒฐ์ ํฉ๋๋ค",
|
| 261 |
+
"input": "๊ฒํ ๊ฒฐ๊ณผ",
|
| 262 |
+
"output": "์น์ธ ๊ฒฐ์ , ํผ๋๋ฐฑ",
|
| 263 |
+
"owner": "๊ฒฝ์์ง",
|
| 264 |
+
"duration": "3๋ถ"
|
| 265 |
+
},
|
| 266 |
+
{
|
| 267 |
+
"id": "6",
|
| 268 |
+
"name": "ํผ๋๋ฐฑ ์ ๊ณต",
|
| 269 |
+
"description": "๊ฐ์ ์ ์ ๋๋ ์ง์์ฌํญ์ ์ ๋ฌํฉ๋๋ค",
|
| 270 |
+
"input": "์์ฌ๊ฒฐ์ ๊ทผ๊ฑฐ",
|
| 271 |
+
"output": "ํผ๋๋ฐฑ ๋ฉ์์ง, ๊ฐ์ ๋ฐฉํฅ",
|
| 272 |
+
"owner": "๊ฒฝ์์ง โ ๊ตฌ๋งคํ",
|
| 273 |
+
"duration": "5๋ถ"
|
| 274 |
+
}
|
| 275 |
+
],
|
| 276 |
+
"total_duration": "์ฝ 25๋ถ",
|
| 277 |
+
"success_criteria": [
|
| 278 |
+
"โ ์ ๋ต์ ํ๋น์ฑ ๊ฒ์ฆ",
|
| 279 |
+
"โ ๋ฆฌ์คํฌ ์์ฉ ๊ฐ๋ฅ ์์ค",
|
| 280 |
+
"โ ์์ฐ ๋ฒ์ ๋ด ์งํ",
|
| 281 |
+
"โ ์ฅ๊ธฐ ๋ชฉํ ๋ถํฉ"
|
| 282 |
+
]
|
| 283 |
+
}
|
| 284 |
+
}
|
| 285 |
+
|
| 286 |
+
# =========================================================
|
| 287 |
+
# Enhanced Configuration with Real Part Names
|
| 288 |
+
# =========================================================
|
| 289 |
+
SCENARIO_PRESETS = {
|
| 290 |
+
"๊ธด๊ธ ๊ณ ์ฅ ๋์": {
|
| 291 |
+
"description": "๐จ ํฌํญ์ ์ฒ ์ ์ปจ๋ฒ ์ด์ด ๋ฒ ์ด๋ง ๊ธด๊ธ ๊ณ ์ฅ",
|
| 292 |
+
"equipment_id": "CONV-PH-007",
|
| 293 |
+
"item_id": "",
|
| 294 |
+
"demand_qty": 10,
|
| 295 |
+
"context": "์ปจ๋ฒ ์ด์ด ๋ฒ ์ด๋ง ๊ณ ์ฅ์ผ๋ก ์์ฐ๋ผ์ธ ์ค๋จ. ์ฆ์ ๊ต์ฒด ํ์.",
|
| 296 |
+
"priority": "๊ธด๊ธ",
|
| 297 |
+
"guide": "๋ฆฌ๋ํ์ ์ต์ํ ์ฐ์ . ๊ตญ๋ด ๊ณต๊ธ์
์ฒด ์ฐ์ ๊ณ ๋ ค."
|
| 298 |
+
},
|
| 299 |
+
"์ ๊ธฐ ๋ฐ์ฃผ ๊ณํ": {
|
| 300 |
+
"description": "๐ ์๊ฐ ์ ๊ธฐ ๋ฐ์ฃผ - ์ ์ํํ ์๋ฐฉ์ ๋น",
|
| 301 |
+
"equipment_id": "PUMP-GY-003",
|
| 302 |
+
"item_id": "SEAL-A45",
|
| 303 |
+
"demand_qty": 50,
|
| 304 |
+
"context": "์๊ฐ ์๋ฐฉ์ ๋น ๊ณํ. ์ต์ ๊ฐ๊ฒฉ ๋ฐ ์ฌ๊ณ ๊ท ํ ํ์.",
|
| 305 |
+
"priority": "์ ์",
|
| 306 |
+
"guide": "๋น์ฉ ์ต์ ํ ์ฐ์ . ESG ๋ฑ๊ธ ๊ณ ๋ ค."
|
| 307 |
+
},
|
| 308 |
+
"๊ท์ ์ค์ ๊ฒ์ฆ": {
|
| 309 |
+
"description": "โ๏ธ ๊ท์ ํ๋ชฉ(ํน์ํํ๋ฌผ์ง) ๊ตฌ๋งค ๊ฒ์ฆ",
|
| 310 |
+
"equipment_id": "VALVE-PH-005",
|
| 311 |
+
"item_id": "",
|
| 312 |
+
"demand_qty": 20,
|
| 313 |
+
"context": "ํน์ ์ค๋ง์ฌ ๊ตฌ๋งค. ํด์ธ๊ตฌ๋งค ์ฐจ๋จ ๊ท์ ์ค์ ํ์.",
|
| 314 |
+
"priority": "๊ท์ ์ค์",
|
| 315 |
+
"guide": "์ปดํ๋ผ์ด์ธ์ค 100% ์ค์. ๊ตญ๋ด์
์ฒด๋ง ํ์ฉ."
|
| 316 |
+
}
|
| 317 |
+
}
|
| 318 |
+
|
| 319 |
+
# Real part names and categories
|
| 320 |
+
REAL_PART_NAMES = {
|
| 321 |
+
"๋ฒ ์ด๋ง": ["SKF 6205 ๋ณผ๋ฒ ์ด๋ง", "NSK ์ํต๋ฒ ์ด๋ง", "NTN ํ
์ดํผ๋ฒ ์ด๋ง"],
|
| 322 |
+
"์คํ์ ": ["์ ์ค๋ง๋ผ 220", "๋ชจ๋น DTE 25", "์ง์์ค์นผํ
์ค ํฐ๋น์ "],
|
| 323 |
+
"ํํฐ": ["ํ์ด๋๋ก๋ฝ ์ ์ํํฐ", "ํ์ปค ์์ดํํฐ", "๋๋๋์จ ์ ๋ฐํํฐ"],
|
| 324 |
+
"๋ฒจํธ": ["๊ฒ์ด์ธ ํ์๊ทธ๋ฆฝ ๋ฒจํธ", "๋ฐ๋ V๋ฒจํธ", "์ตํฐ๋ฒจํธ ํ์ด๋ฐ๋ฒจํธ"],
|
| 325 |
+
"์ผ์": ["์ง๋ฉ์ค ๊ทผ์ ์ผ์", "์ค๋ฏ๋ก ๊ด์ ์ผ์", "ํ๋์ฐ ์๋ ฅ์ผ์"],
|
| 326 |
+
"ํจํน": ["NOK ์ค๋ง", "ํ์ปค ์ ์์ฐ", "๋ฐ์นด ๊ทธ๋๋ํจํน"],
|
| 327 |
+
"ํจ์ฆ": ["LS์ฐ์ MCCB", "์๋์ด๋ ์ฐจ๋จ๊ธฐ", "ABB ํจ์ฆ"],
|
| 328 |
+
"ํธ์ค": ["ํ์ปค ์ ์ํธ์ค", "๋ง๋ฆฌ ๊ณ ์ํธ์ค", "๋ธ๋ฆฌ์ง์คํค ์ฐ์
ํธ์ค"],
|
| 329 |
+
"๋ณผํธ": ["SUS304 ์ก๊ฐ๋ณผํธ", "๊ณ ์ฅ๋ ฅ๋ณผํธ F10T", "์ต์ปค๋ณผํธ M16"],
|
| 330 |
+
"์ค๋ง์ฌ": ["๋กํ์ดํธ ์ค๋ํธ", "์ฐ๋ฆฌ๋ณธ๋ ์ก์ํจํน", "ํจ์ผ ๋ฐ๋ด์ฌ"]
|
| 331 |
+
}
|
| 332 |
+
|
| 333 |
+
# Enhanced supplier info
|
| 334 |
+
REAL_SUPPLIERS = [
|
| 335 |
+
{"name": "ํฌ์ค์ฝ์ผ๋ฏธ์นผ", "type": "๊ตญ๋ด", "esg": "A", "specialty": "ํํ/์คํ์ "},
|
| 336 |
+
{"name": "ํจ์ฑ์ค๊ณต์
", "type": "๊ตญ๋ด", "esg": "A", "specialty": "๋ฒ ์ด๋ง/๊ธฐ๊ณ"},
|
| 337 |
+
{"name": "LS์ฐ์ ", "type": "๊ตญ๋ด", "esg": "B", "specialty": "์ ๊ธฐ/์ผ์"},
|
| 338 |
+
{"name": "์ผํ์ฝ๋ด์", "type": "๊ตญ๋ด", "esg": "B", "specialty": "์ ๊ธฐ๋ถํ"},
|
| 339 |
+
{"name": "ํ๊ด์ฐ์
", "type": "๊ตญ๋ด", "esg": "C", "specialty": "ํธ์ค/ํจํน"},
|
| 340 |
+
{"name": "ํ๊ตญํ์ปค", "type": "๊ตญ๋ด", "esg": "A", "specialty": "์ ์๋ถํ"},
|
| 341 |
+
{"name": "๊ทธ๋ผ์ฝ(Graco)", "type": "ํด์ธ", "esg": "B", "specialty": "์ ์์ฅ๋น"},
|
| 342 |
+
{"name": "์๋จธ์จ(Emerson)", "type": "ํด์ธ", "esg": "C", "specialty": "๋ฐธ๋ธ/์ผ์"}
|
| 343 |
+
]
|
| 344 |
+
|
| 345 |
+
# =========================================================
|
| 346 |
+
# Utility Functions
|
| 347 |
+
# =========================================================
|
| 348 |
+
def now_ts() -> str:
|
| 349 |
+
return time.strftime("%Y-%m-%d %H:%M:%S")
|
| 350 |
+
|
| 351 |
+
def safe_json(obj: Any) -> str:
|
| 352 |
+
try:
|
| 353 |
+
return json.dumps(obj, ensure_ascii=False, indent=2)
|
| 354 |
+
except Exception:
|
| 355 |
+
return str(obj)
|
| 356 |
+
|
| 357 |
+
def format_status(status_dict: Dict[str, Any]) -> str:
|
| 358 |
+
lines = [
|
| 359 |
+
"=" * 60,
|
| 360 |
+
"๐ ์์คํ
์คํ ์ํ",
|
| 361 |
+
"=" * 60,
|
| 362 |
+
"",
|
| 363 |
+
f"๐ ์ฐ๊ฒฐ: {status_dict.get('mode', 'Unknown')}",
|
| 364 |
+
f"๐ฏ ์๋๋ฆฌ์ค: {status_dict.get('scenario', 'N/A')}",
|
| 365 |
+
f"โ๏ธ ์ค๋น: {status_dict.get('equipment', 'N/A')}",
|
| 366 |
+
f"๐ฆ ํ๋ชฉ: {status_dict.get('item_name', 'N/A')}",
|
| 367 |
+
f"๐ ์์: {status_dict.get('demand', 'N/A')}๊ฐ",
|
| 368 |
+
f"๐จ ์ฐ์ ์์: {status_dict.get('priority', 'N/A')}",
|
| 369 |
+
f"\nโ
๋ฐ์ดํฐ ๊ฒ์ฆ: {'ํต๊ณผ' if status_dict.get('tables_ok') else '์คํจ'}",
|
| 370 |
+
f"โฑ๏ธ ์งํ: {status_dict.get('progress', 'N/A')}",
|
| 371 |
+
"\n" + "=" * 60
|
| 372 |
+
]
|
| 373 |
+
return "\n".join(lines)
|
| 374 |
+
|
| 375 |
+
def create_process_guide_html(process_key: str) -> str:
|
| 376 |
+
"""์
๋ฌด ํ๋ก์ธ์ค ๊ฐ์ด๋๋ฅผ HTML๋ก ์์ฑ"""
|
| 377 |
+
workflow = PROCESS_WORKFLOWS.get(process_key, {})
|
| 378 |
+
|
| 379 |
+
if not workflow:
|
| 380 |
+
return "<p>ํ๋ก์ธ์ค ์ ๋ณด๊ฐ ์์ต๋๋ค.</p>"
|
| 381 |
+
|
| 382 |
+
html = f"""
|
| 383 |
+
<div style="font-family: 'Malgun Gothic', Arial, sans-serif; padding: 20px; background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); border-radius: 10px; color: white;">
|
| 384 |
+
<h2 style="margin-top: 0;">{workflow['title']}</h2>
|
| 385 |
+
<p style="font-size: 14px; opacity: 0.9;">์ด ์์์๊ฐ: <strong>{workflow['total_duration']}</strong></p>
|
| 386 |
+
</div>
|
| 387 |
+
|
| 388 |
+
<div style="margin-top: 20px;">
|
| 389 |
+
"""
|
| 390 |
+
|
| 391 |
+
for step in workflow['steps']:
|
| 392 |
+
html += f"""
|
| 393 |
+
<div style="margin-bottom: 20px; padding: 15px; border-left: 4px solid #667eea; background: #f8f9fa; border-radius: 5px;">
|
| 394 |
+
<div style="display: flex; align-items: center; margin-bottom: 10px;">
|
| 395 |
+
<div style="background: #667eea; color: white; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; margin-right: 10px;">
|
| 396 |
+
{step['id']}
|
| 397 |
+
</div>
|
| 398 |
+
<h3 style="margin: 0; color: #2c3e50;">{step['name']}</h3>
|
| 399 |
+
<span style="margin-left: auto; background: #e3f2fd; padding: 3px 10px; border-radius: 10px; font-size: 12px; color: #1976d2;">
|
| 400 |
+
โฑ๏ธ {step['duration']}
|
| 401 |
+
</span>
|
| 402 |
+
</div>
|
| 403 |
+
|
| 404 |
+
<p style="margin: 10px 0; color: #555;">{step['description']}</p>
|
| 405 |
+
|
| 406 |
+
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px;">
|
| 407 |
+
<div style="background: white; padding: 10px; border-radius: 5px; border: 1px solid #e0e0e0;">
|
| 408 |
+
<strong style="color: #1976d2;">๐ฅ ์
๋ ฅ:</strong><br>
|
| 409 |
+
<span style="font-size: 13px; color: #666;">{step['input']}</span>
|
| 410 |
+
</div>
|
| 411 |
+
<div style="background: white; padding: 10px; border-radius: 5px; border: 1px solid #e0e0e0;">
|
| 412 |
+
<strong style="color: #388e3c;">๐ค ์ถ๋ ฅ:</strong><br>
|
| 413 |
+
<span style="font-size: 13px; color: #666;">{step['output']}</span>
|
| 414 |
+
</div>
|
| 415 |
+
</div>
|
| 416 |
+
|
| 417 |
+
<div style="margin-top: 10px; padding: 8px; background: white; border-radius: 5px; border: 1px solid #e0e0e0;">
|
| 418 |
+
<strong style="color: #f57c00;">๐ค ๋ด๋น:</strong>
|
| 419 |
+
<span style="font-size: 13px; color: #666;">{step['owner']}</span>
|
| 420 |
+
</div>
|
| 421 |
+
</div>
|
| 422 |
+
"""
|
| 423 |
+
|
| 424 |
+
html += """
|
| 425 |
+
</div>
|
| 426 |
+
|
| 427 |
+
<div style="margin-top: 30px; padding: 20px; background: #e8f5e9; border-radius: 10px; border-left: 4px solid #4caf50;">
|
| 428 |
+
<h3 style="margin-top: 0; color: #2e7d32;">โ
์ฑ๊ณต ๊ธฐ์ค</h3>
|
| 429 |
+
<ul style="margin: 0; padding-left: 20px;">
|
| 430 |
+
"""
|
| 431 |
+
|
| 432 |
+
for criterion in workflow['success_criteria']:
|
| 433 |
+
html += f"<li style='margin: 5px 0; color: #1b5e20;'>{criterion}</li>"
|
| 434 |
+
|
| 435 |
+
html += """
|
| 436 |
+
</ul>
|
| 437 |
+
</div>
|
| 438 |
+
"""
|
| 439 |
+
|
| 440 |
+
return html
|
| 441 |
+
|
| 442 |
+
# =========================================================
|
| 443 |
+
# Enhanced Data Generator with Real Names
|
| 444 |
+
# =========================================================
|
| 445 |
+
def generate_demo_tables(seed: int = 7) -> Dict[str, pd.DataFrame]:
|
| 446 |
+
"""Generate realistic demo data"""
|
| 447 |
+
random.seed(seed)
|
| 448 |
+
np.random.seed(seed)
|
| 449 |
+
|
| 450 |
+
plants = pd.DataFrame([
|
| 451 |
+
{"plant_id": "PH", "plant_name": "ํฌํญ์ ์ฒ ์", "region": "๊ฒฝ๋ถ", "capacity": 1000},
|
| 452 |
+
{"plant_id": "GY", "plant_name": "๊ด์์ ์ฒ ์", "region": "์ ๋จ", "capacity": 1200},
|
| 453 |
+
{"plant_id": "HQ", "plant_name": "๋ณธ์ฌ", "region": "์์ธ", "capacity": 0},
|
| 454 |
+
])
|
| 455 |
+
|
| 456 |
+
# Equipment with real names
|
| 457 |
+
equipment = []
|
| 458 |
+
eq_configs = [
|
| 459 |
+
("PUMP", "์ ์ํํ", ["PH", "GY"], 6),
|
| 460 |
+
("CONV", "์ปจ๋ฒ ์ด์ด", ["PH", "GY"], 4),
|
| 461 |
+
("VALVE", "์ ์ด๋ฐธ๋ธ", ["PH", "GY"], 3),
|
| 462 |
+
("MOTOR", "๊ตฌ๋๋ชจํฐ", ["PH", "GY"], 5),
|
| 463 |
+
]
|
| 464 |
+
|
| 465 |
+
eq_id = 1
|
| 466 |
+
for eq_type, eq_name_kr, plants_list, count in eq_configs:
|
| 467 |
+
for plant in plants_list:
|
| 468 |
+
for i in range(1, count + 1):
|
| 469 |
+
equipment.append({
|
| 470 |
+
"equipment_id": f"{eq_type}-{plant}-{eq_id:03d}",
|
| 471 |
+
"equipment_name": f"{eq_name_kr}-{plant}-{i}ํธ๊ธฐ",
|
| 472 |
+
"plant_id": plant,
|
| 473 |
+
"equipment_type": eq_name_kr,
|
| 474 |
+
"criticality": random.choice(["๊ธด๊ธ", "๊ธด๊ธ", "์ค์", "๋ณดํต"]),
|
| 475 |
+
"status": "๊ฐ๋์ค",
|
| 476 |
+
"last_maintenance": (datetime.now() - timedelta(days=random.randint(30, 180))).strftime("%Y-%m-%d"),
|
| 477 |
+
})
|
| 478 |
+
eq_id += 1
|
| 479 |
+
equipment = pd.DataFrame(equipment)
|
| 480 |
+
|
| 481 |
+
# Items with real part names
|
| 482 |
+
items = []
|
| 483 |
+
item_id = 1
|
| 484 |
+
for category, part_list in REAL_PART_NAMES.items():
|
| 485 |
+
for part_name in part_list:
|
| 486 |
+
items.append({
|
| 487 |
+
"item_id": f"{category[:3].upper()}-{chr(65 + (item_id % 3))}{item_id:02d}",
|
| 488 |
+
"item_name": part_name,
|
| 489 |
+
"category": category,
|
| 490 |
+
"uom": "EA",
|
| 491 |
+
"risk_class": "๊ท์ " if "ํํ" in part_name or "ํน์" in category else "์ผ๋ฐ",
|
| 492 |
+
"unit_weight": round(0.5 + random.random() * 5, 1),
|
| 493 |
+
"shelf_life_days": random.choice([365, 730, 1095, None]),
|
| 494 |
+
})
|
| 495 |
+
item_id += 1
|
| 496 |
+
items = pd.DataFrame(items)
|
| 497 |
+
|
| 498 |
+
# Compatibility
|
| 499 |
+
compat = []
|
| 500 |
+
for eq_idx, eq_row in equipment.iterrows():
|
| 501 |
+
eq_id = eq_row["equipment_id"]
|
| 502 |
+
eq_type = eq_row["equipment_type"]
|
| 503 |
+
|
| 504 |
+
# Match parts to equipment type
|
| 505 |
+
if "ํํ" in eq_type:
|
| 506 |
+
relevant_cats = ["๋ฒ ์ด๋ง", "์คํ์ ", "ํจํน"]
|
| 507 |
+
elif "์ปจ๋ฒ ์ด์ด" in eq_type:
|
| 508 |
+
relevant_cats = ["๋ฒ ์ด๋ง", "๋ฒจํธ", "์ผ์"]
|
| 509 |
+
elif "๋ฐธ๋ธ" in eq_type:
|
| 510 |
+
relevant_cats = ["์ค๋ง์ฌ", "ํจํน", "์คํ์ "]
|
| 511 |
+
else:
|
| 512 |
+
relevant_cats = ["๋ฒ ์ด๋ง", "์ผ์", "ํํฐ"]
|
| 513 |
+
|
| 514 |
+
for cat in relevant_cats:
|
| 515 |
+
cat_items = items[items["category"] == cat]
|
| 516 |
+
if len(cat_items) > 0:
|
| 517 |
+
selected = cat_items.sample(min(2, len(cat_items)))
|
| 518 |
+
for _, item in selected.iterrows():
|
| 519 |
+
compat.append({
|
| 520 |
+
"equipment_id": eq_id,
|
| 521 |
+
"item_id": item["item_id"],
|
| 522 |
+
"is_mandatory": (cat == relevant_cats[0]),
|
| 523 |
+
"annual_consumption_est": random.randint(20, 200),
|
| 524 |
+
"failure_rate": round(random.random() * 0.05, 3),
|
| 525 |
+
})
|
| 526 |
+
compat = pd.DataFrame(compat).drop_duplicates(["equipment_id", "item_id"])
|
| 527 |
+
|
| 528 |
+
# Storages
|
| 529 |
+
storages = pd.DataFrame([
|
| 530 |
+
{"storage_id": "WH-HQ", "plant_id": "HQ", "storage_name": "๋ณธ์ฌ ์ค์์ฐฝ๊ณ ", "capacity": 10000},
|
| 531 |
+
{"storage_id": "WH-PH", "plant_id": "PH", "storage_name": "ํฌํญ MRO์ฐฝ๊ณ ", "capacity": 5000},
|
| 532 |
+
{"storage_id": "WH-GY", "plant_id": "GY", "storage_name": "๊ด์ MRO์ฐฝ๊ณ ", "capacity": 5000},
|
| 533 |
+
])
|
| 534 |
+
|
| 535 |
+
# Inventory with realistic levels
|
| 536 |
+
inventory = []
|
| 537 |
+
for st_idx, st_row in storages.iterrows():
|
| 538 |
+
sampled_items = items.sample(min(25, len(items)))
|
| 539 |
+
for _, item in sampled_items.iterrows():
|
| 540 |
+
stock_level = random.randint(10, 100)
|
| 541 |
+
safety_stock = int(stock_level * 0.2)
|
| 542 |
+
inventory.append({
|
| 543 |
+
"storage_id": st_row["storage_id"],
|
| 544 |
+
"item_id": item["item_id"],
|
| 545 |
+
"on_hand": stock_level,
|
| 546 |
+
"safety_stock": safety_stock,
|
| 547 |
+
"reserved": random.randint(0, min(5, stock_level)),
|
| 548 |
+
"last_updated": (datetime.now() - timedelta(days=random.randint(1, 30))).strftime("%Y-%m-%d"),
|
| 549 |
+
})
|
| 550 |
+
inventory = pd.DataFrame(inventory)
|
| 551 |
+
|
| 552 |
+
# Suppliers with real names
|
| 553 |
+
suppliers = pd.DataFrame([
|
| 554 |
+
{
|
| 555 |
+
"supplier_id": f"SUP-{i:03d}",
|
| 556 |
+
"supplier_name": sup["name"],
|
| 557 |
+
"supplier_type": sup["type"],
|
| 558 |
+
"rating": round(3.5 + random.random() * 1.5, 1),
|
| 559 |
+
"esg_level": sup["esg"],
|
| 560 |
+
"specialty": sup["specialty"],
|
| 561 |
+
"region": sup["type"],
|
| 562 |
+
"payment_terms": random.choice(["NET30", "NET45", "NET60"]),
|
| 563 |
+
"established_year": random.randint(1990, 2020),
|
| 564 |
+
}
|
| 565 |
+
for i, sup in enumerate(REAL_SUPPLIERS, 1)
|
| 566 |
+
])
|
| 567 |
+
|
| 568 |
+
# Supplier offers with realistic pricing
|
| 569 |
+
offers = []
|
| 570 |
+
for _, item in items.iterrows():
|
| 571 |
+
num_suppliers = random.randint(3, 4)
|
| 572 |
+
selected_sups = suppliers.sample(min(num_suppliers, len(suppliers)))
|
| 573 |
+
|
| 574 |
+
base_price = 10000 + random.randint(0, 90000)
|
| 575 |
+
|
| 576 |
+
for rank, (_, sup) in enumerate(selected_sups.iterrows()):
|
| 577 |
+
price_multiplier = 1.0 + (rank * 0.05) + random.uniform(-0.1, 0.1)
|
| 578 |
+
|
| 579 |
+
offers.append({
|
| 580 |
+
"item_id": item["item_id"],
|
| 581 |
+
"supplier_id": sup["supplier_id"],
|
| 582 |
+
"unit_price": int(base_price * price_multiplier),
|
| 583 |
+
"lead_time_days": 3 + rank * 2 + random.randint(0, 5),
|
| 584 |
+
"moq": [10, 20, 50, 100][rank % 4],
|
| 585 |
+
"contract_type": random.choice(["๋จ๊ฐ๊ณ์ฝ", "์ฅ๊ธฐ๊ณ์ฝ", "์คํ"]),
|
| 586 |
+
"discount_rate": round(random.random() * 0.1, 2) if rank == 0 else 0,
|
| 587 |
+
"quality_grade": random.choice(["A", "A", "B", "C"]),
|
| 588 |
+
})
|
| 589 |
+
supplier_offers = pd.DataFrame(offers)
|
| 590 |
+
|
| 591 |
+
# Policies
|
| 592 |
+
policies = pd.DataFrame([
|
| 593 |
+
{
|
| 594 |
+
"policy_id": "R-001",
|
| 595 |
+
"rule_name": "๊ท์ ํ๋ชฉ ํด์ธ๊ตฌ๋งค ์ ํ",
|
| 596 |
+
"rule_logic": "IF item.risk_class == '๊ท์ ' AND supplier.region == 'ํด์ธ' THEN block",
|
| 597 |
+
"severity": "์ฐจ๋จ",
|
| 598 |
+
"department": "๋ฒ๋ฌดํ"
|
| 599 |
+
},
|
| 600 |
+
{
|
| 601 |
+
"policy_id": "R-002",
|
| 602 |
+
"rule_name": "์์ ์ฌ๊ณ ๋ฏธ๋ง ๊ธด๊ธ๋ฐ์ฃผ",
|
| 603 |
+
"rule_logic": "IF (on_hand - reserved) < safety_stock THEN expedite",
|
| 604 |
+
"severity": "๊ฒฝ๊ณ ",
|
| 605 |
+
"department": "MROํ"
|
| 606 |
+
},
|
| 607 |
+
{
|
| 608 |
+
"policy_id": "R-003",
|
| 609 |
+
"rule_name": "๊ธด๊ธ์ค๋น ์ฐ์ ๋ฐฐ๋ถ",
|
| 610 |
+
"rule_logic": "IF equipment.criticality == '๊ธด๊ธ' THEN priority",
|
| 611 |
+
"severity": "์ฐ์ ์์",
|
| 612 |
+
"department": "์์ฐํ"
|
| 613 |
+
},
|
| 614 |
+
{
|
| 615 |
+
"policy_id": "R-004",
|
| 616 |
+
"rule_name": "ESG C๋ฑ๊ธ ์ ํ",
|
| 617 |
+
"rule_logic": "IF supplier.esg_level == 'C' THEN penalize",
|
| 618 |
+
"severity": "ํจ๋ํฐ",
|
| 619 |
+
"department": "๊ตฌ๋งคํ"
|
| 620 |
+
},
|
| 621 |
+
])
|
| 622 |
+
|
| 623 |
+
# Purchase history
|
| 624 |
+
purchase_history = []
|
| 625 |
+
for i in range(200):
|
| 626 |
+
item = items.sample(1).iloc[0]
|
| 627 |
+
supplier = suppliers.sample(1).iloc[0]
|
| 628 |
+
qty = random.randint(10, 100)
|
| 629 |
+
price = random.randint(10000, 100000)
|
| 630 |
+
|
| 631 |
+
purchase_history.append({
|
| 632 |
+
"po_id": f"PO-2024-{10000 + i}",
|
| 633 |
+
"date": (datetime.now() - timedelta(days=random.randint(1, 365))).strftime("%Y-%m-%d"),
|
| 634 |
+
"item_id": item["item_id"],
|
| 635 |
+
"supplier_id": supplier["supplier_id"],
|
| 636 |
+
"qty": qty,
|
| 637 |
+
"unit_price": price,
|
| 638 |
+
"total_amount": qty * price,
|
| 639 |
+
"delivery_status": random.choice(["์๋ฃ", "์๋ฃ", "์๋ฃ", "์ง์ฐ", "์งํ์ค"]),
|
| 640 |
+
})
|
| 641 |
+
purchase_history = pd.DataFrame(purchase_history)
|
| 642 |
+
|
| 643 |
+
return {
|
| 644 |
+
"plants": plants,
|
| 645 |
+
"equipment": equipment,
|
| 646 |
+
"items": items,
|
| 647 |
+
"compat": compat,
|
| 648 |
+
"storages": storages,
|
| 649 |
+
"inventory": inventory,
|
| 650 |
+
"suppliers": suppliers,
|
| 651 |
+
"supplier_offers": supplier_offers,
|
| 652 |
+
"policies": policies,
|
| 653 |
+
"purchase_history": purchase_history
|
| 654 |
+
}
|
| 655 |
+
|
| 656 |
+
def validate_tables(tables: Dict[str, pd.DataFrame]) -> Tuple[bool, List[str]]:
|
| 657 |
+
"""Validate tables"""
|
| 658 |
+
required = ["plants", "equipment", "items", "compat", "storages", "inventory",
|
| 659 |
+
"suppliers", "supplier_offers", "policies", "purchase_history"]
|
| 660 |
+
|
| 661 |
+
issues = []
|
| 662 |
+
for k in required:
|
| 663 |
+
if k not in tables:
|
| 664 |
+
issues.append(f"Missing: {k}")
|
| 665 |
+
elif not isinstance(tables[k], pd.DataFrame):
|
| 666 |
+
issues.append(f"Invalid type: {k}")
|
| 667 |
+
elif len(tables[k]) == 0:
|
| 668 |
+
issues.append(f"Empty: {k}")
|
| 669 |
+
|
| 670 |
+
return len(issues) == 0, issues
|
| 671 |
+
|
| 672 |
+
# =========================================================
|
| 673 |
+
# Plotly Dashboard Functions
|
| 674 |
+
# =========================================================
|
| 675 |
+
def create_mro_inventory_dashboard(inv_df: pd.DataFrame, item_name: str) -> go.Figure:
|
| 676 |
+
"""MRO ์ฌ๊ณ ํํฉ ๋์๋ณด๋"""
|
| 677 |
+
if len(inv_df) == 0:
|
| 678 |
+
fig = go.Figure()
|
| 679 |
+
fig.add_annotation(text="์ฌ๊ณ ๋ฐ์ดํฐ ์์", showarrow=False, font_size=20)
|
| 680 |
+
fig.update_layout(height=700, title_text="์ฌ๊ณ ์ ๋ณด ์์")
|
| 681 |
+
return fig
|
| 682 |
+
|
| 683 |
+
# ์๋ธํ๋กฏ ์์ฑ
|
| 684 |
+
fig = make_subplots(
|
| 685 |
+
rows=2, cols=2,
|
| 686 |
+
subplot_titles=('์ฐฝ๊ณ ๋ณ ์ฌ๊ณ ํํฉ', '์์ ์ฌ๊ณ ๋๋น ํ์ฌ๊ณ ', '์ฌ๊ณ ์ํ', '์ฐฝ๊ณ ๋ณ ์ ์ ์จ'),
|
| 687 |
+
specs=[[{"type": "bar"}, {"type": "indicator"}],
|
| 688 |
+
[{"type": "pie"}, {"type": "table"}]]
|
| 689 |
+
)
|
| 690 |
+
|
| 691 |
+
# 1. ์ฐฝ๊ณ ๋ณ ์ฌ๊ณ ๋ฐ ์ฐจํธ
|
| 692 |
+
fig.add_trace(
|
| 693 |
+
go.Bar(
|
| 694 |
+
x=inv_df['storage_name'],
|
| 695 |
+
y=inv_df['on_hand'],
|
| 696 |
+
name='ํ์ฌ๊ณ ',
|
| 697 |
+
marker_color='lightblue',
|
| 698 |
+
text=inv_df['on_hand'],
|
| 699 |
+
textposition='auto',
|
| 700 |
+
),
|
| 701 |
+
row=1, col=1
|
| 702 |
+
)
|
| 703 |
+
|
| 704 |
+
fig.add_trace(
|
| 705 |
+
go.Bar(
|
| 706 |
+
x=inv_df['storage_name'],
|
| 707 |
+
y=inv_df['safety_stock'],
|
| 708 |
+
name='์์ ์ฌ๊ณ ',
|
| 709 |
+
marker_color='orange',
|
| 710 |
+
text=inv_df['safety_stock'],
|
| 711 |
+
textposition='auto',
|
| 712 |
+
),
|
| 713 |
+
row=1, col=1
|
| 714 |
+
)
|
| 715 |
+
|
| 716 |
+
# 2. ์ด ์ฌ๊ณ ๊ฒ์ด์ง
|
| 717 |
+
total_stock = inv_df['on_hand'].sum()
|
| 718 |
+
total_safety = inv_df['safety_stock'].sum()
|
| 719 |
+
|
| 720 |
+
fig.add_trace(
|
| 721 |
+
go.Indicator(
|
| 722 |
+
mode="gauge+number+delta",
|
| 723 |
+
value=total_stock,
|
| 724 |
+
delta={'reference': total_safety, 'increasing': {'color': "green"}},
|
| 725 |
+
title={'text': f"์ด ์ฌ๊ณ ๋<br><sub>{item_name}</sub>"},
|
| 726 |
+
gauge={
|
| 727 |
+
'axis': {'range': [0, total_safety * 2]},
|
| 728 |
+
'bar': {'color': "darkblue"},
|
| 729 |
+
'steps': [
|
| 730 |
+
{'range': [0, total_safety], 'color': "lightgray"},
|
| 731 |
+
{'range': [total_safety, total_safety * 1.5], 'color': "lightgreen"}
|
| 732 |
+
],
|
| 733 |
+
'threshold': {
|
| 734 |
+
'line': {'color': "red", 'width': 4},
|
| 735 |
+
'thickness': 0.75,
|
| 736 |
+
'value': total_safety
|
| 737 |
+
}
|
| 738 |
+
}
|
| 739 |
+
),
|
| 740 |
+
row=1, col=2
|
| 741 |
+
)
|
| 742 |
+
|
| 743 |
+
# 3. ์ฌ๊ณ ์ํ ํ์ด ์ฐจํธ
|
| 744 |
+
inv_df['available'] = inv_df['on_hand'] - inv_df['reserved']
|
| 745 |
+
|
| 746 |
+
fig.add_trace(
|
| 747 |
+
go.Pie(
|
| 748 |
+
labels=['๊ฐ์ฉ์ฌ๊ณ ', '์์ฝ๋จ', '์์ ์ฌ๊ณ '],
|
| 749 |
+
values=[
|
| 750 |
+
inv_df['available'].sum(),
|
| 751 |
+
inv_df['reserved'].sum(),
|
| 752 |
+
max(0, total_safety - inv_df['available'].sum())
|
| 753 |
+
],
|
| 754 |
+
marker_colors=['green', 'orange', 'red'],
|
| 755 |
+
hole=0.3,
|
| 756 |
+
),
|
| 757 |
+
row=2, col=1
|
| 758 |
+
)
|
| 759 |
+
|
| 760 |
+
# 4. ์์ธ ํ
์ด๋ธ
|
| 761 |
+
fig.add_trace(
|
| 762 |
+
go.Table(
|
| 763 |
+
header=dict(
|
| 764 |
+
values=['์ฐฝ๊ณ ', 'ํ์ฌ๊ณ ', '์์ ์ฌ๊ณ ', '์์ฝ', '๊ฐ์ฉ'],
|
| 765 |
+
fill_color='paleturquoise',
|
| 766 |
+
align='left'
|
| 767 |
+
),
|
| 768 |
+
cells=dict(
|
| 769 |
+
values=[
|
| 770 |
+
inv_df['storage_name'],
|
| 771 |
+
inv_df['on_hand'],
|
| 772 |
+
inv_df['safety_stock'],
|
| 773 |
+
inv_df['reserved'],
|
| 774 |
+
inv_df['available']
|
| 775 |
+
],
|
| 776 |
+
fill_color='lavender',
|
| 777 |
+
align='left'
|
| 778 |
+
)
|
| 779 |
+
),
|
| 780 |
+
row=2, col=2
|
| 781 |
+
)
|
| 782 |
+
|
| 783 |
+
fig.update_layout(
|
| 784 |
+
height=700,
|
| 785 |
+
showlegend=True,
|
| 786 |
+
title_text=f"๐ฆ MRO ์ฌ๊ณ ๋ถ์ ๋์๋ณด๋ - {item_name}",
|
| 787 |
+
title_font_size=20
|
| 788 |
+
)
|
| 789 |
+
|
| 790 |
+
return fig
|
| 791 |
+
|
| 792 |
+
def create_mro_workflow_status(equipment_info: Dict, compat_items: pd.DataFrame) -> go.Figure:
|
| 793 |
+
"""MRO ์ํฌํ๋ก์ฐ ์ํ ์๊ฐํ"""
|
| 794 |
+
fig = go.Figure()
|
| 795 |
+
|
| 796 |
+
# ์ํฌํ๋ก์ฐ ๋จ๊ณ
|
| 797 |
+
steps = [
|
| 798 |
+
"์ค๋น ํ์ธ",
|
| 799 |
+
"ํธํ๋ถํ ์กฐํ",
|
| 800 |
+
"์ฌ๊ณ ํ์ธ",
|
| 801 |
+
"์์ ๊ฒ์ฆ",
|
| 802 |
+
"๋ฐ์ฃผ ์์ฒญ"
|
| 803 |
+
]
|
| 804 |
+
|
| 805 |
+
statuses = ["์๋ฃ", "์๋ฃ", "์งํ์ค", "๋๊ธฐ", "๋๊ธฐ"]
|
| 806 |
+
colors = ["green", "green", "orange", "gray", "gray"]
|
| 807 |
+
|
| 808 |
+
# Funnel ์ฐจํธ๋ก ์ํฌํ๋ก์ฐ ํํ
|
| 809 |
+
fig.add_trace(go.Funnel(
|
| 810 |
+
y=steps,
|
| 811 |
+
x=[100, 80, 60, 40, 20],
|
| 812 |
+
textposition="inside",
|
| 813 |
+
textinfo="label+percent initial",
|
| 814 |
+
marker={"color": colors},
|
| 815 |
+
connector={"line": {"color": "royalblue", "width": 3}}
|
| 816 |
+
))
|
| 817 |
+
|
| 818 |
+
equipment_name = equipment_info.get('equipment_name', 'N/A') if equipment_info else 'N/A'
|
| 819 |
+
|
| 820 |
+
fig.update_layout(
|
| 821 |
+
title_text=f"๐ MRO ์ํฌํ๋ก์ฐ ์งํ ์ํ<br><sub>์ค๋น: {equipment_name}</sub>",
|
| 822 |
+
height=400,
|
| 823 |
+
showlegend=False
|
| 824 |
+
)
|
| 825 |
+
|
| 826 |
+
return fig
|
| 827 |
+
|
| 828 |
+
def create_procurement_comparison_dashboard(offers_df: pd.DataFrame, rules_eval: Dict) -> go.Figure:
|
| 829 |
+
"""๊ตฌ๋งค ๋ด๋น์ - ๊ณต๊ธ์
์ฒด ๋น๊ต ๋์๋ณด๋"""
|
| 830 |
+
if len(offers_df) == 0:
|
| 831 |
+
fig = go.Figure()
|
| 832 |
+
fig.add_annotation(text="๊ณต๊ธ์
์ฒด ๋ฐ์ดํฐ ์์", showarrow=False, font_size=20)
|
| 833 |
+
fig.update_layout(height=700, title_text="๊ณต๊ธ์
์ฒด ์ ๋ณด ์์")
|
| 834 |
+
return fig
|
| 835 |
+
|
| 836 |
+
# ์๋ธํ๋กฏ
|
| 837 |
+
fig = make_subplots(
|
| 838 |
+
rows=2, cols=2,
|
| 839 |
+
subplot_titles=(
|
| 840 |
+
'๐ฐ ๊ฐ๊ฒฉ ๋น๊ต',
|
| 841 |
+
'โฑ๏ธ ๋ฉ๊ธฐ ๋น๊ต',
|
| 842 |
+
'๐ ESG ๋ฑ๊ธ ๋ถํฌ',
|
| 843 |
+
'๐ฏ ์ข
ํฉ ํ๊ฐ'
|
| 844 |
+
),
|
| 845 |
+
specs=[
|
| 846 |
+
[{"type": "bar"}, {"type": "scatter"}],
|
| 847 |
+
[{"type": "pie"}, {"type": "table"}]
|
| 848 |
+
]
|
| 849 |
+
)
|
| 850 |
+
|
| 851 |
+
# ๊ท์น ํ๊ฐ ๊ฒฐ๊ณผ ์ถ๊ฐ
|
| 852 |
+
offers_df['blocked'] = offers_df['supplier_id'].apply(
|
| 853 |
+
lambda x: rules_eval.get(x, {}).get('block', False)
|
| 854 |
+
)
|
| 855 |
+
offers_df['color'] = offers_df['blocked'].apply(lambda x: 'red' if x else 'green')
|
| 856 |
+
|
| 857 |
+
# 1. ๊ฐ๊ฒฉ ๋น๊ต ๋ฐ ์ฐจํธ
|
| 858 |
+
fig.add_trace(
|
| 859 |
+
go.Bar(
|
| 860 |
+
x=offers_df['supplier_name'],
|
| 861 |
+
y=offers_df['unit_price'],
|
| 862 |
+
marker_color=offers_df['color'],
|
| 863 |
+
text=[f"{p:,}์" for p in offers_df['unit_price']],
|
| 864 |
+
textposition='auto',
|
| 865 |
+
name='๋จ๊ฐ',
|
| 866 |
+
),
|
| 867 |
+
row=1, col=1
|
| 868 |
+
)
|
| 869 |
+
|
| 870 |
+
# 2. ๊ฐ๊ฒฉ-๋ฉ๊ธฐ ์ค์บํฐ
|
| 871 |
+
fig.add_trace(
|
| 872 |
+
go.Scatter(
|
| 873 |
+
x=offers_df['lead_time_days'],
|
| 874 |
+
y=offers_df['unit_price'],
|
| 875 |
+
mode='markers+text',
|
| 876 |
+
marker=dict(
|
| 877 |
+
size=15,
|
| 878 |
+
color=offers_df['color'],
|
| 879 |
+
line=dict(width=2, color='white')
|
| 880 |
+
),
|
| 881 |
+
text=offers_df['supplier_name'],
|
| 882 |
+
textposition="top center",
|
| 883 |
+
name='๊ณต๊ธ์
์ฒด',
|
| 884 |
+
),
|
| 885 |
+
row=1, col=2
|
| 886 |
+
)
|
| 887 |
+
|
| 888 |
+
# 3. ESG ๋ฑ๊ธ ํ์ด
|
| 889 |
+
esg_counts = offers_df['esg_level'].value_counts()
|
| 890 |
+
fig.add_trace(
|
| 891 |
+
go.Pie(
|
| 892 |
+
labels=esg_counts.index,
|
| 893 |
+
values=esg_counts.values,
|
| 894 |
+
marker_colors=['lightgreen', 'lightyellow', 'lightcoral'],
|
| 895 |
+
hole=0.3,
|
| 896 |
+
),
|
| 897 |
+
row=2, col=1
|
| 898 |
+
)
|
| 899 |
+
|
| 900 |
+
# 4. ์ข
ํฉ ํ๊ฐ ํ
์ด๋ธ
|
| 901 |
+
evaluation = offers_df.copy()
|
| 902 |
+
evaluation['์ข
ํฉ์ ์'] = (
|
| 903 |
+
(100 - (evaluation['unit_price'] / evaluation['unit_price'].max() * 50)) +
|
| 904 |
+
(100 - (evaluation['lead_time_days'] / evaluation['lead_time_days'].max() * 30)) +
|
| 905 |
+
evaluation['esg_level'].map({'A': 20, 'B': 10, 'C': 0})
|
| 906 |
+
).round(1)
|
| 907 |
+
evaluation['์์'] = evaluation['์ข
ํฉ์ ์'].rank(ascending=False).astype(int)
|
| 908 |
+
|
| 909 |
+
fig.add_trace(
|
| 910 |
+
go.Table(
|
| 911 |
+
header=dict(
|
| 912 |
+
values=['์์', '๊ณต๊ธ์
์ฒด', '๋จ๊ฐ', '๋ฉ๊ธฐ', 'ESG', '์ ์'],
|
| 913 |
+
fill_color='paleturquoise',
|
| 914 |
+
align='center'
|
| 915 |
+
),
|
| 916 |
+
cells=dict(
|
| 917 |
+
values=[
|
| 918 |
+
evaluation['์์'],
|
| 919 |
+
evaluation['supplier_name'],
|
| 920 |
+
[f"{p:,}" for p in evaluation['unit_price']],
|
| 921 |
+
[f"{d}์ผ" for d in evaluation['lead_time_days']],
|
| 922 |
+
evaluation['esg_level'],
|
| 923 |
+
evaluation['์ข
ํฉ์ ์']
|
| 924 |
+
],
|
| 925 |
+
fill_color=[['white' if not b else 'lightcoral' for b in evaluation['blocked']]],
|
| 926 |
+
align='center'
|
| 927 |
+
)
|
| 928 |
+
),
|
| 929 |
+
row=2, col=2
|
| 930 |
+
)
|
| 931 |
+
|
| 932 |
+
fig.update_layout(
|
| 933 |
+
height=700,
|
| 934 |
+
showlegend=False,
|
| 935 |
+
title_text="๐ ๊ณต๊ธ์
์ฒด ์ข
ํฉ ๋น๊ต ๋์๋ณด๋",
|
| 936 |
+
title_font_size=20
|
| 937 |
+
)
|
| 938 |
+
|
| 939 |
+
fig.update_xaxes(title_text="๋ฉ๊ธฐ (์ผ)", row=1, col=2)
|
| 940 |
+
fig.update_yaxes(title_text="๋จ๊ฐ (์)", row=1, col=2)
|
| 941 |
+
|
| 942 |
+
return fig
|
| 943 |
+
|
| 944 |
+
def create_procurement_workflow(opt_result: Dict) -> go.Figure:
|
| 945 |
+
"""๊ตฌ๋งค ์ํฌํ๋ก์ฐ ์งํ ์ํ"""
|
| 946 |
+
fig = go.Figure()
|
| 947 |
+
|
| 948 |
+
# ์ํฌํ๋ก์ฐ ๋จ๊ณ์ ์ํ
|
| 949 |
+
workflow_steps = [
|
| 950 |
+
{"step": "1. ์์ ์ ์", "status": "์๋ฃ", "time": "10๋ถ"},
|
| 951 |
+
{"step": "2. ๊ณต๊ธ์
์ฒด ์กฐํ", "status": "์๋ฃ", "time": "5๋ถ"},
|
| 952 |
+
{"step": "3. ๊ท์ ๊ฒ์ฆ", "status": "์๋ฃ", "time": "2๋ถ"},
|
| 953 |
+
{"step": "4. ์ต์ ํ ๋ถ์", "status": "์๋ฃ", "time": "3๋ถ"},
|
| 954 |
+
{"step": "5. ๋ฐ์ฃผ ์น์ธ", "status": "๋๊ธฐ์ค", "time": "-"},
|
| 955 |
+
{"step": "6. PO ๋ฐํ", "status": "๋๊ธฐ์ค", "time": "-"},
|
| 956 |
+
]
|
| 957 |
+
|
| 958 |
+
# Progress Bar ์คํ์ผ
|
| 959 |
+
y_pos = list(range(len(workflow_steps)))
|
| 960 |
+
colors = []
|
| 961 |
+
for step_info in workflow_steps:
|
| 962 |
+
if step_info["status"] == "์๋ฃ":
|
| 963 |
+
colors.append("lightgreen")
|
| 964 |
+
elif step_info["status"] == "์งํ์ค":
|
| 965 |
+
colors.append("lightyellow")
|
| 966 |
+
else:
|
| 967 |
+
colors.append("lightgray")
|
| 968 |
+
|
| 969 |
+
fig.add_trace(go.Bar(
|
| 970 |
+
y=[s["step"] for s in workflow_steps],
|
| 971 |
+
x=[100 if s["status"] == "์๋ฃ" else 50 if s["status"] == "์งํ์ค" else 0
|
| 972 |
+
for s in workflow_steps],
|
| 973 |
+
orientation='h',
|
| 974 |
+
marker=dict(color=colors),
|
| 975 |
+
text=[f"{s['status']} ({s['time']})" for s in workflow_steps],
|
| 976 |
+
textposition='auto',
|
| 977 |
+
))
|
| 978 |
+
|
| 979 |
+
fig.update_layout(
|
| 980 |
+
title_text="๐ ๊ตฌ๋งค ์ํฌํ๋ก์ฐ ์งํ ํํฉ",
|
| 981 |
+
xaxis_title="์งํ๋ฅ (%)",
|
| 982 |
+
height=400,
|
| 983 |
+
showlegend=False
|
| 984 |
+
)
|
| 985 |
+
|
| 986 |
+
return fig
|
| 987 |
+
|
| 988 |
+
def create_executive_kpi_dashboard(
|
| 989 |
+
opt_result: Dict,
|
| 990 |
+
offers_df: pd.DataFrame,
|
| 991 |
+
purchase_history: pd.DataFrame
|
| 992 |
+
) -> go.Figure:
|
| 993 |
+
"""๊ฒฝ์์ง KPI ๋์๋ณด๋"""
|
| 994 |
+
|
| 995 |
+
fig = make_subplots(
|
| 996 |
+
rows=2, cols=3,
|
| 997 |
+
subplot_titles=(
|
| 998 |
+
'๐ฐ ๋น์ฉ ์ ๊ฐ',
|
| 999 |
+
'โ๏ธ ์ปดํ๋ผ์ด์ธ์ค',
|
| 1000 |
+
'๐ ESG ์ ์',
|
| 1001 |
+
'โฑ๏ธ ์ฒ๋ฆฌ ์๊ฐ',
|
| 1002 |
+
'๐ฏ ๋ชฉํ ๋ฌ์ฑ๋ฅ ',
|
| 1003 |
+
'๐ ์๊ฐ ํธ๋ ๋'
|
| 1004 |
+
),
|
| 1005 |
+
specs=[
|
| 1006 |
+
[{"type": "indicator"}, {"type": "indicator"}, {"type": "indicator"}],
|
| 1007 |
+
[{"type": "indicator"}, {"type": "indicator"}, {"type": "scatter"}]
|
| 1008 |
+
]
|
| 1009 |
+
)
|
| 1010 |
+
|
| 1011 |
+
# 1. ๋น์ฉ ์ ๊ฐ
|
| 1012 |
+
if len(offers_df) > 0:
|
| 1013 |
+
min_price = offers_df['unit_price'].min()
|
| 1014 |
+
max_price = offers_df['unit_price'].max()
|
| 1015 |
+
savings = ((max_price - min_price) / max_price * 100) if max_price > 0 else 0
|
| 1016 |
+
else:
|
| 1017 |
+
savings = 0
|
| 1018 |
+
|
| 1019 |
+
fig.add_trace(
|
| 1020 |
+
go.Indicator(
|
| 1021 |
+
mode="gauge+number+delta",
|
| 1022 |
+
value=savings,
|
| 1023 |
+
title={'text': "๋น์ฉ ์ ๊ฐ๋ฅ (%)"},
|
| 1024 |
+
delta={'reference': 10},
|
| 1025 |
+
gauge={
|
| 1026 |
+
'axis': {'range': [0, 50]},
|
| 1027 |
+
'bar': {'color': "darkblue"},
|
| 1028 |
+
'steps': [
|
| 1029 |
+
{'range': [0, 10], 'color': "lightgray"},
|
| 1030 |
+
{'range': [10, 25], 'color': "lightgreen"},
|
| 1031 |
+
{'range': [25, 50], 'color': "green"}
|
| 1032 |
+
],
|
| 1033 |
+
'threshold': {
|
| 1034 |
+
'line': {'color': "red", 'width': 4},
|
| 1035 |
+
'thickness': 0.75,
|
| 1036 |
+
'value': 15
|
| 1037 |
+
}
|
| 1038 |
+
}
|
| 1039 |
+
),
|
| 1040 |
+
row=1, col=1
|
| 1041 |
+
)
|
| 1042 |
+
|
| 1043 |
+
# 2. ์ปดํ๋ผ์ด์ธ์ค ์ค์์จ
|
| 1044 |
+
fig.add_trace(
|
| 1045 |
+
go.Indicator(
|
| 1046 |
+
mode="gauge+number",
|
| 1047 |
+
value=100,
|
| 1048 |
+
title={'text': "๊ท์ ์ค์์จ (%)"},
|
| 1049 |
+
gauge={
|
| 1050 |
+
'axis': {'range': [0, 100]},
|
| 1051 |
+
'bar': {'color': "green"},
|
| 1052 |
+
'steps': [
|
| 1053 |
+
{'range': [0, 80], 'color': "lightcoral"},
|
| 1054 |
+
{'range': [80, 95], 'color': "lightyellow"},
|
| 1055 |
+
{'range': [95, 100], 'color': "lightgreen"}
|
| 1056 |
+
]
|
| 1057 |
+
}
|
| 1058 |
+
),
|
| 1059 |
+
row=1, col=2
|
| 1060 |
+
)
|
| 1061 |
+
|
| 1062 |
+
# 3. ESG ํ๊ท ์ ์
|
| 1063 |
+
if len(offers_df) > 0:
|
| 1064 |
+
esg_score = offers_df['esg_level'].map({'A': 100, 'B': 70, 'C': 40}).mean()
|
| 1065 |
+
else:
|
| 1066 |
+
esg_score = 0
|
| 1067 |
+
|
| 1068 |
+
fig.add_trace(
|
| 1069 |
+
go.Indicator(
|
| 1070 |
+
mode="gauge+number",
|
| 1071 |
+
value=esg_score,
|
| 1072 |
+
title={'text': "ESG ํ๊ท ์ ์"},
|
| 1073 |
+
gauge={
|
| 1074 |
+
'axis': {'range': [0, 100]},
|
| 1075 |
+
'bar': {'color': "darkgreen"},
|
| 1076 |
+
'steps': [
|
| 1077 |
+
{'range': [0, 50], 'color': "lightcoral"},
|
| 1078 |
+
{'range': [50, 80], 'color': "lightyellow"},
|
| 1079 |
+
{'range': [80, 100], 'color': "lightgreen"}
|
| 1080 |
+
]
|
| 1081 |
+
}
|
| 1082 |
+
),
|
| 1083 |
+
row=1, col=3
|
| 1084 |
+
)
|
| 1085 |
+
|
| 1086 |
+
# 4. ํ๊ท ์ฒ๋ฆฌ ์๊ฐ
|
| 1087 |
+
fig.add_trace(
|
| 1088 |
+
go.Indicator(
|
| 1089 |
+
mode="number+delta",
|
| 1090 |
+
value=20,
|
| 1091 |
+
title={'text': "์ฒ๋ฆฌ ์๊ฐ (๋ถ)"},
|
| 1092 |
+
delta={'reference': 30, 'increasing': {'color': "red"}, 'decreasing': {'color': "green"}},
|
| 1093 |
+
number={'suffix': "๋ถ"}
|
| 1094 |
+
),
|
| 1095 |
+
row=2, col=1
|
| 1096 |
+
)
|
| 1097 |
+
|
| 1098 |
+
# 5. ๋ชฉํ ๋ฌ์ฑ๋ฅ
|
| 1099 |
+
fig.add_trace(
|
| 1100 |
+
go.Indicator(
|
| 1101 |
+
mode="gauge+number",
|
| 1102 |
+
value=85,
|
| 1103 |
+
title={'text': "์๊ฐ ๋ชฉํ ๋ฌ์ฑ๋ฅ (%)"},
|
| 1104 |
+
gauge={
|
| 1105 |
+
'axis': {'range': [0, 100]},
|
| 1106 |
+
'bar': {'color': "royalblue"},
|
| 1107 |
+
'threshold': {
|
| 1108 |
+
'line': {'color': "red", 'width': 4},
|
| 1109 |
+
'thickness': 0.75,
|
| 1110 |
+
'value': 80
|
| 1111 |
+
}
|
| 1112 |
+
}
|
| 1113 |
+
),
|
| 1114 |
+
row=2, col=2
|
| 1115 |
+
)
|
| 1116 |
+
|
| 1117 |
+
# 6. ์๊ฐ ํธ๋ ๋
|
| 1118 |
+
months = ['1์', '2์', '3์', '4์', '5์', '6์']
|
| 1119 |
+
values = [75, 78, 82, 85, 88, 90]
|
| 1120 |
+
|
| 1121 |
+
fig.add_trace(
|
| 1122 |
+
go.Scatter(
|
| 1123 |
+
x=months,
|
| 1124 |
+
y=values,
|
| 1125 |
+
mode='lines+markers',
|
| 1126 |
+
name='๋ฐ์ฃผ ํจ์จ',
|
| 1127 |
+
line=dict(color='royalblue', width=3),
|
| 1128 |
+
marker=dict(size=10)
|
| 1129 |
+
),
|
| 1130 |
+
row=2, col=3
|
| 1131 |
+
)
|
| 1132 |
+
|
| 1133 |
+
fig.update_layout(
|
| 1134 |
+
height=700,
|
| 1135 |
+
showlegend=False,
|
| 1136 |
+
title_text="๐ ๊ฒฝ์์ง KPI ๋์๋ณด๋",
|
| 1137 |
+
title_font_size=22
|
| 1138 |
+
)
|
| 1139 |
+
|
| 1140 |
+
return fig
|
| 1141 |
+
|
| 1142 |
+
def create_action_items_table(opt_result: Dict, offers_df: pd.DataFrame) -> pd.DataFrame:
|
| 1143 |
+
"""๊ฒฝ์์ง Action Items ์์ฑ"""
|
| 1144 |
+
|
| 1145 |
+
action_items = []
|
| 1146 |
+
|
| 1147 |
+
# 1. ์ฆ์ ๋ฐ์ฃผ ์น์ธ ํญ๋ชฉ
|
| 1148 |
+
alloc = opt_result.get('allocation', {})
|
| 1149 |
+
if alloc:
|
| 1150 |
+
for supplier_id, details in alloc.items():
|
| 1151 |
+
if isinstance(details, dict):
|
| 1152 |
+
action_items.append({
|
| 1153 |
+
"์ฐ์ ์์": "๐ด ๊ธด๊ธ",
|
| 1154 |
+
"Action Item": f"{details.get('supplier_name')} ๋ฐ์ฃผ ์น์ธ",
|
| 1155 |
+
"์๋": f"{details.get('qty')}๊ฐ",
|
| 1156 |
+
"์์ ๋น์ฉ": f"{details.get('qty', 0) * details.get('unit_price', 0):,}์",
|
| 1157 |
+
"๋ด๋น": "๊ตฌ๋งคํ",
|
| 1158 |
+
"๊ธฐํ": "์ฆ์",
|
| 1159 |
+
"์ํ": "์น์ธ ๋๊ธฐ"
|
| 1160 |
+
})
|
| 1161 |
+
|
| 1162 |
+
# 2. ์ฌ๊ณ ๋ณด์ถฉ ๊ถ๊ณ
|
| 1163 |
+
action_items.append({
|
| 1164 |
+
"์ฐ์ ์์": "๐ก ์ค์",
|
| 1165 |
+
"Action Item": "์์ ์ฌ๊ณ ๋ฏธ๋ฌ ํ๋ชฉ ๋ณด์ถฉ",
|
| 1166 |
+
"์๋": "3๊ฐ ํ๋ชฉ",
|
| 1167 |
+
"์์ ๋น์ฉ": "๊ฒํ ํ์",
|
| 1168 |
+
"๋ด๋น": "MROํ",
|
| 1169 |
+
"๊ธฐํ": "1์ฃผ์ผ ๋ด",
|
| 1170 |
+
"์ํ": "๊ฒํ ์ค"
|
| 1171 |
+
})
|
| 1172 |
+
|
| 1173 |
+
# 3. ESG ๊ฐ์
|
| 1174 |
+
if len(offers_df) > 0:
|
| 1175 |
+
c_grade_count = len(offers_df[offers_df['esg_level'] == 'C'])
|
| 1176 |
+
if c_grade_count > 0:
|
| 1177 |
+
action_items.append({
|
| 1178 |
+
"์ฐ์ ์์": "๐ข ๋ณดํต",
|
| 1179 |
+
"Action Item": "ESG C๋ฑ๊ธ ๊ณต๊ธ์
์ฒด ๋์ฒด ๊ฒํ ",
|
| 1180 |
+
"์๋": f"{c_grade_count}๊ฐ์ฌ",
|
| 1181 |
+
"์์ ๋น์ฉ": "์ํฅ๋ ๋ถ์ ํ์",
|
| 1182 |
+
"๋ด๋น": "๊ตฌ๋งคํ",
|
| 1183 |
+
"๊ธฐํ": "1๊ฐ์ ๋ด",
|
| 1184 |
+
"์ํ": "๊ณํ ๋จ๊ณ"
|
| 1185 |
+
})
|
| 1186 |
+
|
| 1187 |
+
# 4. ์ฅ๊ธฐ ๊ณ์ฝ ํ์
|
| 1188 |
+
action_items.append({
|
| 1189 |
+
"์ฐ์ ์์": "๐ข ๋ณดํต",
|
| 1190 |
+
"Action Item": "์ฃผ์ ๊ณต๊ธ์
์ฒด ์ฅ๊ธฐ๊ณ์ฝ ํ์",
|
| 1191 |
+
"์๋": "2-3๊ฐ์ฌ",
|
| 1192 |
+
"์์ ๋น์ฉ": "5-10% ์ ๊ฐ ์์",
|
| 1193 |
+
"๋ด๋น": "๊ตฌ๋งคํ",
|
| 1194 |
+
"๊ธฐํ": "๋ถ๊ธฐ ๋ด",
|
| 1195 |
+
"์ํ": "๊ณํ ๋จ๊ณ"
|
| 1196 |
+
})
|
| 1197 |
+
|
| 1198 |
+
return pd.DataFrame(action_items)
|
| 1199 |
+
|
| 1200 |
+
# =========================================================
|
| 1201 |
+
# Core Components
|
| 1202 |
+
# =========================================================
|
| 1203 |
+
@dataclass
|
| 1204 |
+
class ToolCallLog:
|
| 1205 |
+
ts: str
|
| 1206 |
+
actor: str
|
| 1207 |
+
tool: str
|
| 1208 |
+
input: Dict[str, Any]
|
| 1209 |
+
output_preview: str
|
| 1210 |
+
|
| 1211 |
+
class MCPToolRegistry:
|
| 1212 |
+
def __init__(self, tables: Dict[str, pd.DataFrame]):
|
| 1213 |
+
self.tables = tables
|
| 1214 |
+
self.logs: List[ToolCallLog] = []
|
| 1215 |
+
|
| 1216 |
+
def _log(self, actor: str, tool: str, inp: Dict[str, Any], out: Any):
|
| 1217 |
+
self.logs.append(ToolCallLog(
|
| 1218 |
+
ts=now_ts(),
|
| 1219 |
+
actor=actor,
|
| 1220 |
+
tool=tool,
|
| 1221 |
+
input=inp,
|
| 1222 |
+
output_preview=str(out)[:500]
|
| 1223 |
+
))
|
| 1224 |
+
|
| 1225 |
+
def query_inventory(self, actor: str, item_id: str) -> pd.DataFrame:
|
| 1226 |
+
inv = self.tables["inventory"]
|
| 1227 |
+
stor = self.tables["storages"]
|
| 1228 |
+
df = inv[inv["item_id"] == item_id].copy()
|
| 1229 |
+
if len(df) > 0:
|
| 1230 |
+
df = df.merge(stor, on="storage_id", how="left")
|
| 1231 |
+
self._log(actor, "query_inventory", {"item_id": item_id}, f"{len(df)} rows")
|
| 1232 |
+
return df
|
| 1233 |
+
|
| 1234 |
+
def query_offers(self, actor: str, item_id: str) -> pd.DataFrame:
|
| 1235 |
+
offers = self.tables["supplier_offers"]
|
| 1236 |
+
suppliers = self.tables["suppliers"]
|
| 1237 |
+
df = offers[offers["item_id"] == item_id].copy()
|
| 1238 |
+
if len(df) > 0:
|
| 1239 |
+
df = df.merge(suppliers, on="supplier_id", how="left")
|
| 1240 |
+
self._log(actor, "query_offers", {"item_id": item_id}, f"{len(df)} rows")
|
| 1241 |
+
return df
|
| 1242 |
+
|
| 1243 |
+
def query_compat_items(self, actor: str, equipment_id: str) -> pd.DataFrame:
|
| 1244 |
+
compat = self.tables["compat"]
|
| 1245 |
+
items = self.tables["items"]
|
| 1246 |
+
df = compat[compat["equipment_id"] == equipment_id].copy()
|
| 1247 |
+
if len(df) > 0:
|
| 1248 |
+
df = df.merge(items, on="item_id", how="left")
|
| 1249 |
+
self._log(actor, "query_compat_items", {"equipment_id": equipment_id}, f"{len(df)} rows")
|
| 1250 |
+
return df
|
| 1251 |
+
|
| 1252 |
+
def get_equipment_info(self, actor: str, equipment_id: str) -> Dict[str, Any]:
|
| 1253 |
+
eq = self.tables["equipment"]
|
| 1254 |
+
match = eq[eq["equipment_id"] == equipment_id]
|
| 1255 |
+
if len(match) == 0:
|
| 1256 |
+
return {}
|
| 1257 |
+
info = match.iloc[0].to_dict()
|
| 1258 |
+
self._log(actor, "get_equipment_info", {"equipment_id": equipment_id}, safe_json(info))
|
| 1259 |
+
return info
|
| 1260 |
+
|
| 1261 |
+
def audit_log_df(self) -> pd.DataFrame:
|
| 1262 |
+
if not self.logs:
|
| 1263 |
+
return pd.DataFrame({"๋ฉ์์ง": ["๋ก๊ทธ ์์"]})
|
| 1264 |
+
return pd.DataFrame([{
|
| 1265 |
+
"์๊ฐ": l.ts[:19],
|
| 1266 |
+
"์์ด์ ํธ": l.actor,
|
| 1267 |
+
"๋๊ตฌ": l.tool,
|
| 1268 |
+
"์
๋ ฅ": str(l.input)[:50],
|
| 1269 |
+
} for l in self.logs])
|
| 1270 |
+
|
| 1271 |
+
def apply_rules(tables: Dict[str, pd.DataFrame], item_id: str,
|
| 1272 |
+
supplier_row: Dict[str, Any]) -> Dict[str, Any]:
|
| 1273 |
+
"""Apply rules"""
|
| 1274 |
+
items = tables["items"]
|
| 1275 |
+
item_match = items[items["item_id"] == item_id]
|
| 1276 |
+
|
| 1277 |
+
if len(item_match) == 0:
|
| 1278 |
+
return {"block": False, "alerts": [], "explanations": [], "rules_fired": []}
|
| 1279 |
+
|
| 1280 |
+
item = item_match.iloc[0].to_dict()
|
| 1281 |
+
|
| 1282 |
+
decision = {
|
| 1283 |
+
"block": False,
|
| 1284 |
+
"alerts": [],
|
| 1285 |
+
"explanations": [],
|
| 1286 |
+
"rules_fired": []
|
| 1287 |
+
}
|
| 1288 |
+
|
| 1289 |
+
if item.get("risk_class") == "๊ท์ " and supplier_row.get("region") == "ํด์ธ":
|
| 1290 |
+
decision["block"] = True
|
| 1291 |
+
decision["rules_fired"].append("R-001")
|
| 1292 |
+
decision["explanations"].append(
|
| 1293 |
+
f"๐ซ R-001: ๊ท์ ํ๋ชฉ({item.get('item_name')}) ํด์ธ์
์ฒด({supplier_row.get('supplier_name')}) ๊ตฌ๋งค ์ฐจ๋จ"
|
| 1294 |
+
)
|
| 1295 |
+
|
| 1296 |
+
if supplier_row.get("esg_level") == "C":
|
| 1297 |
+
decision["rules_fired"].append("R-004")
|
| 1298 |
+
decision["explanations"].append(
|
| 1299 |
+
f"๐ R-004: ESG C๋ฑ๊ธ({supplier_row.get('supplier_name')}) ํจ๋ํฐ"
|
| 1300 |
+
)
|
| 1301 |
+
|
| 1302 |
+
return decision
|
| 1303 |
+
|
| 1304 |
+
def optimize_order_allocation(demand_qty: int, offers_df: pd.DataFrame,
|
| 1305 |
+
rules_eval: Dict[str, Dict[str, Any]]) -> Dict[str, Any]:
|
| 1306 |
+
"""Optimize allocation"""
|
| 1307 |
+
if not PULP_AVAILABLE:
|
| 1308 |
+
return {
|
| 1309 |
+
"status": "UNAVAILABLE",
|
| 1310 |
+
"reason": "PuLP not installed",
|
| 1311 |
+
"allocation": {},
|
| 1312 |
+
"demand": demand_qty
|
| 1313 |
+
}
|
| 1314 |
+
|
| 1315 |
+
feasible = []
|
| 1316 |
+
blocked = []
|
| 1317 |
+
|
| 1318 |
+
for _, r in offers_df.iterrows():
|
| 1319 |
+
sid = r["supplier_id"]
|
| 1320 |
+
if rules_eval.get(sid, {}).get("block"):
|
| 1321 |
+
blocked.append({
|
| 1322 |
+
"supplier_id": sid,
|
| 1323 |
+
"supplier_name": r.get("supplier_name", sid),
|
| 1324 |
+
"reason": "๊ท์น ์๋ฐ"
|
| 1325 |
+
})
|
| 1326 |
+
else:
|
| 1327 |
+
feasible.append(r)
|
| 1328 |
+
|
| 1329 |
+
if len(feasible) == 0:
|
| 1330 |
+
return {
|
| 1331 |
+
"status": "INFEASIBLE",
|
| 1332 |
+
"reason": "๋ชจ๋ ๊ณต๊ธ์
์ฒด ์ฐจ๋จ",
|
| 1333 |
+
"allocation": {},
|
| 1334 |
+
"blocked_suppliers": blocked,
|
| 1335 |
+
"demand": demand_qty
|
| 1336 |
+
}
|
| 1337 |
+
|
| 1338 |
+
fdf = pd.DataFrame(feasible)
|
| 1339 |
+
prob = LpProblem("MRO_Allocation", LpMinimize)
|
| 1340 |
+
|
| 1341 |
+
x = {}
|
| 1342 |
+
for _, r in fdf.iterrows():
|
| 1343 |
+
sid = r["supplier_id"]
|
| 1344 |
+
x[sid] = LpVariable(f"x_{sid}", lowBound=0, cat="Integer")
|
| 1345 |
+
|
| 1346 |
+
prob += lpSum(list(x.values())) >= demand_qty, "DemandConstraint"
|
| 1347 |
+
|
| 1348 |
+
obj_terms = []
|
| 1349 |
+
for _, r in fdf.iterrows():
|
| 1350 |
+
sid = r["supplier_id"]
|
| 1351 |
+
price = float(r["unit_price"])
|
| 1352 |
+
obj_terms.append(x[sid] * price)
|
| 1353 |
+
|
| 1354 |
+
prob += lpSum(obj_terms), "TotalCost"
|
| 1355 |
+
prob.solve()
|
| 1356 |
+
|
| 1357 |
+
alloc = {}
|
| 1358 |
+
total_cost = 0.0
|
| 1359 |
+
for _, r in fdf.iterrows():
|
| 1360 |
+
sid = r["supplier_id"]
|
| 1361 |
+
val = x[sid].value()
|
| 1362 |
+
if val is not None and val > 0:
|
| 1363 |
+
qty = int(val)
|
| 1364 |
+
alloc[sid] = {
|
| 1365 |
+
"qty": qty,
|
| 1366 |
+
"unit_price": float(r["unit_price"]),
|
| 1367 |
+
"supplier_name": r.get("supplier_name", sid),
|
| 1368 |
+
"lead_time": int(r.get("lead_time_days", 0))
|
| 1369 |
+
}
|
| 1370 |
+
total_cost += qty * float(r["unit_price"])
|
| 1371 |
+
|
| 1372 |
+
return {
|
| 1373 |
+
"status": LpStatus.get(prob.status, "Unknown"),
|
| 1374 |
+
"allocation": alloc,
|
| 1375 |
+
"demand": demand_qty,
|
| 1376 |
+
"blocked_suppliers": blocked,
|
| 1377 |
+
"total_cost": round(total_cost, 2)
|
| 1378 |
+
}
|
| 1379 |
+
|
| 1380 |
+
class LLMOrchestrator:
|
| 1381 |
+
def __init__(self):
|
| 1382 |
+
self.api_key = os.environ.get("OPENAI_API_KEY", "").strip()
|
| 1383 |
+
self.demo_mode = (not self.api_key or not OPENAI_AVAILABLE)
|
| 1384 |
+
|
| 1385 |
+
if not self.demo_mode:
|
| 1386 |
+
try:
|
| 1387 |
+
self.client = OpenAI(api_key=self.api_key)
|
| 1388 |
+
test_resp = self.client.chat.completions.create(
|
| 1389 |
+
model="gpt-4o-mini",
|
| 1390 |
+
messages=[{"role": "user", "content": "test"}],
|
| 1391 |
+
max_tokens=5
|
| 1392 |
+
)
|
| 1393 |
+
print("โ
OpenAI API ์ฐ๊ฒฐ ์ฑ๊ณต!")
|
| 1394 |
+
except Exception:
|
| 1395 |
+
self.demo_mode = True
|
| 1396 |
+
self.client = None
|
| 1397 |
+
else:
|
| 1398 |
+
self.client = None
|
| 1399 |
+
|
| 1400 |
+
def chat(self, role: str, system: str, user: str) -> str:
|
| 1401 |
+
if self.demo_mode:
|
| 1402 |
+
return self._demo_response(role)
|
| 1403 |
+
try:
|
| 1404 |
+
resp = self.client.chat.completions.create(
|
| 1405 |
+
model="gpt-4o-mini",
|
| 1406 |
+
temperature=0.2,
|
| 1407 |
+
messages=[
|
| 1408 |
+
{"role": "system", "content": system},
|
| 1409 |
+
{"role": "user", "content": user}
|
| 1410 |
+
]
|
| 1411 |
+
)
|
| 1412 |
+
return resp.choices[0].message.content
|
| 1413 |
+
except Exception as e:
|
| 1414 |
+
return f"[ERROR: {e}]\n" + self._demo_response(role)
|
| 1415 |
+
|
| 1416 |
+
def _demo_response(self, role: str) -> str:
|
| 1417 |
+
return f"[DEMO MODE - {role}] AI ๋ถ์ ์๋ฃ"
|
| 1418 |
+
|
| 1419 |
+
# =========================================================
|
| 1420 |
+
# LangGraph Workflow
|
| 1421 |
+
# =========================================================
|
| 1422 |
+
class DemoState(TypedDict, total=False):
|
| 1423 |
+
tables: Dict[str, pd.DataFrame]
|
| 1424 |
+
mcp: MCPToolRegistry
|
| 1425 |
+
llm: LLMOrchestrator
|
| 1426 |
+
scenario: str
|
| 1427 |
+
equipment_id: str
|
| 1428 |
+
item_id: str
|
| 1429 |
+
demand_qty: int
|
| 1430 |
+
priority: str
|
| 1431 |
+
tables_ok: bool
|
| 1432 |
+
validation_issues: List[str]
|
| 1433 |
+
progress: str
|
| 1434 |
+
inventory_view: pd.DataFrame
|
| 1435 |
+
offers_view: pd.DataFrame
|
| 1436 |
+
rules_eval: Dict[str, Any]
|
| 1437 |
+
optimization: Dict[str, Any]
|
| 1438 |
+
narrative: Dict[str, str]
|
| 1439 |
+
audit_log: pd.DataFrame
|
| 1440 |
+
selected_item_name: str
|
| 1441 |
+
equipment_info: Dict[str, Any]
|
| 1442 |
+
compat_items: pd.DataFrame
|
| 1443 |
+
|
| 1444 |
+
def node_validate(state: DemoState) -> DemoState:
|
| 1445 |
+
ok, issues = validate_tables(state["tables"])
|
| 1446 |
+
state["tables_ok"] = ok
|
| 1447 |
+
state["validation_issues"] = issues
|
| 1448 |
+
state["progress"] = "1/4 ๊ฒ์ฆ ์๋ฃ"
|
| 1449 |
+
return state
|
| 1450 |
+
|
| 1451 |
+
def node_mro_agent(state: DemoState) -> DemoState:
|
| 1452 |
+
mcp: MCPToolRegistry = state["mcp"]
|
| 1453 |
+
equipment_id = state.get("equipment_id", "")
|
| 1454 |
+
item_id = state.get("item_id", "")
|
| 1455 |
+
|
| 1456 |
+
# Get equipment info
|
| 1457 |
+
equipment_info = mcp.get_equipment_info("MRO_AGENT", equipment_id)
|
| 1458 |
+
state["equipment_info"] = equipment_info
|
| 1459 |
+
|
| 1460 |
+
# Get compatible items
|
| 1461 |
+
compat_df = pd.DataFrame()
|
| 1462 |
+
if equipment_id:
|
| 1463 |
+
compat_df = mcp.query_compat_items("MRO_AGENT", equipment_id)
|
| 1464 |
+
state["compat_items"] = compat_df
|
| 1465 |
+
|
| 1466 |
+
if not item_id and len(compat_df) > 0:
|
| 1467 |
+
mandatory = compat_df[compat_df["is_mandatory"] == True]
|
| 1468 |
+
if len(mandatory) > 0:
|
| 1469 |
+
selected = mandatory.iloc[0]
|
| 1470 |
+
else:
|
| 1471 |
+
selected = compat_df.iloc[0]
|
| 1472 |
+
item_id = selected["item_id"]
|
| 1473 |
+
state["item_id"] = item_id
|
| 1474 |
+
state["selected_item_name"] = selected.get("item_name", item_id)
|
| 1475 |
+
|
| 1476 |
+
inv_df = pd.DataFrame()
|
| 1477 |
+
if item_id:
|
| 1478 |
+
inv_df = mcp.query_inventory("MRO_AGENT", item_id)
|
| 1479 |
+
state["inventory_view"] = inv_df
|
| 1480 |
+
|
| 1481 |
+
llm: LLMOrchestrator = state["llm"]
|
| 1482 |
+
if "narrative" not in state:
|
| 1483 |
+
state["narrative"] = {}
|
| 1484 |
+
state["narrative"]["mro"] = llm.chat("MRO", "MRO ๋ถ์", "์ค๋น/์ฌ๊ณ ")
|
| 1485 |
+
state["progress"] = "2/4 MRO ์๋ฃ"
|
| 1486 |
+
return state
|
| 1487 |
+
|
| 1488 |
+
def node_procurement_agent(state: DemoState) -> DemoState:
|
| 1489 |
+
mcp: MCPToolRegistry = state["mcp"]
|
| 1490 |
+
item_id = state.get("item_id", "")
|
| 1491 |
+
demand_qty = int(state.get("demand_qty", 10))
|
| 1492 |
+
|
| 1493 |
+
offers_df = pd.DataFrame()
|
| 1494 |
+
if item_id:
|
| 1495 |
+
offers_df = mcp.query_offers("PROC_AGENT", item_id)
|
| 1496 |
+
state["offers_view"] = offers_df
|
| 1497 |
+
|
| 1498 |
+
rules_eval = {}
|
| 1499 |
+
if len(offers_df) > 0:
|
| 1500 |
+
for _, r in offers_df.iterrows():
|
| 1501 |
+
sid = r["supplier_id"]
|
| 1502 |
+
supplier_row = {
|
| 1503 |
+
"supplier_id": sid,
|
| 1504 |
+
"supplier_name": r.get("supplier_name", sid),
|
| 1505 |
+
"region": r.get("region", ""),
|
| 1506 |
+
"esg_level": r.get("esg_level", ""),
|
| 1507 |
+
}
|
| 1508 |
+
rules_eval[sid] = apply_rules(state["tables"], item_id, supplier_row)
|
| 1509 |
+
state["rules_eval"] = rules_eval
|
| 1510 |
+
|
| 1511 |
+
opt_result = {}
|
| 1512 |
+
if len(offers_df) > 0:
|
| 1513 |
+
opt_result = optimize_order_allocation(demand_qty, offers_df, rules_eval)
|
| 1514 |
+
else:
|
| 1515 |
+
opt_result = {
|
| 1516 |
+
"status": "NO_DATA",
|
| 1517 |
+
"reason": "๊ณต๊ธ์
์ฒด ์ ๋ณด ์์",
|
| 1518 |
+
"allocation": {},
|
| 1519 |
+
"demand": demand_qty
|
| 1520 |
+
}
|
| 1521 |
+
state["optimization"] = opt_result
|
| 1522 |
+
|
| 1523 |
+
llm: LLMOrchestrator = state["llm"]
|
| 1524 |
+
state["narrative"]["proc"] = llm.chat("PROC", "๊ตฌ๋งค ์ ๋ต", "์ต์ ํ")
|
| 1525 |
+
state["narrative"]["exec"] = llm.chat("EXEC", "์์ ์์ฝ", "์ข
ํฉ")
|
| 1526 |
+
state["progress"] = "3/4 ๊ตฌ๋งค ์๋ฃ"
|
| 1527 |
+
return state
|
| 1528 |
+
|
| 1529 |
+
def node_collect_audit(state: DemoState) -> DemoState:
|
| 1530 |
+
mcp: MCPToolRegistry = state["mcp"]
|
| 1531 |
+
state["audit_log"] = mcp.audit_log_df()
|
| 1532 |
+
state["progress"] = "4/4 ์๋ฃ โ"
|
| 1533 |
+
return state
|
| 1534 |
+
|
| 1535 |
+
def build_workflow():
|
| 1536 |
+
if not LANGGRAPH_AVAILABLE:
|
| 1537 |
+
return None
|
| 1538 |
+
try:
|
| 1539 |
+
graph = StateGraph(DemoState)
|
| 1540 |
+
graph.add_node("validate", node_validate)
|
| 1541 |
+
graph.add_node("mro_agent", node_mro_agent)
|
| 1542 |
+
graph.add_node("procurement_agent", node_procurement_agent)
|
| 1543 |
+
graph.add_node("collect_audit", node_collect_audit)
|
| 1544 |
+
graph.set_entry_point("validate")
|
| 1545 |
+
graph.add_edge("validate", "mro_agent")
|
| 1546 |
+
graph.add_edge("mro_agent", "procurement_agent")
|
| 1547 |
+
graph.add_edge("procurement_agent", "collect_audit")
|
| 1548 |
+
graph.add_edge("collect_audit", END)
|
| 1549 |
+
return graph.compile()
|
| 1550 |
+
except Exception as e:
|
| 1551 |
+
print(f"โ ๏ธ LangGraph failed: {e}")
|
| 1552 |
+
return None
|
| 1553 |
+
|
| 1554 |
+
APP = build_workflow()
|
| 1555 |
+
|
| 1556 |
+
# =========================================================
|
| 1557 |
+
# Main Execution - Enhanced with Dashboards
|
| 1558 |
+
# =========================================================
|
| 1559 |
+
def run_demo(scenario: str, seed: int, equipment_id: str, item_id: str,
|
| 1560 |
+
demand_qty: int) -> Tuple:
|
| 1561 |
+
"""Main execution - returns 12 outputs (enhanced)"""
|
| 1562 |
+
try:
|
| 1563 |
+
seed_int = int(seed)
|
| 1564 |
+
demand_int = int(demand_qty)
|
| 1565 |
+
|
| 1566 |
+
tables = generate_demo_tables(seed=seed_int)
|
| 1567 |
+
mcp = MCPToolRegistry(tables)
|
| 1568 |
+
llm = LLMOrchestrator()
|
| 1569 |
+
|
| 1570 |
+
preset = SCENARIO_PRESETS.get(scenario, SCENARIO_PRESETS["๊ธด๊ธ ๊ณ ์ฅ ๋์"])
|
| 1571 |
+
|
| 1572 |
+
state: DemoState = {
|
| 1573 |
+
"tables": tables,
|
| 1574 |
+
"mcp": mcp,
|
| 1575 |
+
"llm": llm,
|
| 1576 |
+
"scenario": scenario,
|
| 1577 |
+
"equipment_id": equipment_id.strip(),
|
| 1578 |
+
"item_id": item_id.strip(),
|
| 1579 |
+
"demand_qty": demand_int,
|
| 1580 |
+
"priority": preset.get("priority", "์ ์"),
|
| 1581 |
+
}
|
| 1582 |
+
|
| 1583 |
+
if APP is not None:
|
| 1584 |
+
out = APP.invoke(state)
|
| 1585 |
+
else:
|
| 1586 |
+
out = node_validate(state)
|
| 1587 |
+
out = node_mro_agent(out)
|
| 1588 |
+
out = node_procurement_agent(out)
|
| 1589 |
+
out = node_collect_audit(out)
|
| 1590 |
+
|
| 1591 |
+
status = {
|
| 1592 |
+
"mode": "โ ๏ธ DEMO" if llm.demo_mode else "โ
LLM",
|
| 1593 |
+
"scenario": scenario,
|
| 1594 |
+
"tables_ok": out.get("tables_ok", False),
|
| 1595 |
+
"equipment": out.get("equipment_id", ""),
|
| 1596 |
+
"item_name": out.get("selected_item_name", ""),
|
| 1597 |
+
"demand": out.get("demand_qty", 0),
|
| 1598 |
+
"priority": out.get("priority", "์ ์"),
|
| 1599 |
+
"progress": out.get("progress", "์๋ฃ"),
|
| 1600 |
+
}
|
| 1601 |
+
|
| 1602 |
+
status_text = format_status(status)
|
| 1603 |
+
|
| 1604 |
+
# Data extraction
|
| 1605 |
+
inv_df = out.get("inventory_view", pd.DataFrame())
|
| 1606 |
+
offers_df = out.get("offers_view", pd.DataFrame())
|
| 1607 |
+
audit_df = out.get("audit_log", pd.DataFrame())
|
| 1608 |
+
equipment_info = out.get("equipment_info", {})
|
| 1609 |
+
compat_items = out.get("compat_items", pd.DataFrame())
|
| 1610 |
+
rules_eval = out.get("rules_eval", {})
|
| 1611 |
+
opt_result = out.get("optimization", {})
|
| 1612 |
+
purchase_history = tables.get("purchase_history", pd.DataFrame())
|
| 1613 |
+
|
| 1614 |
+
item_name = out.get("selected_item_name", "๋ถํ")
|
| 1615 |
+
|
| 1616 |
+
# Create dashboards
|
| 1617 |
+
mro_dashboard = create_mro_inventory_dashboard(inv_df, item_name)
|
| 1618 |
+
mro_workflow = create_mro_workflow_status(equipment_info, compat_items)
|
| 1619 |
+
proc_dashboard = create_procurement_comparison_dashboard(offers_df, rules_eval)
|
| 1620 |
+
proc_workflow = create_procurement_workflow(opt_result)
|
| 1621 |
+
exec_dashboard = create_executive_kpi_dashboard(opt_result, offers_df, purchase_history)
|
| 1622 |
+
action_items = create_action_items_table(opt_result, offers_df)
|
| 1623 |
+
|
| 1624 |
+
# Fallback for empty dataframes
|
| 1625 |
+
if len(audit_df) == 0:
|
| 1626 |
+
audit_df = pd.DataFrame({"๋ฉ์์ง": ["๊ฐ์ฌ๋ก๊ทธ ์์"]})
|
| 1627 |
+
|
| 1628 |
+
print("โ
๋์๋ณด๋ ์์ฑ ์๋ฃ\n")
|
| 1629 |
+
|
| 1630 |
+
# Return 12 outputs
|
| 1631 |
+
return (
|
| 1632 |
+
status_text, # 1
|
| 1633 |
+
mro_dashboard, # 2 - MRO ์ฌ๊ณ ๋์๋ณด๋
|
| 1634 |
+
mro_workflow, # 3 - MRO ์ํฌํ๋ก์ฐ
|
| 1635 |
+
proc_dashboard, # 4 - ๊ตฌ๋งค ๋น๊ต ๋์๋ณด๋
|
| 1636 |
+
proc_workflow, # 5 - ๊ตฌ๋งค ์ํฌํ๋ก์ฐ
|
| 1637 |
+
exec_dashboard, # 6 - ๊ฒฝ์์ง KPI
|
| 1638 |
+
action_items, # 7 - Action Items
|
| 1639 |
+
offers_df, # 8 - ๊ณต๊ธ์
์ฒด ์๋ณธ ๋ฐ์ดํฐ
|
| 1640 |
+
inv_df, # 9 - ์ฌ๊ณ ์๋ณธ ๋ฐ์ดํฐ
|
| 1641 |
+
opt_result, # 10 - ์ต์ ํ ๊ฒฐ๊ณผ (dict๋ฅผ text๋ก)
|
| 1642 |
+
audit_df, # 11 - ๊ฐ์ฌ ๋ก๊ทธ
|
| 1643 |
+
out.get("selected_item_name", "N/A") # 12 - ํ๋ชฉ๋ช
|
| 1644 |
+
)
|
| 1645 |
+
|
| 1646 |
+
except Exception as e:
|
| 1647 |
+
print(f"โ ์ค๋ฅ: {e}\n{traceback.format_exc()}")
|
| 1648 |
+
error_msg = f"โ ์ค๋ฅ\n\n{str(e)}"
|
| 1649 |
+
empty_fig = go.Figure()
|
| 1650 |
+
empty_fig.add_annotation(text="์ค๋ฅ ๋ฐ์", showarrow=False)
|
| 1651 |
+
empty_df = pd.DataFrame({"์ค๋ฅ": [str(e)[:100]]})
|
| 1652 |
+
|
| 1653 |
+
return (
|
| 1654 |
+
error_msg, empty_fig, empty_fig, empty_fig, empty_fig,
|
| 1655 |
+
empty_fig, empty_df, empty_df, empty_df, {}, empty_df, "N/A"
|
| 1656 |
+
)
|
| 1657 |
+
|
| 1658 |
+
def update_scenario(scenario: str) -> Tuple[str, str, int, str]:
|
| 1659 |
+
preset = SCENARIO_PRESETS.get(scenario, SCENARIO_PRESETS["๊ธด๊ธ ๊ณ ์ฅ ๋์"])
|
| 1660 |
+
guide_text = f"""**๐ {preset['description']}**
|
| 1661 |
+
|
| 1662 |
+
**๋ฐฐ๊ฒฝ**: {preset['context']}
|
| 1663 |
+
**์ฐ์ ์์**: {preset.get('priority', '์ ์')}
|
| 1664 |
+
**๊ฐ์ด๋**: {preset.get('guide', '')}
|
| 1665 |
+
"""
|
| 1666 |
+
|
| 1667 |
+
return (
|
| 1668 |
+
preset["equipment_id"],
|
| 1669 |
+
preset["item_id"],
|
| 1670 |
+
preset["demand_qty"],
|
| 1671 |
+
guide_text
|
| 1672 |
+
)
|
| 1673 |
+
|
| 1674 |
+
# =========================================================
|
| 1675 |
+
# Enhanced Gradio UI with Process Guides
|
| 1676 |
+
# =========================================================
|
| 1677 |
+
print("๐จ ํ๋ก์ธ์ค ๊ฐ์ด๋ ํตํฉ UI ๊ตฌ์ฑ ์ค...\n")
|
| 1678 |
+
|
| 1679 |
+
with gr.Blocks(title="POSCO DX MRO Composite AI", theme=gr.themes.Soft()) as demo:
|
| 1680 |
+
|
| 1681 |
+
gr.Markdown("""
|
| 1682 |
+
# ๐ญ POSCO DX - MRO Composite AI ํ๋ก์ธ์ค ๊ฐ์ด๋ ํตํฉ ๋ฒ์
|
| 1683 |
+
|
| 1684 |
+
## ๐ฏ ์
๋ฌด ํ๋ก์ธ์ค ์๋ํ + AI ์์ฌ๊ฒฐ์ ์ง์ ์์คํ
|
| 1685 |
+
|
| 1686 |
+
**3-Agent Collaboration**: MRO ์ด์ โ ๊ตฌ๋งค/์กฐ๋ฌ โ ๊ฒฝ์์ง ์น์ธ
|
| 1687 |
+
""")
|
| 1688 |
+
|
| 1689 |
+
# Process Overview Section
|
| 1690 |
+
with gr.Accordion("๐ ์ ์ฒด ์
๋ฌด ํ๋ก์ธ์ค ๊ฐ์", open=False):
|
| 1691 |
+
gr.Markdown("""
|
| 1692 |
+
### ๐ End-to-End ์ํฌํ๋ก์ฐ
|
| 1693 |
+
|
| 1694 |
+
```
|
| 1695 |
+
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
|
| 1696 |
+
โ 1๏ธโฃ MRO ์ด์ โ โโโ> โ 2๏ธโฃ ๊ตฌ๋งค/์กฐ๋ฌ โ โโโ> โ 3๏ธโฃ ๊ฒฝ์์ง ์น์ธ โ
|
| 1697 |
+
โ โ โ โ โ โ
|
| 1698 |
+
โ โข ๊ณ ์ฅ ์ ์ โ โ โข ๊ณต๊ธ์
์ฒด ์กฐํ โ โ โข KPI ํ์ธ โ
|
| 1699 |
+
โ โข ๋ถํ ํ์ธ โ โ โข ๊ท์ ๊ฒ์ฆ โ โ โข ์์ฌ๊ฒฐ์ โ
|
| 1700 |
+
โ โข ์ฌ๊ณ ํ์ธ โ โ โข ์ต์ ํ ๋ถ์ โ โ โข ํผ๋๋ฐฑ โ
|
| 1701 |
+
โ โข ๋ฐ์ฃผ ์์ฒญ โ โ โข ์น์ธ ์์ฒญ โ โ โ
|
| 1702 |
+
โโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโโโโ
|
| 1703 |
+
โฑ๏ธ 15๋ถ โฑ๏ธ 25๋ถ โฑ๏ธ 25๋ถ
|
| 1704 |
+
```
|
| 1705 |
+
|
| 1706 |
+
### ๐ก ํต์ฌ ๊ฐ์น
|
| 1707 |
+
|
| 1708 |
+
1. **์๋ํ**: ์ค๋น-๋ถํ ๋งค์นญ, ์ฌ๊ณ ์กฐํ, ๊ท์ ๊ฒ์ฆ ๋ฑ ๋ฐ๋ณต ์
๋ฌด ์๋ํ
|
| 1709 |
+
2. **์ต์ ํ**: AI ๊ธฐ๋ฐ ๋น์ฉ ์ต์ ํ ๋ฐ ๊ณต๊ธ์
์ฒด ์ ์
|
| 1710 |
+
3. **๊ฒ์ฆ**: Neuro-Symbolic AI๋ก 100% ๊ท์ ์ค์ ๋ณด์ฅ
|
| 1711 |
+
4. **๊ฐ์์ฑ**: ์ค์๊ฐ ๋์๋ณด๋๋ก ์ ๊ณผ์ ๋ชจ๋ํฐ๋ง
|
| 1712 |
+
5. **์ถ์ ์ฑ**: ๋ชจ๋ ์์ฌ๊ฒฐ์ ๊ณผ์ ์๋ ๊ธฐ๋ก
|
| 1713 |
+
|
| 1714 |
+
### ๐ ๊ธฐ๋ ํจ๊ณผ
|
| 1715 |
+
|
| 1716 |
+
- โฑ๏ธ **์ฒ๋ฆฌ ์๊ฐ**: ๊ธฐ์กด 3-5์ผ โ **1์๊ฐ ์ด๋ด**
|
| 1717 |
+
- ๐ฐ **๋น์ฉ ์ ๊ฐ**: ํ๊ท **15-25%** ๊ตฌ๋งค ๋น์ฉ ์ ๊ฐ
|
| 1718 |
+
- โ๏ธ **์ปดํ๋ผ์ด์ธ์ค**: **100%** ๊ท์ ์ค์
|
| 1719 |
+
- ๐ **ํจ์จ์ฑ**: ๋ด๋น์ ์
๋ฌด ์๊ฐ **60%** ๋จ์ถ
|
| 1720 |
+
""")
|
| 1721 |
+
|
| 1722 |
+
with gr.Row():
|
| 1723 |
+
with gr.Column():
|
| 1724 |
+
gr.Markdown("### ๐ฏ ์๋๋ฆฌ์ค")
|
| 1725 |
+
scenario_radio = gr.Radio(
|
| 1726 |
+
choices=list(SCENARIO_PRESETS.keys()),
|
| 1727 |
+
value="๊ธด๊ธ ๊ณ ์ฅ ๋์",
|
| 1728 |
+
label="๋ถ์ ์๋๋ฆฌ์ค"
|
| 1729 |
+
)
|
| 1730 |
+
scenario_info = gr.Markdown(
|
| 1731 |
+
value=f"""**๐ {SCENARIO_PRESETS['๊ธด๊ธ ๊ณ ์ฅ ๋์']['description']}**
|
| 1732 |
+
|
| 1733 |
+
**๋ฐฐ๊ฒฝ**: {SCENARIO_PRESETS['๊ธด๊ธ ๊ณ ์ฅ ๋์']['context']}
|
| 1734 |
+
**๊ฐ์ด๋**: {SCENARIO_PRESETS['๊ธด๊ธ ๊ณ ์ฅ ๋์']['guide']}
|
| 1735 |
+
"""
|
| 1736 |
+
)
|
| 1737 |
+
|
| 1738 |
+
with gr.Column():
|
| 1739 |
+
gr.Markdown("### โ๏ธ ํ๋ผ๋ฏธํฐ")
|
| 1740 |
+
seed_number = gr.Number(value=7, label="๏ฟฝ๏ฟฝ์ดํฐ ์๋", precision=0)
|
| 1741 |
+
equipment_text = gr.Textbox(value="CONV-PH-007", label="์ค๋น ID")
|
| 1742 |
+
item_text = gr.Textbox(value="", label="ํ๋ชฉ ID (์ ํ)")
|
| 1743 |
+
demand_number = gr.Number(value=10, label="์๋", precision=0)
|
| 1744 |
+
|
| 1745 |
+
run_button = gr.Button("๐ Composite AI ๋ถ์ ์คํ", variant="primary", size="lg")
|
| 1746 |
+
|
| 1747 |
+
gr.Markdown("---")
|
| 1748 |
+
|
| 1749 |
+
status_output = gr.Textbox(label="๐ ์คํ ์ํ", lines=10)
|
| 1750 |
+
selected_item_display = gr.Textbox(label="๐ฆ ์ ํ๋ ํ๋ชฉ", interactive=False)
|
| 1751 |
+
|
| 1752 |
+
with gr.Tabs():
|
| 1753 |
+
with gr.Tab("๐ง MRO ๋ด๋น์"):
|
| 1754 |
+
# Process Guide for MRO
|
| 1755 |
+
with gr.Accordion("๐ MRO ์ด์ ํ๋ก์ธ์ค ๊ฐ์ด๋", open=True):
|
| 1756 |
+
mro_process_html = gr.HTML(create_process_guide_html("mro"))
|
| 1757 |
+
|
| 1758 |
+
gr.Markdown("---")
|
| 1759 |
+
gr.Markdown("### ๐ ๋์๋ณด๋ ๋ฐ ๋ถ์ ๊ฒฐ๊ณผ")
|
| 1760 |
+
|
| 1761 |
+
mro_inventory_plot = gr.Plot(label="๐ฆ ์ฌ๊ณ ๋ถ์ ๋์๋ณด๋")
|
| 1762 |
+
mro_workflow_plot = gr.Plot(label="๐ MRO ์ํฌํ๋ก์ฐ ์งํ")
|
| 1763 |
+
mro_inventory_table = gr.Dataframe(label="๐ ์์ธ ์ฌ๊ณ ๋ฐ์ดํฐ")
|
| 1764 |
+
|
| 1765 |
+
with gr.Tab("๐ฐ ๊ตฌ๋งค ๋ด๋น์"):
|
| 1766 |
+
# Process Guide for Procurement
|
| 1767 |
+
with gr.Accordion("๐ ๊ตฌ๋งค/์กฐ๋ฌ ํ๋ก์ธ์ค ๊ฐ์ด๋", open=True):
|
| 1768 |
+
proc_process_html = gr.HTML(create_process_guide_html("procurement"))
|
| 1769 |
+
|
| 1770 |
+
gr.Markdown("---")
|
| 1771 |
+
gr.Markdown("### ๐ ๋์๋ณด๋ ๋ฐ ๋ถ์ ๊ฒฐ๊ณผ")
|
| 1772 |
+
|
| 1773 |
+
proc_comparison_plot = gr.Plot(label="๐ ๊ณต๊ธ์
์ฒด ๋น๊ต ๋์๋ณด๋")
|
| 1774 |
+
proc_workflow_plot = gr.Plot(label="๐ ๊ตฌ๋งค ์ํฌํ๋ก์ฐ")
|
| 1775 |
+
proc_offers_table = gr.Dataframe(label="๐ ๊ณต๊ธ์
์ฒด ์์ธ ์ ๋ณด")
|
| 1776 |
+
|
| 1777 |
+
with gr.Tab("๐ ๊ฒฝ์์ง"):
|
| 1778 |
+
# Process Guide for Executive
|
| 1779 |
+
with gr.Accordion("๐ ๊ฒฝ์์ง ์์ฌ๊ฒฐ์ ํ๋ก์ธ์ค ๊ฐ์ด๋", open=True):
|
| 1780 |
+
exec_process_html = gr.HTML(create_process_guide_html("executive"))
|
| 1781 |
+
|
| 1782 |
+
gr.Markdown("---")
|
| 1783 |
+
gr.Markdown("### ๐ ๋์๋ณด๋ ๋ฐ ๋ถ์ ๊ฒฐ๊ณผ")
|
| 1784 |
+
|
| 1785 |
+
exec_kpi_plot = gr.Plot(label="๐ ๊ฒฝ์์ง KPI ๋์๋ณด๋")
|
| 1786 |
+
exec_action_table = gr.Dataframe(label="๐ Action Items")
|
| 1787 |
+
|
| 1788 |
+
gr.Markdown("### ๐ฌ ๊ฒฝ์์ง ํผ๋๋ฐฑ")
|
| 1789 |
+
with gr.Row():
|
| 1790 |
+
feedback_text = gr.Textbox(
|
| 1791 |
+
label="๊ฐ์ ์ ์ / ํผ๋๋ฐฑ",
|
| 1792 |
+
placeholder="์: ESG C๋ฑ๊ธ ์
์ฒด ๋น์ค์ 20% ์ดํ๋ก ์ ํํ์๊ธฐ ๋ฐ๋๋๋ค.",
|
| 1793 |
+
lines=3
|
| 1794 |
+
)
|
| 1795 |
+
with gr.Row():
|
| 1796 |
+
approve_btn = gr.Button("โ
์น์ธ", variant="primary")
|
| 1797 |
+
reject_btn = gr.Button("โ ๋ฐ๋ ค", variant="stop")
|
| 1798 |
+
suggest_btn = gr.Button("๐ก ๊ฐ์ ์ ์", variant="secondary")
|
| 1799 |
+
|
| 1800 |
+
feedback_output = gr.Textbox(label="ํผ๋๋ฐฑ ์ฒ๋ฆฌ ๊ฒฐ๊ณผ", lines=2)
|
| 1801 |
+
|
| 1802 |
+
with gr.Tab("๐ ๊ฐ์ฌ ๋ก๊ทธ"):
|
| 1803 |
+
gr.Markdown("""
|
| 1804 |
+
### ๊ฐ์ฌ ์ถ์ (Audit Trail)
|
| 1805 |
+
|
| 1806 |
+
**๋ชฉ์ **: ๋ชจ๋ ์์ฌ๊ฒฐ์ ๊ณผ์ ์ถ์ ๋ฐ ์ปดํ๋ผ์ด์ธ์ค ํ๋ณด
|
| 1807 |
+
|
| 1808 |
+
**๊ธฐ๋ก ํญ๋ชฉ**:
|
| 1809 |
+
- ๐ ์๊ฐ: ์์
์ํ ์๊ฐ
|
| 1810 |
+
- ๐ค ์์ด์ ํธ: MRO/๊ตฌ๋งค/๊ฒฝ์์ง
|
| 1811 |
+
- ๐ง ๋๊ตฌ: ์ฌ์ฉํ ๊ธฐ๋ฅ
|
| 1812 |
+
- ๐ฅ ์
๋ ฅ: ํ๋ผ๋ฏธํฐ
|
| 1813 |
+
- ๐ค ์ถ๋ ฅ: ๊ฒฐ๊ณผ ์์ฝ
|
| 1814 |
+
|
| 1815 |
+
**ํ์ฉ**:
|
| 1816 |
+
- ๊ท์ ์ค์ ๊ฐ์ฌ
|
| 1817 |
+
- ํ๋ก์ธ์ค ๊ฐ์
|
| 1818 |
+
- ์ฑ
์ ์ถ์ ์ฑ
|
| 1819 |
+
""")
|
| 1820 |
+
audit_table = gr.Dataframe(label="๐ ์ ์ฒด ๊ฐ์ฌ ๋ก๊ทธ")
|
| 1821 |
+
|
| 1822 |
+
# Hidden outputs for optimization result
|
| 1823 |
+
opt_result_json = gr.JSON(label="์ต์ ํ ์์ธ ๊ฒฐ๊ณผ", visible=False)
|
| 1824 |
+
|
| 1825 |
+
gr.Markdown("""
|
| 1826 |
+
---
|
| 1827 |
+
## ๐ก ์์คํ
์ฌ์ฉ ๊ฐ์ด๋
|
| 1828 |
+
|
| 1829 |
+
### ๐ ๋จ๊ณ๋ณ ์ฌ์ฉ๋ฒ
|
| 1830 |
+
|
| 1831 |
+
#### 1๏ธโฃ ์๋๋ฆฌ์ค ์ ํ
|
| 1832 |
+
- **๊ธด๊ธ ๊ณ ์ฅ ๋์**: ์ค๋น ๊ณ ์ฅ์ผ๋ก ์ฆ์ ๊ต์ฒด๊ฐ ํ์ํ ๊ฒฝ์ฐ
|
| 1833 |
+
- **์ ๊ธฐ ๋ฐ์ฃผ ๊ณํ**: ์๊ฐ/๋ถ๊ธฐ ์ ๊ธฐ ๋ฐ์ฃผ ์ต์ ํ
|
| 1834 |
+
- **๊ท์ ์ค์ ๊ฒ์ฆ**: ํน์ ํ๋ชฉ ๊ตฌ๋งค ์ ์ปดํ๋ผ์ด์ธ์ค ํ์ธ
|
| 1835 |
+
|
| 1836 |
+
#### 2๏ธโฃ ํ๋ผ๋ฏธํฐ ์
๋ ฅ
|
| 1837 |
+
- **์ค๋น ID**: ๊ณ ์ฅ/์ ๋น ๋์ ์ค๋น (์๋ ์
๋ ฅ)
|
| 1838 |
+
- **ํ๋ชฉ ID**: ํน์ ํ๋ชฉ ์ง์ (์ ํ์ฌํญ, ๋น์ฐ๋ฉด ์๋ ์ ํ)
|
| 1839 |
+
- **์๋**: ๋ฐ์ฃผ ํ์ ์๋
|
| 1840 |
+
|
| 1841 |
+
#### 3๏ธโฃ ๋ถ์ ์คํ
|
| 1842 |
+
- "๐ Composite AI ๋ถ์ ์คํ" ๋ฒํผ ํด๋ฆญ
|
| 1843 |
+
- ์ฝ 5-10์ด ๋ด ๊ฒฐ๊ณผ ํ์ธ
|
| 1844 |
+
|
| 1845 |
+
#### 4๏ธโฃ ๊ฒฐ๊ณผ ๊ฒํ
|
| 1846 |
+
- **MRO ํญ**: ์ฌ๊ณ ํํฉ ๋ฐ ๋ฐ์ฃผ ํ์์ฑ ํ์ธ
|
| 1847 |
+
- **๊ตฌ๋งค ํญ**: ๊ณต๊ธ์
์ฒด ๋น๊ต ๋ฐ ์ต์ ์ ํ
|
| 1848 |
+
- **๊ฒฝ์์ง ํญ**: KPI ํ์ธ ๋ฐ ์์ฌ๊ฒฐ์
|
| 1849 |
+
|
| 1850 |
+
#### 5๏ธโฃ ์น์ธ/ํผ๋๋ฐฑ
|
| 1851 |
+
- Action Items ๊ฒํ ํ ์น์ธ/๋ฐ๋ ค ๊ฒฐ์
|
| 1852 |
+
- ๊ฐ์ ์ ์ ์
๋ ฅ ์ ์๋์ผ๋ก ๋ด๋น ๋ถ์์ ์ ๋ฌ
|
| 1853 |
+
|
| 1854 |
+
### ๐ ํ๋ก์ธ์ค ์ดํด
|
| 1855 |
+
|
| 1856 |
+
๊ฐ ํญ์ "๐ ํ๋ก์ธ์ค ๊ฐ์ด๋"๋ฅผ ํผ์น๋ฉด:
|
| 1857 |
+
- ๋จ๊ณ๋ณ ์์ธ ์ ์ฐจ
|
| 1858 |
+
- ์
๋ ฅ/์ถ๋ ฅ ๋ช
์ธ
|
| 1859 |
+
- ๋ด๋น์ ๋ฐ ์์ ์๊ฐ
|
| 1860 |
+
- ์ฑ๊ณต ๊ธฐ์ค
|
| 1861 |
+
|
| 1862 |
+
์ ํ์ธํ ์ ์์ต๋๋ค.
|
| 1863 |
+
|
| 1864 |
+
### ๐ ์ฃผ์ ๊ธฐ๋ฅ
|
| 1865 |
+
|
| 1866 |
+
1. **์๋ ๋ถํ ๋งค์นญ**: ์ค๋น ID๋ง์ผ๋ก ํธํ ๋ถํ ์๋ ๊ฒ์
|
| 1867 |
+
2. **์ ์ฌ ์ฌ๊ณ ํตํฉ**: ๋ณธ์ฌ, ํฌํญ, ๊ด์ ์ ์ฒด ์ฐฝ๊ณ ์ค์๊ฐ ์กฐํ
|
| 1868 |
+
3. **AI ๊ท์ ๊ฒ์ฆ**: ๊ท์ ํ๋ชฉ, ESG ๋ฑ๊ธ ๋ฑ ์๋ ๊ฒ์ฆ
|
| 1869 |
+
4. **์ต์ ํ ์์ง**: Linear Programming์ผ๋ก ๋น์ฉ ์ต์ํ
|
| 1870 |
+
5. **์ธํฐ๋ํฐ๋ธ ๋์๋ณด๋**: Plotly ์ฐจํธ๋ก ๋๋ฆด๋ค์ด ๋ถ์ ๊ฐ๋ฅ
|
| 1871 |
+
|
| 1872 |
+
### ๐ API Key ์ค์ (Hugging Face Spaces)
|
| 1873 |
+
|
| 1874 |
+
OpenAI ๊ธฐ๋ฅ์ ์ฌ์ฉํ๋ ค๋ฉด:
|
| 1875 |
+
1. Space Settings โ Secrets์ผ๋ก ์ด๋
|
| 1876 |
+
2. ์ Secret ์ถ๊ฐ:
|
| 1877 |
+
- Name: `OPENAI_API_KEY`
|
| 1878 |
+
- Value: `your-openai-api-key`
|
| 1879 |
+
3. Space ์ฌ์์
|
| 1880 |
+
|
| 1881 |
+
API ํค ์์ด๋ ๋ฐ๋ชจ ๋ชจ๋๋ก ๊ธฐ๋ณธ ๊ธฐ๋ฅ ์ฌ์ฉ ๊ฐ๋ฅํฉ๋๋ค.
|
| 1882 |
+
""")
|
| 1883 |
+
|
| 1884 |
+
# Event Handlers
|
| 1885 |
+
scenario_radio.change(
|
| 1886 |
+
fn=update_scenario,
|
| 1887 |
+
inputs=[scenario_radio],
|
| 1888 |
+
outputs=[equipment_text, item_text, demand_number, scenario_info]
|
| 1889 |
+
)
|
| 1890 |
+
|
| 1891 |
+
run_button.click(
|
| 1892 |
+
fn=run_demo,
|
| 1893 |
+
inputs=[scenario_radio, seed_number, equipment_text, item_text, demand_number],
|
| 1894 |
+
outputs=[
|
| 1895 |
+
status_output, # 1
|
| 1896 |
+
mro_inventory_plot, # 2
|
| 1897 |
+
mro_workflow_plot, # 3
|
| 1898 |
+
proc_comparison_plot, # 4
|
| 1899 |
+
proc_workflow_plot, # 5
|
| 1900 |
+
exec_kpi_plot, # 6
|
| 1901 |
+
exec_action_table, # 7
|
| 1902 |
+
proc_offers_table, # 8
|
| 1903 |
+
mro_inventory_table, # 9
|
| 1904 |
+
opt_result_json, # 10
|
| 1905 |
+
audit_table, # 11
|
| 1906 |
+
selected_item_display # 12
|
| 1907 |
+
]
|
| 1908 |
+
)
|
| 1909 |
+
|
| 1910 |
+
# Feedback handlers
|
| 1911 |
+
def handle_approve(feedback):
|
| 1912 |
+
return f"โ
์น์ธ ์๋ฃ: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\nํผ๋๋ฐฑ: {feedback}"
|
| 1913 |
+
|
| 1914 |
+
def handle_reject(feedback):
|
| 1915 |
+
return f"โ ๋ฐ๋ ค๋จ: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n์ฌ์ : {feedback}"
|
| 1916 |
+
|
| 1917 |
+
def handle_suggest(feedback):
|
| 1918 |
+
return f"๐ก ๊ฐ์ ์ ์ ์ ์: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}\n๋ด์ฉ: {feedback}"
|
| 1919 |
+
|
| 1920 |
+
approve_btn.click(fn=handle_approve, inputs=[feedback_text], outputs=[feedback_output])
|
| 1921 |
+
reject_btn.click(fn=handle_reject, inputs=[feedback_text], outputs=[feedback_output])
|
| 1922 |
+
suggest_btn.click(fn=handle_suggest, inputs=[feedback_text], outputs=[feedback_output])
|
| 1923 |
+
|
| 1924 |
+
print("=" * 60)
|
| 1925 |
+
print("โ
ํ๋ก์ธ์ค ๊ฐ์ด๋ ํตํฉ UI ์๋ฃ!")
|
| 1926 |
+
print("=" * 60)
|
| 1927 |
+
|
| 1928 |
+
if __name__ == "__main__":
|
| 1929 |
+
demo.launch(
|
| 1930 |
+
server_name="0.0.0.0",
|
| 1931 |
+
server_port=7860,
|
| 1932 |
+
show_error=True
|
| 1933 |
+
)
|
| 1934 |
+
|
| 1935 |
+
print("\n๐ ํ๋ก์ธ์ค ๊ฐ์ด๋ ํตํฉ ๋ฒ์ ์คํ ์ค!\n")
|
requirements.txt
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
numpy==1.24.3
|
| 2 |
+
pandas==2.0.3
|
| 3 |
+
networkx==3.1
|
| 4 |
+
plotly==5.18.0
|
| 5 |
+
pulp==2.7.0
|
| 6 |
+
gradio==4.44.1
|
| 7 |
+
langgraph==0.0.40
|
| 8 |
+
openai==1.40.0
|
| 9 |
+
langchain-core==0.1.52
|
| 10 |
+
|