GenerationConfig

Struct GenerationConfig 

Source
#[non_exhaustive]
pub struct GenerationConfig {
Show 18 fields pub temperature: Option<f32>, pub top_p: Option<f32>, pub top_k: Option<f32>, pub candidate_count: Option<i32>, pub max_output_tokens: Option<i32>, pub stop_sequences: Vec<String>, pub response_logprobs: Option<bool>, pub logprobs: Option<i32>, pub presence_penalty: Option<f32>, pub frequency_penalty: Option<f32>, pub seed: Option<i32>, pub response_mime_type: String, pub response_schema: Option<Schema>, pub response_json_schema: Option<Value>, pub routing_config: Option<RoutingConfig>, pub speech_config: Option<SpeechConfig>, pub thinking_config: Option<ThinkingConfig>, pub image_config: Option<ImageConfig>, /* private fields */
}
Available on crate features llm-utility-service or prediction-service only.
Expand description

Generation config.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§temperature: Option<f32>

Optional. Controls the randomness of predictions.

§top_p: Option<f32>

Optional. If specified, nucleus sampling will be used.

§top_k: Option<f32>

Optional. If specified, top-k sampling will be used.

§candidate_count: Option<i32>

Optional. Number of candidates to generate.

§max_output_tokens: Option<i32>

Optional. The maximum number of output tokens to generate per message.

§stop_sequences: Vec<String>

Optional. Stop sequences.

§response_logprobs: Option<bool>

Optional. If true, export the logprobs results in response.

§logprobs: Option<i32>

Optional. Logit probabilities.

§presence_penalty: Option<f32>

Optional. Positive penalties.

§frequency_penalty: Option<f32>

Optional. Frequency penalties.

§seed: Option<i32>

Optional. Seed.

§response_mime_type: String

Optional. Output response mimetype of the generated candidate text. Supported mimetype:

  • text/plain: (default) Text output.
  • application/json: JSON response in the candidates. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined. This is a preview feature.
§response_schema: Option<Schema>

Optional. The Schema object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an OpenAPI 3.0 schema object. If set, a compatible response_mime_type must also be set. Compatible mimetypes: application/json: Schema for JSON response.

§response_json_schema: Option<Value>

Optional. Output schema of the generated response. This is an alternative to response_schema that accepts JSON Schema.

If set, response_schema must be omitted, but response_mime_type is required.

While the full JSON Schema may be sent, not all features are supported. Specifically, only the following properties are supported:

  • $id
  • $defs
  • $ref
  • $anchor
  • type
  • format
  • title
  • description
  • enum (for strings and numbers)
  • items
  • prefixItems
  • minItems
  • maxItems
  • minimum
  • maximum
  • anyOf
  • oneOf (interpreted the same as anyOf)
  • properties
  • additionalProperties
  • required

The non-standard propertyOrdering property may also be set.

Cyclic references are unrolled to a limited degree and, as such, may only be used within non-required properties. (Nullable properties are not sufficient.) If $ref is set on a sub-schema, no other properties, except for than those starting as a $, may be set.

§routing_config: Option<RoutingConfig>

Optional. Routing configuration.

§speech_config: Option<SpeechConfig>

Optional. The speech generation config.

§thinking_config: Option<ThinkingConfig>

Optional. Config for thinking features. An error will be returned if this field is set for models that don’t support thinking.

§image_config: Option<ImageConfig>

Optional. Config for image generation features.

Implementations§

Source§

impl GenerationConfig

Source

pub fn new() -> Self

Source

pub fn set_temperature<T>(self, v: T) -> Self
where T: Into<f32>,

Sets the value of temperature.

§Example
let x = GenerationConfig::new().set_temperature(42.0);
Source

pub fn set_or_clear_temperature<T>(self, v: Option<T>) -> Self
where T: Into<f32>,

Sets or clears the value of temperature.

§Example
let x = GenerationConfig::new().set_or_clear_temperature(Some(42.0));
let x = GenerationConfig::new().set_or_clear_temperature(None::<f32>);
Source

pub fn set_top_p<T>(self, v: T) -> Self
where T: Into<f32>,

Sets the value of top_p.

§Example
let x = GenerationConfig::new().set_top_p(42.0);
Source

pub fn set_or_clear_top_p<T>(self, v: Option<T>) -> Self
where T: Into<f32>,

Sets or clears the value of top_p.

§Example
let x = GenerationConfig::new().set_or_clear_top_p(Some(42.0));
let x = GenerationConfig::new().set_or_clear_top_p(None::<f32>);
Source

pub fn set_top_k<T>(self, v: T) -> Self
where T: Into<f32>,

Sets the value of top_k.

§Example
let x = GenerationConfig::new().set_top_k(42.0);
Source

pub fn set_or_clear_top_k<T>(self, v: Option<T>) -> Self
where T: Into<f32>,

