Ask a Question to the Avatar
DevelopingPOST
/api/v1/streaming-avatar/askYou need to set the context for QA by using /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 use
type 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
text
string
required
question
channel
string
required
channel
Example
{
"text": "hello",
"channel": "f84fd"
}
Request samples
Responses
Success(200)
Bad Request(400)
HTTP Code: 200
Content Type : JSONapplication/json
Data Schema
code
integer
required
0 is OK
data
object
required
trace_id
string
required
Example
{
"code": 0,
"data": {},
"trace_id": "9c8fd69b-80d0-4f8a-a119-941ed78d4960"
}
Last modified: a month ago