Class BetaDream

  • All Implemented Interfaces:

    
    public final class BetaDream
    
                        

    An asynchronous job that reads a memory store and past sessions, then writes a reorganized version of that memory store.

    By default the dream writes its result to a new memory store and doesn't change the input memory store. With output_behavior set to update_existing, it writes its result into the input memory store instead.

    The Dreams API is in research preview: the request and response shapes are volatile and may change without the deprecation period that applies to stable endpoints.

    See the Dreams guide for what a dream reads and produces.

    • Constructor Detail

    • Method Detail

      • id

         final String id()

        The unique ID of the dream (drm_...).

      • createdAt

         final OffsetDateTime createdAt()

        When the dream was created, in RFC 3339.

        Lists of dreams are sorted by this time, newest first.

      • endedAt

         final Optional<OffsetDateTime> endedAt()

        When the dream reached completed, failed, or canceled, in RFC 3339, or null if it is still pending or running.

      • model

         final BetaDreamModelConfig model()

        The model that runs a dream, from the request that created it.

        The dream uses this model for all of its work. The response always gives the model as an object, even if the request gave only a model ID.

      • outputBehavior

         final BetaOutputBehavior outputBehavior()

        Where the dream writes its result, as set in the request that created the dream. If that request left out output_behavior, the dream used the create_new behavior.

      • outputs

         final List<BetaDreamOutput> outputs()

        The memory store that holds the dream's result, as a one-item array, or an empty array until the dream records that memory store.

        The array is empty while the dream is pending and for a short time after it starts running. It can stay empty if the dream fails or is canceled before then. The memory store holds the complete result only once status is completed.

        See the Dreams guide for how to review and use the result.

      • sessionId

         final Optional<String> sessionId()

        The ID of the session that runs the dream (sesn_...), or null if that session hasn't started.

        Stream that session's events to follow what the dream reads and writes.

        See the Dreams guide for how to watch a running dream.

      • status

         final BetaDreamStatus status()

        Where a dream is in its lifecycle.

        completed, failed, and canceled are final: once a dream has one of these statuses, its status doesn't change again.

        See the Dreams guide for what each status means.

      • usage

         final BetaDreamUsage usage()

        The dream's token counts, which stop changing once its status is completed or failed. After a cancel, they can keep changing.

      • _type

         final JsonValue _type()

        Expected to always return the following:

        JsonValue.from("dream")

        However, this method can be useful for debugging and logging (e.g. if the server responded with an unexpected value).

      • _id

         final JsonField<String> _id()

        Returns the raw JSON value of id.

        Unlike id, this method doesn't throw if the JSON field has an unexpected type.

      • _archivedAt

         final JsonField<OffsetDateTime> _archivedAt()

        Returns the raw JSON value of archivedAt.

        Unlike archivedAt, this method doesn't throw if the JSON field has an unexpected type.

      • _createdAt

         final JsonField<OffsetDateTime> _createdAt()

        Returns the raw JSON value of createdAt.

        Unlike createdAt, this method doesn't throw if the JSON field has an unexpected type.

      • _endedAt

         final JsonField<OffsetDateTime> _endedAt()

        Returns the raw JSON value of endedAt.

        Unlike endedAt, this method doesn't throw if the JSON field has an unexpected type.

      • _error

         final JsonField<BetaDreamError> _error()

        Returns the raw JSON value of error.

        Unlike error, this method doesn't throw if the JSON field has an unexpected type.

      • _inputs

         final JsonField<List<BetaDreamInput>> _inputs()

        Returns the raw JSON value of inputs.

        Unlike inputs, this method doesn't throw if the JSON field has an unexpected type.

      • _instructions

         final JsonField<String> _instructions()

        Returns the raw JSON value of instructions.

        Unlike instructions, this method doesn't throw if the JSON field has an unexpected type.

      • _outputs

         final JsonField<List<BetaDreamOutput>> _outputs()

        Returns the raw JSON value of outputs.

        Unlike outputs, this method doesn't throw if the JSON field has an unexpected type.

      • _sessionId

         final JsonField<String> _sessionId()

        Returns the raw JSON value of sessionId.

        Unlike sessionId, this method doesn't throw if the JSON field has an unexpected type.

      • _status

         final JsonField<BetaDreamStatus> _status()

        Returns the raw JSON value of status.

        Unlike status, this method doesn't throw if the JSON field has an unexpected type.

      • _usage

         final JsonField<BetaDreamUsage> _usage()

        Returns the raw JSON value of usage.

        Unlike usage, this method doesn't throw if the JSON field has an unexpected type.

      • validate

         final BetaDream validate()

        Validates that the types of all values in this object match their expected types recursively.

        This method is not forwards compatible with new types from the API for existing fields.

      • builder

         final static BetaDream.Builder builder()

        Returns a mutable builder for constructing an instance of BetaDream.

        The following fields are required:

        .id()
        .archivedAt()
        .createdAt()
        .endedAt()
        .error()
        .inputs()
        .instructions()
        .model()
        .outputBehavior()
        .outputs()
        .sessionId()
        .status()
        .usage()