{@inheritDoc}
Source
public function toArray(): array
{
$data = [];
if ($this->outputModalities !== null) {
$data[self::KEY_OUTPUT_MODALITIES] = array_map(static function (ModalityEnum $modality): string {
return $modality->value;
}, $this->outputModalities);
}
if ($this->systemInstruction !== null) {
$data[self::KEY_SYSTEM_INSTRUCTION] = $this->systemInstruction;
}
if ($this->candidateCount !== null) {
$data[self::KEY_CANDIDATE_COUNT] = $this->candidateCount;
}
if ($this->maxTokens !== null) {
$data[self::KEY_MAX_TOKENS] = $this->maxTokens;
}
if ($this->temperature !== null) {
$data[self::KEY_TEMPERATURE] = $this->temperature;
}
if ($this->topP !== null) {
$data[self::KEY_TOP_P] = $this->topP;
}
if ($this->topK !== null) {
$data[self::KEY_TOP_K] = $this->topK;
}
if ($this->stopSequences !== null) {
$data[self::KEY_STOP_SEQUENCES] = $this->stopSequences;
}
if ($this->presencePenalty !== null) {
$data[self::KEY_PRESENCE_PENALTY] = $this->presencePenalty;
}
if ($this->frequencyPenalty !== null) {
$data[self::KEY_FREQUENCY_PENALTY] = $this->frequencyPenalty;
}
if ($this->logprobs !== null) {
$data[self::KEY_LOGPROBS] = $this->logprobs;
}
if ($this->topLogprobs !== null) {
$data[self::KEY_TOP_LOGPROBS] = $this->topLogprobs;
}
if ($this->functionDeclarations !== null) {
$data[self::KEY_FUNCTION_DECLARATIONS] = array_map(static function (FunctionDeclaration $functionDeclaration): array {
return $functionDeclaration->toArray();
}, $this->functionDeclarations);
}
if ($this->webSearch !== null) {
$data[self::KEY_WEB_SEARCH] = $this->webSearch->toArray();
}
if ($this->outputFileType !== null) {
$data[self::KEY_OUTPUT_FILE_TYPE] = $this->outputFileType->value;
}
if ($this->outputMimeType !== null) {
$data[self::KEY_OUTPUT_MIME_TYPE] = $this->outputMimeType;
}
if ($this->outputSchema !== null) {
$data[self::KEY_OUTPUT_SCHEMA] = $this->outputSchema;
}
if ($this->outputMediaOrientation !== null) {
$data[self::KEY_OUTPUT_MEDIA_ORIENTATION] = $this->outputMediaOrientation->value;
}
if ($this->outputMediaAspectRatio !== null) {
$data[self::KEY_OUTPUT_MEDIA_ASPECT_RATIO] = $this->outputMediaAspectRatio;
}
if ($this->outputSpeechVoice !== null) {
$data[self::KEY_OUTPUT_SPEECH_VOICE] = $this->outputSpeechVoice;
}
if (!empty($this->customOptions)) {
$data[self::KEY_CUSTOM_OPTIONS] = $this->customOptions;
}
return $data;
}
Changelog
| Version | Description |
|---|---|
| 0.1.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.