AICore Generate Content¶
Generate Content action is used to send a generateContent request to the AI Core service.
All the properties defined under Action are applicable to this action.
AICore Generate Content Properties¶
Property | Type | Required | Default |
---|---|---|---|
Headers | object |
No | {"content-type":"application/json"} |
Path | string |
No | |
Properties | GenerateContentProperties | Yes | |
ResourceGroup | string |
No | "default" |
Target | AICoreTarget | Yes | |
_Type | const |
Yes |
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 "/models/gemini-1.5-pro:generateContent" are not required if "/models/gemini-1.5-pro:generateContent" 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.Generate.Content"
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 Gemini models
Text Input¶
{
"_Type": "Action.Type.AICore.Generate.Content",
"ResourceGroup": "default",
"Target": {
"Service": "/MyMDKApp/Services/MyAICore.service",
"Path": "/models/gemini-1.5-pro:generateContent"
},
"Properties" : {
"Contents": [
{
"role": "user",
"parts": {
"text": "sample input prompt"
}
}
],
"SystemInstruction": {
"role": string,
"parts": [{
"text": "You are a helpful assistant."
}]
},
"SafetySettings": {
"category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
"threshold": "BLOCK_LOW_AND_ABOVE"
},
"GenerationConfig": {
"maxOutputTokens": 100,
"temperature": 0.7,
"top_p": 0.9,
"top_k": 40
}
}
}
Image Input¶
{
"_Type": "Action.Type.AICore.Generate.Content",
"Target": {
"Service": "/MyMDKApp/Services/MyAICore.service",
"Path": "/models/gemini-1.5-pro:generateContent"
},
"Properties" : {
"Contents": [{
"role": "user",
"parts": [
{
"text": "Describe this picture:"
},
{
"fileData": {
"mimeType": "image/png",
"fileUri": "https://path/images/image.png"
}
},
{
"inlineData": {
"mimeType": "image/jpeg",
"data": "{base64_image}"
}
}
]
}]
}
}
Tools¶
{
"_Type": "Action.Type.AICore.Generate.Content",
"Target": {
"Service": "/MyMDKApp/Services/MyAICore.service",
"Path": "/models/gemini-1.5-pro:generateContent"
},
"Properties" : {
Contents: [{
role: "user",
parts: {
text: "Please fetch the weather data for the city of London."
}
}],
Tools: [
{
"function_declarations": [
{
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"]
}
}
]
}
]
}
}