Sets or clears the value of top_k.

§Example
let x = GenerationConfig::new().set_or_clear_top_k(Some(42.0));
let x = GenerationConfig::new().set_or_clear_top_k(None::<f32>);
Source

pub fn set_candidate_count<T>(self, v: T) -> Self
where T: Into<i32>,

Sets the value of candidate_count.

§Example
let x = GenerationConfig::new().set_candidate_count(42);
Source

pub fn set_or_clear_candidate_count<T>(self, v: Option<T>) -> Self
where T: Into<i32>,

Sets or clears the value of candidate_count.

§Example
let x = GenerationConfig::new().set_or_clear_candidate_count(Some(42));
let x = GenerationConfig::new().set_or_clear_candidate_count(None::<i32>);
Source

pub fn set_max_output_tokens<T>(self, v: T) -> Self
where T: Into<i32>,

Sets the value of max_output_tokens.

§Example
let x = GenerationConfig::new().set_max_output_tokens(42);
Source

pub fn set_or_clear_max_output_tokens<T>(self, v: Option<T>) -> Self
where T: Into<i32>,

Sets or clears the value of max_output_tokens.

§Example
let x = GenerationConfig::new().set_or_clear_max_output_tokens(Some(42));
let x = GenerationConfig::new().set_or_clear_max_output_tokens(None::<i32>);
Source

pub fn set_stop_sequences<T, V>(self, v: T) -> Self
where T: IntoIterator<Item = V>, V: Into<String>,

Sets the value of stop_sequences.

§Example
let x = GenerationConfig::new().set_stop_sequences(["a", "b", "c"]);
Source

pub fn set_response_logprobs<T>(self, v: T) -> Self
where T: Into<bool>,

Sets the value of response_logprobs.

§Example
let x = GenerationConfig::new().set_response_logprobs(true);
Source

pub fn set_or_clear_response_logprobs<T>(self, v: Option<T>) -> Self
where T: Into<bool>,

Sets or clears the value of response_logprobs.

§Example
let x = GenerationConfig::new().set_or_clear_response_logprobs(Some(false));
let x = GenerationConfig::new().set_or_clear_response_logprobs(None::<bool>);
Source

pub fn set_logprobs<T>(self, v: T) -> Self
where T: Into<i32>,

Sets the value of logprobs.

§Example
let x = GenerationConfig::new().set_logprobs(42);
Source

pub fn set_or_clear_logprobs<T>(self, v: Option<T>) -> Self
where T: Into<i32>,

Sets or clears the value of logprobs.

§Example
let x = GenerationConfig::new().set_or_clear_logprobs(Some(42));
let x = GenerationConfig::new().set_or_clear_logprobs(None::<i32>);
Source

pub fn set_presence_penalty<T>(self, v: T) -> Self
where T: Into<f32>,

Sets the value of presence_penalty.

§Example
let x = GenerationConfig::new().set_presence_penalty(42.0);
Source

pub fn set_or_clear_presence_penalty<T>(self, v: Option<T>) -> Self
where T: Into<f32>,

Sets or clears the value of presence_penalty.

§Example
let x = GenerationConfig::new().set_or_clear_presence_penalty(Some(42.0));
let x = GenerationConfig::new().set_or_clear_presence_penalty(None::<f32>);
Source

pub fn set_frequency_penalty<T>(self, v: T) -> Self
where T: Into<f32>,

Sets the value of frequency_penalty.

§Example
let x = GenerationConfig::new().set_frequency_penalty(42.0);
Source

pub fn set_or_clear_frequency_penalty<T>(self, v: Option<T>) -> Self
where T: Into<f32>,

Sets or clears the value of frequency_penalty.

§Example
let x = GenerationConfig::new().set_or_clear_frequency_penalty(Some(42.0));
let x = GenerationConfig::new().set_or_clear_frequency_penalty(None::<f32>);
Source

pub fn set_seed<T>(self, v: T) -> Self
where T: Into<i32>,

Sets the value of seed.

§Example
let x = GenerationConfig::new().set_seed(42);
Source

pub fn set_or_clear_seed<T>(self, v: Option<T>) -> Self
where T: Into<i32>,

Sets or clears the value of seed.

§Example
let x = GenerationConfig::new().set_or_clear_seed(Some(42));
let x = GenerationConfig::new().set_or_clear_seed(None::<i32>);
Source

pub fn set_response_mime_type<T: Into<String>>(self, v: T) -> Self

Sets the value of response_mime_type.

§Example
let x = GenerationConfig::new().set_response_mime_type("example");
Source

pub fn set_response_schema<T>(self, v: T) -> Self
where T: Into<Schema>,

Sets the value of response_schema.

