Implementation of a chat segment

ChatSegmentImpl

Implements

Constructors

  • Initializes a new ChatSegmentImpl instance with the given content, start and end indices, metadata, and options. It validates the content and boundaries, generates a unique ID, and sets the sequence ID, timestamp, and order.

    Parameters

    • content: string

      Raw content of the chat segment

    • startIndex: number

      Start index of the chat segment

    • endIndex: number

      End index of the chat segment

    • metadata: ChatMetadata

      Metadata of the chat segment

    • options: ChatSegmentOptions

      Options for creating the chat segment

    Returns ChatSegmentImpl

Properties

id: string

The unique identifier of the segment.

sequenceId: string

The ID of the sequence to which the segment belongs.

timestamp: Date

The timestamp of the segment.

Accessors

  • get content(): string
  • Returns the sanitized content of the chat segment

    Returns string

  • get endIndex(): number
  • Returns the end index of the chat segment

    Returns number

  • get metadata(): ChatMetadata
  • Validates the content of the chat segment, ensuring it's not empty and starts with the "Me" keyword

    Returns ChatMetadata

  • get order(): number
  • Returns the order of the chat segment

    Returns number

  • get startIndex(): number
  • Returns the start index of the chat segment

    Returns number

Methods

  • Checks if this segment contains the given index

    Parameters

    • index: number

      The index to check

    Returns boolean

    True if this segment contains the index, false otherwise

  • Checks if this segment overlaps with another segment

    Parameters

    Returns boolean

    True if this segment overlaps with the other segment, false otherwise

  • Creates a new segment with updated order

    Parameters

    • newOrder: number

      The new order of the segment

    Returns ChatSegmentImpl

    A new chat segment with the updated order

  • Creates a segment from raw log content

    Parameters

    • logContent: string

      The raw log content

    • startIndex: number

      The start index of the segment

    • endIndex: number

      The end index of the segment

    • metadata: ChatMetadata

      The metadata of the segment

    • options: ChatSegmentOptions

      The options for creating the segment

    Returns ChatSegmentImpl

    A new chat segment created from the raw log content