Chat completions Beta
Using the OpenAI Chat API, you can build your own applications with gpt-3.5-turbo and gpt-4 to do things like:
使用 OpenAI Chat API,您可以使用 gpt-3.5-turbo 和 gpt-4 构建自己的应用程序来执行以下操作:
- Draft an email or other piece of writing
起草电子邮件或其他书面文件 - Write Python code 编写 Python 代码
- Answer questions about a set of documents
回答有关一组文件的问题 - Create conversational agents 创建会话代理
- Give your software a natural language interface
为您的软件提供自然语言界面 - Tutor in a range of subjects
一系列科目的导师 - Translate languages 翻译语言
- Simulate characters for video games and much more
模拟视频游戏中的角色等等
This guide explains how to make an API call for chat-based language models and shares tips for getting good results. You can also experiment with the new chat format in the OpenAI Playground.
本指南解释了如何为基于聊天的语言模型进行 API 调用,并分享获得良好结果的技巧。您还可以在 OpenAI Playground 中试验新的聊天格式。
Introduction
Chat models take a series of messages as input, and return a model-generated message as output.
聊天模型将一系列消息作为输入,并返回模型生成的消息作为输出。
Although the chat format is designed to make multi-turn conversations easy, it’s just as useful for single-turn tasks without any conversations (such as those previously served by instruction following models like text-davinci-003).
尽管聊天格式旨在使多轮对话变得简单,但它对于没有任何对话的单轮任务同样有用(例如以前由指令遵循模型提供服务的任务,如 text-davinci-003 )。
An example API call looks as follows:
示例 API 调用如下所示:
# Note: you need to be using OpenAI Python v0.27.0 for the code below to work
import openai
openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "system", "content": "You are a helpful assistant."},
{
"role": "user", "content": "Who won the world series in 2020?"},
{
"role": "assistant", "content": "The Los Angeles Dodgers won the World Series in 2020."},
{
"role": "user", "content": "Where was it played?"<

本文介绍了如何使用OpenAI的ChatAPI,通过gpt-3.5-turbo和gpt-4来构建应用程序,执行如起草文档、编写代码、问答、创建会话代理等任务。API调用涉及消息参数,包括系统、用户和助手的角色,以及如何管理令牌和对话历史。此外,文章还提供了关于如何指导聊天模型和调整输出的建议。
最低0.47元/天 解锁文章
330

被折叠的 条评论
为什么被折叠?



