Skip to content

Commit e574c12

Browse files
RobertCraigiestainless-app[bot]
authored andcommitted
fix(responses): add output_text back
1 parent e3c0612 commit e574c12

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/openai/types/responses/response.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,17 @@ class Response(BaseModel):
259259
[Learn more](https://platform.openai.com/docs/guides/safety-best-practices#safety-identifiers).
260260
"""
261261

262+
@property
263+
def output_text(self) -> str:
264+
"""Convenience property that aggregates all `output_text` items from the `output` list.
265+
266+
If no `output_text` content blocks exist, then an empty string is returned.
267+
"""
268+
texts: List[str] = []
269+
for output in self.output:
270+
if output.type == "message":
271+
for content in output.content:
272+
if content.type == "output_text":
273+
texts.append(content.text)
274+
275+
return "".join(texts)

0 commit comments

Comments
 (0)