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

io.quarkiverse.langchain4j.watsonx.prompt.impl.GraniteCodePromptFormatter 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 code prompt formatter.
 */
public class GraniteCodePromptFormatter implements PromptFormatter {

    @Override
    public String system() {
        return "System:\n";
    }

    @Override
    public String user() {
        return "Question:\n";
    }

    @Override
    public String assistant() {
        return "Answer:\n";
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy