docs: 更新协议文档,删除废弃计划文档
- 更新 http-error-codes, user-points-chat-data-protocol - 更新 divination-run-protocol, profile-protocol - 删除废弃的后端和前端设计计划文档
This commit is contained in:
@@ -35,6 +35,7 @@ from schemas.agent.forwarded_props import (
|
||||
)
|
||||
from schemas.domain.divination import DerivedDivinationData
|
||||
from schemas.agent.runtime_models import (
|
||||
FollowUpOutput,
|
||||
WorkerAgentOutputLite,
|
||||
resolve_worker_output_model,
|
||||
)
|
||||
@@ -102,21 +103,23 @@ class AgentScopeRunner:
|
||||
worker_toolkit = self._build_toolkit()
|
||||
if cancel_checker is not None and await cancel_checker():
|
||||
raise asyncio.CancelledError("run canceled by user")
|
||||
derived_divination = self._resolve_derived_divination(
|
||||
run_input=run_input
|
||||
)
|
||||
await self._emit_step_event(
|
||||
pipeline=pipeline,
|
||||
run_input=run_input,
|
||||
step_name="divination",
|
||||
event_type="DIVINATION_DERIVED",
|
||||
runtime_mode=runtime_mode,
|
||||
extra_event={
|
||||
"divination": derived_divination.model_dump(
|
||||
mode="json", by_alias=True, exclude_none=True
|
||||
)
|
||||
},
|
||||
)
|
||||
derived_divination: DerivedDivinationData | None = None
|
||||
if runtime_mode == RuntimeMode.CHAT:
|
||||
derived_divination = self._resolve_derived_divination(
|
||||
run_input=run_input
|
||||
)
|
||||
await self._emit_step_event(
|
||||
pipeline=pipeline,
|
||||
run_input=run_input,
|
||||
step_name="divination",
|
||||
event_type="DIVINATION_DERIVED",
|
||||
runtime_mode=runtime_mode,
|
||||
extra_event={
|
||||
"divination": derived_divination.model_dump(
|
||||
mode="json", by_alias=True, exclude_none=True
|
||||
)
|
||||
},
|
||||
)
|
||||
worker_output = await self._execute_worker_step(
|
||||
pipeline=pipeline,
|
||||
run_input=run_input,
|
||||
@@ -208,9 +211,11 @@ class AgentScopeRunner:
|
||||
stage_config: SystemAgentRuntimeConfig,
|
||||
runtime_client_time: ClientTimeContext | None,
|
||||
runtime_mode: RuntimeMode,
|
||||
derived_divination: DerivedDivinationData,
|
||||
) -> WorkerAgentOutputLite:
|
||||
worker_output_model = resolve_worker_output_model()
|
||||
derived_divination: DerivedDivinationData | None,
|
||||
) -> WorkerAgentOutputLite | FollowUpOutput:
|
||||
worker_output_model = resolve_worker_output_model(
|
||||
runtime_mode=runtime_mode.value
|
||||
)
|
||||
await self._emit_step_event(
|
||||
pipeline=pipeline,
|
||||
run_input=run_input,
|
||||
@@ -252,11 +257,11 @@ class AgentScopeRunner:
|
||||
toolkit: Any,
|
||||
run_input: RunAgentInput,
|
||||
stage_config: SystemAgentRuntimeConfig,
|
||||
worker_output_model: type[WorkerAgentOutputLite],
|
||||
worker_output_model: type[WorkerAgentOutputLite | FollowUpOutput],
|
||||
pipeline: PipelineLike,
|
||||
runtime_client_time: ClientTimeContext | None,
|
||||
runtime_mode: RuntimeMode,
|
||||
derived_divination: DerivedDivinationData,
|
||||
derived_divination: DerivedDivinationData | None,
|
||||
) -> StageExecutionResult:
|
||||
tracking_model = self._build_model(stage_config=stage_config)
|
||||
formatter = OpenAIChatFormatter()
|
||||
@@ -292,12 +297,11 @@ class AgentScopeRunner:
|
||||
usage_summary=tracking_model.usage_summary(),
|
||||
)
|
||||
await emitter.emit_final_text_end(
|
||||
worker_output={
|
||||
**worker_payload.model_dump(mode="json", exclude_none=True),
|
||||
"divination_derived": derived_divination.model_dump(
|
||||
mode="json", by_alias=True, exclude_none=True
|
||||
),
|
||||
},
|
||||
worker_output=self._build_final_worker_output(
|
||||
worker_payload=worker_payload,
|
||||
runtime_mode=runtime_mode,
|
||||
derived_divination=derived_divination,
|
||||
),
|
||||
response_metadata=response_metadata,
|
||||
)
|
||||
return StageExecutionResult(
|
||||
@@ -316,15 +320,18 @@ class AgentScopeRunner:
|
||||
*,
|
||||
context_messages: list[Msg],
|
||||
run_input: RunAgentInput,
|
||||
derived_divination: DerivedDivinationData,
|
||||
derived_divination: DerivedDivinationData | None,
|
||||
) -> list[Msg]:
|
||||
if context_messages:
|
||||
last = context_messages[-1]
|
||||
if last.role == "user":
|
||||
return context_messages
|
||||
|
||||
_, _ = extract_latest_user_payload(run_input)
|
||||
user_text = build_divination_user_prompt(derived=derived_divination)
|
||||
_, latest_user_text = extract_latest_user_payload(run_input)
|
||||
if derived_divination is None:
|
||||
user_text = latest_user_text
|
||||
else:
|
||||
user_text = build_divination_user_prompt(derived=derived_divination)
|
||||
user_blocks = [{"type": "text", "text": user_text}]
|
||||
if (
|
||||
user_blocks
|
||||
@@ -422,12 +429,23 @@ class AgentScopeRunner:
|
||||
|
||||
@staticmethod
|
||||
def _resolve_runtime_mode(*, run_input: RunAgentInput) -> RuntimeMode:
|
||||
try:
|
||||
return parse_forwarded_props_runtime_mode(
|
||||
getattr(run_input, "forwarded_props", None)
|
||||
return parse_forwarded_props_runtime_mode(
|
||||
getattr(run_input, "forwarded_props", None)
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def _build_final_worker_output(
|
||||
*,
|
||||
worker_payload: WorkerAgentOutputLite | FollowUpOutput,
|
||||
runtime_mode: RuntimeMode,
|
||||
derived_divination: DerivedDivinationData | None,
|
||||
) -> dict[str, Any]:
|
||||
payload = worker_payload.model_dump(mode="json", exclude_none=True)
|
||||
if runtime_mode == RuntimeMode.CHAT and derived_divination is not None:
|
||||
payload["divination_derived"] = derived_divination.model_dump(
|
||||
mode="json", by_alias=True, exclude_none=True
|
||||
)
|
||||
except ValueError:
|
||||
return RuntimeMode.CHAT
|
||||
return payload
|
||||
|
||||
@staticmethod
|
||||
def _resolve_provider_api_key(*, factory_name: str) -> str:
|
||||
|
||||
Reference in New Issue
Block a user