全部產品
Search
文件中心

Intelligent Media Services:資料歸檔

更新時間:Dec 03, 2025

本文將為您介紹如何?資料歸檔。

功能說明

資料歸檔是將使用者與AI智能體的對話轉化為文本資訊並進行儲存,企業可通過API介面調用以消費這部分資料。同時,企業也可以將使用者與AI智能體通話的音視頻資料存放區至Object Storage Service服務(OSS)或ApsaraVideo for VOD(VOD)平台。

功能實現

阿里雲為您提供以下幾種資料歸檔方式:常值內容的聊天記錄、音頻逐句回調以及ARTC錄製的通話內容:

文本聊天記錄

您可以通過調用DescribeAIAgentInstance - 查詢智能體執行個體詳情API,擷取CallLogUrl欄位中的文字檔地址,將產生的文本聊天記錄進行儲存。

調用樣本

import os
import sys

from typing import List

from alibabacloud_ice20201109.client import Client as ICE20201109Client
from alibabacloud_credentials.client import Client as CredentialClient
from alibabacloud_tea_openapi import models as open_api_models
from alibabacloud_ice20201109 import models as ice20201109_models
from alibabacloud_tea_util import models as util_models
from alibabacloud_tea_console.client import Client as ConsoleClient
from alibabacloud_tea_util.client import Client as UtilClient


class Sample:
    def __init__(self):
        pass

    @staticmethod
    def create_client() -> ICE20201109Client:
        """
        使用憑據初始化帳號Client
        @return: Client
        @throws Exception
        """
        # 工程代碼建議使用更安全的無AK方式,憑據配置方式請參見:https://www.alibabacloud.com/help/document_detail/378659.html。
        credential = CredentialClient()
        config = open_api_models.Config(
            credential=credential
        )
        # Endpoint 請參考 https://api.aliyun.com/product/ICE
        config.endpoint = f'ice.us-west-1.aliyuncs.com'
        return ICE20201109Client(config)

    @staticmethod
    def main(
        args: List[str],
    ) -> None:
        client = Sample.create_client()
        describe_aiagent_instance_request = ice20201109_models.DescribeAIAgentInstanceRequest(
            instance_id='YOUR_INSTANCE_ID'
        )
        runtime = util_models.RuntimeOptions()
        try:
            resp = client.describe_aiagent_instance_with_options(describe_aiagent_instance_request, runtime)
            ConsoleClient.log(UtilClient.to_jsonstring(resp))
            ConsoleClient.log(UtilClient.to_jsonstring(resp.body.instance.call_log_url))
        except Exception as error:
            # 此處僅做列印展示,請謹慎對待異常處理,在工程專案中切勿直接忽略異常。
            # 錯誤 message
            print(error.message)
            # 診斷地址
            print(error.data.get("Recommend"))
            UtilClient.assert_as_string(error.message)

if __name__ == '__main__':
    Sample.main(sys.argv[1:])

CallLogUrl結構樣本

{
    "instanceid": "b9566********************3c5eb2",
    "startTime": 1755138072.2456193,
    "agentUserId": "AGENT_USER1b7**************fac945",
    "remoteUserId": "210413545",
    "dialog": [
        {
            "id": 1,
            "begin": 4.45,
            "role": "agent",
            "type": "greeting",
            "text": "哈嘍,我是阿里視頻雲的小雲,來聊聊天吧"
        },
        {
            "id": 2,
            "begin": 5.383,
            "role": "user",
            "type": "normal",
            "text": "講個有趣的兒童故事。"
        },
        {
            "id": 3,
            "begin": 53.951,
            "role": "agent",
            "type": "normal",
            "text": "從前,有一隻叫巧巧的小狐狸,它住在一個奇妙的森林裡。巧巧特別喜歡收集五彩的樹葉,每片葉子都是它的寶貝。有一天,它撿到了一片魔法葉子,這片葉子每天會變出一個小驚喜。有一天是美味的蜂蜜,另一次是漂亮的彩虹雨傘,森林裡的動物們都羨慕極了。\n\n巧巧決定分享這份快樂,它邀請小夥伴們一起遊戲,分享魔法葉子的驚喜。從此,森林裡的快樂和友情日益增長,大家一起度過了許多難忘的時光。這就是小巧和她的魔法葉子的故事,每晚聽著這個故事,孩子們就會甜甜地進入夢鄉。"
        },
        {
            "id": 4,
            "begin": 54.922,
            "role": "user",
            "type": "normal",
            "text": "換個故事。"
        },
        {
            "id": 5,
            "begin": 81.97,
            "role": "agent",
            "type": "normal",
            "text": "在很久很久以前,有一個叫星塵的宇宙探險家,他有一把星星做成的鑰匙。每當他遇到難題,鑰匙就會亮起,指引他找到解決問題的辦法。他的朋友們都很愛他,因為每次冒險回來,他總是帶著新奇的故事和滿滿的勇氣。和星塵一起去探索未知的宇宙,就成了孩子們最嚮往的冒險。"
        },
        {
            "id": 6,
            "begin": 84.78,
            "role": "user",
            "type": "normal",
            "text": "再換個故事。"
        },
        {
            "id": 7,
            "begin": 88.561,
            "role": "user",
            "type": "normal",
            "text": "我。那個。"
        }
    ]
}

音頻逐句回調

您可以通過在控制台配置聊天記錄即時回調以及使用者、智能體音頻逐句回調。回調具體詳情,請參見智能體回調

image

ARTC通話錄製

您可使用即時音視頻(ARTC)的雲端錄製功能進行錄製,具體詳情請參見雲端錄製

說明

該方法僅適用於ARTC,不適用於電話呼出、呼入。