Create a Document Based Digital Human
This section is meant to help you create a new digital human leveraging the Document based (doc_qa) operationMode.
1. Create Head
The complete process is done using the POST /head/create endpoint.
The following code snipped shows you how to create a very simple Digital Human operating in Document-Based Q&A mode.
Please refer to the for more details and Create a Digital Human for more infomation of the POST endpoint.
curl -X 'POST' \
'https://platform-api.unith.ai/head/create' \
-H 'accept: application/json' \
-H 'Authorization: Bearer yourBearerToken' \
-H 'Content-Type: application/json' \
-d '{
"headVisualId": "yourHeadVisualId",
"name": "Lev",
"alias": "Lev",
"languageSpeechRecognition": "en-US",
"langCode": "en-US",
"ttsProvider": "elevenlabs",
"operationMode": "doc_qa",
"ocProvider": "playground",
"ttsVoice": " "voiceId": "pNInz6obpgDQGcFmaJgB_eleven_flash_v2",
"greetings": "Hi there"
}'{
"id": "generatedID",
"createdAt": "2024-04-05T08:26:22.616Z",
"updatedAt": "2024-04-05T08:26:22.616Z",
"name": "lev",
"publicId": "lev-123",
"publicUrl": "https://chat.unith.ai/[org]-[num]/lev-123?api_key=orgAPIKey",
"fileUrl": null,
"alias": "Lev",
"documentJsonDto": null,
"documentUrl": null,
"promptConfig": {
"system_prompt": [
""
],
"qa_prompt": {
"introduction": "",
"personality": "Act as a Brand Ambassador. Your objective is to provide concise responses. Maintain an enthusiastic, polite and helpful tone in your responses.",
"qa_instructions": "Use context_search tool to retrieve the response. Do not retry the search. If the information IS NOT CONTAINED IN THE CONTEXT respond with respond with I'm sorry, but it seems like I couldn't find a match for your query. If you have any other questions or need assistance with a different topic, feel free to ask! All responses should not exceed 30 words in length and keep the answer as concise as possible. If asked about any specific people (by name), places or telephone numbers not mentioned in the document, state that you are not allowed to speak about people due to privacy. In case a user poses a question not related to the document address the query accurately, then smoothly redirect the conversation back to context."
},
"intentions": []
},
"greetings": "Hi there",
"language": "en-GB",
"languageSpeechRecognition": "en-GB",
"phrases": [],
"encodedPath": "asdfasgsfsdfgdsgfdfg",
"ttsProvider": "audiostack",
"operationMode": "doc_qa",
"ocProvider": "playground",
"ttsVoice": "kelso",
"iconConfig": null,
"customWords": {},
"headVisualId": "65bfab67-6e3e-4408-b994-05b06e565ace",
"isActive": true,
"voiceflowApiKey": null,
"avatar": null,
"pluginOperationalModeConfig": null,
"isRandomSuggestions": true
}Result
At this point, your Digital Human is now live and can be accessed via the URL found in the publicUrl property of the response.
{
...
"publicId": "headId",
"publicUrl": "https://chat.unith.ai/[org-id]/[head-id]?api_key=[org-api-key]",
...
}Take note of th generated headId which you will use for the following steps, and any time you need to update your digital human
While you can access your Digital Human, it is still not functional at this stage, since it does not have a knowledge base document provided.
2. Upload Document
All doc_qa Digital Humans require a knowledge document to be uploade. To do so, you then need to use the Document Upload endpoint
curl -X 'POST' \
'https://platform-api.unith.ai/document/file' \
-H 'accept: */*' \
-H 'x-head-talking-head-id: yourHeadId' \
-H 'Authorization: Bearer hiamastring' \
-H 'Content-Type: multipart/form-data' \
-F 'document=@Unith Product Highlights.pdf;type=application/pdf'201At this point, your Digital Human is now live and can be accessed via the URL found in the publicUrl property.
{
...
"publicId": "generatedPublicId",
"publicUrl": "https://chat.unith.ai/[org-id]/[head-id]?api_key=[org-api-key]",
...
}2.1 Refine Generated Suggestions
Retrieve head information using GET head/{Id}
curl -X 'GET' \
'https://platform-api.unith.ai/head{<headId}' \
-H 'accept: application/json' \
-H 'Authorization: Bearer <uniquetoken>'In the response, review the dynamically generated suggestions and Update them as required.
{
"id": "<headId>",
....
"documentJsonDto": {
"summary": "The relationship between human rights, democracy, and climate change is complex. The effects of climate change can lead to a \"climate apartheid\" where the wealthy can escape its impacts while the rest of the world suffers. Poorer countries, who contribute less to climate change, are often the most affected and have limited resources to mitigate its effects. Climate change can also exacerbate poverty, trapping families in a cycle of disadvantage for generations. However, current tools for addressing climate change often do not consider issues of just distribution and the impact on human rights.",
"suggestions": [
"What is the potential impact of climate change on human rights and democracy, according to United Nations Special Rapporteur Philip Alston?",
"How did the effects of Superstorm Sandy in 2012 highlight the unequal distribution of resources during natural disasters?",
"How can controlling the price of carbon potentially lead to a \"climate apartheid\" between richer and poorer countries?",
"In what ways do countries in the Global South bear the burden of natural disasters and weather extremes, despite contributing less to the global carbon footprint?",
"How do poverty and climate change exacerbate each other, according to a 2020 World Bank paper?",
"What is the definition of the \"cycle of poverty\" and how does it relate to the potential negative impacts of climate change?",
"How do tools for addressing climate change often overlook questions of just distribution and the environmental effects on human rights?",
"How many additional people are estimated to be pushed into extreme poverty by 2030 due to climate change, according to the World Bank?"
]
},
...
}2.2 Refine prompt
Converse with your Digital Human
At this point, your Digital Human is fully converational live and can be accessed via the URL found in the publicUrl property of the response.