代码生成
开发环境
http://dev-cn.your-api-server.com
开发环境
http://dev-cn.your-api-server.com
POST
/v2/text/code_generation
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'http://dev-cn.your-api-server.com/v2/text/code_generation' \
--header 'Authorization;' \
--header 'content-type: application/json' \
--data-raw '{
"response_as_dict": true,
"attributes_as_list": false,
"show_original_response": false,
"temperature": 0,
"max_tokens": 1000
}'
响应示例响应示例
200 - 成功示例
{
"openai": {
"generated_text": "Sure, here's a Python function that checks if a year is a leap year:\n\n```python\ndef is_leap_year(year):\n \"\"\"\n Returns True if the given year is a leap year, False otherwise.\n \"\"\"\n if year % 4 == 0:\n if year % 100 == 0:\n if year % 400 == 0:\n return True\n else:\n return False\n else:\n return True\n else:\n return False\n```\n\nThis function takes a year as input and returns True if it is a leap year, and False otherwise. It uses the standard rules for determining leap years: a year is a leap year if it is divisible by 4, unless it is also divisible by 100, in which case it is only a leap year if it is also divisible by 400."
},
"google": {
"generated_text": "```python\ndef is_leap_year(year):\n \"\"\"\n Determines whether a year is a leap year.\n\n Args:\n year: The year to check.\n\n Returns:\n True if the year is a leap year, False otherwise.\n \"\"\"\n\n # A year is a leap year if it is divisible by 4, unless it is divisible by 100\n # unless it is also divisible by 400.\n\n if year % 4 == 0:\n if year % 100 == 0:\n return year % 400 == 0\n else:\n return True\n else:\n return False\n```"
},
"nlpcloud": {
"generated_text": "def is_leap_year(year):\n if (year%4 == 0 and year%100 != 0) or (year%400 == 0):\n return True\n return False"
}
}
请求参数
Header 参数
content-type
string
必需
示例值:
application/json
Authorization
string
必需
默认值:
Bearer <your_key>
Body 参数application/json
返回响应
修改于 2024-04-11 06:07:42