Record Class QianFanApi.ChatCompletionRequest

java.lang.Object
java.lang.Record
org.springframework.ai.qianfan.api.QianFanApi.ChatCompletionRequest
Record Components:
messages - A list of messages comprising the conversation so far.
model - ID of the model to use.
frequencyPenalty - Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.
maxTokens - The maximum number of tokens to generate in the chat completion. The total length of input tokens and generated tokens is limited by the model's context length. appear in the text so far, increasing the model's likelihood to talk about new topics.
responseFormat - An object specifying the format that the model must output. Setting to { "type": "json_object" } enables JSON mode, which guarantees the message the model generates is valid JSON.
stop - Up to 4 sequences where the API will stop generating further tokens.
stream - If set, partial message deltas will be sent.Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.
temperature - What sampling temperature to use, between 0 and 1. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic. We generally recommend altering this or top_p but not both.
topP - An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered. We generally recommend altering this or temperature but not both.
Enclosing class:
QianFanApi

public static record QianFanApi.ChatCompletionRequest(List<QianFanApi.ChatCompletionMessage> messages, String system, String model, Double frequencyPenalty, Integer maxTokens, Double presencePenalty, QianFanApi.ChatCompletionRequest.ResponseFormat responseFormat, List<String> stop, Boolean stream, Double temperature, Double topP) extends Record
Creates a model response for the given chat conversation.
  • Constructor Details

    • ChatCompletionRequest

      public ChatCompletionRequest(List<QianFanApi.ChatCompletionMessage> messages, String system, String model, Double temperature)
      Shortcut constructor for a chat completion request with the given messages and model.
      Parameters:
      messages - A list of messages comprising the conversation so far.
      model - ID of the model to use.
      temperature - What sampling temperature to use, between 0 and 1.
    • ChatCompletionRequest

      public ChatCompletionRequest(List<QianFanApi.ChatCompletionMessage> messages, String system, String model, Double temperature, boolean stream)
      Shortcut constructor for a chat completion request with the given messages, model and control for streaming.
      Parameters:
      messages - A list of messages comprising the conversation so far.
      model - ID of the model to use.
      temperature - What sampling temperature to use, between 0 and 1.
      stream - If set, partial message deltas will be sent.Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.
    • ChatCompletionRequest

      public ChatCompletionRequest(List<QianFanApi.ChatCompletionMessage> messages, String system, Boolean stream)
      Shortcut constructor for a chat completion request with the given messages, model, tools and tool choice. Streaming is set to false, temperature to 0.8 and all other parameters are null.
      Parameters:
      messages - A list of messages comprising the conversation so far.
      stream - If set, partial message deltas will be sent.Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message.
    • ChatCompletionRequest

      public ChatCompletionRequest(List<QianFanApi.ChatCompletionMessage> messages, String system, String model, Double frequencyPenalty, Integer maxTokens, Double presencePenalty, QianFanApi.ChatCompletionRequest.ResponseFormat responseFormat, List<String> stop, Boolean stream, Double temperature, Double topP)
      Creates an instance of a ChatCompletionRequest record class.
      Parameters:
      messages - the value for the messages record component
      system - the value for the system record component
      model - the value for the model record component
      frequencyPenalty - the value for the frequencyPenalty record component
      maxTokens - the value for the maxTokens record component
      presencePenalty - the value for the presencePenalty record component
      responseFormat - the value for the responseFormat record component
      stop - the value for the stop record component
      stream - the value for the stream record component
      temperature - the value for the temperature record component
      topP - the value for the topP 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.
    • messages

      Returns the value of the messages record component.
      Returns:
      the value of the messages record component
    • system

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

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

      public Double frequencyPenalty()
      Returns the value of the frequencyPenalty record component.
      Returns:
      the value of the frequencyPenalty record component
    • maxTokens

      public Integer maxTokens()
      Returns the value of the maxTokens record component.
      Returns:
      the value of the maxTokens record component
    • presencePenalty

      public Double presencePenalty()
      Returns the value of the presencePenalty record component.
      Returns:
      the value of the presencePenalty record component
    • responseFormat

      Returns the value of the responseFormat record component.
      Returns:
      the value of the responseFormat record component
    • stop

      public List<String> stop()
      Returns the value of the stop record component.
      Returns:
      the value of the stop record component
    • stream

      public Boolean stream()
      Returns the value of the stream record component.
      Returns:
      the value of the stream record component
    • temperature

      public Double temperature()
      Returns the value of the temperature record component.
      Returns:
      the value of the temperature record component
    • topP

      public Double topP()
      Returns the value of the topP record component.
      Returns:
      the value of the topP record component