Tous les produits
Search
Centre de documentation

Object Storage Service:Résumé intelligent de documents

Dernière mise à jour :Sep 24, 2026

Le résumé intelligent de documents condense automatiquement les longs documents en brefs résumés mettant en évidence les points clés. Cette fonctionnalité évite aux lecteurs d'avoir à parcourir l'intégralité des documents et leur permet d'en saisir rapidement le contenu.

Prérequis

Le bucket Object Storage Service (OSS) correspondant est lié à un projet Intelligent Media Management (IMM). Pour plus d'informations sur la liaison d'un bucket OSS à un projet IMM depuis la console OSS, consultez la rubrique Démarrage rapide. Pour plus d'informations sur la liaison d'un bucket OSS à un projet IMM via l'API IMM, consultez la rubrique AttachOSSBucket.

Notes d'utilisation

  • Le résumé intelligent de documents prend uniquement en charge le traitement synchrone (x-oss-process).

  • Pour utiliser la fonctionnalité de résumé intelligent de documents, envoyez des requêtes via la méthode POST.

  • L'accès anonyme est refusé.

  • Vous devez disposer des autorisations nécessaires pour utiliser cette fonctionnalité. Pour plus d'informations, consultez la rubrique relative aux autorisations.

Paramètres

Action : doc/summarize

Le tableau suivant décrit les paramètres que vous pouvez spécifier lors de l'utilisation de la fonctionnalité de résumé intelligent de documents.

Paramètre

Type

Obligatoire

Description

content

string

Oui

Contenu à résumer. Le contenu doit être encodé en Base64 URL-safe.

Remarque

La taille du contenu ne peut pas dépasser 19 500 octets.

format

string

Non

Mode de renvoi de la réponse. Valeurs valides :

  • json (par défaut) : mode standard. Un paquet de données contenant la réponse complète est renvoyé.

  • event-stream : mode Server-Sent Events (SSE). Plusieurs paquets sont renvoyés. Chaque paquet contient des données complètes.

Le tableau suivant décrit les paramètres de réponse.

Paramètre

Type

Description

RequestId

string

ID de la requête.

Output

struct

Sortie.

Nœuds enfants : Text et FinishReason

Text

string

Résumé.

Nœud parent : Output

FinishReason

string

État de la tâche de résumé. Valeurs valides :

  • null : la tâche est en cours d'exécution.

  • stop : la tâche est terminée.

Nœud parent : Output

Utiliser l'API RESTful

Remarque

Si vous utilisez l'API RESTful pour résumer un document, vous devez spécifier le nom du document, qui sert uniquement d'espace réservé. Le résumé intelligent de documents identifie uniquement la valeur du paramètre content comme texte à résumer.

Résumer des documents en mode standard

Méthode de traitement

  • Document à traiter : example.doc

  • Texte à résumer : Ernest Hemingway's "The Old Man and the Sea" is a tale of an old fisherman, Santiago, and his epic struggle to catch a giant marlin. This story is a profound exploration of human endurance, perseverance, and the battle against the forces of nature. Santiago's unwavering determination and dignity in the face of adversity serve as a testament to the strength of the human spirit.

  • Format de réponse : JSON

Exemple de requête

POST /example.doc?x-oss-process HTTP/1.1
Host: doc-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e

