Create generation

POST /generations

根据提供的内容、文件或提示创建一个生成任务,生成考试题目。

在创建生成任务时,需要通过 creation_type 来声明任务类型,通过 question_rules 来指定生成题目的种类和数量。

creation_type:

  • knowledge_base 通过资料生成题目
  • question_bank 格式化本地题库
  • oneline 无资料情况下,根据需求描述生成题目

如果你已经拥有一个本地题库,它们可能是 Word、Excel 或 PDF 文件,你可以先上传文件,然后创建一个 question_bank 类型的任务。

{ file: 'file-xxxxxx', creation_type: 'question_bank' }

如果你有一份文档资料,它们可能是 Word、PDF 或 PPT 文件,你可以先上传文件,然后创建一个 knowledge_base 类型的任务。

{
  file: 'file-xxxxxx',
  creation_type: 'knowledge_base',
  question_rules: [{ type: 'single_choice', count: 10 }]
}

如果你没有任何资料,你可以直接创建一个 oneline 类型的任务。

{
  prompt: '帮我生成一套反诈知识的试卷',
  creation_type: 'oneline',
  question_rules: [{ type: 'single_choice', count: 10 }]
}

question_rule:

  • type 题目类型,可选值:
    • single_choice 单选题
    • multiple_choice 多选题
    • true_or_false 判断题
  • count 题目数量,合计生成的题目数量最大为 100。
application/json

Body object

One of:

Responses

  • 201 application/json

    generation created

    Hide response attributes Show response attributes object
    • id string

      Format should match the following pattern: ^gen-.

    • object string

      Value is generation.

    • created_at string(date-time)
    • finished_at string(date-time) | null
    • status string

      Values are queued, generating, succeeded, failed, or cancelled.

  • 400 application/json

    generation not created

POST /generations
curl \
 -X POST https://v5.jinshuju.net/exam/api/generations \
 -H "Content-Type: application/json" \
 -d '{"file":"file-xxxxxx","creation_type":"knowledge_base","question_rules":[{"type":"single_choice","count":10}]}'
{
  "file": "file-xxxxxx",
  "creation_type": "knowledge_base",
  "question_rules": [
    {
      "type": "single_choice",
      "count": 10
    }
  ]
}
{
  "content": "This is an example content",
  "creation_type": "knowledge_base",
  "question_rules": [
    {
      "type": "single_choice",
      "count": 10
    }
  ]
}
{
  "prompt": "帮我生成一套反诈知识的试卷",
  "creation_type": "oneline",
  "question_rules": [
    {
      "type": "single_choice",
      "count": 10
    }
  ]
}
Response examples (201)
{
  "id": "gen-6757a41fe88e5d8d2a0bbc3c",
  "object": "generation",
  "status": "generating",
  "created_at": "2024-12-10T10:14:55.221+08:00",
  "finished_at": null
}
Response examples (400)
{
  "error": {
    "type": "invalid_request_error",
    "message": "Creation Type can't be blank"
  }
}