pbl_domain_ext/wwwroot/api/pbl_world_get_context.dspy
2026-09-18 18:18:56 +08:00

20 lines
1.3 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# api/pbl_world_get_context.dspy — 契约端点只读世界上下文聚合world + 其下 scene/entity 关联)
# 实现pbl_domain_ext/api.py:pbl_world_get_contextinit.py 经 load_pbl_domain_ext() 注册为 ServerEnv 全局 env.pbl_world_get_context
# 入参tenant_id* world_id* with_scenes with_entities
# 规范module-development-spec §2.5 —— dspy 无 import、显式 return、转发**全部**客户端参数(禁硬编码 dispatch 字段)
# 薄扩展铁律:只读写关联表 pbl_domain_ref基表 world/scene/entity 一律只读Q-OPEN-3
debug('pbl_world_get_context.dspy: START params_kw=%s' % (dict(params_kw) if params_kw else {}))
try:
_params = dict(params_kw) if params_kw else {}
_resp = pbl_world_get_context(_params)
if not isinstance(_resp, dict):
_resp = {'success': False, 'code': 'PBL_DE_INTERNAL',
'message': '契约函数返回非 dict', 'data': None}
debug('pbl_world_get_context.dspy: DONE success=%s code=%s' % (_resp.get('success'), _resp.get('code')))
return _resp
except Exception as exc:
debug('pbl_world_get_context.dspy: FAIL %s' % format_exc())
return {'success': False, 'code': 'PBL_DE_INTERNAL', 'message': str(exc),
'detail': format_exc(), 'http_status': 500, 'data': None}