io.quarkiverse.langchain4j.QuarkusAiServicesFactory Maven / Gradle / Ivy
package io.quarkiverse.langchain4j;
import static dev.langchain4j.exception.IllegalConfigurationException.illegalConfiguration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import dev.langchain4j.model.image.ImageModel;
import dev.langchain4j.service.AiServiceContext;
import dev.langchain4j.service.AiServices;
import dev.langchain4j.spi.services.AiServicesFactory;
import io.quarkiverse.langchain4j.audit.AuditService;
import io.quarkiverse.langchain4j.runtime.AiServicesRecorder;
import io.quarkiverse.langchain4j.runtime.ToolsRecorder;
import io.quarkiverse.langchain4j.runtime.aiservice.AiServiceClassCreateInfo;
import io.quarkiverse.langchain4j.runtime.aiservice.AiServiceMethodCreateInfo;
import io.quarkiverse.langchain4j.runtime.aiservice.ChatMemorySeeder;
import io.quarkiverse.langchain4j.runtime.aiservice.QuarkusAiServiceContext;
public class QuarkusAiServicesFactory implements AiServicesFactory {
@Override
public QuarkusAiServices create(AiServiceContext context) {
if (context instanceof QuarkusAiServiceContext) {
return new QuarkusAiServices<>(context);
} else {
// the context is always empty (except for the aiServiceClass) anyway and never escapes, so we can just use our own type
return new QuarkusAiServices<>(new QuarkusAiServiceContext(context.aiServiceClass));
}
}
public static class InstanceHolder {
public static final QuarkusAiServicesFactory INSTANCE = new QuarkusAiServicesFactory();
}
public static class QuarkusAiServices extends AiServices {
public QuarkusAiServices(AiServiceContext context) {
super(context);
}
@Override
public AiServices tools(List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy