add duration and boot config procoessor dep

This commit is contained in:
Mark Pollack
2023-08-22 16:42:28 -07:00
parent 635a6210eb
commit c9905fdaec
4 changed files with 20 additions and 2 deletions

View File

@@ -19,7 +19,7 @@ public class BeanOutputParser<T> implements OutputParser<T> {
private Class clazz;
public BeanOutputParser(Class clazz) {
public BeanOutputParser(Class<T> clazz) {
Objects.requireNonNull(clazz, "Java Class can not be null;");
this.clazz = clazz;
generateSchema();

View File

@@ -41,6 +41,12 @@
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
<!-- test dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>

View File

@@ -46,7 +46,7 @@ public class OpenAiAutoConfiguration {
throw new IllegalArgumentException(
"You must provide an API key with the property name " + CONFIG_PREFIX + ".api-key");
}
return new OpenAiService(openAiProperties.getApiKey());
return new OpenAiService(openAiProperties.getApiKey(), openAiProperties.getDuration());
}
@Bean

View File

@@ -18,6 +18,8 @@ package org.springframework.ai.autoconfigure.openai;
import org.springframework.boot.context.properties.ConfigurationProperties;
import java.time.Duration;
import static org.springframework.ai.autoconfigure.openai.OpenAiProperties.CONFIG_PREFIX;
@ConfigurationProperties(CONFIG_PREFIX)
@@ -29,6 +31,8 @@ public class OpenAiProperties {
private Double temperature = 0.7;
private Duration duration = Duration.ofSeconds(60);
private String model = "gpt-3.5-turbo";
public String getApiKey() {
@@ -55,4 +59,12 @@ public class OpenAiProperties {
this.temperature = temperature;
}
public Duration getDuration() {
return duration;
}
public void setDuration(Duration duration) {
this.duration = duration;
}
}