x-oss-process=doc/summarize,content__5Zub5aSn5ZCN6JGX77yM6KKr6KqJ5Li65Lit5Zu95paH5a2m5a6d5bqT5Lit55qE55KA55Ko5piO54-g77yM5piv5Lit5Zu95Y-k5Luj5bCP6K-06Im65pyv5beF5bOw55qE6LGh5b6B44CC6L-Z5Zub6YOo5Li-5LiW6Ze75ZCN55qE5bCP6K-05beo6JGX77yM5YiG5Yir5piv572X6LSv5Lit5omA5Yib5L2c55qE5Y6G5Y-y6aKY5p2Q5bCP6K-044CK5LiJ5Zu95ryU5LmJ44CL77yM5ZC05om_5oGp56yU5LiL55qE56We6a2U5aWH5bm75L2c5ZOB44CK6KW_5ri46K6w44CL77yM5pa96ICQ5bq15Yib5L2c55qE6Iux6ZuE5Lyg5aWH5bCP6K-044CK5rC05rWS5Lyg44CL77yM5Lul5Y-K5pu56Zuq6Iq55pKw5YaZ55qE5Lq65oOF5LiW5pWF5LiO5a625peP5YW06KGw55qE57uP5YW45LmL5L2c44CK57qi5qW85qKm44CL44CC44CK5LiJ5Zu95ryU5LmJ44CL5Lul5Lic5rGJ5pyr5bm05Y-K5LiJ5Zu95pe25Luj5Li66IOM5pmv77yM55Sf5Yqo5o-P57uY5LqG576k6ZuE5LqJ6Zy455qE5Y6G5Y-y55S75Y2377yb44CK6KW_5ri46K6w44CL5YiZ5Lul5ZSQ5YOn5biI5b6S5Y-W57uP55qE5pWF5LqL5Li65Li757q_77yM6J6N5ZCI5LqG5aSn6YeP55qE56We6K-d5Lyg6K-05ZKM5rCR6Ze05pWF5LqL77yM5bGV546w5Ye65LiA5bmF55Gw5Li95aWH54m555qE56We6a2U5LiW55WM77yb44CK5rC05rWS5Lyg44CL6K6y6L-w5LqG5YyX5a6L5pyr5bm05qKB5bGx5aW95rGJ5Lus5Y-N5oqX5bCB5bu657uf5rK76ICF55qE5aOu5Li95Y-y6K-X77yM5bGV546w5LqG6I2J6I696Iux6ZuE5Lus55qE6LGq6L-I5rCU5qaC77yb6ICM44CK57qi5qW85qKm44CL5YiZ5piv6YCa6L-H5a-56LS-5a6d546J5Y-K5YW25ZGo5Zu05Lq654mp5ZG96L-Q55qE5rex5YWl5YmW5p6Q77yM5Y-N5pig5LqG5bCB5bu656S-5Lya5pyr5pyf5aSn5a625peP55qE6I2j5p6v5YW06KGw5ZKM56S-5Lya546w5a6e55qE5rex5Yi75o-t56S644CC6L-Z5Zub5aSn5ZCN6JGX77yM5ZCE5YW354m56Imy77yM5ZCE5pyJ5Y2D56eL77yM5LiN5LuF5Zyo5Lit5Zu95paH5a2m5Y-y5LiK55WZ5LiL5LqG5rWT5aKo6YeN5b2p55qE5LiA56yU77yM5pu05Zyo5LiW55WM5paH5a2m6aKG5Z-f5YaF5Lqn55Sf5LqG5rex6L-c5b2x5ZON77yM5oiQ5Li65LqG5Lit5Y2O5paH5YyW5LiN5Y-v5oiW57y655qE6YeN6KaB57uE5oiQ6YOo5YiG44CC

Exemple de réponse

HTTP/1.1 200 OK
Server: AliyunOSS
Date: Thu, 10 Aug 2023 11:09:00 GMT
Content-Type: application/json;charset=UTF-8
Connection: close
Vary: Accept-Encoding
x-oss-request-id: 676144309D4E643133E487D4
x-oss-server-time: 2010
Content-Encoding: gzip

{
  "RequestId":"676144309D4E643133E487D4",
  "Output":{
    "Text":"\"The Old Man and the Sea\" by Ernest Hemingway is a narrative about an elderly fisherman, Santiago, who embarks on an epic journey to catch a massive marlin. The story delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and dignity amidst challenges highlight the resilience of the human spirit.",
    "FinishReason":"stop"
  }
}

Résumer des documents en mode SSE

Méthode de traitement

  • Document à traiter : example.doc

  • Texte à résumer : Ernest Hemingway's "The Old Man and the Sea" is a tale of an old fisherman, Santiago, and his epic struggle to catch a giant marlin. This story is a profound exploration of human endurance, perseverance, and the battle against the forces of nature. Santiago's unwavering determination and dignity in the face of adversity serve as a testament to the strength of the human spirit.

  • Format de réponse : event-stream

Exemple de requête

POST /example.doc?x-oss-process HTTP/1.1
Host: doc-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e