§Example
use google_cloud_aiplatform_v1::model::Schema;
let x = GenerationConfig::new().set_response_schema(Schema::default()/* use setters */);
Source

pub fn set_or_clear_response_schema<T>(self, v: Option<T>) -> Self
where T: Into<Schema>,

Sets or clears the value of response_schema.

§Example
use google_cloud_aiplatform_v1::model::Schema;
let x = GenerationConfig::new().set_or_clear_response_schema(Some(Schema::default()/* use setters */));
let x = GenerationConfig::new().set_or_clear_response_schema(None::<Schema>);
Source

pub fn set_response_json_schema<T>(self, v: T) -> Self
where T: Into<Value>,

Sets the value of response_json_schema.

§Example
use wkt::Value;
let x = GenerationConfig::new().set_response_json_schema(Value::default()/* use setters */);
Source

pub fn set_or_clear_response_json_schema<T>(self, v: Option<T>) -> Self
where T: Into<Value>,

Sets or clears the value of response_json_schema.

§Example
use wkt::Value;
let x = GenerationConfig::new().set_or_clear_response_json_schema(Some(Value::default()/* use setters */));
let x = GenerationConfig::new().set_or_clear_response_json_schema(None::<Value>);
Source

pub fn set_routing_config<T>(self, v: T) -> Self
where T: Into<RoutingConfig>,

Sets the value of routing_config.

§Example
use google_cloud_aiplatform_v1::model::generation_config::RoutingConfig;
let x = GenerationConfig::new().set_routing_config(RoutingConfig::default()/* use setters */);
Source

pub fn set_or_clear_routing_config<T>(self, v: Option<T>) -> Self
where T: Into<RoutingConfig>,

Sets or clears the value of routing_config.

§Example
use google_cloud_aiplatform_v1::model::generation_config::RoutingConfig;
let x = GenerationConfig::new().set_or_clear_routing_config(Some(RoutingConfig::default()/* use setters */));
let x = GenerationConfig::new().set_or_clear_routing_config(None::<RoutingConfig>);
Source

pub fn set_speech_config<T>(self, v: T) -> Self
where T: Into<SpeechConfig>,

Sets the value of speech_config.

§Example
use google_cloud_aiplatform_v1::model::SpeechConfig;
let x = GenerationConfig::new().set_speech_config(SpeechConfig::default()/* use setters */);
Source

pub fn set_or_clear_speech_config<T>(self, v: Option<T>) -> Self
where T: Into<SpeechConfig>,

Sets or clears the value of speech_config.

§Example
use google_cloud_aiplatform_v1::model::SpeechConfig;
let x = GenerationConfig::new().set_or_clear_speech_config(Some(SpeechConfig::default()/* use setters */));
let x = GenerationConfig::new().set_or_clear_speech_config(None::<SpeechConfig>);
Source

pub fn set_thinking_config<T>(self, v: T) -> Self
where T: Into<ThinkingConfig>,

Sets the value of thinking_config.

§Example
use google_cloud_aiplatform_v1::model::generation_config::ThinkingConfig;
let x = GenerationConfig::new().set_thinking_config(ThinkingConfig::default()/* use setters */);
Source

pub fn set_or_clear_thinking_config<T>(self, v: Option<T>) -> Self
where T: Into<ThinkingConfig>,

Sets or clears the value of thinking_config.

§Example
use google_cloud_aiplatform_v1::model::generation_config::ThinkingConfig;
let x = GenerationConfig::new().set_or_clear_thinking_config(Some(ThinkingConfig::default()/* use setters */));
let x = GenerationConfig::new().set_or_clear_thinking_config(None::<ThinkingConfig>);
Source

pub fn set_image_config<T>(self, v: T) -> Self
where T: Into<ImageConfig>,

Sets the value of image_config.

§Example
use google_cloud_aiplatform_v1::model::ImageConfig;
let x = GenerationConfig::new().set_image_config(ImageConfig::default()/* use setters */);
Source

pub fn set_or_clear_image_config<T>(self, v: Option<T>) -> Self
where T: Into<ImageConfig>,

Sets or clears the value of image_config.

§Example
use google_cloud_aiplatform_v1::model::ImageConfig;
let x = GenerationConfig::new().set_or_clear_image_config(Some(ImageConfig::default()/* use setters */));
let x = GenerationConfig::new().set_or_clear_image_config(None::<ImageConfig>);

Trait Implementations§

Source§

impl Clone for GenerationConfig

Source§

fn clone(&self) -> GenerationConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GenerationConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for GenerationConfig

Source§

fn default() -> GenerationConfig

Returns the “default value” for a type. Read more
Source§

impl Message for GenerationConfig

Source§

fn typename() -> &'static str

The typename of this message.
Source§

impl PartialEq for GenerationConfig

Source§

fn eq(&self, other: &GenerationConfig) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for GenerationConfig

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,