utils Module
Enums
ONNXTemplate |
ONNXTemplate is an enumeration that represents different ONNX model templates. |
Functions
apply_template
Apply the specified ONNX template to the given chat history.
apply_template(history: ChatHistory, template: ONNXTemplate) -> str
Parameters
Name | Description |
---|---|
history
Required
|
<xref:semantic_kernel.connectors.ai.onnx.utils.ChatHistory>
The chat history to which the template will be applied. |
template
Required
|
The ONNX template to apply. |
Returns
Type | Description |
---|---|
The result of applying the template to the chat history. |
Exceptions
Type | Description |
---|---|
If an error occurs while applying the template. |
gemma_template
Generates a formatted string for the Gemma model based on the provided chat history.
gemma_template(history: ChatHistory) -> str
Parameters
Name | Description |
---|---|
history
Required
|
<xref:semantic_kernel.connectors.ai.onnx.utils.ChatHistory>
An object containing the chat history with messages. |
Returns
Type | Description |
---|---|
A formatted string representing the chat history for the Gemma model. |
Exceptions
Type | Description |
---|---|
If a system message is encountered in the chat history. |
llama_template
Generates a formatted string from a given chat history for use with the LLaMA model.
llama_template(history: ChatHistory) -> str
Parameters
Name | Description |
---|---|
history
Required
|
<xref:semantic_kernel.connectors.ai.onnx.utils.ChatHistory>
An object containing the chat history, which includes a list of messages. |
Returns
Type | Description |
---|---|
A formatted string where each message is wrapped with specific header and end tags, and the final string ends with an assistant header tag. |
phi3_template
Generates a formatted string from the chat history for use with the phi3 model.
phi3_template(history: ChatHistory) -> str
Parameters
Name | Description |
---|---|
history
Required
|
<xref:semantic_kernel.connectors.ai.onnx.utils.ChatHistory>
An object containing the chat history with a list of messages. |
Returns
Type | Description |
---|---|
A formatted string where each message is prefixed with the role and suffixed with an end marker. |
phi3v_template
Generates a formatted string from a given chat history for use with the phi3v model.
phi3v_template(history: ChatHistory) -> str
Parameters
Name | Description |
---|---|
history
Required
|
<xref:semantic_kernel.connectors.ai.onnx.utils.ChatHistory>
An object containing the chat history with messages. |
Returns
Type | Description |
---|---|
A formatted string representing the chat history, with special tokens indicating the role of each message (system, user, assistant) and the type of content (text, image). |