From 420bf5ed78559a0c0f40006b804d3edda6efce2e Mon Sep 17 00:00:00 2001 From: Mark Pollack Date: Wed, 13 Nov 2024 17:58:20 -0500 Subject: [PATCH] Remove files accidentally added to main --- .../chat/FunctionCallbackWrapperKotlinIT.kt | 91 ------------------ .../openai/chat/MockKotlinWeatherService.kt | 92 ------------------- models/spring-ai-postgresml/.attach_pid127642 | 0 3 files changed, 183 deletions(-) delete mode 100644 models/spring-ai-openai/src/test/kotlin/org/springframework/ai/openai/chat/FunctionCallbackWrapperKotlinIT.kt delete mode 100644 models/spring-ai-openai/src/test/kotlin/org/springframework/ai/openai/chat/MockKotlinWeatherService.kt delete mode 100644 models/spring-ai-postgresml/.attach_pid127642 diff --git a/models/spring-ai-openai/src/test/kotlin/org/springframework/ai/openai/chat/FunctionCallbackWrapperKotlinIT.kt b/models/spring-ai-openai/src/test/kotlin/org/springframework/ai/openai/chat/FunctionCallbackWrapperKotlinIT.kt deleted file mode 100644 index 157dc8f42..000000000 --- a/models/spring-ai-openai/src/test/kotlin/org/springframework/ai/openai/chat/FunctionCallbackWrapperKotlinIT.kt +++ /dev/null @@ -1,91 +0,0 @@ -/* - * 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.openai.chat - -import org.assertj.core.api.Assertions.assertThat -import org.junit.jupiter.api.Test -import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable -import org.slf4j.LoggerFactory -import org.springframework.ai.chat.messages.UserMessage -import org.springframework.ai.chat.prompt.Prompt -import org.springframework.ai.model.function.FunctionCallback -import org.springframework.ai.model.function.FunctionCallbackWrapper -import org.springframework.ai.openai.OpenAiChatModel -import org.springframework.ai.openai.OpenAiChatOptions -import org.springframework.ai.openai.api.OpenAiApi -import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.SpringBootConfiguration -import org.springframework.boot.autoconfigure.AutoConfigurations -import org.springframework.boot.test.context.SpringBootTest -import org.springframework.boot.test.context.runner.ApplicationContextRunner -import org.springframework.context.annotation.Bean - -@EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+") -class FunctionCallbackWrapperKotlinIT { - - private val logger = LoggerFactory.getLogger(FunctionCallbackWrapperKotlinIT::class.java) - - - private val contextRunner = ApplicationContextRunner() - .withUserConfiguration(Config::class.java) - - - @Test - fun functionCallTest() { - this.contextRunner.run {context -> - - val chatModel = context.getBean(OpenAiChatModel::class.java) - assertThat(chatModel).isNotNull - - val userMessage = UserMessage( - "What are the weather conditions in San Francisco, Tokyo, and Paris? Find the temperature in Celsius for each of the three locations.") - - val response = chatModel - .call(Prompt(listOf(userMessage), OpenAiChatOptions.builder().withFunction("WeatherInfo").build())) - - logger.info("Response: " + response) - - assertThat(response.getResult().output.content).contains("30", "10", "15") - } - } - - - @SpringBootConfiguration - open class Config { - - @Bean - open fun chatCompletionApi(): OpenAiApi { - return OpenAiApi(System.getenv("OPENAI_API_KEY")) - } - - @Bean - open fun openAiClient(openAiApi: OpenAiApi): OpenAiChatModel { - return OpenAiChatModel(openAiApi) - } - - @Bean - open fun weatherFunctionInfo(): FunctionCallback { - - return FunctionCallbackWrapper.builder(MockKotlinWeatherService()) - .withName("WeatherInfo") - .withInputType(KotlinRequest::class.java) - .withDescription( - "Find the weather conditions, forecasts, and temperatures for a location, like a city or state.") - .build(); - } - } -} diff --git a/models/spring-ai-openai/src/test/kotlin/org/springframework/ai/openai/chat/MockKotlinWeatherService.kt b/models/spring-ai-openai/src/test/kotlin/org/springframework/ai/openai/chat/MockKotlinWeatherService.kt deleted file mode 100644 index ae1d757f6..000000000 --- a/models/spring-ai-openai/src/test/kotlin/org/springframework/ai/openai/chat/MockKotlinWeatherService.kt +++ /dev/null @@ -1,92 +0,0 @@ -/* - * 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.openai.chat - -import com.fasterxml.jackson.annotation.JsonClassDescription -import com.fasterxml.jackson.annotation.JsonInclude -import com.fasterxml.jackson.annotation.JsonInclude.Include -import com.fasterxml.jackson.annotation.JsonProperty -import com.fasterxml.jackson.annotation.JsonPropertyDescription - -class MockKotlinWeatherService : Function1 { - - override fun invoke(kotlinRequest: KotlinRequest): KotlinResponse { - var temperature = 10.0 - if (kotlinRequest.location.contains("Paris")) { - temperature = 15.0 - } - else if (kotlinRequest.location.contains("Tokyo")) { - temperature = 10.0 - } - else if (kotlinRequest.location.contains("San Francisco")) { - temperature = 30.0 - } - - return KotlinResponse(temperature, 15.0, 20.0, 2.0, 53, 45, Unit.C); - } -} - -/** - * Temperature units. - */ -enum class Unit(val unitName: String) { - - /** - * Celsius. - */ - C("metric"), - /** - * Fahrenheit. - */ - F("imperial"); -} - -/** - * Weather Function request. - */ -@JsonInclude(Include.NON_NULL) -@JsonClassDescription("Weather API request") -data class KotlinRequest( - @get:JsonProperty(required = true, value = "location") - @get:JsonPropertyDescription("The city and state e.g. San Francisco, CA") - val location: String = "", - - @get:JsonProperty(required = true, value = "lat") - @get:JsonPropertyDescription("The city latitude") - val lat: Double = 0.0, - - @get:JsonProperty(required = true, value = "lon") - @get:JsonPropertyDescription("The city longitude") - val lon: Double = 0.0, - - @get:JsonProperty(required = true, value = "unit") - @get:JsonPropertyDescription("Temperature unit") - val unit: Unit = Unit.C -) - - -/** - * Weather Function response. - */ -data class KotlinResponse(val temp: Double, - val feels_like: Double, - val temp_min: Double, - val temp_max: Double, - val pressure: Int, - val humidity: Int, - val unit: Unit -) diff --git a/models/spring-ai-postgresml/.attach_pid127642 b/models/spring-ai-postgresml/.attach_pid127642 deleted file mode 100644 index e69de29bb..000000000