x-oss-process=doc/summarize,format_event-stream,content__5Zub5aSn5ZCN6JGX77yM6KKr6KqJ5Li65Lit5Zu95paH5a2m5a6d5bqT5Lit55qE55KA55Ko5piO54-g77yM5piv5Lit5Zu95Y-k5Luj5bCP6K-06Im65pyv5beF5bOw55qE6LGh5b6B44CC6L-Z5Zub6YOo5Li-5LiW6Ze75ZCN55qE5bCP6K-05beo6JGX77yM5YiG5Yir5piv572X6LSv5Lit5omA5Yib5L2c55qE5Y6G5Y-y6aKY5p2Q5bCP6K-044CK5LiJ5Zu95ryU5LmJ44CL77yM5ZC05om_5oGp56yU5LiL55qE56We6a2U5aWH5bm75L2c5ZOB44CK6KW_5ri46K6w44CL77yM5pa96ICQ5bq15Yib5L2c55qE6Iux6ZuE5Lyg5aWH5bCP6K-044CK5rC05rWS5Lyg44CL77yM5Lul5Y-K5pu56Zuq6Iq55pKw5YaZ55qE5Lq65oOF5LiW5pWF5LiO5a625peP5YW06KGw55qE57uP5YW45LmL5L2c44CK57qi5qW85qKm44CL44CC44CK5LiJ5Zu95ryU5LmJ44CL5Lul5Lic5rGJ5pyr5bm05Y-K5LiJ5Zu95pe25Luj5Li66IOM5pmv77yM55Sf5Yqo5o-P57uY5LqG576k6ZuE5LqJ6Zy455qE5Y6G5Y-y55S75Y2377yb44CK6KW_5ri46K6w44CL5YiZ5Lul5ZSQ5YOn5biI5b6S5Y-W57uP55qE5pWF5LqL5Li65Li757q_77yM6J6N5ZCI5LqG5aSn6YeP55qE56We6K-d5Lyg6K-05ZKM5rCR6Ze05pWF5LqL77yM5bGV546w5Ye65LiA5bmF55Gw5Li95aWH54m555qE56We6a2U5LiW55WM77yb44CK5rC05rWS5Lyg44CL6K6y6L-w5LqG5YyX5a6L5pyr5bm05qKB5bGx5aW95rGJ5Lus5Y-N5oqX5bCB5bu657uf5rK76ICF55qE5aOu5Li95Y-y6K-X77yM5bGV546w5LqG6I2J6I696Iux6ZuE5Lus55qE6LGq6L-I5rCU5qaC77yb6ICM44CK57qi5qW85qKm44CL5YiZ5piv6YCa6L-H5a-56LS-5a6d546J5Y-K5YW25ZGo5Zu05Lq654mp5ZG96L-Q55qE5rex5YWl5YmW5p6Q77yM5Y-N5pig5LqG5bCB5bu656S-5Lya5pyr5pyf5aSn5a625peP55qE6I2j5p6v5YW06KGw5ZKM56S-5Lya546w5a6e55qE5rex5Yi75o-t56S644CC6L-Z5Zub5aSn5ZCN6JGX77yM5ZCE5YW354m56Imy77yM5ZCE5pyJ5Y2D56eL77yM5LiN5LuF5Zyo5Lit5Zu95paH5a2m5Y-y5LiK55WZ5LiL5LqG5rWT5aKo6YeN5b2p55qE5LiA56yU77yM5pu05Zyo5LiW55WM5paH5a2m6aKG5Z-f5YaF5Lqn55Sf5LqG5rex6L-c5b2x5ZON77yM5oiQ5Li65LqG5Lit5Y2O5paH5YyW5LiN5Y-v5oiW57y655qE6YeN6KaB57uE5oiQ6YOo5YiG44CC

Exemple de réponse

HTTP/1.1 200 OK
Server: AliyunOSS
Date: Thu, 10 Aug 2023 11:20:11 GMT
Content-Type: text/event-stream;charset=UTF-8
Transfer-Encoding: chunked
Connection: close
x-oss-request-id: 669F7CE338492236349AF037
x-oss-server-time: 587

id: 0
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The","FinishReason":"null"}}

id: 1
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old","FinishReason":"null"}}

id: 2
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man","FinishReason":"null"}}

id: 3
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and","FinishReason":"null"}}

