| 7 | import java.util.List; |
| 8 | |
| 9 | public interface LlmClient { |
| 10 | |
| 11 | ChatResponse chat(List<Message> messages, List<Tool> tools) throws IOException; |
| 12 | |
| 13 | ChatResponse chat(List<Message> messages, List<Tool> tools, StreamListener listener) throws IOException; |
| 14 | |
| 15 | String getModelName(); |
| 16 | |
| 17 | String getProviderName(); |
| 18 | |
| 19 | default int maxContextWindow() { |
| 20 | return 128_000; |
| 21 | } |
| 22 | |
| 23 | default boolean supportsPromptCaching() { |
| 24 | return false; |
| 25 | } |
| 26 | |
| 27 | default String promptCacheMode() { |
| 28 | return "none"; |
| 29 | } |
| 30 | |
| 31 | record ContentPart(String type, String text, String imageBase64, String imageUrl, String mimeType) { |
| 32 | public static ContentPart text(String text) { |
| 33 | return new ContentPart("text", text, null, null, null); |
| 34 | } |
| 35 | |
| 36 | public static ContentPart imageBase64(String imageBase64, String mimeType) { |
| 37 | return new ContentPart("image_base64", null, imageBase64, null, |
| 38 | mimeType == null || mimeType.isBlank() ? "image/png" : mimeType); |
| 39 | } |
| 40 | |
| 41 | public static ContentPart imageUrl(String imageUrl) { |
| 42 | return new ContentPart("image_url", null, null, imageUrl, null); |
| 43 | } |
| 44 | |
| 45 | public boolean isText() { |
| 46 | return "text".equals(type); |
| 47 | } |
| 48 | |
| 49 | public boolean isImage() { |
| 50 | return "image_base64".equals(type) || "image_url".equals(type); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | record Message(String role, String content, String reasoningContent, List<ToolCall> toolCalls, |
| 55 | String toolCallId, List<ContentPart> contentParts) { |
| 56 | public Message(String role, String content, String reasoningContent, List<ToolCall> toolCalls, |
| 57 | String toolCallId) { |
| 58 | this(role, content, reasoningContent, toolCalls, toolCallId, null); |
| 59 | } |
| 60 | |
| 61 | public Message(String role, String content) { |
| 62 | this(role, content, null, null, null); |
| 63 | } |
| 64 | |
| 65 | public static Message system(String content) { |
| 66 | return new Message("system", content); |
no outgoing calls
no test coverage detected