文档库语境化问答
POST
https://api.ai21.com/studio/v1/library/answer请求参数
Body 参数application/json
question
string
必需
包含要根据文档库中的内容回答的问题的字符串。限制:150 个字符
path
string
可选
用于将问题集中在库中的特定路径上。选修的
labels
array[string]
可选
用于将问题集中在图书馆中带有特定标签的文档上。选修的
fileIds
array[string]
可选
用于将问题集中在图书馆中的特定文档上。选修的
示例
{
"question": "string",
"path": "string",
"labels": [
"string"
],
"fileIds": [
"string"
]
}
示例代码
返回响应
找到答案(200)
未找到答案(200)
“问题”字段丢失(400)
“问题”超过最大字符数(400)
HTTP 状态码: 200
内容格式: JSONapplication/json
数据结构
id
string
必需
answerInContext
boolean
必需
answer
string
必需
sources
array [object {4}]
必需
fileId
string
可选
name
string
可选
highlights
array[string]
可选
publicUrl
string
可选
示例
成功示例
{
"id": "c54b82ca-9347-137b-b76c-9dadcb992a1f",
"answerInContext": true,
"answer": "Koalas eat the leaves of Eucalyptus trees.",
"sources": [
{
"fileId": "912e8968-fa0d-4eb2-8ec1-9c35a10c9517",
"name": "main/endangered_species/koala.txt",
"highlights": [
"Koalas typically inhabit open Eucalyptus woodland, as the leaves of these trees make up most of their diet.\n\nThis eucalypt diet has low nutritional and caloric content and contains toxins that deter most other mammals from feeding on it.\n\nKoalas are largely sedentary and sleep up to twenty hours a day.\n\nThey are asocial animals, and bonding exists only between mothers and dependent offspring.\n\nAdult males communicate with loud bellows that intimidate rivals and attract mates.\n\nMales mark their presence with secretions from scent glands located on their chests.\n\nBeing marsupials, koalas give birth to underdeveloped young that crawl into their mothers' pouches, where they stay for the first six to seven months of their lives.\n\nThese young koalas, known as joeys, are fully weaned around a year old.",
"Koalas have few natural predators and parasites, but are threatened by various pathogens, such as Chlamydiaceae bacteria and koala retrovirus.",
"The koala or, inaccurately, koala bear (Phascolarctos cinereus), is an arboreal herbivorous marsupial native to Australia.\n\nIt is the only extant representative of the family Phascolarctidae and its closest living relatives are the wombats.",
"The koala is found in coastal areas of the mainland's eastern and southern regions, inhabiting Queensland, New South Wales, Victoria, and South Australia.\n\nIt is easily recognisable by its stout, tailless body and large head with round, fluffy ears and large, spoon-shaped nose.\n\nThe koala has a body length of 60–85 cm (24–33 in) and weighs 4–15 kg (9–33 lb).\n\nFur colour ranges from silver grey to chocolate brown.\n\nKoalas from the northern populations are typically smaller and lighter in colour than their counterparts further south.\n\nThese populations possibly are separate subspecies, but this is disputed.",
"During the Oligocene and Miocene, koalas lived in rainforests and had less specialised diets.[13] Some species, such as the Riversleigh rainforest koala (Nimiokoala greystanesi) and some species of Perikoala, were around the same size as the modern koala, while others, such as species of Litokoala, were one-half to two-thirds its size.[14] Like the modern species, prehistoric koalas had well developed ear structures which suggests that long-distance vocalising and sedentism developed early.[13] During the Miocene, the Australian continent began drying out, leading to the decline of rainforests and the spread of open Eucalyptus woodlands.\n\nThe genus Phascolarctos split from Litokoala in the late Miocene[13][15] and had several adaptations that allowed it to live on a specialised eucalyptus diet: a shifting of the palate towards the front of the skull; larger molars and premolars; smaller pterygoid fossa;[13] and a larger gap between the molar and the incisor teeth.[16]: 226 \n\nP. cinereus may have emerged as a dwarf form of the giant koala (P. stirtoni).\n\nThe reduction in the size of large mammals has been seen as a common phenomenon worldwide during the late Pleistocene, and several Australian mammals, such as the agile wallaby, are traditionally believed to have resulted from this dwarfing."
],
"publicUrl": "https://en.wikipedia.org/wiki/Koala"
}
]
}
最后修改时间: 1 年前