Llama-2-70b-chat
开发环境
http://dev-cn.your-api-server.com
开发环境
http://dev-cn.your-api-server.com
POST
https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/llama_2_70b
创建chat
返回说明
请求示例(多轮)
响应示例(多轮)
{
"id": "as-i4g16spxm8",
"object": "chat.completion",
"created": 1693291334,
"result": " Sure, here's the current weather conditions and forecast for Shanghai, China:\n\nCurrent Weather:\n\n* Temperature: 22°C (72°F)\n* Humidity: 62%\n* Wind Speed: 20 km/h (12 mph)\n* Conditions: Partly Cloudy\n\nForecast:\n\n* Today: Partly cloudy skies with a high of 25°C (77°F) and a low of 18°C (64°F).\n* Tomorrow: Intervals of clouds and sunshine with a high of 26°C (79°F) and a low of 19°C (66°F).\n* Weekend: Mostly sunny with a high of 28°C (82°F) on Saturday and 27°C (81°F) on Sunday.\n\nNote: These weather conditions are subject to change and are based on the current data available.\n\nI hope this helps! Let me know if you have any other questions.",
"is_truncated": false,
"need_clear_history": false,
"usage": {
"prompt_tokens": 182,
"completion_tokens": 141,
"total_tokens": 323
}
}
请求示例(流式)
响应示例(流式)
data: {"id":"as-b2wn45xp3d","object":"chat.completion","created":1693291403,"sentence_id":0,"is_end":false,"is_truncated":false,"result":" Certainly! Here are a few popular self-driving routes in China that you may find helpful:\\n\\n1. The Silk Road: This route runs from Xi\'an to Kashgar, passing through the ancient cities of the Silk Road. It\'s a long route, but it offers stunning scenery and a glimpse into China\'s rich ","need_clear_history":false,"usage":{"prompt_tokens":11,"completion_tokens":70,"total_tokens":81}}
data: {"id":"as-b2wn45xp3d","object":"chat.completion","created":1693291408,"sentence_id":1,"is_end":false,"is_truncated":false,"result":"history.\\n2. The Yellow Mountains: Located in eastern China, the Yellow Mountains (Huangshan) offer breathtaking views of granite peaks, pine forests, and scenic valleys. The area is also home to many ancient villages and cultural sites.\\n3. The Li River: This route runs from Guilin to Yangshuo, passing through some of China\'s ","need_clear_history":false,"usage":{"prompt_tokens":11,"completion_tokens":68,"total_tokens":149}}
data: {"id":"as-b2wn45xp3d","object":"chat.completion","created":1693291413,"sentence_id":2,"is_end":false,"is_truncated":false,"result":"most beautiful karst landscape. The scenery is stunning, with towering limestone cliffs, picturesque villages, and scenic river views.\\n4. The Tibetan Plateau: If you\'re looking for a more adventurous route, consider driving across the Tibetan Plateau. The route takes you through high-altitude mountains, vast grasslands, and picturesque villages. However, keep in ","need_clear_history":false,"usage":{"prompt_tokens":11,"completion_tokens":68,"total_tokens":217}}
data: {"id":"as-b2wn45xp3d","object":"chat.completion","created":1693291417,"sentence_id":3,"is_end":false,"is_truncated":false,"result":"mind that the roads can be rough, and the high altitude may pose some health risks.\\n5. The Coastal Route: This route runs along China\'s eastern coast, passing through major cities like Shanghai, Hangzhou, and Beijing. It offers a mix of urban and rural scenery, as well as many historical and ","need_clear_history":false,"usage":{"prompt_tokens":11,"completion_tokens":67,"total_tokens":284}}
data: {"id":"as-b2wn45xp3d","object":"chat.completion","created":1693291421,"sentence_id":4,"is_end":false,"is_truncated":false,"result":"cultural sites.\\n\\nThese are just a few examples of popular self-driving routes in China. Keep in mind that driving in China can be challenging, especially for foreigners who may not be familiar with local roads and driving customs. Be sure to research the route thoroughly, obtain the necessary permits and insurance, ","need_clear_history":false,"usage":{"prompt_tokens":11,"completion_tokens":67,"total_tokens":351}}
data: {"id":"as-b2wn45xp3d","object":"chat.completion","created":1693291422,"sentence_id":5,"is_end":true,"is_truncated":false,"result":"and drive defensively.","need_clear_history":false,"usage":{"prompt_tokens":11,"completion_tokens":3,"total_tokens":354}}
错误码
名称 | 描述 |
---|---|
error_code | 错误码 |
error_msg | 错误描述信息,帮助理解和解决发生的错误 |
{
"error_code": 110,
"error_msg": "Access token invalid or no longer valid"
}
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://aip.baidubce.com/rpc/2.0/ai_custom/v1/wenxinworkshop/chat/llama_2_70b?access_token =' \
--header 'Content-Type: application/json' \
--data-raw '{
"messages\t": [
{
"role\t": "string",
"content": "string"
}
],
"stream": true,
"temperature\t": 0,
"top_k\t": 0,
"top_p\t": 0,
"penalty_score": 0,
"stop\t": [
"string"
],
"user_id": "string"
}'
响应示例响应示例
{
"id": "string",
"object": "string",
"created": 0,
"result": "string",
"is_truncated": true,
"need_clear_history": true,
"usage": {
"prompt_tokens": 0,
"completion_tokens": 0,
"total_tokens": 0
}
}
请求参数
Query 参数
access_token
string
必需
Body 参数application/json