AICore Chat Completions¶
Chat Completions action is used to send a /chats/completions request to the AI Core service.
All the properties defined under Action are applicable to this action.
AICore Chat Completions Properties¶
Property | Type | Required | Default |
---|---|---|---|
APIVersion | string |
No | "2024-02-01" |
Headers | object |
No | {"content-type":"application/json"} |
Path | string |
No | |
Properties | ChatCompletionsProperties | Yes | |
ResourceGroup | string |
No | "default" |
Target | AICoreTarget | Yes | |
_Type | const |
Yes |
APIVersion¶
Specify the API version. For information about the supported API versions, see Chat completions in the Microsoft documentation.
- type:
string
- default:
"2024-02-01"
Headers¶
Custom headers to be included as part of the request to the AI Core Service in key/value pair format
- type:
object
- default:
{"content-type":"application/json"}
Path¶
The endpoints such as "/chat/completions" are not required if if "/chat/completions" is already in the full path of destination
- type:
string
Properties¶
A list of the property names and values in key/value pairs format.
ResourceGroup¶
Specify the resource group. Resource groups represent a virtual collection of related resources within the scope of your AI runtime environment.
- type:
string
- default:
"default"
Target¶
- type: AICoreTarget
_Type¶
- type:
const
The value of this property must be:
"Action.Type.AICore.Chat.Completions"
Action Result¶
Refer to the MDK Guide to understand what an action result is.
The success ActionResult of this action is of a JS primitive type, object or a JS array. The failure ActionResult is an error message.
Examples¶
Please refer to AI Core Service Guide for the supported models
Text Input¶
Text input is supported by the following models: GPT-4-32k, GPT-4, GPT-3.5-Turbo-16k, GPT-3.5-Turbo, meta--llama3-70b-instruct and mistralai--mixtral-8x7b-instruct-v01
{
"_Type": "Action.Type.AICore.Chat.Completions",
"ResourceGroup": "default",
"APIVersion": "2023-05-15",
"Target": {
"Service": "/MyMDKApp/Services/MyAICore.service",
"Path": "/chat/completions"
},
"Properties" : {
"Model": "gpt-3.5-turbo",
"Messages": [
{
"role": "user",
"content": "sample input prompt"
}
],
"MaxTokens": 100,
"Temperature": 0.0,
"FrequencyPenalty": 0,
"PresencePenalty": 0,
}
}
Image Input¶
Image input is supported by the following models: GPT-4o, GPT-4-Turbo and GPT-4o-mini
{
"_Type": "Action.Type.AICore.Chat.Completions",
"APIVersion": "2023-05-15",
"Target": {
"Service": "/MyMDKApp/Services/MyAICore.service",
"Path": "/chat/completions"
},
"Properties" : {
"Model": "gpt-4o",
"Messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this picture:"
},
{
"type": "image_url",
"image_url": {
"url": "https://path/images/image.png"
}
},
{
"type": "image_url",
"image_url": {
"url": "data:image/jpeg;base64,{base64_image}"
}
}
]
},
"MaxTokens": 100
}
}
Tools¶
Tools and Tool_choice properties are supported by GPT models.
{
"_Type": "Action.Type.AICore.Chat.Completions",
"APIVersion": "2023-05-15",
"Target": {
"Service": "/MyMDKApp/Services/MyAICore.service",
"Path": "/chat/completions"
},
"Properties" : {
"Model": "gpt-4o",
"Messages": [
{
"role": "user",
"content": "Please fetch the weather data for the city of London.",
},
],
"Tools": [
{
"type": "function",
"function": {
"name": "fetch_weather_data",
"description": "Fetch weather data from OpenWeatherMap API",
"parameters": {
"type": "object",
"properties": {
"city": {
"type": "string",
"description": "The name of the city to get weather data for",
},
},
"required": ["city"],
},
},
},
],
"ToolChoice": {
"type": "function",
"function": {
"name": "fetch_weather_data",
},
},
"MaxTokens": 100
}
}