English
Fx.AI
About 1448 wordsAbout 5 min
2026-01-09
1. detectPic Image Recognition
Image Recognition
Fx.AI.detectPic(<String modelId>, <String path>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| modelId | String | Unique identifier of the object recognition model | Y |
| path | String | nPath of the image | Y |
Code examples
def(boolean error, Map data, String errorMessage) = Fx.AI.detectPic("5dabce96e75d9594e1dc05f6", "N_202006_09_87e2be5f5c364bda9cb5ed61a21ddd25")
if (error) {
log.error("detectPic " + errorMessage)
//1. Terminate execution with error
//Fx.message.throwException("detectPic " + errorMessage)
//2. Terminate execution using return
//return;
//3. Continue execution
}
//dosomethingNotice
- Enterprises can only use the model if they possess it.
2. invoiceValidation Invoice Verification
Invoice Verification
Fx.AI.invoiceValidation(<InvoiceData arg>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| arg | InvoiceData | Invoice verification entity object | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| code | integer | |
| message | string | |
| data | object |
| data | object | Description |
|---|---|---|
| N_202308_29_e157da5c641f446f92dbc9e2ba8c8885 | object |
| N_202308_29_e157da5c641f446f92dbc9e2ba8c8885 | object | Description |
|---|---|---|
| success | boolean | |
| errorCode | string | |
| errorMsg | string | |
| ocrJson | null | |
| ocrType | null |
Return an example
{
"code": 200,
"message": "OK",
"data": {
"N_202308_29_e157da5c641f446f92dbc9e2ba8c8885": {
"success": false,
"errorCode": "216630",
"errorMsg": "recognize error",
"ocrJson": null,
"ocrType": null
}
}
}Code examples
InvoiceData invoice = InvoiceData.builder()
.type("elec_normal_invoice")
.code("011002100511")
.number("24830566")
.date("20210620")
.amount("339.62")
.checkCode("957725")
.build()
def(Boolean error, Object data, String errorMessage) = Fx.AI.invoiceValidation(invoice)
if (error) {
log.error("detectPic " + errorMessage)
//1. Use error reporting to terminate execution
//Fx.message.throwException("detectPic " + errorMessage)
//2. Use return to terminate execution
//return;
//3. Continue execution
}
//dosomethingReference Interface
- Reference guide: InvoiceData
3. queryOcrTypes Get supported OCR recognition types
Get supported OCR recognition types
Fx.AI.queryOcrTypes()
Request parameters
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| code | integer | |
| message | string | |
| data | array[object] |
| data | object | Description |
|---|---|---|
| type | string | |
| desc | string | |
| descKey | string |
Return an example
{
"code": 200,
"message": "message",
"data":
[
{
"type": "type",
"desc": "desc",
"descKey": "descKey"
}
]
}Code examples
def (ue, ud, uem) = Fx.AI.queryOcrTypes()
if(ue){
log.info(uem)
}
else{
log.info(ud)
}4. ocrImages OCR recognition
OCR recognition
Fx.AI.ocrImages(<string ocrType>, <array paths>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| ocrType | string | Y | |
| paths | array[string] | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| code | integer | |
| message | string | |
| data | object |
| data | object | Description |
|---|---|---|
| N_202308_29_e157da5c641f446f92dbc9e2ba8c8885 | object |
| N_202308_29_e157da5c641f446f92dbc9e2ba8c8885 | object | Description |
|---|---|---|
| success | boolean | |
| errorCode | string | |
| errorMsg | string | |
| ocrJson | null | |
| ocrType | null |
Return an example
{
"code": 200,
"message": "OK",
"data": {
"N_202308_29_e157da5c641f446f92dbc9e2ba8c8885": {
"success": false,
"errorCode": "216630",
"errorMsg": "recognize error",
"ocrJson": null,
"ocrType": null
}
}
}Code examples
def (ue, ud, uem) = Fx.AI.ocrImages("MultipleInvoice", ["N_202311_28_8c3e4c6e652748eb9c52142a32d2bcce"])
if (ue) {
log.info(uem)
}
else {
log.info(ud)
}5. Call the chatCompletions API of the large language model
Calling the AI large model chatCompletions interface
Fx.AI.chatCompletions(<Map map>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| map | Map | Map parameter for invoking the chatCompletions interface of large language models | Y |
| map | Map | Map parameter for invoking the chatCompletions interface of large language models | Required |
|---|---|---|---|
| model | String | Specifies the large language model to be invoked, e.g., ERNIE-Bot, qwen-turbo | Y |
| messages | List[object] | Historical conversation messages with AI | Y |
| temperature | BigDecimal | Temperature is a value that controls the confidence of model predictions. Lowering temperature makes predictions more accurate and deterministic but potentially less creative. Increasing temperature yields more diverse completions but may result in less accurate or overly creative outputs. Range: 0-1, default: 0.7 | -- |
| messages | object | Description | Required |
|---|---|---|---|
| role | String | Role used in the conversation: system (system), assistant (large language model), user (user) | Y |
| content | String | Content of the conversation message | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| finish_reason | String | The reason why the model stopped generating text |
| message | String | The text content generated by the large language model |
Return an example
{
"finish_reason": "normal",
"message": "Certainly. Here's a brief diary example:\n\n---\n\nFriday, April 15, 2023 Sunny\n\nToday my mood was as bright as the sunshine outside. In the morning, I went jogging with the first rays of sunlight, feeling full of energy. In the afternoon, I met with friends at a café, and time slipped away amidst laughter and conversation. In the evening, sitting alone at my desk reading favorite books, my heart was peaceful and content. A simple day, yet filled with happiness and warmth.\n\n---\n\nI hope this diary meets your requirements."
}Code examples
//model: Currently supported large language models include:
//ERNIE-Bot, ERNIE-Bot4.0 (Baidu Wenxin)
//generalv2, generalv3 (iFLYTEK)
//qwen-turbo, qwen-plus (Alibaba Tongyi Qianwen)
//hunyuan-pro, hunyuan-standard (Tencent Hunyuan)
//ep-20240618123932-5zk5j (Doubao-pro-4k), ep-20240618123950-llzrs (Doubao-pro-32k) (ByteDance Doubao)
//messages: Conversation messages with the model are of List type, containing two fields: role and content
//- role: participant role
//system: context set by the system
//assistant: content returned by the model
//user: content sent by the user
//- content: specific text content
//temperature: A value controlling the model's prediction confidence. Lower temperature yields more accurate and deterministic results but may lack creativity. Higher temperature produces more diverse completions but may result in less accurate or creative outputs. Range: 0-1
Map request = [
"model": "ERNIE-Bot",
"messages": [
[
"role": "user",
"content": "Hello ERNIE-Bot, could you generate a diary entry of about 100 words for me?"
]
],
"temperature": 0.7
]
def(boolean error, Map data, String errorMessage) = Fx.AI.chatCompletions(request)
if (error) {
log.error("chatCompletions " + errorMessage)
//1. Use error to terminate execution
//Fx.message.throwException("chatCompletions " + errorMessage)
//2. Use return to terminate execution
//return;
//3. Continue execution
}
log.info(data)
//dosomethingNotice
- AI capabilities require purchasing resource packages: [AI Product Resource Pack]
6. completionsByPrompt Invokes the large model generation interface via prompt templates
Invoking Large Model Generation APIs via Prompt Templates
Fx.AI.completionsByPrompt(<String promptApiName>, <Map objectData>, <String bingObjectDataId>, <List otherObjectData>, <Map sceneVariables>)
Request parameters
Request Body
| Parameter Name | object | Description | Required |
|---|---|---|---|
| promptApiName | String | Prompt template apiName | Y |
| objectData | Map | Bound main object data | -- |
| bingObjectDataId | String | Bound main object data ID (mutually exclusive with objectData parameter; when both are provided, objectData takes precedence) | -- |
| otherObjectData | List[object] | Other object data used in the prompt template (objectApinName represents object apiName, dataId represents data ID) | -- |
| sceneVariables | Map | Custom scene variables for prompt template (keys must correspond with those defined in the prompt template) | -- |
| otherObjectData | object | Description | Required |
|---|---|---|---|
| objectApinName | List | Object apiName | Y |
| dataId | List | Data ID | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| message | String | Output result of the large language model |
Return an example
{
"message": "{\n \"outputLanguage\": \"English\",\n \"outText\": \"Hello\"\n}"
}Code examples
// Prompt template apiName
String promptApiName = 'prompt_GrQPP__c'
// Complete information of the bound main object data
Map objectData = [
"name": "Customer Data 123",
"object_describe_api_name": "AccountObj"
]
// Bound main object data ID. Either this parameter or objectData can be used (if both are provided, objectData takes priority)
String bingObjectDataId = "63b6b583b6b41e00018ae21d"
// Other object data used in the prompt template: objectApinName is the object API name, dataId is the data ID
List otherObjectData = [
[
"objectApinName": "LeadsObj",
"dataId": "62a9b7c16d5aad00017bff4f"
],
[
"objectApinName": "SalesOrderObj",
"dataId": "62a9b7c16d5aad00017bff4f"
]
]
// Custom scenario variables for the prompt template (keys must match those in the prompt template)
Map sceneVariables = [
"content": "Hello",
"targetLanguage": "English"
]
def(boolean error, Map data, String errorMessage) = Fx.AI.completionsByPrompt(promptApiName, objectData, bingObjectDataId, otherObjectData, sceneVariables)
if (error) {
log.error("completionsByPrompt " + errorMessage)
//1. Use error to terminate execution
//Fx.message.throwException("completionsByPrompt " + errorMessage)
//2. Use return to terminate execution
//return;
//3. Continue execution
}
log.info(data)
//dosomethingNotice
- AI capabilities require purchasing resource packages: [AI Product Resource Package]
7. Retrieve content via semantic search
Retrieving object data through semantic search
Fx.AI.RAGRetrieval(<String ragApiName>, <String query>)
Request parameters
Request Body
| Parameter Name | Knowledge Base | Description | Required |
|---|---|---|---|
| ragApiName | String | Semantic search index API name | Y |
| query | String | User query | Y |
Return Parameters
| Parameter Name | object | Description |
|---|---|---|
| scoreThreshold | BigDecimal | Reference threshold |
| hits | List[object] |
| hits | object | Description |
|---|---|---|
| objectApiName | String | Object API name |
| id | String | Object data ID |
| content | String | Article content |
| retrievalType | String | Retrieval type |
| score | BigDecimal | Score |
Return an example
{
"scoreThreshold": 2.0,
"hits": [
{
"objectApiName": "ServiceKnowledgeObj",
"id": "6718e6c45bc3550001a216e7",
"content": "RocketMQ and MySQL Knowledge Points\n\n\nContent of mysql.docx file:\nInterviewer: Please elaborate on RocketMQ's message acknowledgment mechanism? xxx",
"score": 0.009232215
},
{
"objectApiName": "ServiceKnowledgeObj",
"id": "66bad2bd0a62fe00018dbd0b",
"content": "Special Topic: Analysis and Optimization of Mass Data Scheduled Workflows xxx",
"score": 0.0058653383
}
]
}Code examples
// ragAPIName is the newly created data in [Semantic Search Index] under [AI Platform Management] in the admin console
String ragAPIName = "rag_service_knowledge__c"
// Content to be retrieved
String query = "Connect to Tianrun"
def(boolean error, Map data, String message) = Fx.AI.RAGRetrieval(ragAPIName, query)
if (error) {
log.error("chatCompletions " + errorMessage)
//1. Use error to terminate execution
//Fx.message.throwException("chatCompletions " + errorMessage)
//2. Use return to terminate execution
//return;
//3. Continue execution
}
log.info(data)
//dosomethingNotice
- This is part of AI capabilities and requires purchasing a resource package: [AI Product Resource Package]
Owner:韩统武(已停用)
Reference object com.fxiaoke.functions.model.InvoiceData
Field description
| Parameter Name | object | Description |
|---|---|---|
| date | java.lang.String | Invoice date: |
| number | java.lang.String | Invoice number |
| amount | java.lang.String | Invoice amount (excluding tax) |
| code | java.lang.String | Invoice code |
| type | java.lang.String | Invoice type |
| checkCode | java.lang.String | Invoice verification code (last 6 digits), optional |
