Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ public void PromptExecutionSettingsCloneWorksAsExpected(string thinkingConfigJso
string json = $$"""
{
"model_id": "gemini-pro",
"service_id": "gemini-service",
"temperature": 0.7,
"top_p": 0.7,
"top_k": 25,
Expand All @@ -207,23 +208,30 @@ public void PromptExecutionSettingsCloneWorksAsExpected(string thinkingConfigJso
"threshold": "{{threshold.Label}}"
}
],
"labels": { "env": "test", "team": "sk" },
"cached_content": "projects/p/locations/l/cachedContents/c",
"thinking_config": {{thinkingConfigJson}}
}
""";
var executionSettings = JsonSerializer.Deserialize<GeminiPromptExecutionSettings>(json);
executionSettings!.FunctionChoiceBehavior = FunctionChoiceBehavior.Auto();

// Act
var clone = executionSettings!.Clone() as GeminiPromptExecutionSettings;
var clone = executionSettings.Clone() as GeminiPromptExecutionSettings;

// Assert
Assert.NotNull(clone);
Assert.Equal(executionSettings.ModelId, clone.ModelId);
Assert.Equal(executionSettings.ServiceId, clone.ServiceId);
Assert.Equal(executionSettings.Temperature, clone.Temperature);
Assert.Equivalent(executionSettings.ExtensionData, clone.ExtensionData);
Assert.Equivalent(executionSettings.StopSequences, clone.StopSequences);
Assert.Equivalent(executionSettings.SafetySettings, clone.SafetySettings);
Assert.Equal(executionSettings.AudioTimestamp, clone.AudioTimestamp);
Assert.Equivalent(executionSettings.ThinkingConfig, clone.ThinkingConfig);
Assert.Equivalent(executionSettings.Labels, clone.Labels);
Assert.Equal(executionSettings.CachedContent, clone.CachedContent);
Assert.Same(executionSettings.FunctionChoiceBehavior, clone.FunctionChoiceBehavior);
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,8 @@ public override PromptExecutionSettings Clone()
return new GeminiPromptExecutionSettings()
{
ModelId = this.ModelId,
ServiceId = this.ServiceId,
FunctionChoiceBehavior = this.FunctionChoiceBehavior,
ExtensionData = this.ExtensionData is not null ? new Dictionary<string, object>(this.ExtensionData) : null,
Temperature = this.Temperature,
TopP = this.TopP,
Expand All @@ -338,6 +340,8 @@ public override PromptExecutionSettings Clone()
AudioTimestamp = this.AudioTimestamp,
ResponseMimeType = this.ResponseMimeType,
ResponseSchema = this.ResponseSchema,
Labels = this.Labels is not null ? new Dictionary<string, string>(this.Labels) : null,
CachedContent = this.CachedContent,
ThinkingConfig = this.ThinkingConfig?.Clone()
};
}
Expand Down
Loading