process-gpt-agent-sdk 0.3.17__tar.gz → 0.3.18__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of process-gpt-agent-sdk might be problematic. Click here for more details.
- {process_gpt_agent_sdk-0.3.17 → process_gpt_agent_sdk-0.3.18}/PKG-INFO +1 -1
- {process_gpt_agent_sdk-0.3.17 → process_gpt_agent_sdk-0.3.18}/process_gpt_agent_sdk.egg-info/PKG-INFO +1 -1
- {process_gpt_agent_sdk-0.3.17 → process_gpt_agent_sdk-0.3.18}/processgpt_agent_sdk/database.py +7 -1
- {process_gpt_agent_sdk-0.3.17 → process_gpt_agent_sdk-0.3.18}/processgpt_agent_sdk/processgpt_agent_framework.py +17 -5
- process_gpt_agent_sdk-0.3.18/processgpt_agent_sdk/utils.py +193 -0
- {process_gpt_agent_sdk-0.3.17 → process_gpt_agent_sdk-0.3.18}/pyproject.toml +1 -1
- process_gpt_agent_sdk-0.3.17/processgpt_agent_sdk/utils.py +0 -100
- {process_gpt_agent_sdk-0.3.17 → process_gpt_agent_sdk-0.3.18}/README.md +0 -0
- {process_gpt_agent_sdk-0.3.17 → process_gpt_agent_sdk-0.3.18}/process_gpt_agent_sdk.egg-info/SOURCES.txt +0 -0
- {process_gpt_agent_sdk-0.3.17 → process_gpt_agent_sdk-0.3.18}/process_gpt_agent_sdk.egg-info/dependency_links.txt +0 -0
- {process_gpt_agent_sdk-0.3.17 → process_gpt_agent_sdk-0.3.18}/process_gpt_agent_sdk.egg-info/requires.txt +0 -0
- {process_gpt_agent_sdk-0.3.17 → process_gpt_agent_sdk-0.3.18}/process_gpt_agent_sdk.egg-info/top_level.txt +0 -0
- {process_gpt_agent_sdk-0.3.17 → process_gpt_agent_sdk-0.3.18}/processgpt_agent_sdk/__init__.py +0 -0
- {process_gpt_agent_sdk-0.3.17 → process_gpt_agent_sdk-0.3.18}/setup.cfg +0 -0
{process_gpt_agent_sdk-0.3.17 → process_gpt_agent_sdk-0.3.18}/processgpt_agent_sdk/database.py
RENAMED
|
@@ -157,8 +157,14 @@ async def fetch_context_bundle(
|
|
|
157
157
|
notify = (row.get("notify_emails") or "").strip()
|
|
158
158
|
mcp = row.get("tenant_mcp") or None
|
|
159
159
|
form_id = row.get("form_id")
|
|
160
|
-
form_fields = row.get("form_fields")
|
|
160
|
+
form_fields = row.get("form_fields")
|
|
161
161
|
form_html = row.get("form_html")
|
|
162
|
+
|
|
163
|
+
# form 정보가 없는 경우 자유형식 폼으로 처리
|
|
164
|
+
if not form_id or not form_fields:
|
|
165
|
+
form_id = "freeform"
|
|
166
|
+
form_fields = [{"key": "freeform", "type": "textarea", "text": "자유형식 입력", "placeholder": "원하는 내용을 자유롭게 입력해주세요."}]
|
|
167
|
+
form_html = None
|
|
162
168
|
agents = row.get("agents") or []
|
|
163
169
|
return notify, mcp, (form_id, form_fields, form_html), agents
|
|
164
170
|
|
|
@@ -23,7 +23,7 @@ from .database import (
|
|
|
23
23
|
get_consumer_id,
|
|
24
24
|
fetch_context_bundle,
|
|
25
25
|
)
|
|
26
|
-
from .utils import summarize_error_to_user
|
|
26
|
+
from .utils import summarize_error_to_user, summarize_feedback
|
|
27
27
|
|
|
28
28
|
load_dotenv()
|
|
29
29
|
logging.basicConfig(level=logging.INFO)
|
|
@@ -93,7 +93,7 @@ class TodoListRowContext:
|
|
|
93
93
|
class ProcessGPTRequestContext(RequestContext):
|
|
94
94
|
def __init__(self, row: Dict[str, Any]):
|
|
95
95
|
self.row = row
|
|
96
|
-
self._user_input = (row.get("
|
|
96
|
+
self._user_input = (row.get("query") or "").strip()
|
|
97
97
|
self._message = self._user_input
|
|
98
98
|
self._current_task = None
|
|
99
99
|
self._task_state = row.get("draft_status") or ""
|
|
@@ -124,16 +124,27 @@ class ProcessGPTRequestContext(RequestContext):
|
|
|
124
124
|
)
|
|
125
125
|
form_id, form_fields, form_html = form_tuple
|
|
126
126
|
|
|
127
|
-
logger.info("📦 컨텍스트 번들 조회 완료 - agents: %d개, notify_emails: %s",
|
|
127
|
+
logger.info("📦 컨텍스트 번들 조회 완료 - agents: %d개, notify_emails: %s, form_type: %s",
|
|
128
128
|
len(agents) if isinstance(agents, list) else 0,
|
|
129
|
-
"있음" if notify_emails else "없음"
|
|
129
|
+
"있음" if notify_emails else "없음",
|
|
130
|
+
"자유형식" if form_id == "freeform" else "정의된 폼")
|
|
130
131
|
|
|
131
132
|
except Exception as e:
|
|
132
133
|
logger.error("❌ 컨텍스트 번들 조회 실패: %s", str(e))
|
|
133
134
|
# 사용자 친화 요약은 상위 경계에서 한 번만 기록하도록 넘김
|
|
134
135
|
raise ContextPreparationError(e)
|
|
135
136
|
|
|
136
|
-
# 3단계:
|
|
137
|
+
# 3단계: 피드백 요약 처리
|
|
138
|
+
logger.info("📝 피드백 요약 처리 중...")
|
|
139
|
+
feedback_str = self.row.get("feedback", "")
|
|
140
|
+
contents_str = self.row.get("output", "") or self.row.get("draft", "")
|
|
141
|
+
summarized_feedback = ""
|
|
142
|
+
|
|
143
|
+
if feedback_str.strip():
|
|
144
|
+
summarized_feedback = await summarize_feedback(feedback_str, contents_str)
|
|
145
|
+
logger.info("✅ 피드백 요약 완료 - 원본: %d자 → 요약: %d자", len(feedback_str), len(summarized_feedback))
|
|
146
|
+
|
|
147
|
+
# 4단계: 컨텍스트 구성
|
|
137
148
|
logger.info("🏗️ 컨텍스트 구성 중...")
|
|
138
149
|
self._extra_context = {
|
|
139
150
|
"id": self.row.get("id"),
|
|
@@ -146,6 +157,7 @@ class ProcessGPTRequestContext(RequestContext):
|
|
|
146
157
|
"form_html": form_html,
|
|
147
158
|
"form_id": form_id,
|
|
148
159
|
"notify_user_emails": notify_emails,
|
|
160
|
+
"summarized_feedback": summarized_feedback,
|
|
149
161
|
}
|
|
150
162
|
|
|
151
163
|
logger.info("✅ 컨텍스트 준비 완료! (agents=%d개)",
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
import os
|
|
2
|
+
import logging
|
|
3
|
+
import traceback
|
|
4
|
+
from typing import Any, Dict, Optional, List
|
|
5
|
+
|
|
6
|
+
try:
|
|
7
|
+
# 비동기 클라이언트 사용 → 이벤트 루프 블로킹 방지
|
|
8
|
+
from openai import AsyncOpenAI
|
|
9
|
+
except Exception:
|
|
10
|
+
AsyncOpenAI = None # type: ignore
|
|
11
|
+
|
|
12
|
+
logger = logging.getLogger(__name__)
|
|
13
|
+
|
|
14
|
+
# ─────────────────────────────
|
|
15
|
+
# Lazy Singleton OpenAI Client
|
|
16
|
+
# ─────────────────────────────
|
|
17
|
+
_client: Optional["AsyncOpenAI"] = None # type: ignore[name-defined]
|
|
18
|
+
|
|
19
|
+
def _require_env(name: str, default: Optional[str] = None) -> str:
|
|
20
|
+
v = os.getenv(name, default if default is not None else "")
|
|
21
|
+
if not v:
|
|
22
|
+
raise RuntimeError(f"Missing required environment variable: {name}")
|
|
23
|
+
return v
|
|
24
|
+
|
|
25
|
+
def get_client() -> "AsyncOpenAI": # type: ignore[name-defined]
|
|
26
|
+
global _client
|
|
27
|
+
if _client is not None:
|
|
28
|
+
return _client
|
|
29
|
+
if AsyncOpenAI is None:
|
|
30
|
+
raise RuntimeError("OpenAI SDK (async) is not available")
|
|
31
|
+
base_url = os.getenv("OPENAI_BASE_URL", "https://api.openai.com/v1")
|
|
32
|
+
api_key = _require_env("OPENAI_API_KEY", "")
|
|
33
|
+
_client = AsyncOpenAI(base_url=base_url, api_key=api_key)
|
|
34
|
+
return _client
|
|
35
|
+
|
|
36
|
+
# ─────────────────────────────
|
|
37
|
+
# 공통 LLM 호출 유틸
|
|
38
|
+
# ─────────────────────────────
|
|
39
|
+
async def _llm_request(system: str, user: str, model_env: str, default_model: str) -> str:
|
|
40
|
+
model_name = os.getenv(model_env, default_model)
|
|
41
|
+
logger.info("📡 LLM 요청 전송 (모델: %s)", model_name)
|
|
42
|
+
|
|
43
|
+
client = get_client()
|
|
44
|
+
# responses API (신규)
|
|
45
|
+
resp = await client.responses.create(
|
|
46
|
+
model=model_name,
|
|
47
|
+
input=[
|
|
48
|
+
{"role": "system", "content": system},
|
|
49
|
+
{"role": "user", "content": user},
|
|
50
|
+
],
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
# 다양한 SDK 출력 구조 호환
|
|
54
|
+
text: Optional[str] = None
|
|
55
|
+
try:
|
|
56
|
+
text = getattr(resp, "output_text", None) # 최신 필드
|
|
57
|
+
except Exception:
|
|
58
|
+
text = None
|
|
59
|
+
|
|
60
|
+
if not text and hasattr(resp, "choices") and resp.choices: # 구 구조 호환
|
|
61
|
+
choice0 = resp.choices[0]
|
|
62
|
+
text = getattr(getattr(choice0, "message", None), "content", None)
|
|
63
|
+
|
|
64
|
+
if not text:
|
|
65
|
+
raise RuntimeError("No text in LLM response")
|
|
66
|
+
|
|
67
|
+
return text.strip()
|
|
68
|
+
|
|
69
|
+
# ─────────────────────────────
|
|
70
|
+
# 공개 API
|
|
71
|
+
# ─────────────────────────────
|
|
72
|
+
async def summarize_error_to_user(exc: Exception, meta: Dict[str, Any]) -> str:
|
|
73
|
+
"""
|
|
74
|
+
예외 정보를 바탕으로 사용자 친화적인 5줄 요약을 생성.
|
|
75
|
+
- 모델: gpt-4.1-nano (환경변수 ERROR_SUMMARY_MODEL로 재정의 가능)
|
|
76
|
+
- 폴백: 없음 (LLM 실패 시 예외를 상위로 전파)
|
|
77
|
+
"""
|
|
78
|
+
logger.info("🔍 오류 컨텍스트 분석 시작")
|
|
79
|
+
|
|
80
|
+
err_text = f"{type(exc).__name__}: {str(exc)}"
|
|
81
|
+
|
|
82
|
+
# 가벼운 스택 문자열 (상위 3프레임)
|
|
83
|
+
try:
|
|
84
|
+
tb = "".join(traceback.TracebackException.from_exception(exc, limit=3).format())
|
|
85
|
+
except Exception:
|
|
86
|
+
tb = traceback.format_exc(limit=3)
|
|
87
|
+
|
|
88
|
+
meta_items: List[str] = []
|
|
89
|
+
for k in ("task_id", "proc_inst_id", "agent_orch", "tool"):
|
|
90
|
+
v = meta.get(k)
|
|
91
|
+
if v:
|
|
92
|
+
meta_items.append(f"{k}={v}")
|
|
93
|
+
meta_text = ", ".join(meta_items)
|
|
94
|
+
|
|
95
|
+
logger.info("📋 오류 컨텍스트 정리 완료 - %s", meta_text)
|
|
96
|
+
|
|
97
|
+
system = (
|
|
98
|
+
"당신은 엔터프라이즈 SDK의 오류 비서입니다. "
|
|
99
|
+
"사용자(비개발자도 이해 가능)를 위해, 아래 조건을 정확히 지켜 5줄로 한국어 설명을 만드세요.\n"
|
|
100
|
+
"형식: 각 줄은 1문장씩, 총 5줄.\n"
|
|
101
|
+
"포함 요소: ①무슨 문제인지(원인 추정) ②어떤 영향이 있는지 ③즉시 할 일(대처) "
|
|
102
|
+
"④재발 방지 팁 ⑤필요시 지원 요청 경로.\n"
|
|
103
|
+
"과장 금지, 간결하고 친절하게."
|
|
104
|
+
)
|
|
105
|
+
user = (
|
|
106
|
+
f"[오류요약대상]\n"
|
|
107
|
+
f"- 컨텍스트: {meta_text}\n"
|
|
108
|
+
f"- 에러: {err_text}\n"
|
|
109
|
+
f"- 스택(상위 3프레임):\n{tb}\n"
|
|
110
|
+
f"위 정보를 바탕으로 5줄 설명을 출력하세요."
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
try:
|
|
114
|
+
text = await _llm_request(system, user, "ERROR_SUMMARY_MODEL", "gpt-4.1-nano")
|
|
115
|
+
logger.info("✅ LLM 오류 요약 생성 완료")
|
|
116
|
+
return text
|
|
117
|
+
except Exception as e:
|
|
118
|
+
logger.warning("⚠️ LLM 오류 요약 생성 실패: %s", e, exc_info=True)
|
|
119
|
+
# 폴백 없이 상위 전파
|
|
120
|
+
raise
|
|
121
|
+
|
|
122
|
+
async def summarize_feedback(feedback_str: str, contents_str: str = "") -> str:
|
|
123
|
+
"""
|
|
124
|
+
피드백과 결과물을 바탕으로 통합된 피드백 요약을 생성.
|
|
125
|
+
- 모델: gpt-4.1-nano (환경변수 FEEDBACK_SUMMARY_MODEL로 재정의 가능)
|
|
126
|
+
- 폴백: 없음 (LLM 실패 시 예외를 상위로 전파)
|
|
127
|
+
"""
|
|
128
|
+
logger.info(
|
|
129
|
+
"🔍 피드백 요약 처리 시작 | 피드백: %d자, 결과물: %d자",
|
|
130
|
+
len(feedback_str or ""), len(contents_str or "")
|
|
131
|
+
)
|
|
132
|
+
|
|
133
|
+
system_prompt = _get_feedback_system_prompt()
|
|
134
|
+
user_prompt = _create_feedback_summary_prompt(feedback_str, contents_str)
|
|
135
|
+
|
|
136
|
+
try:
|
|
137
|
+
text = await _llm_request(system_prompt, user_prompt, "FEEDBACK_SUMMARY_MODEL", "gpt-4.1-nano")
|
|
138
|
+
logger.info("✅ LLM 피드백 요약 생성 완료")
|
|
139
|
+
return text
|
|
140
|
+
except Exception as e:
|
|
141
|
+
logger.error("❌ LLM 피드백 요약 생성 실패: %s", e, exc_info=True)
|
|
142
|
+
# 폴백 없이 상위 전파
|
|
143
|
+
raise
|
|
144
|
+
|
|
145
|
+
# ─────────────────────────────
|
|
146
|
+
# 프롬프트 유틸
|
|
147
|
+
# ─────────────────────────────
|
|
148
|
+
def _create_feedback_summary_prompt(feedbacks_str: str, contents_str: str = "") -> str:
|
|
149
|
+
"""피드백 정리 프롬프트 - 현재 결과물과 피드백을 함께 분석"""
|
|
150
|
+
blocks: List[str] = ["다음은 사용자의 피드백과 결과물입니다. 이를 분석하여 통합된 피드백을 작성해주세요:"]
|
|
151
|
+
if feedbacks_str and feedbacks_str.strip():
|
|
152
|
+
blocks.append(f"=== 피드백 내용 ===\n{feedbacks_str}")
|
|
153
|
+
if contents_str and contents_str.strip():
|
|
154
|
+
blocks.append(f"=== 현재 결과물/작업 내용 ===\n{contents_str}")
|
|
155
|
+
|
|
156
|
+
blocks.append(
|
|
157
|
+
"""**상황 분석 및 처리 방식:**
|
|
158
|
+
- **현재 결과물을 보고 어떤 점이 문제인지, 개선이 필요한지 판단**
|
|
159
|
+
- 피드백이 있다면 그 의도와 요구사항을 정확히 파악
|
|
160
|
+
- 결과물 자체가 마음에 안들어서 다시 작업을 요청하는 경우일 수 있음
|
|
161
|
+
- 작업 방식이나 접근법이 잘못되었다고 판단하는 경우일 수 있음
|
|
162
|
+
- 부분적으로는 좋지만 특정 부분의 수정이나 보완이 필요한 경우일 수 있음
|
|
163
|
+
- 현재 결과물에 매몰되지 말고, 실제 어떤 부분이 문제인지 파악하여 개선 방안을 제시
|
|
164
|
+
|
|
165
|
+
**피드백 통합 원칙:**
|
|
166
|
+
- **가장 최신 피드백을 최우선으로 반영**
|
|
167
|
+
- 결과물과 피드백을 종합적으로 분석하여 핵심 문제점 파악
|
|
168
|
+
- **시간 흐름을 파악하여 피드백들 간의 연결고리와 문맥을 이해**
|
|
169
|
+
- 구체적이고 실행 가능한 개선사항 제시
|
|
170
|
+
- **자연스럽고 통합된 하나의 완전한 피드백으로 작성**
|
|
171
|
+
- 최대 1000자까지 허용하여 상세히 작성
|
|
172
|
+
|
|
173
|
+
**중요한 상황별 처리:**
|
|
174
|
+
- 결과물 품질에 대한 불만 → **품질 개선** 요구
|
|
175
|
+
- 작업 방식에 대한 불만 → **접근법 변경** 요구
|
|
176
|
+
- 이전에 저장을 했는데 잘못 저장되었다면 → **수정**이 필요
|
|
177
|
+
- 이전에 조회만 했는데 저장이 필요하다면 → **저장**이 필요
|
|
178
|
+
- 부분적 수정이 필요하다면 → **특정 부분 개선** 요구
|
|
179
|
+
|
|
180
|
+
출력 형식: 현재 상황을 종합적으로 분석한 완전한 피드백 문장 (다음 작업자가 즉시 이해하고 실행할 수 있도록)"""
|
|
181
|
+
)
|
|
182
|
+
return "\n\n".join(blocks)
|
|
183
|
+
|
|
184
|
+
def _get_feedback_system_prompt() -> str:
|
|
185
|
+
"""피드백 요약용 시스템 프롬프트"""
|
|
186
|
+
return """당신은 피드백 정리 전문가입니다.
|
|
187
|
+
|
|
188
|
+
핵심 원칙:
|
|
189
|
+
- 최신 피드백을 최우선으로 하여 시간 흐름을 파악
|
|
190
|
+
- 피드백 간 문맥과 연결고리를 파악하여 하나의 완전한 요청으로 통합
|
|
191
|
+
- 자연스럽고 통합된 피드백으로 작성
|
|
192
|
+
- 구체적인 요구사항과 개선사항을 누락 없이 포함
|
|
193
|
+
- 다음 작업자가 즉시 이해할 수 있도록 명확하게"""
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import traceback
|
|
3
|
-
import logging
|
|
4
|
-
from typing import Any, Dict
|
|
5
|
-
|
|
6
|
-
# OpenAI 호환 엔드포인트 사용 (환경변수 기반)
|
|
7
|
-
# OPENAI_API_KEY, OPENAI_BASE_URL(required if not default)
|
|
8
|
-
try:
|
|
9
|
-
from openai import OpenAI
|
|
10
|
-
except Exception: # 라이브러리 미설치/호환 환경 대비
|
|
11
|
-
OpenAI = None # type: ignore
|
|
12
|
-
|
|
13
|
-
logger = logging.getLogger(__name__)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
async def summarize_error_to_user(exc: Exception, meta: Dict[str, Any]) -> str:
|
|
17
|
-
"""
|
|
18
|
-
예외 정보를 바탕으로 사용자 친화적인 5줄 요약을 생성.
|
|
19
|
-
- 모델: gpt-4.1-nano (요청사항 반영)
|
|
20
|
-
- 실패 시 Fallback: 간단한 수동 요약문
|
|
21
|
-
"""
|
|
22
|
-
# 오류 컨텍스트 정리
|
|
23
|
-
logger.info("🔍 오류 컨텍스트 분석 중...")
|
|
24
|
-
err_text = f"{type(exc).__name__}: {str(exc)}"
|
|
25
|
-
tb = traceback.format_exc(limit=3)
|
|
26
|
-
meta_lines = [
|
|
27
|
-
f"task_id={meta.get('task_id')}",
|
|
28
|
-
f"proc_inst_id={meta.get('proc_inst_id')}",
|
|
29
|
-
f"agent_orch={meta.get('agent_orch')}",
|
|
30
|
-
f"tool={meta.get('tool')}",
|
|
31
|
-
]
|
|
32
|
-
meta_text = ", ".join([x for x in meta_lines if x])
|
|
33
|
-
logger.info("📋 오류 컨텍스트 분석 완료 - %s", meta_text)
|
|
34
|
-
|
|
35
|
-
system = (
|
|
36
|
-
"당신은 엔터프라이즈 SDK의 오류 비서입니다. "
|
|
37
|
-
"사용자(비개발자도 이해 가능)를 위해, 아래 조건을 정확히 지켜 5줄로 한국어 설명을 만드세요.\n"
|
|
38
|
-
"형식: 각 줄은 1문장씩, 총 5줄.\n"
|
|
39
|
-
"포함 요소: ①무슨 문제인지(원인 추정) ②어떤 영향이 있는지 ③즉시 할 일(대처) "
|
|
40
|
-
"④재발 방지 팁 ⑤필요시 지원 요청 경로.\n"
|
|
41
|
-
"과장 금지, 간결하고 친절하게."
|
|
42
|
-
)
|
|
43
|
-
user = (
|
|
44
|
-
f"[오류요약대상]\n"
|
|
45
|
-
f"- 컨텍스트: {meta_text}\n"
|
|
46
|
-
f"- 에러: {err_text}\n"
|
|
47
|
-
f"- 스택(상위 3프레임):\n{tb}\n"
|
|
48
|
-
f"위 정보를 바탕으로 5줄 설명을 출력하세요."
|
|
49
|
-
)
|
|
50
|
-
|
|
51
|
-
try:
|
|
52
|
-
if OpenAI is None:
|
|
53
|
-
logger.warning("⚠️ OpenAI SDK 사용 불가 - Fallback 모드로 전환")
|
|
54
|
-
raise RuntimeError("OpenAI SDK not available")
|
|
55
|
-
|
|
56
|
-
logger.info("🤖 OpenAI 클라이언트 초기화 중...")
|
|
57
|
-
client = OpenAI(
|
|
58
|
-
base_url=os.getenv("OPENAI_BASE_URL", "https://api.openai.com/v1"),
|
|
59
|
-
api_key=os.getenv("OPENAI_API_KEY", ""),
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
model_name = os.getenv("ERROR_SUMMARY_MODEL", "gpt-4.1-nano")
|
|
63
|
-
logger.info("📡 LLM 요청 전송 중... (모델: %s)", model_name)
|
|
64
|
-
|
|
65
|
-
# responses API (신규 SDK)
|
|
66
|
-
resp = client.responses.create(
|
|
67
|
-
model=model_name,
|
|
68
|
-
input=[{"role": "system", "content": system},
|
|
69
|
-
{"role": "user", "content": user}],
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
logger.info("🔍 LLM 응답 분석 중...")
|
|
73
|
-
# 텍스트 추출(호환성 고려)
|
|
74
|
-
text = None
|
|
75
|
-
try:
|
|
76
|
-
text = resp.output_text # type: ignore[attr-defined]
|
|
77
|
-
except Exception:
|
|
78
|
-
# 다른 필드 구조 호환
|
|
79
|
-
if hasattr(resp, "choices") and resp.choices:
|
|
80
|
-
text = getattr(resp.choices[0].message, "content", None) # type: ignore
|
|
81
|
-
if not text:
|
|
82
|
-
raise RuntimeError("No text in LLM response")
|
|
83
|
-
|
|
84
|
-
logger.info("✅ LLM 오류 요약 생성 완료")
|
|
85
|
-
return text.strip()
|
|
86
|
-
|
|
87
|
-
except Exception as e:
|
|
88
|
-
logger.warning("⚠️ LLM 오류 요약 생성 실패: %s - Fallback 모드로 전환", str(e))
|
|
89
|
-
# Fallback: 간단 5줄
|
|
90
|
-
logger.info("📝 Fallback 오류 요약 생성 중...")
|
|
91
|
-
|
|
92
|
-
fallback_text = (
|
|
93
|
-
"1) 처리 중 알 수 없는 오류가 발생했어요(환경/입력 값 문제일 수 있어요).\n"
|
|
94
|
-
"2) 작업 결과가 저장되지 않았거나 일부만 반영됐을 수 있어요.\n"
|
|
95
|
-
"3) 입력 값과 네트워크 상태를 확인하고, 다시 시도해 주세요.\n"
|
|
96
|
-
"4) 같은 문제가 반복되면 로그와 설정(키/URL/권한)을 점검해 주세요.\n"
|
|
97
|
-
"5) 계속되면 관리자나 운영팀에 문의해 원인 분석을 요청해 주세요."
|
|
98
|
-
)
|
|
99
|
-
logger.info("✅ Fallback 오류 요약 생성 완료")
|
|
100
|
-
return fallback_text
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{process_gpt_agent_sdk-0.3.17 → process_gpt_agent_sdk-0.3.18}/processgpt_agent_sdk/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|