FirebaseAILogic Framework Reference Stay organized with collections Save and categorize content based on your preferences.
Segment
@available(iOS15.0,macOS12.0,tvOS15.0,watchOS8.0,*)publicstructSegment:Sendable,Equatable,HashableextensionSegment:DecodableRepresents a specific segment within aModelContent struct, often used to pinpoint theexact location of text or data that grounding information refers to.
The zero-based index of the
Partobject within thepartsarray of its parentModelContentobject. This identifies which part of the content the segment belongs to.Declaration
Swift
publicletpartIndex:IntThe zero-based start index of the segment within the specified
Part, measured in UTF-8bytes. This offset is inclusive, starting from 0 at the beginning of the part’s content.Declaration
Swift
publicletstartIndex:IntThe zero-based end index of the segment within the specified
Part, measured in UTF-8bytes. This offset is exclusive, meaning the character at this index is not included in thesegment.Declaration
Swift
publicletendIndex:IntThe text corresponding to the segment from the response.
Declaration
Swift
publiclettext:String
Declaration
Swift
publicinit(fromdecoder:Decoder)throws
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-10-28 UTC.