process-gpt-agent-sdk 0.2.4__py3-none-any.whl → 0.2.6__py3-none-any.whl
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.2.4.dist-info → process_gpt_agent_sdk-0.2.6.dist-info}/METADATA +1 -1
- {process_gpt_agent_sdk-0.2.4.dist-info → process_gpt_agent_sdk-0.2.6.dist-info}/RECORD +8 -8
- processgpt_agent_sdk/core/database.py +3 -13
- processgpt_agent_sdk/server.py +22 -5
- processgpt_agent_sdk/utils/event_handler.py +14 -5
- processgpt_agent_sdk/utils/summarizer.py +2 -2
- {process_gpt_agent_sdk-0.2.4.dist-info → process_gpt_agent_sdk-0.2.6.dist-info}/WHEEL +0 -0
- {process_gpt_agent_sdk-0.2.4.dist-info → process_gpt_agent_sdk-0.2.6.dist-info}/top_level.txt +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
processgpt_agent_sdk/__init__.py,sha256=IvAL5WBZhI83LYQogRP6-i04bxZkhmkgmES4FRQY888,185
|
|
2
|
-
processgpt_agent_sdk/server.py,sha256=
|
|
2
|
+
processgpt_agent_sdk/server.py,sha256=4_uifUFuZCGy1HEBpVAilhjlti25iQ0bjbmeFVrFakU,11366
|
|
3
3
|
processgpt_agent_sdk/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
processgpt_agent_sdk/core/database.py,sha256=
|
|
4
|
+
processgpt_agent_sdk/core/database.py,sha256=Xkd3k_gmLdq3c5_AYYTNIMPm-2UeK7DlY4XdigzL-xU,15891
|
|
5
5
|
processgpt_agent_sdk/tools/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
6
|
processgpt_agent_sdk/tools/human_query_tool.py,sha256=I4Q5AS5YRem0pkIz5_bhMnS5NGlGhKky4_HE22UOdmE,10871
|
|
7
7
|
processgpt_agent_sdk/tools/knowledge_tools.py,sha256=AOtxvLypu343877ZzzELGq3At-E_2NiAqEw0Njlephg,8937
|
|
@@ -9,10 +9,10 @@ processgpt_agent_sdk/tools/safe_tool_loader.py,sha256=18aT1M9FqCecu-JJvKxikYpl7n
|
|
|
9
9
|
processgpt_agent_sdk/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
10
|
processgpt_agent_sdk/utils/context_manager.py,sha256=efNUGxMMJi8Nxy5bOpfYAk2AIjgWoXS0tz6zkROZKrs,1804
|
|
11
11
|
processgpt_agent_sdk/utils/crewai_event_listener.py,sha256=MwIMtRjw7L1uV8QRvlNV1agxRzjL3hC5EYBQIsMX2XA,9155
|
|
12
|
-
processgpt_agent_sdk/utils/event_handler.py,sha256=
|
|
12
|
+
processgpt_agent_sdk/utils/event_handler.py,sha256=meyxMaiGH7VvKQJRhlHKRbWhSzxyEzoHGAEGVIxNocA,2879
|
|
13
13
|
processgpt_agent_sdk/utils/logger.py,sha256=d6Chvwx6qLAyirXRFg4bARzEovo1UYaRgLTaknHad9E,1271
|
|
14
|
-
processgpt_agent_sdk/utils/summarizer.py,sha256=
|
|
15
|
-
process_gpt_agent_sdk-0.2.
|
|
16
|
-
process_gpt_agent_sdk-0.2.
|
|
17
|
-
process_gpt_agent_sdk-0.2.
|
|
18
|
-
process_gpt_agent_sdk-0.2.
|
|
14
|
+
processgpt_agent_sdk/utils/summarizer.py,sha256=h2OBfVYq1JB0A2rLqSdYObEDlN54DzsHTmqnStis4XI,5743
|
|
15
|
+
process_gpt_agent_sdk-0.2.6.dist-info/METADATA,sha256=Sry4j_NwnQTt0K4WsBgPP2jJYVe562jNSIcyhSKxa9c,12898
|
|
16
|
+
process_gpt_agent_sdk-0.2.6.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
17
|
+
process_gpt_agent_sdk-0.2.6.dist-info/top_level.txt,sha256=Xe6zrj3_3Vv7d0pl5RRtenVUckwOVBVLQn2P03j5REo,21
|
|
18
|
+
process_gpt_agent_sdk-0.2.6.dist-info/RECORD,,
|
|
@@ -142,7 +142,7 @@ async def fetch_done_data(proc_inst_id: Optional[str]) -> List[Any]:
|
|
|
142
142
|
resp = await _async_retry(_call, name="fetch_done_data", fallback=lambda: None)
|
|
143
143
|
if not resp:
|
|
144
144
|
return []
|
|
145
|
-
return [row.get("output") for row in (resp.data or [])]
|
|
145
|
+
return [row.get("output") for row in (resp.data or []) if row.get("output")]
|
|
146
146
|
|
|
147
147
|
|
|
148
148
|
def fetch_human_response_sync(job_id: str) -> Optional[Dict[str, Any]]:
|
|
@@ -359,20 +359,10 @@ async def fetch_human_users_by_proc_inst_id(proc_inst_id: str) -> str:
|
|
|
359
359
|
# 데이터 저장
|
|
360
360
|
# 설명: 이벤트/알림/작업 결과 저장
|
|
361
361
|
# ============================================================================
|
|
362
|
-
async def record_event(
|
|
363
|
-
"""UI용 events 테이블에 이벤트 기록"""
|
|
362
|
+
async def record_event(payload: Dict[str, Any]) -> None:
|
|
363
|
+
"""UI용 events 테이블에 이벤트 기록 (전달된 payload 그대로 저장)"""
|
|
364
364
|
def _call():
|
|
365
365
|
client = get_db_client()
|
|
366
|
-
payload: Dict[str, Any] = {
|
|
367
|
-
"id": str(uuid.uuid4()),
|
|
368
|
-
"job_id": todo.get("proc_inst_id") or str(todo.get("id")),
|
|
369
|
-
"todo_id": str(todo.get("id")),
|
|
370
|
-
"proc_inst_id": todo.get("proc_inst_id"),
|
|
371
|
-
"crew_type": todo.get("agent_orch"),
|
|
372
|
-
"data": data,
|
|
373
|
-
}
|
|
374
|
-
if event_type is not None:
|
|
375
|
-
payload["event_type"] = event_type
|
|
376
366
|
return client.table("events").insert(payload).execute()
|
|
377
367
|
|
|
378
368
|
resp = await _async_retry(_call, name="record_event", fallback=lambda: None)
|
processgpt_agent_sdk/server.py
CHANGED
|
@@ -114,6 +114,7 @@ class ProcessGPTAgentServer:
|
|
|
114
114
|
"agent_list": agent_list or [],
|
|
115
115
|
"mcp_config": mcp_config,
|
|
116
116
|
"form_id": form_id,
|
|
117
|
+
"todo_id": str(task_record.get("id")),
|
|
117
118
|
"form_types": form_types or [],
|
|
118
119
|
"form_html": form_html or "",
|
|
119
120
|
"activity_name": str(task_record.get("activity_name", "")),
|
|
@@ -132,7 +133,8 @@ class ProcessGPTAgentServer:
|
|
|
132
133
|
executor = self._executor
|
|
133
134
|
|
|
134
135
|
context = ProcessGPTRequestContext(prepared_data)
|
|
135
|
-
|
|
136
|
+
loop = asyncio.get_running_loop()
|
|
137
|
+
event_queue = ProcessGPTEventQueue(task_record, loop=loop)
|
|
136
138
|
|
|
137
139
|
try:
|
|
138
140
|
set_context(
|
|
@@ -234,9 +236,10 @@ class ProcessGPTRequestContext(RequestContext):
|
|
|
234
236
|
# 설명: 실행기 이벤트를 내부 큐에 넣고, 비동기 처리 태스크를 생성해 저장 로직 호출
|
|
235
237
|
# =============================================================================
|
|
236
238
|
class ProcessGPTEventQueue(EventQueue):
|
|
237
|
-
def __init__(self, task_record: Dict[str, Any]):
|
|
239
|
+
def __init__(self, task_record: Dict[str, Any], loop: asyncio.AbstractEventLoop | None = None):
|
|
238
240
|
"""현재 처리 중인 작업 레코드를 보관한다."""
|
|
239
241
|
self.todo = task_record
|
|
242
|
+
self._loop = loop
|
|
240
243
|
super().__init__()
|
|
241
244
|
|
|
242
245
|
def enqueue_event(self, event: Event):
|
|
@@ -263,13 +266,27 @@ class ProcessGPTEventQueue(EventQueue):
|
|
|
263
266
|
pass
|
|
264
267
|
|
|
265
268
|
def _create_bg_task(self, coro: Any, label: str) -> None:
|
|
266
|
-
"""백그라운드 태스크 생성 및 완료 콜백으로 예외 로깅.
|
|
269
|
+
"""백그라운드 태스크 생성 및 완료 콜백으로 예외 로깅.
|
|
270
|
+
|
|
271
|
+
- 실행 중인 이벤트 루프가 없을 때도 전달된 루프에 안전하게 예약한다.
|
|
272
|
+
"""
|
|
267
273
|
try:
|
|
268
|
-
|
|
274
|
+
loop = self._loop
|
|
275
|
+
if loop is None:
|
|
276
|
+
try:
|
|
277
|
+
loop = asyncio.get_running_loop()
|
|
278
|
+
except RuntimeError:
|
|
279
|
+
raise
|
|
280
|
+
|
|
269
281
|
def _cb(t: asyncio.Task):
|
|
270
282
|
exc = t.exception()
|
|
271
283
|
if exc:
|
|
272
284
|
handle_application_error(f"백그라운드 태스크 오류({label})", exc, raise_error=False)
|
|
273
|
-
|
|
285
|
+
|
|
286
|
+
def _schedule():
|
|
287
|
+
task = loop.create_task(coro)
|
|
288
|
+
task.add_done_callback(_cb)
|
|
289
|
+
|
|
290
|
+
loop.call_soon_threadsafe(_schedule)
|
|
274
291
|
except Exception as e:
|
|
275
292
|
handle_application_error(f"백그라운드 태스크 생성 실패({label})", e, raise_error=False)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from __future__ import annotations
|
|
2
2
|
|
|
3
3
|
from typing import Any, Dict
|
|
4
|
+
import uuid
|
|
4
5
|
|
|
5
6
|
from a2a.server.events import Event
|
|
6
7
|
from .logger import handle_application_error, write_log_message
|
|
@@ -40,8 +41,10 @@ async def process_event_message(todo: Dict[str, Any], event: Event) -> None:
|
|
|
40
41
|
|
|
41
42
|
# done: 종료 이벤트 → 기록 후 MCP 정리
|
|
42
43
|
if evt_type == "done":
|
|
43
|
-
|
|
44
|
-
|
|
44
|
+
payload = data.get("data") or {}
|
|
45
|
+
if isinstance(payload, dict) and "id" not in payload:
|
|
46
|
+
payload["id"] = str(uuid.uuid4())
|
|
47
|
+
await record_event(payload)
|
|
45
48
|
try:
|
|
46
49
|
SafeToolLoader.shutdown_all_adapters()
|
|
47
50
|
write_log_message("MCP 리소스 정리 완료")
|
|
@@ -53,11 +56,17 @@ async def process_event_message(todo: Dict[str, Any], event: Event) -> None:
|
|
|
53
56
|
if evt_type == "output":
|
|
54
57
|
payload = data.get("data") or {}
|
|
55
58
|
is_final = bool(payload.get("final") or payload.get("is_final")) if isinstance(payload, dict) else False
|
|
56
|
-
content = payload.get("content") if isinstance(payload, dict) else payload
|
|
59
|
+
content = payload.get("content") or payload.get("data") if isinstance(payload, dict) else payload
|
|
57
60
|
await save_task_result(str(todo.get("id")), content, final=is_final)
|
|
58
61
|
return
|
|
62
|
+
|
|
63
|
+
# event : 일반 이벤트 저장 (워커 데이터 그대로 보존)
|
|
64
|
+
if evt_type == "event":
|
|
65
|
+
payload = data.get("data") or {}
|
|
66
|
+
if isinstance(payload, dict) and "id" not in payload:
|
|
67
|
+
payload["id"] = str(uuid.uuid4())
|
|
68
|
+
await record_event(payload)
|
|
69
|
+
return
|
|
59
70
|
|
|
60
|
-
# event: 일반 이벤트 저장 (워커 데이터 그대로 보존)
|
|
61
|
-
await record_event(todo, data, event_type="event")
|
|
62
71
|
except Exception as e:
|
|
63
72
|
handle_application_error("process_event_message 처리 실패", e, raise_error=False)
|
|
@@ -24,12 +24,12 @@ async def summarize_async(outputs: Any, feedbacks: Any, contents: Any = None) ->
|
|
|
24
24
|
output_summary = ""
|
|
25
25
|
feedback_summary = ""
|
|
26
26
|
|
|
27
|
-
if outputs_str:
|
|
27
|
+
if outputs_str and outputs_str not in ("[]", "{}", "[{}]"):
|
|
28
28
|
write_log_message("요약 호출(이전결과물)")
|
|
29
29
|
output_prompt = _create_output_summary_prompt(outputs_str)
|
|
30
30
|
output_summary = await _call_openai_api_async(output_prompt, task_name="output")
|
|
31
31
|
|
|
32
|
-
if feedbacks_str
|
|
32
|
+
if feedbacks_str and feedbacks_str not in ("[]", "{}"):
|
|
33
33
|
write_log_message("요약 호출(피드백)")
|
|
34
34
|
feedback_prompt = _create_feedback_summary_prompt(feedbacks_str, contents_str)
|
|
35
35
|
feedback_summary = await _call_openai_api_async(feedback_prompt, task_name="feedback")
|
|
File without changes
|
{process_gpt_agent_sdk-0.2.4.dist-info → process_gpt_agent_sdk-0.2.6.dist-info}/top_level.txt
RENAMED
|
File without changes
|