/*
 * Copyright 2023 - 2024 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.springframework.ai.watsonx.api;

import static org.assertj.core.api.Assertions.assertThat;

import org.junit.Test;

import org.springframework.ai.watsonx.WatsonxAiChatOptions;

import java.util.List;

/**
 * @author Pablo Sanchidrian Herrera
 * @author John Jairo Moreno Rojas
 */
public class WatsonxAiChatOptionTest {

	@Test
	public void testOptions() {
		WatsonxAiChatOptions options = WatsonxAiChatOptions.builder()
			.withDecodingMethod("sample")
			.withTemperature(1.2f)
			.withTopK(20)
			.withTopP(0.5f)
			.withMaxNewTokens(100)
			.withMinNewTokens(20)
			.withStopSequences(List.of("\n\n\n"))
			.withRepetitionPenalty(1.1f)
			.withRandomSeed(4)
			.build();

		var optionsMap = options.toMap();

		assertThat(optionsMap).containsEntry("decoding_method", "sample");
		assertThat(optionsMap).containsEntry("temperature", 1.2);
		assertThat(optionsMap).containsEntry("top_k", 20);
		assertThat(optionsMap).containsEntry("top_p", 0.5);
		assertThat(optionsMap).containsEntry("max_new_tokens", 100);
		assertThat(optionsMap).containsEntry("min_new_tokens", 20);
		assertThat(optionsMap).containsEntry("stop_sequences", List.of("\n\n\n"));
		assertThat(optionsMap).containsEntry("repetition_penalty", 1.1);
		assertThat(optionsMap).containsEntry("random_seed", 4);
	}

	@Test
	public void testFilterOut() {
		WatsonxAiChatOptions options = WatsonxAiChatOptions.builder().withModel("google/flan-ul2").build();
		var mappedOptions = WatsonxAiChatOptions.filterNonSupportedFields(options.toMap());
		assertThat(mappedOptions).doesNotContainEntry("model", "google/flan-ul2");
	}

}

org.springframework.ai.watsonx.WatsonxAiChatOptions.builder
[((1021, 1304), 'org.springframework.ai.watsonx.WatsonxAiChatOptions.builder'), ((1021, 1292), 'org.springframework.ai.watsonx.WatsonxAiChatOptions.builder'), ((1021, 1270), 'org.springframework.ai.watsonx.WatsonxAiChatOptions.builder'), ((1021, 1238), 'org.springframework.ai.watsonx.WatsonxAiChatOptions.builder'), ((1021, 1197), 'org.springframework.ai.watsonx.WatsonxAiChatOptions.builder'), ((1021, 1172), 'org.springframework.ai.watsonx.WatsonxAiChatOptions.builder'), ((1021, 1146), 'org.springframework.ai.watsonx.WatsonxAiChatOptions.builder'), ((1021, 1127), 'org.springframework.ai.watsonx.WatsonxAiChatOptions.builder'), ((1021, 1110), 'org.springframework.ai.watsonx.WatsonxAiChatOptions.builder'), ((1021, 1084), 'org.springframework.ai.watsonx.WatsonxAiChatOptions.builder'), ((1982, 2049), 'org.springframework.ai.watsonx.WatsonxAiChatOptions.builder'), ((1982, 2041), 'org.springframework.ai.watsonx.WatsonxAiChatOptions.builder')]