id: 4
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by","FinishReason":"null"}}

id: 5
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway","FinishReason":"null"}}

id: 6
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story","FinishReason":"null"}}

id: 7
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an","FinishReason":"null"}}

id: 8
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman,","FinishReason":"null"}}

id: 9
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his ardu","FinishReason":"null"}}

id: 10
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch","FinishReason":"null"}}

id: 11
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin","FinishReason":"null"}}

id: 12
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative del","FinishReason":"null"}}

id: 13
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of","FinishReason":"null"}}

id: 14
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance","FinishReason":"null"}}

id: 15
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle","FinishReason":"null"}}

id: 16
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago","FinishReason":"null"}}

id: 17
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and","FinishReason":"null"}}

id: 18
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and dignity amidst challenges highlight","FinishReason":"null"}}

id: 19
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and dignity amidst challenges highlight the resilience of the","FinishReason":"null"}}

id: 20
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and dignity amidst challenges highlight the resilience of the human spirit.","FinishReason":"stop"}}

Utiliser les SDK OSS

L'exemple de code suivant montre comment résumer un document à l'aide des SDK Object Storage Service (OSS) pour les langages de programmation courants. Si vous souhaitez résumer des documents à l'aide des SDK OSS pour d'autres langages, adaptez les paramètres en vous basant sur l'exemple ci-dessous.

Java

Le SDK OSS pour Java version 3.17.4 ou ultérieure est requis.

import com.aliyun.oss.*;
import com.aliyun.oss.common.auth.*;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.common.utils.BinaryUtil;
import com.aliyun.oss.common.utils.IOUtils;
import com.aliyun.oss.model.GenericResult;
import com.aliyun.oss.model.ProcessObjectRequest;

import java.io.IOException;
import java.util.Formatter;

