MCPcopy Create free account
hub / github.com/microsoft/Webwright / _serialize_response_input

Function _serialize_response_input

src/webwright/models/openai_model.py:38–61  ·  view source on GitHub ↗
(messages: list[dict[str, Any]])

Source from the content-addressed store, hash-verified

36
37
38def _serialize_response_input(messages: list[dict[str, Any]]) -> list[dict[str, Any]]:
39 serialized: list[dict[str, Any]] = []
40 for message in messages:
41 role = message["role"]
42 if role == "exit":
43 continue
44 content = message.get("content", "")
45 if isinstance(content, str):
46 serialized_content = [text_part(content)]
47 else:
48 serialized_content = [part for part in content if isinstance(part, dict)]
49 # The Responses API accepts "developer" for system-style instructions.
50 mapped_role = "developer" if role == "system" else role
51 serialized.append(
52 {
53 "type": "message",
54 "role": mapped_role,
55 "content": [
56 _serialize_response_content_part(part, role=mapped_role)
57 for part in serialized_content
58 ],
59 }
60 )
61 return serialized
62
63
64def _extract_response_text(payload: dict[str, Any]) -> str:

Callers 2

_build_payloadMethod · 0.85
_build_text_payloadMethod · 0.85

Calls 2

text_partFunction · 0.90

Tested by

no test coverage detected