mirror of
https://github.com/NCBM/plyngent.git
synced 2026-07-23 05:55:16 +08:00
core/agent: clear basedpyright warnings on Responses adapter
This commit is contained in:
@@ -146,10 +146,11 @@ def _reasoning_summary_text(response: Response) -> str:
|
|||||||
summary = raw.get("summary")
|
summary = raw.get("summary")
|
||||||
if not isinstance(summary, list):
|
if not isinstance(summary, list):
|
||||||
continue
|
continue
|
||||||
for block in summary:
|
summary_items = cast("list[object]", summary)
|
||||||
if not isinstance(block, dict):
|
for block_obj in summary_items:
|
||||||
|
if not isinstance(block_obj, dict):
|
||||||
continue
|
continue
|
||||||
block_map = cast("dict[str, object]", block)
|
block_map = cast("dict[str, object]", block_obj)
|
||||||
if block_map.get("type") in {"summary_text", "output_text"}:
|
if block_map.get("type") in {"summary_text", "output_text"}:
|
||||||
text = block_map.get("text")
|
text = block_map.get("text")
|
||||||
if isinstance(text, str) and text:
|
if isinstance(text, str) and text:
|
||||||
@@ -258,7 +259,7 @@ def usage_chunk_from_response(response: Response, *, model: str) -> ChatCompleti
|
|||||||
created=created,
|
created=created,
|
||||||
model=model,
|
model=model,
|
||||||
choices=[],
|
choices=[],
|
||||||
usage=cast("dict[str, Any]", response.usage),
|
usage=response.usage,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,8 @@ class ResponsesChatClient:
|
|||||||
uses ``POST /responses``.
|
uses ``POST /responses``.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
_client: OpenAIClient
|
||||||
|
|
||||||
def __init__(self, client: OpenAIClient) -> None:
|
def __init__(self, client: OpenAIClient) -> None:
|
||||||
self._client = client
|
self._client = client
|
||||||
|
|
||||||
@@ -80,10 +82,8 @@ class ResponsesChatClient:
|
|||||||
} and isinstance(event.delta, str) and event.delta:
|
} and isinstance(event.delta, str) and event.delta:
|
||||||
yield reasoning_delta_chunk(model=model, content=event.delta)
|
yield reasoning_delta_chunk(model=model, content=event.delta)
|
||||||
continue
|
continue
|
||||||
if etype == "response.completed" and event.response is not UNSET and isinstance(
|
if etype == "response.completed" and event.response is not UNSET:
|
||||||
event.response, dict
|
# Decode full response for tools + usage (field is dict | Unset).
|
||||||
):
|
|
||||||
# Decode full response for tools + usage
|
|
||||||
import msgspec
|
import msgspec
|
||||||
|
|
||||||
from plyngent.lmproto.openai.model import Response as ResponseModel
|
from plyngent.lmproto.openai.model import Response as ResponseModel
|
||||||
|
|||||||
Reference in New Issue
Block a user