You can pass business parameters to Alibaba Cloud Model Studio or your self-developed large language model (LLM) to provide additional context for more accurate responses.
Feature introduction
Parameter passthrough lets you send custom business data, such as user context, environment tags, user IDs, or membership information, along with requests in a service call chain. This provides the LLM with additional context to maintain business logic, improve response accuracy, and enhance observability while ensuring data integrity.
Use cases
In AI agent applications, you can pass parameters to applications in Alibaba Cloud Model Studio or your self-developed model. For example, in a customer service scenario, passing the user's issue type, business segment, and inquiry history helps the LLM provide more accurate and relevant answers, improving support efficiency.
Example: In e-commerce support, passing a user's purchased product information allows the LLM to quickly resolve product usage or after-sales issues.
Implementation
Audio/video call agents
Pass to Model Studio
-
Server-side initiation: When you call the GenerateAIAgentCall or StartAIAgentInstance API, configure the
AIAgentConfigparameter. For more information, see AIAgentConfig. -
Client-side initiation: In the
ARTCAICallConfig.agentConfig.llmConfigparameter, configure theBailianAppParamsparameter to pass parameters to Alibaba Cloud Model Studio. For more information, see Model Studio parameter details.
Client-side sample code
Android
// Create and configure an ARTCAICallConfig object.
ARTCAICallEngine.ARTCAICallConfig artcaiCallConfig = new ARTCAICallEngine.ARTCAICallConfig();
// Configure the bailianAppParams parameter of agentConfig. This is a JSON string.
artcaiCallConfig.agentConfig.llmConfig.bailianAppParams = "XXX";
// Omit the call initiation process.
iOS
// Configure the bailianAppParams parameter of agentConfig.
let agentConfig = ARTCAICallAgentConfig() // Create an ARTCAICallAgentConfig object.
agentConfig.llmConfig.bailianAppParams = ["xxx", "xxxx"]
// Omit the call initiation process.
...
Web
// Configure the aiAgentBailianAppParams parameter of agentConfig.
const agentConfig = new AICallAgentConfig(); // Create an ARTCAICallAgentConfig object.
agentConfig.llmConfig.bailianAppParams = {
// Configure the bailianAppParams parameter.
};
// Omit the call initiation process.
Pass to a self-developed model
-
Server-side initiation: When you call the GenerateAIAgentCall or StartAIAgentInstance API, configure the
userDataparameter. -
Client-side initiation: When you start the agent, set the
userDataproperty.
For more information about retrieving the custom userData after the agent starts, see LLM standard interface.
Client-side sample code
Android
ARTCAICallEngine.ARTCAICallConfig artcaiCallConfig = new ARTCAICallEngine.ARTCAICallConfig(); // Create an ARTCAICallConfig object. For more information, see the user guide.
artcaiCallConfig.userData = "{\"xxx\": \"xxx\"}" // Set business parameters for the model.
... // Set other parameters as needed.
engine.init(artcaiCallConfig); // Initialize the engine.
engine.call(token); // Initiate a call.
iOS
let callConfig = ARTCAICallConfig() // Create an ARTCAICallConfig object. For more information, see the user guide.
callConfig.userData = ["xxx": "xxxx"] // Set business parameters for the model.
... // Set other parameters as needed.
self.engine.call(config: callConfig) // Initiate a call.
Web
const callConfig = {
// Create an AICallConfig object. For more information, see the user guide.
};
callConfig.userData = JSON.stringify({xxx: 'xxx'})
// Initiate a call.
engine.callWithConfig(callConfig);
Chatbot agents
Pass to Model Studio
-
Before you call the APIs provided by the
AICallKit SDKto configure business parameters, ensure that theAICallKit SDKlibrary is correctly imported. -
ARTCAIChatTemplateConfigis a class used to create a template configuration for messaging conversations. ThebailianParamparameter is a JSON string that contains the business parameters to pass to Alibaba Cloud Model Studio. -
ARTCAIChatEngineis the engine class for managing messaging conversations. Use thesetTemplateConfigmethod to apply the configuredtemplateConfigto the engine. This ensures that the business parameters are passed during subsequent interactions with Alibaba Cloud Model Studio.
Sample code
Android
// Parameters for the Alibaba Cloud Model Studio application center. This is a JSON string.
String bailianParam = "XXX";
// Create the TemplateConfig parameter for the messaging conversation.
ARTCAIChatEngine.ARTCAIChatTemplateConfig templateConfig= new ARTCAIChatEngine.ARTCAIChatTemplateConfig(bailianParam, "");
// Set the configuration parameters for the messaging conversation. mChatEngine is an ARTCAIChatEngine object.
mChatEngine.setTemplateConfig(templateConfig);
iOS
// Create the TemplateConfig parameter for the messaging conversation.
let templateConfig = ARTCAIChatTemplateConfig()
// Set parameters for the Alibaba Cloud Model Studio application center.
templateConfig.bailianAppParams = ["xxx":"xxxxx"]
// Set templateConfig for the messaging conversation engine.
self.engine.templateConfig = templateConfig
Web
const engine = new AIChatEngine();
// Create the TemplateConfig parameter for the messaging conversation.
const templateConfig = new AIChatTemplateConfig();
// Set parameters for the Alibaba Cloud Model Studio application center.
templateConfig.bailianAppParams = {
xxx: 'xxxxx',
};
// Set templateConfig for the messaging conversation engine.
engine.templateConfig = templateConfig;
Pass to a self-developed large model
-
To pass business parameters to a self-developed large model, call the
setUserDatamethod of theAICallKit SDK. Before you call this method, ensure that the SDK library is correctly imported. -
The
userDataparameter is a JSON string that contains the business parameters to pass to a self-developed model. -
Use the
mChatEngine.setUserData()method to set the business parameters in the engine.
Sample code
Android
// Custom business parameters (as a JSON string).
String userData = "XXX";
// Set the parameters on the engine (mChatEngine).
mChatEngine.setUserData(userData);
iOS
// Custom business parameters.
let userData = ["xxx":"xxxxx"]
// Set the userData on the chat engine.
self.engine.userData = userData
Web
// Custom business parameters.
const userData = { xxx: 'xxxxx' };
// Set the userData on the chat engine.
engine.userData = userData;
Model Studio parameter details
|
Parameter |
Type |
Description |
Example |
|
biz_params |
Object |
The custom parameters passed to a workflow application or agent orchestration application. For details, see Application parameter pass-through Note
|
|
|
memory_id |
String |
A unique identifier for long-term memory, used to preserve and recall historical information. |
YOUR_MEMORY_ID |
|
image_list |
Array |
The URLs of images that provide visual context for the current operation. |
["https://example.com/images/example.jpg"] |
|
rag_options |
Object |
Retrieval-Augmented Generation (RAG) parameters. These include but are not limited to retrieving specified knowledge bases or documents. |
|
|
Array |
The knowledge base ID. When specified, all documents in the knowledge base are retrieved. |
["KnowledgeBaseID1", "KnowledgeBaseID2"] |
|
Array |
The ID of the unstructured document to process. |
["DocumentID1", "DocumentID2"] |
|
Object |
The metadata of unstructured documents. When specified, documents containing the specified metadata are retrieved. |
{ "name": "Zhang San" } |
|
Object |
The column names and values used to filter structured documents. |
{ "key1": "value1", "key2": "value2" } |
|
Array |
The tags of unstructured documents. When specified, documents with matching tags are retrieved. |
["Tag1", "Tag2"] |
For more information, see Workflow and Legacy Agent Application API. Examples:
Pass to an Alibaba Cloud Model Studio plugin
aliyunBailianParamsJson = {
"biz_params": {
"user_defined_params":
{
"your_plugin_id":
{
"article_index": 2
}
}
},
"memory_id": "your_memory_id",
"image_list": [
"https://your_image_url" # Example image URL
],
"rag_options": {
"pipeline_ids": [
"your_id", # Replace with the actual knowledge base ID
],
"file_ids": [
"DocumentID1", # Replace with the actual document ID
"DocumentID2" # Replace with the actual document ID
],
"metadata_filter": {
"name": "John Doe" # Replace with the required metadata filter condition
},
"structured_filter": {
"key1": "value1", # Example filter condition
"key2": "value2" # Example filter condition
},
"tags": [
"Tag1", # Replace with actual tags
"Tag2" # Replace with actual tags
]
}
}
bailianParams = json.dumps(aliyunBailianParamsJson)
Pass to an Alibaba Cloud Model Studio workflow
aliyunBailianParamsJson = {
"biz_params": {
"key1": "value1"
},
"memory_id": "your_memory_id",
"image_list": [
"https://your_image_url" # Example image URL
],
"rag_options": {
"pipeline_ids": [
"your_id", # Replace with the actual knowledge base ID
],
"file_ids": [
"DocumentID1", # Replace with the actual document ID
"DocumentID2" # Replace with the actual document ID
],
"metadata_filter": {
"name": "John Doe" # Replace with the required metadata filter condition
},
"structured_filter": {
"key1": "value1", # Example filter condition
"key2": "value2" # Example filter condition
},
"tags": [
"Tag1", # Replace with actual tags
"Tag2" # Replace with actual tags
]
}
}
bailianParams = json.dumps(aliyunBailianParamsJson)