All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkiverse.langchain4j.watsonx.prompt.impl.GranitePromptFormatter Maven / Gradle / Ivy

There is a newer version: 0.21.0
Show newest version
package io.quarkiverse.langchain4j.watsonx.prompt.impl;

import java.util.List;

import dev.langchain4j.agent.tool.ToolSpecification;
import dev.langchain4j.data.message.ChatMessage;
import io.quarkiverse.langchain4j.watsonx.prompt.PromptFormatter;

/**
 * Granite prompt formatter.
 */
public class GranitePromptFormatter implements PromptFormatter {

    @Override
    public String system() {
        return "<|system|>\n";
    }

    @Override
    public String user() {
        return "<|user|>\n";
    }

    @Override
    public String assistant() {
        return "<|assistant|>\n";
    }

    @Override
    public String endOf(ChatMessage chatMessage) {
        return "";
    }

    @Override
    public String format(List messages, List tools) {
        return """
                %s\
                %s\
                """.formatted(systemMessageFormatter(messages), messagesFormatter(messages));
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy