M2b:导入改造产出可审阅灵胚(启镜物化世谱)与组装管线(符文展开/火候进入 IR),Kernel 打通采样参数链路
This commit is contained in:
1 parent
e6a3b7121f
commit
5f36e3785c
86 files changed
+424
-14455
No files matched your search
@@ -55,13 +55,14 @@ class Kernel:
|
||||
system_contract: str | None = None,
|
||||
origin: str = "kernel",
|
||||
on_run_final: OnRunFinal | None = None,
|
||||
temperature: float | None = None,
|
||||
max_tokens: int | None = None,
|
||||
) -> Run:
|
||||
"""创建 Run 行(queued)并异步启动循环;前台席位在循环内排队获取。"""
|
||||
profile = resolve_profile()
|
||||
async with self._sessions() as session:
|
||||
run = Run(
|
||||
character_id=character_id,
|
||||
session_id=None,
|
||||
status="queued",
|
||||
kind="foreground",
|
||||
goal=prompt[:300] if prompt else None,
|
||||
@@ -79,6 +80,8 @@ class Kernel:
|
||||
seat_key=None,
|
||||
system_contract=system_contract,
|
||||
on_final=on_run_final,
|
||||
temperature=temperature,
|
||||
max_tokens=max_tokens,
|
||||
)
|
||||
async with self._sessions() as session:
|
||||
created = await session.get(Run, run_id)
|
||||
@@ -93,7 +96,6 @@ class Kernel:
|
||||
async with self._sessions() as session:
|
||||
run = Run(
|
||||
character_id=None,
|
||||
session_id=None,
|
||||
status="queued",
|
||||
kind="rehearsal",
|
||||
goal=prompt[:300] if prompt else None,
|
||||
@@ -127,6 +129,8 @@ class Kernel:
|
||||
seat_key: str | None,
|
||||
system_contract: str | None,
|
||||
on_final: OnRunFinal | None,
|
||||
temperature: float | None = None,
|
||||
max_tokens: int | None = None,
|
||||
) -> None:
|
||||
task = asyncio.create_task(
|
||||
self.loop.execute(
|
||||
@@ -137,6 +141,8 @@ class Kernel:
|
||||
seat_key=seat_key,
|
||||
system_contract=system_contract,
|
||||
on_final=on_final,
|
||||
temperature=temperature,
|
||||
max_tokens=max_tokens,
|
||||
)
|
||||
)
|
||||
self._tasks.add(task)
|
||||
|
||||
@@ -87,6 +87,8 @@ class KernelRunLoop:
|
||||
seat_key: str | None = None,
|
||||
system_contract: str | None = None,
|
||||
on_final: OnRunFinal | None = None,
|
||||
temperature: float | None = None,
|
||||
max_tokens: int | None = None,
|
||||
) -> RunOutcome:
|
||||
assert character_id or seat_key, "Run 必须绑定人物或提供席位键(试演)"
|
||||
trace = trace_id or new_trace_id()
|
||||
@@ -101,6 +103,8 @@ class KernelRunLoop:
|
||||
seat_key=seat_key,
|
||||
system_contract=system_contract,
|
||||
outcome=outcome,
|
||||
temperature=temperature,
|
||||
max_tokens=max_tokens,
|
||||
)
|
||||
except TimeoutError:
|
||||
outcome.status = "interrupted"
|
||||
@@ -128,6 +132,8 @@ class KernelRunLoop:
|
||||
seat_key: str | None,
|
||||
system_contract: str | None,
|
||||
outcome: RunOutcome,
|
||||
temperature: float | None = None,
|
||||
max_tokens: int | None = None,
|
||||
) -> None:
|
||||
ctx = RunContext(run_id=run_id, character_id=character_id, trace_id=trace_id)
|
||||
try:
|
||||
@@ -151,6 +157,8 @@ class KernelRunLoop:
|
||||
prompt,
|
||||
system_contract or _SYSTEM_CONTRACT_PLACEHOLDER,
|
||||
outcome,
|
||||
temperature=temperature,
|
||||
max_tokens=max_tokens,
|
||||
)
|
||||
|
||||
async def _turn(
|
||||
@@ -161,6 +169,8 @@ class KernelRunLoop:
|
||||
prompt: str,
|
||||
system_contract: str,
|
||||
outcome: RunOutcome,
|
||||
temperature: float | None = None,
|
||||
max_tokens: int | None = None,
|
||||
) -> None:
|
||||
ctx = RunContext(
|
||||
run_id=run_id, character_id=character_id, trace_id=trace_id, payload={"prompt": prompt}
|
||||
@@ -179,6 +189,8 @@ class KernelRunLoop:
|
||||
run_id=run_id,
|
||||
trace_id=trace_id,
|
||||
character_id=character_id,
|
||||
temperature=temperature,
|
||||
max_tokens=max_tokens,
|
||||
)
|
||||
await self._emit(
|
||||
run_id,
|
||||
|
||||
Reference in new issue
Block a user