Package akka.javasdk.agent
Interface ModelProvider.Custom
- All Superinterfaces:
ModelProvider
- Enclosing interface:
ModelProvider
Custom models can be added by implementing this interface and, and the underlying
implementations of
dev.langchain4j.model.chat.ChatModel and (optionally)
dev.langchain4j.model.chat.StreamingChatModel.
Refer to the Langchain4j documentation or reference implementations for how to implement the
ChatModel and StreamingChatModel.
-
Nested Class Summary
Nested classes/interfaces inherited from interface akka.javasdk.agent.ModelProvider
ModelProvider.Anthropic, ModelProvider.AzureOpenAi, ModelProvider.Bedrock, ModelProvider.BedrockPromptCachePlacement, ModelProvider.Custom, ModelProvider.FromConfig, ModelProvider.GoogleAIGemini, ModelProvider.HuggingFace, ModelProvider.LocalAI, ModelProvider.MistralAi, ModelProvider.Ollama, ModelProvider.OpenAi, ModelProvider.VertexAi -
Method Summary
Modifier and TypeMethodDescriptionIf you don't need streaming you can throw an exception from this method.default StringOverride this method to provide a meaningful model name for your custom provider.default ModelProviderwithAdditionalModelRequestHeaders(List<akka.http.javadsl.model.HttpHeader> additionalModelRequestHeaders) A custom provider builds its own chat model, so the SDK cannot attach headers to its requests.
-
Method Details
-
createChatModel
Object createChatModel()- Returns:
- an instance of
dev.langchain4j.model.chat.ChatModel
-
createStreamingChatModel
Object createStreamingChatModel()If you don't need streaming you can throw an exception from this method.- Returns:
- an instance of
dev.langchain4j.model.chat.StreamingChatModel
-
modelName
Override this method to provide a meaningful model name for your custom provider.- Returns:
- the model name, defaults to 'custom'.
-
withAdditionalModelRequestHeaders
default ModelProvider withAdditionalModelRequestHeaders(List<akka.http.javadsl.model.HttpHeader> additionalModelRequestHeaders) A custom provider builds its own chat model, so the SDK cannot attach headers to its requests. Override this method to keep the given headers, and add them increateChatModel()andcreateStreamingChatModel(). The given list is the one stated in code. The SDK does not merge it with headers the provider already holds.- Specified by:
withAdditionalModelRequestHeadersin interfaceModelProvider- Parameters:
additionalModelRequestHeaders- the headers to add to each model request- Returns:
- a copy of this provider carrying the given headers
- Throws:
UnsupportedOperationException- unless this method is overridden
-