Files
cnb/docs/api-groups/ai/api.json
2026-01-16 13:03:57 +08:00

200 lines
5.3 KiB
JSON
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
{
"swagger": "2.0",
"info": {
"title": "CNB OPENAPI",
"contact": {
"name": "Open API Support",
"url": "https://docs.cnb.cool/",
"email": "cnb@tencent.com"
},
"version": "1.0"
},
"paths": {
"/{repo}/-/ai/chat/completions": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/vnd.cnb.api+json"
],
"tags": [
"AI"
],
"summary": "AI 对话。调用者需有代码写权限CI 中使用 CNB_TOKEN 不检查写权限。AI chat completions. Requires caller to have repo write permission (except when using CNB_TOKEN in CI).",
"operationId": "AiChatCompletions",
"parameters": [
{
"type": "string",
"description": "仓库完整路径",
"name": "repo",
"in": "path",
"required": true
},
{
"description": "AI chat completions params. The params may differ by model.",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.AiChatCompletionsReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.AiChatCompletionsResult"
}
}
},
"description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-code:r"
}
},
"/{repo}/-/build/ai/auto-pr": {
"post": {
"security": [
{
"BearerAuth": []
}
],
"consumes": [
"application/json"
],
"produces": [
"application/vnd.cnb.api+json"
],
"tags": [
"AI"
],
"summary": "根据传入的需求内容和需求标题借助 AI 自动编码并提 PR。Automatically code and create a PR with AI based on the input requirement content and title.",
"operationId": "AiAutoPr",
"parameters": [
{
"type": "string",
"description": "仓库完整路径",
"name": "repo",
"in": "path",
"required": true
},
{
"description": "AI auto PR params",
"name": "request",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/dto.AiAutoPrReq"
}
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/dto.AiAutoPrResult"
}
}
},
"description": "访问令牌调用此接口需包含以下权限。Required permissions for access token. \nrepo-code:rw"
}
}
},
"definitions": {
"dto.AiChatCompletionsReq": {
"type": "object",
"properties": {
"messages": {
"description": "对话内容",
"type": "array",
"items": {
"$ref": "#/definitions/dto.Message"
}
},
"model": {
"description": "模型名称",
"type": "string"
},
"stream": {
"description": "是否流式返回结果,部分模型可能不支持非流式",
"type": "boolean"
}
}
},
"dto.AiChatCompletionsResult": {
"type": "object",
"properties": {
"choices": {
"description": "选择",
"type": "array",
"items": {
"$ref": "#/definitions/dto.AiChatCompletionsChoice"
}
},
"created": {
"description": "创建时间",
"type": "integer"
},
"id": {
"description": "ID",
"type": "string"
},
"model": {
"description": "模型",
"type": "string"
},
"object": {
"description": "对象",
"type": "string"
}
}
},
"dto.AiAutoPrReq": {
"type": "object",
"properties": {
"body": {
"description": "需求内容",
"type": "string"
},
"branch": {
"description": "基于该分支编码并提交代码到随机分支,然后将随机分支提 PR 到该分支",
"type": "string"
},
"source": {
"description": "需求来源,默认为 issue其他来源的需求可写上会出现在代码提交日志的描述信息里",
"type": "string"
},
"title": {
"description": "需求标题",
"type": "string"
},
"url": {
"description": "需求来源 URL 地址",
"type": "string"
}
}
},
"dto.AiAutoPrResult": {
"type": "object",
"properties": {
"buildLogUrl": {
"description": "构建链接",
"type": "string"
},
"message": {
"description": "message",
"type": "string"
},
"sn": {
"description": "构建号",
"type": "string"
}
}
}
}
}