Arsipkan data percakapan dari sesi Real-time Conversational AI sebagai teks, audio, atau rekaman untuk kepatuhan, analitik, dan fine-tuning LLM.
Ikhtisar
Arsip data menangkap percakapan antara pengguna dan AI agent dalam bentuk teks terstruktur untuk disimpan dan diambil kembali nanti melalui API. Data audio dan video juga dapat disimpan di Object Storage Service (OSS) atau ApsaraVideo VOD.
Arsipkan data percakapan
Real-time Conversational AI menyediakan tiga metode arsip. Gunakan satu atau lebih metode sesuai dengan kebutuhan data aplikasi Anda:
|
Metode |
Data yang ditangkap |
Paling cocok untuk |
|
Catatan chat teks |
Transkrip percakapan lengkap dengan stempel waktu |
Jejak audit, analitik, fine-tuning LLM |
|
Callback audio per kalimat |
File audio per kalimat dan transkrip melalui webhook |
Pemrosesan real-time, akses latensi rendah |
|
Rekaman cloud ARTC |
Rekaman audio/video panggilan lengkap yang disimpan di OSS |
Kepatuhan, pemutaran ulang |
Catatan chat teks
Setelah sesi berakhir, panggil API DescribeAIAgentInstance dan baca bidang CallLogUrl dari respons. URL tersebut mengarah ke file JSON yang berisi transkrip lengkap percakapan.
Contoh kode
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:
"""
Inisialisasi client menggunakan kredensial.
Untuk mengonfigurasi kredensial, lihat https://www.alibabacloud.com/help/document_detail/378659.html.
"""
# Gunakan autentikasi tanpa kredensial di lingkungan produksi.
credential = CredentialClient()
config = open_api_models.Config(
credential=credential
)
# Untuk endpoint, lihat 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:
print(error.message)
print(error.data.get("Recommend"))
UtilClient.assert_as_string(error.message)
if __name__ == '__main__':
Sample.main(sys.argv[1:])
Contoh struktur CallLogUrl
File CallLogUrl berupa dokumen JSON. Semua entri dialog diurutkan berdasarkan begin (dalam detik sejak awal sesi). Setiap entri memiliki bidang berikut: id, begin, role (agent atau user), type (greeting atau normal), dan text.
{
"instanceid": "b9566********************3c5eb2",
"startTime": 1755138072.2456193,
"agentUserId": "AGENT_USER1b7**************fac945",
"remoteUserId": "210413545",
"dialog": [
{
"id": 1,
"begin": 4.45,
"role": "agent",
"type": "greeting",
"text": "Hello. I am Xiaoyun from Alibaba Video Cloud. Let's chat."
},
{
"id": 2,
"begin": 5.383,
"role": "user",
"type": "normal",
"text": "Tell me an interesting children's story."
},
{
"id": 3,
"begin": 53.951,
"role": "agent",
"type": "normal",
"text": "Once upon a time, in a magical forest, there lived a little fox named Qiaoqiao. Qiaoqiao loved collecting colorful leaves, and each one was her treasure. One day, she found a magic leaf that produced a small surprise every day. One day it was delicious honey, another time a beautiful rainbow umbrella, and all the animals in the forest were very envious.\n\nQiaoqiao decided to share this joy. She invited her friends to play together and share the surprises from the magic leaf. From then on, happiness and friendship in the forest grew, and they spent many unforgettable moments together. This is the story of Qiaoqiao and her magic leaf. Listening to this story every night, children would sweetly fall into their dreams."
},
{
"id": 4,
"begin": 54.922,
"role": "user",
"type": "normal",
"text": "Tell me a different story."
},
{
"id": 5,
"begin": 81.97,
"role": "agent",
"type": "normal",
"text": "A long, long time ago, there was a space explorer named Stardust who had a key made of stars. Whenever he encountered a problem, the key would light up and guide him to a solution. His friends loved him because he always returned from his adventures with new stories and a lot of courage. Exploring the unknown universe with Stardust became the adventure that children longed for the most."
},
{
"id": 6,
"begin": 84.78,
"role": "user",
"type": "normal",
"text": "Tell me another story."
},
{
"id": 7,
"begin": 88.561,
"role": "user",
"type": "normal",
"text": "I... um..."
}
]
}
Callback audio per kalimat
Di Konsol, aktifkan real-time chat record callback dan sentence-by-sentence user and AI agent audio callback. Untuk detail konfigurasi, lihat agent callback.
Saat mengonfigurasi callback, masukkan callback URL dan Token otentikasi. Untuk sentence-by-sentence user and AI agent audio callback, pilih juga lokasi penyimpanan OSS. Gunakan HTTPS untuk callback URL.
Rekaman cloud ARTC
Gunakan fitur rekaman cloud dari Alibaba Real-Time Communication (ARTC) untuk merekam panggilan. Untuk detailnya, lihat Cloud recording.
Metode ini hanya berlaku untuk ARTC, tidak berlaku untuk panggilan telepon outbound atau inbound.