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

Function _extract_response_text

src/webwright/models/openai_model.py:64–82  ·  view source on GitHub ↗
(payload: dict[str, Any])

Source from the content-addressed store, hash-verified

62
63
64def _extract_response_text(payload: dict[str, Any]) -> str:
65 output_text = payload.get("output_text")
66 if isinstance(output_text, str) and output_text:
67 return output_text
68
69 texts: list[str] = []
70 for item in payload.get("output") or []:
71 if not isinstance(item, dict):
72 continue
73 if item.get("type") != "message":
74 continue
75 for content in item.get("content") or []:
76 if not isinstance(content, dict):
77 continue
78 if isinstance(content.get("text"), str):
79 texts.append(content["text"])
80 elif isinstance(content.get("output_text"), str):
81 texts.append(content["output_text"])
82 return "\n".join(texts)
83
84
85def _usage_metrics_from_response_payload(payload: dict[str, Any]) -> dict[str, int]:

Callers 1

_extract_textMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected