Class CopyPseudoAIChatBuilderImpl
- java.lang.Object
-
- net.stoerr.ai.aigenpipeline.framework.chat.CopyPseudoAIChatBuilderImpl
-
- All Implemented Interfaces:
AIChatBuilder
public class CopyPseudoAIChatBuilderImpl extends Object implements AIChatBuilder
A pseudo AI chat model that just copies the input to the output.
-
-
Field Summary
Fields Modifier and Type Field Description protected StringBuilder
allInputs
static String
MODEL_COPY
Pseudo model that just concatenates the inputs and writes these to the output.
-
Constructor Summary
Constructors Constructor Description CopyPseudoAIChatBuilderImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description AIChatBuilder
assistantMsg(String text)
We assume the "put it into the mouth of the AI" pattern is used.String
execute()
Executes the chat completion request and returns the response.AIChatBuilder
key(String key)
Sets the API key for the chat completion request.AIChatBuilder
maxTokens(int maxTokens)
Sets the maximum number of tokens the completion can use.AIChatBuilder
model(String model)
Sets the AI model to be used for the chat completion.AIChatBuilder
organizationId(String organizationId)
Sets the organization ID for the chat completion request - if applicable (OpenAI).AIChatBuilder
systemMsg(String text)
Adds a system message to the chat.String
toJson()
Converts the chat completion request to a JSON string.AIChatBuilder
url(String url)
Sets the URL for the chat completion request.AIChatBuilder
userMsg(String text)
Adds a user message to the chat.
-
-
-
Field Detail
-
MODEL_COPY
public static final String MODEL_COPY
Pseudo model that just concatenates the inputs and writes these to the output.- See Also:
- Constant Field Values
-
allInputs
protected final StringBuilder allInputs
-
-
Method Detail
-
url
public AIChatBuilder url(String url)
Description copied from interface:AIChatBuilder
Sets the URL for the chat completion request.- Specified by:
url
in interfaceAIChatBuilder
- Parameters:
url
- The URL.- Returns:
- The builder instance for chaining.
-
key
public AIChatBuilder key(String key)
Description copied from interface:AIChatBuilder
Sets the API key for the chat completion request.- Specified by:
key
in interfaceAIChatBuilder
- Parameters:
key
- The API key.- Returns:
- The builder instance for chaining.
-
organizationId
public AIChatBuilder organizationId(String organizationId)
Description copied from interface:AIChatBuilder
Sets the organization ID for the chat completion request - if applicable (OpenAI).- Specified by:
organizationId
in interfaceAIChatBuilder
- Parameters:
organizationId
- The organization ID.- Returns:
- The builder instance for chaining.
-
maxTokens
public AIChatBuilder maxTokens(int maxTokens)
Description copied from interface:AIChatBuilder
Sets the maximum number of tokens the completion can use.- Specified by:
maxTokens
in interfaceAIChatBuilder
- Parameters:
maxTokens
- The maximum number of tokens.- Returns:
- The builder instance for chaining.
-
model
public AIChatBuilder model(String model)
Description copied from interface:AIChatBuilder
Sets the AI model to be used for the chat completion.- Specified by:
model
in interfaceAIChatBuilder
- Parameters:
model
- The model name.- Returns:
- The builder instance for chaining.
-
systemMsg
public AIChatBuilder systemMsg(String text)
Description copied from interface:AIChatBuilder
Adds a system message to the chat.- Specified by:
systemMsg
in interfaceAIChatBuilder
- Parameters:
text
- The text of the message.- Returns:
- The builder instance for chaining.
-
userMsg
public AIChatBuilder userMsg(String text)
Description copied from interface:AIChatBuilder
Adds a user message to the chat.- Specified by:
userMsg
in interfaceAIChatBuilder
- Parameters:
text
- The text of the message.- Returns:
- The builder instance for chaining.
-
assistantMsg
public AIChatBuilder assistantMsg(String text)
We assume the "put it into the mouth of the AI" pattern is used. Then all the assistant messages are actually the inputs. (That is a bit dangerous if it's used differently, but the easiest way.)- Specified by:
assistantMsg
in interfaceAIChatBuilder
- Parameters:
text
- The text of the message.- Returns:
- The builder instance for chaining.
-
toJson
public String toJson()
Description copied from interface:AIChatBuilder
Converts the chat completion request to a JSON string.- Specified by:
toJson
in interfaceAIChatBuilder
- Returns:
- The JSON string.
-
execute
public String execute()
Description copied from interface:AIChatBuilder
Executes the chat completion request and returns the response.- Specified by:
execute
in interfaceAIChatBuilder
- Returns:
- The chat completion response.
-
-