Record Class OllamaApi.GenerateResponse

java.lang.Object
java.lang.Record
org.springframework.ai.ollama.api.OllamaApi.GenerateResponse
Record Components:
model - The model used for completion.
createdAt - When the request was made.
response - The completion response. Empty if the response was streamed, if not streamed, this will contain the full response
done - Whether this is the final response. If true, this response may be followed by another response with the following, additional fields: context, prompt_eval_count, prompt_eval_duration, eval_count, eval_duration.
context - Encoding of the conversation used in this response, this can be sent in the next request to keep a conversational memory.
totalDuration - Time spent generating the response.
loadDuration - Time spent loading the model.
promptEvalCount - Number of times the prompt was evaluated.
promptEvalDuration - Time spent evaluating the prompt.
evalCount - Number of tokens in the response.
evalDuration - Time spent generating the response.
Enclosing class:
OllamaApi

public static record OllamaApi.GenerateResponse(String model, Instant createdAt, String response, Boolean done, List<Integer> context, Duration totalDuration, Duration loadDuration, Integer promptEvalCount, Duration promptEvalDuration, Integer evalCount, Duration evalDuration) extends Record
The response object returned from the /generate endpoint. To calculate how fast the response is generated in tokens per second (token/s), divide eval_count / eval_duration.
  • Constructor Details

    • GenerateResponse

      public GenerateResponse(String model, Instant createdAt, String response, Boolean done, List<Integer> context, Duration totalDuration, Duration loadDuration, Integer promptEvalCount, Duration promptEvalDuration, Integer evalCount, Duration evalDuration)
      Creates an instance of a GenerateResponse record class.
      Parameters:
      model - the value for the model record component
      createdAt - the value for the createdAt record component
      response - the value for the response record component
      done - the value for the done record component
      context - the value for the context record component
      totalDuration - the value for the totalDuration record component
      loadDuration - the value for the loadDuration record component
      promptEvalCount - the value for the promptEvalCount record component
      promptEvalDuration - the value for the promptEvalDuration record component
      evalCount - the value for the evalCount record component
      evalDuration - the value for the evalDuration record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • model

      public String model()
      Returns the value of the model record component.
      Returns:
      the value of the model record component
    • createdAt

      public Instant createdAt()
      Returns the value of the createdAt record component.
      Returns:
      the value of the createdAt record component
    • response

      public String response()
      Returns the value of the response record component.
      Returns:
      the value of the response record component
    • done

      public Boolean done()
      Returns the value of the done record component.
      Returns:
      the value of the done record component
    • context

      public List<Integer> context()
      Returns the value of the context record component.
      Returns:
      the value of the context record component
    • totalDuration

      public Duration totalDuration()
      Returns the value of the totalDuration record component.
      Returns:
      the value of the totalDuration record component
    • loadDuration

      public Duration loadDuration()
      Returns the value of the loadDuration record component.
      Returns:
      the value of the loadDuration record component
    • promptEvalCount

      public Integer promptEvalCount()
      Returns the value of the promptEvalCount record component.
      Returns:
      the value of the promptEvalCount record component
    • promptEvalDuration

      public Duration promptEvalDuration()
      Returns the value of the promptEvalDuration record component.
      Returns:
      the value of the promptEvalDuration record component
    • evalCount

      public Integer evalCount()
      Returns the value of the evalCount record component.
      Returns:
      the value of the evalCount record component
    • evalDuration

      public Duration evalDuration()
      Returns the value of the evalDuration record component.
      Returns:
      the value of the evalDuration record component