public class Demo {
    public static void main(String[] args) throws ClientException, com.aliyuncs.exceptions.ClientException {
        // Specify the endpoint of the region in which the bucket is located. 
        String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
        // Specify the ID of the Alibaba Cloud region in which the bucket is located. Example: cn-hangzhou. 
        String region = "cn-hangzhou";
        // Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured. 
        EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
        // Specify the name of the bucket. 
        String bucketName = "examplebucket";
        // Specify the name of the document object, which is used only as a placeholder. Intelligent document summarization does not read the content of the document. 
        String key ="example.docx";
        // Specify the text content to be summarized. 
        String content = "yourContent";
        String encodeContent = BinaryUtil.toBase64String(content.getBytes()).replaceAll("\\+","-")
                .replaceAll("/","_").replaceAll("=","");

        // Create an OSSClient instance.
        // Call the shutdown method to release resources when the OSSClient is no longer in use. 
        ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
        clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
        OSS ossClient = OSSClientBuilder.create()
                .endpoint(endpoint)
                .credentialsProvider(credentialsProvider)
                .clientConfiguration(clientBuilderConfiguration)
                .region(region)
                .build();

        try {

            StringBuilder sbStyle = new StringBuilder();
            Formatter styleFormatter = new Formatter(sbStyle);
            // Create a processing instruction for intelligent document summarization. 
            styleFormatter.format("doc/summarize,content_%s",
                    encodeContent);
            System.out.println(sbStyle.toString());
            ProcessObjectRequest request = new ProcessObjectRequest(bucketName, key, sbStyle.toString());
            GenericResult processResult = ossClient.processObject(request);
            String json = IOUtils.readStreamAsString(processResult.getResponse().getContent(), "UTF-8");
            processResult.getResponse().getContent().close();
            System.out.println(json);
        } catch (OSSException oe) {
            System.out.println("Caught an OSSException, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + oe.getErrorMessage());
            System.out.println("Error Code:" + oe.getErrorCode());
            System.out.println("Request ID:" + oe.getRequestId());
            System.out.println("Host ID:" + oe.getHostId());
        } catch (ClientException ce) {
            System.out.println("Caught an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

PHP

Le SDK OSS pour PHP version 2.7.0 ou ultérieure est requis.

<?php
// Obtain access credentials from environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.  
$ak = getenv('OSS_ACCESS_KEY_ID');
$sk = getenv('OSS_ACCESS_KEY_SECRET');
// Specify the name of the bucket. Example: examplebucket. 
$bucket = 'examplebucket';
// Specify the name of the document object, which is used only as a placeholder. Intelligent document summarization does not read the content of the document. 
$objectKey = 'example.docx';
// Specify the text content to be summarized. 
$txt = "yourTxt";

$base64url = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($txt));
// Create a processing instruction for intelligent document summarization. 
$body = sprintf("x-oss-process=doc/summarize,content_%s", $base64url);

$httpVerb = 'POST';
$contentMd5 = base64_encode(md5($body, true));
$contentType = '';
$date = gmdate('D, d M Y H:i:s T');
$stringToSign = $httpVerb . "\n" . $contentMd5 . "\n" . $contentType . "\n" . $date . "\n" . "/{$bucket}/{$objectKey}?x-oss-process";
$signature = base64_encode(hash_hmac('sha1', $stringToSign, $sk, true));

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://{$bucket}.oss-cn-hangzhou.aliyuncs.com/{$objectKey}?x-oss-process");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    'Date: ' . $date,
    'Authorization: OSS ' . $ak . ':' . $signature,
    'Content-Type: ' . $contentType,
    'Content-Md5:' . $contentMd5,
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);

$response = curl_exec($ch);

$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($response === false) {
    echo "Error: " . curl_error($ch);
} else {
    if ($httpcode == 200) {
        var_dump($response);
    } else {
        echo "Error: HTTP code " . $httpcode;
    }
}

Go

Le SDK OSS pour Go version 3.0.2 ou ultérieure est requis.

package main

import (
    "encoding/base64"
    "encoding/json"
    "fmt"
    "io"
    "os"
    "strings"

    "github.com/aliyun/aliyun-oss-go-sdk/oss"
)

type TextData struct {
    RequestId string `json:"RequestId"`
    Output    struct {
    Text         string `json:"Text"`
    FinishReason string `json:"FinishReason"`
    } `json:"Output"`
}

func main() {
    // Obtain the temporary access credentials from the environment variables. Before you run the sample code, make sure that the OSS_ACCESS_KEY_ID, OSS_ACCESS_KEY_SECRET, and OSS_SESSION_TOKEN environment variables are configured. 
    provider, err := oss.NewEnvironmentVariableCredentialsProvider()
    if err != nil {
    fmt.Println("Error:", err)
    os.Exit(-1)
    }
    // Create an OSSClient instance. 
    client, err := oss.New("https://oss-cn-hangzhou.aliyuncs.com", "", "", oss.SetCredentialsProvider(&provider), oss.AuthVersion(oss.AuthV4), oss.Region("cn-hangzhou"))
    if err != nil {
    fmt.Println("Error:", err)
    os.Exit(-1)
    }

    // Specify the name of the bucket. Example: examplebucket. 
    bucketName := "examplebucket"
    bucket, err := client.Bucket(bucketName)
    if err != nil {
    fmt.Println("Error:", err)
    os.Exit(-1)
    }
    params := make(map[string]interface{})
    params["x-oss-process"] = nil
    // Specify the text content to be summarized. 
    txt := "yourTxt"
    // Create a processing instruction for intelligent document summarization. 
    data := fmt.Sprintf("x-oss-process=doc/summarize,content_%v", base64.URLEncoding.EncodeToString([]byte(txt)))
    // example.docx is a document in the bucket. It is used as a placeholder. Intelligent document summarization does not read the content of the document. 
    response, err := bucket.Do("POST", "example.docx", params, nil, strings.NewReader(data), nil)
    if err != nil {
    fmt.Println("Error:", err)
    os.Exit(-1)
    }

    defer response.Body.Close()
    jsonData, err := io.ReadAll(response.Body)
    if err != nil {
    fmt.Println("Error:", err)
    os.Exit(-1)
    }
    var text TextData
    err = json.Unmarshal(jsonData, &text)
    if err != nil {
    fmt.Println("Error:", err)
    os.Exit(-1)
    }
    fmt.Printf("RequestId:%v\n", text.RequestId)
    fmt.Printf("Text:%v\n", text.Output.Text)
    fmt.Printf("FinishReason:%v\n", text.Output.FinishReason)
}