AI21 Labs
  1. 语境化问答 API
AI21 Labs
  • J2 完整 API
    • J2 完整 API
    • J2 完整版
      POST
  • 自定义 J-2 模型
    • 数据集 API
      • 数据集 API
      • 获取数据集列表
      • 获取数据集
      • 删除数据集
    • 自定义模型 API
      • 自定义模型 API
      • 自定义模型训练
      • 获取自定义模型列表
      • 获取自定义模型
      • 自定义模型完整训练
      • 更新默认轮次
  • 特定任务模型
    • 释义 API
      • 释义 API
      • 释义
    • 语法错误修正 API
      • 语法错误修正 API
      • 语法错误更正
    • 文本改进 API
      • 文本改进 API
      • 文本改进
    • 总结 API
      • 总结 API
      • 总结
    • 按段总结 API
      • 按段总结
      • 按段总结
    • 文本分割 API
      • 文本分割 API
      • 文本分割
    • 语境化问答 API
      • 语境化问答 API
      • 管理文档库
        • 将文档上传到图书馆
        • 检索文档列表
        • 通过 ID 检索文档
        • 更新文档参数
        • 删除文档
      • 单文档语境化问答
        POST
      • 文档库语境化问答
        POST
    • 语义搜索 API
      • 语义搜索 API
      • 语义搜索
    • 嵌入式 API
      • 嵌入式
  • SDK
    • Python SDK
    • Python SDK
  • 其他
    • 分词 API
      • 分词
  1. 语境化问答 API

文档库语境化问答

开发环境
http://dev-cn.your-api-server.com
开发环境
http://dev-cn.your-api-server.com
POST
https://api.ai21.com/studio/v1/library/answer
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.ai21.com/studio/v1/library/answer' \
--header 'Content-Type: application/json' \
--data-raw '{
    "question": "string",
    "path": "string",
    "labels": [
        "string"
    ],
    "fileIds": [
        "string"
    ]
}'
响应示例响应示例
200 - 成功示例
{
  "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"
    }
  ]
}

请求参数

Body 参数application/json
question
string 
必需
包含要根据文档库中的内容回答的问题的字符串。限制:150 个字符
path
string 
可选
用于将问题集中在库中的特定路径上。选修的
labels
array[string]
可选
用于将问题集中在图书馆中带有特定标签的文档上。选修的
fileIds
array[string]
可选
用于将问题集中在图书馆中的特定文档上。选修的
示例

返回响应

🟢200找到答案
application/json
Body
id
string 
必需
answerInContext
boolean 
必需
answer
string 
必需
sources
array [object {4}] 
必需
fileId
string 
可选
name
string 
可选
highlights
array[string]
可选
publicUrl
string 
可选
🟢200未找到答案
🟠400“问题”字段丢失
🟠400“问题”超过最大字符数
上一页
单文档语境化问答
下一页
语义搜索 API
Built with