io.kestra.plugin.openai.AbstractTask Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of plugin-openai Show documentation
Show all versions of plugin-openai Show documentation
Interact with OpenAI from Kestra.
The newest version!
package io.kestra.plugin.openai;
import com.theokanning.openai.service.OpenAiService;
import io.kestra.core.exceptions.IllegalVariableEvaluationException;
import io.kestra.core.models.property.Property;
import io.kestra.core.models.tasks.Task;
import io.kestra.core.runners.RunContext;
import lombok.*;
import lombok.experimental.SuperBuilder;
import java.time.Duration;
@SuperBuilder
@ToString
@EqualsAndHashCode
@Getter
@NoArgsConstructor
public abstract class AbstractTask extends Task implements OpenAiInterface{
protected Property apiKey;
protected Property user;
@Builder.Default
protected long clientTimeout = 10;
protected OpenAiService client(RunContext runContext) throws IllegalVariableEvaluationException {
String apiKey = runContext.render(this.apiKey.as(runContext, String.class));
return new OpenAiService(apiKey, Duration.ofSeconds(clientTimeout));
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy