Ask a Question to the Avatar
Developing
Global Server
Global Server
POST
/api/v1/streaming-avatar/ask
/api/v1/streaming-avatar/set-qa-context
. We provide basic QA function by prompt engineering. For more advanced QA capabilities, such as Retrieval-Augmented Generation (RAG), you will need to implement the QA logic yourself. In this case, you can use the Speak /api/v1/streaming-avatar/speak
API to directly control what the avatar says.If you want to get the avatar says from
/api/v1/streaming-avatar/ask
, please usetype StreamData = {
type: 'QA';
message: string;
pos?: 'start' | 'middle' | 'end';
};
rtcClient.on('stream-message', onStreamMessage);
const onStreamMessage = (uid, message) => {
let data: Record<string, any>;
try {
message = new TextDecoder().decode(message);
console.log(`receice ${message} from ${uid}`);
data = JSON.parse(message);
} catch (e) {
console.error('invalid json string:', message);
return;
}
if (data.type === 'QA') {
// todo Logic for handling reply messages
}
};
Request
Body Params application/json
Request samples
Responses
Modified at 2024-12-27 10:38:06