更新时间:2023-06-16 GMT+08:00
分享

Create Request接口

功能介绍

create a code generation request.if agent receives a code generation request, it will:- record the request into mysql,- decompose the request into topn tasks.- send the tasks to kafka.if agent receives a duplicated code generation request, it will not decompose request and send to kafka.

调试

您可以在API Explorer中调试该接口,支持自动认证鉴权。API Explorer可以自动生成SDK代码示例,并提供SDK代码示例调试功能。

URI

POST /v2/aims/codemodelserver/code-generation/request

表1 Query参数

参数

是否必选

参数类型

描述

topn

Integer

the number of samples

scenario

String

the scenario of code content

resubmit

Boolean

if resubmit is true, the de-duplication will be ignored

model_id

String

choose the model

request_type

String

An enumeration.

  • function
  • rawtext

枚举值:

  • function
  • rawtext

请求参数

表2 请求Header参数

参数

是否必选

参数类型

描述

x-auth-token

String

iam x-auth-token

表3 请求Body参数

参数

是否必选

参数类型

描述

context

String

context

docstring

String

docstring

ide_type

String

the type of ide

ide_version

String

the version of ide

language

String

code language

plugin_version

String

the version of plugin

signature

String

signature

above_text

String

the text above the cursor

following_text

String

the text following the cursor

响应参数

状态码: 200

表4 响应Body参数

参数

参数类型

描述

request_id

String

the unique id of the request

status

String

the status of the request

枚举值:

  • created
  • dispatched
  • completed
  • timeout
  • unknown

dispatched_task_number

Integer

the number of tasks dispatched successfully

请求示例

创建一个签名为“def add(x, y):”、语言为“python”、文档字符串为“sum two numbers”的代码生成请求。

POST https://{endpoint}/v2/aims/codemodelserver/code-generation/request

{
  "signature" : "def add(x, y):",
  "language" : "python",
  "docstring" : "sum two numbers",
  "context" : "    return x + y",
  "ide_type" : "pycharm professional",
  "ide_version" : "2022.1.3",
  "plugin_version" : "v0.1.0"
}

响应示例

状态码: 200

Successful Response

{
  "request_id" : "d980c2b5242eb97aa07a1f6645a6793a",
  "status" : "created",
  "dispatched_task_number" : 0
}

状态码

状态码

描述

200

Successful Response

错误码

请参见错误码

分享:

    相关文档

    相关产品