fabagent / agents /tools /process.py
hee_!J
feat(tools): agent tool registry - 7๊ฐœ tool + OpenAI function schema
d6ae565
Raw
History Blame Contribute Delete
4.13 kB
"""๊ณต์ • ๊ด€๋ จ tools - downstream ์˜์กด์„ฑ + WIP + yield baseline
์‹ค fab์—์„  MES + Yield Management System์—์„œ ์กฐํšŒ๋˜๋Š” ๊ฐ’
"""
from data.wip import get_affected_wip
# ๊ณต์ • ํ๋ฆ„ (๋Œ€ํ‘œ ๋ผ์ธ: Photo -> Etch -> CMP -> Diffusion -> Implant -> Metal -> Test)
# ๊ฐ entry๋Š” (downstream_stage, typical_delta_pct, severity)
_DOWNSTREAM = {
"Photo": [
("Etch", 18, "impacted"),
("CMP", 5, "minor"),
],
"Etch": [
("CMP", 15, "impacted"),
("Diffusion", 3, "minor"),
],
"CMP": [
("Diffusion", 8, "impacted"),
("Implant", 12, "impacted"),
("Test", 6, "minor"),
],
"Diffusion": [
("Implant", 10, "impacted"),
("Metal", 4, "minor"),
],
"Implant": [
("Metal", 7, "impacted"),
("Test", 5, "minor"),
],
}
# ๊ณต์ •๋ณ„ yield ๊ธฐ์ค€์„  (์ตœ๊ทผ 30์ผ ํ‰๊ท , %)
_YIELD_BASELINE = {
"Photo": 96.4,
"Etch": 95.8,
"CMP": 96.1,
"Diffusion": 97.2,
"Implant": 96.7,
}
def get_downstream_steps(current_stage: str) -> dict:
"""ํ˜„์žฌ ๊ณต์ • ์ดํ›„๋กœ ์˜ํ–ฅ ๋ฐ›๋Š” ํ›„๊ณต์ • ๋ชฉ๋ก ๋ฐ˜ํ™˜
๊ฐ ํ›„๊ณต์ •์— ๋Œ€ํ•ด typical delta(%, ์˜ํ–ฅ ๊ฐ•๋„)์™€ severity(impacted/minor) ์ œ๊ณต
"""
deps = _DOWNSTREAM.get(current_stage, [])
return {
"current_stage": current_stage,
"downstream": [
{"stage": s, "typical_delta_pct": d, "severity": sev}
for s, d, sev in deps
],
}
def query_wip_status(alarm_id: str) -> dict:
"""์•Œ๋žŒ์œผ๋กœ ์˜ํ–ฅ ๋ฐ›๋Š” WIP(๊ฐ€๊ณต์ค‘ยท๋Œ€๊ธฐ์ค‘) lot ์ˆ˜ + wafer ์ˆ˜ ์กฐํšŒ"""
lots = get_affected_wip(alarm_id)
return {"alarm_id": alarm_id, "wip": lots}
def get_yield_baseline(process: str) -> dict:
"""๊ณต์ •์˜ ์ตœ๊ทผ 30์ผ yield ๊ธฐ์ค€์„ (%) ๋ฐ˜ํ™˜
์ด์ƒ ๋ฐœ์ƒ ์‹œ baseline ๋Œ€๋น„ yield_loss ๊ณ„์‚ฐ์— ์‚ฌ์šฉ
"""
baseline = _YIELD_BASELINE.get(process)
if baseline is None:
return {"error": f"๋“ฑ๋ก๋˜์ง€ ์•Š์€ ๊ณต์ •: {process}"}
return {"process": process, "baseline_yield_pct": baseline, "window": "์ตœ๊ทผ 30์ผ"}
SCHEMA_DOWNSTREAM = {
"type": "function",
"function": {
"name": "get_downstream_steps",
"description": (
"ํ˜„์žฌ ๊ณต์ • ์ดํ›„ ์˜ํ–ฅ ๋ฐ›๋Š” ํ›„๊ณต์ • ๋ชฉ๋ก์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค. "
"๊ฐ ํ›„๊ณต์ •์˜ ์ผ๋ฐ˜์  ์˜ํ–ฅ ๊ฐ•๋„(typical_delta_pct)์™€ severity(impacted/minor)๋ฅผ ํฌํ•จ. "
"Tier 3 ์˜ํ–ฅ ํ‰๊ฐ€์—์„œ downstream_dependencies ์‚ฐ์ถœ์— ์‚ฌ์šฉํ•˜์„ธ์š”."
),
"parameters": {
"type": "object",
"properties": {
"current_stage": {
"type": "string",
"description": "ํ˜„์žฌ ๊ณต์ • (Photo, Etch, CMP, Diffusion, Implant ์ค‘)",
},
},
"required": ["current_stage"],
},
},
}
SCHEMA_WIP = {
"type": "function",
"function": {
"name": "query_wip_status",
"description": (
"์•Œ๋žŒ์œผ๋กœ ์˜ํ–ฅ ๋ฐ›๋Š” WIP(๊ฐ€๊ณต์ค‘ยท๋Œ€๊ธฐ์ค‘) lot/wafer ์ˆ˜๋ฅผ MES์—์„œ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค. "
"Tier 3 impact_lots ํ•„๋“œ๋ฅผ ์ฑ„์šธ ๋•Œ ์‚ฌ์šฉํ•˜์„ธ์š”."
),
"parameters": {
"type": "object",
"properties": {
"alarm_id": {
"type": "string",
"description": "์•Œ๋žŒ ID (A1, A2, A3)",
},
},
"required": ["alarm_id"],
},
},
}
SCHEMA_YIELD = {
"type": "function",
"function": {
"name": "get_yield_baseline",
"description": (
"๊ณต์ •์˜ ์ตœ๊ทผ 30์ผ yield ๊ธฐ์ค€์„ (%)์„ ์กฐํšŒํ•ฉ๋‹ˆ๋‹ค. "
"yield_loss๋ฅผ baseline ๋Œ€๋น„๋กœ ์ •๋Ÿ‰ํ™”ํ•  ๋•Œ ์‚ฌ์šฉํ•˜์„ธ์š”."
),
"parameters": {
"type": "object",
"properties": {
"process": {
"type": "string",
"description": "๊ณต์ • ์ด๋ฆ„ (Photo, Etch, CMP, Diffusion, Implant)",
},
},
"required": ["process"],
},
},
}