Package com.langchainbeam
Class LangchainModelHandler
java.lang.Object
com.langchainbeam.LangchainModelHandler
- All Implemented Interfaces:
Serializable
A handler class for managing LangChain model options and instruction prompts.
This class is used to configure the model options (e.g., model name,
temperature)
and the
instruction prompt that is passed to the model for inference.
The handler encapsulates the LangchainModelOptions
and the
instruction prompt, which
are necessary to interact with LangChain's model provider interface. The
handler is designed
to be used in conjunction with LangchainBeam
to run inference tasks
on a PCollection
of data.
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionLangchainModelHandler
(LangchainModelOptions options, String instructionPrompt) Constructs a newLangchainModelHandler
with the specified model options and instruction prompt.LangchainModelHandler
(LangchainModelOptions options, String instructionPrompt, Map<String, String> outputFormat) Constructs a newLangchainModelHandler
with the specified model options, instruction prompt, and output format. -
Method Summary
Modifier and TypeMethodDescriptionReturns theLangchainModelOptions
for this handler, which includes model configurations such as the model name and API key.Returns the instruction prompt that guides the model in performing tasks such as classification or generating outputs.
-
Constructor Details
-
LangchainModelHandler
Constructs a newLangchainModelHandler
with the specified model options and instruction prompt.- Parameters:
options
- theLangchainModelOptions
containing model configurations such as model name and API keyinstructionPrompt
- the instruction prompt that will guide the model's behavior (e.g., for classification tasks)
-
LangchainModelHandler
public LangchainModelHandler(LangchainModelOptions options, String instructionPrompt, Map<String, String> outputFormat) Constructs a newLangchainModelHandler
with the specified model options, instruction prompt, and output format.- Parameters:
options
- theLangchainModelOptions
containing model configurationsinstructionPrompt
- the instruction prompt to guide the model on processing the element. Note: Instruct to respond in JSON to get output as a JSON string. Use out `outputFormat` Map to specify the formatoutputFormat
- the desired output format, represented as a map of keys and values as description
-
-
Method Details
-
getOptions
Returns theLangchainModelOptions
for this handler, which includes model configurations such as the model name and API key.- Returns:
- the model options used for inference
-
getPrompt
Returns the instruction prompt that guides the model in performing tasks such as classification or generating outputs.- Returns:
- the instruction prompt string
-