Spaces:
Sleeping
Sleeping
Download runtime/v8_bridge.py from G-ACE/astera-customerAI: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/spaces/G-ACE/astera-customerAI/resolve/main/runtime/v8_bridge.py
- Command line
-
hf download hf://spaces/G-ACE/astera-customerAI/runtime/v8_bridge.py
-
curl -L -o v8_bridge.py https://huggingface.co/spaces/G-ACE/astera-customerAI/resolve/main/runtime/v8_bridge.py
1.17 kB
| from __future__ import annotations | |
| from typing import Any, Protocol | |
| from .schemas import NeedTask, RoleResult, SharedRolePacket | |
| class V8Adapter(Protocol): | |
| async def analyze_need(self, message: str, context: dict[str, Any]) -> dict[str, Any]: ... | |
| async def compare_results(self, packet: SharedRolePacket, results: list[RoleResult]) -> dict[str, Any]: ... | |
| class V8Bridge: | |
| def __init__(self, adapter: V8Adapter): self.adapter = adapter | |
| async def analyze_need(self, message: str, context: dict[str, Any]) -> tuple[str, str, list[NeedTask]]: | |
| raw = await self.adapter.analyze_need(message, context) | |
| tasks = [NeedTask.model_validate(item) for item in raw.get("tasks", [])] | |
| if not tasks: raise ValueError("v8_preflight_missing_tasks") | |
| return str(raw.get("normalized_need") or message).strip(), str(raw.get("audience") or "general").strip() or "general", tasks | |
| async def compare(self, packet: SharedRolePacket, results: list[RoleResult]) -> dict[str, Any]: | |
| raw = await self.adapter.compare_results(packet, results) | |
| if not isinstance(raw, dict): raise TypeError("v8_compare_invalid") | |
| return raw | |