首页 > 其他分享 >ChatGPT API Transition Guide

ChatGPT API Transition Guide

时间:2023-06-11 12:36:11浏览次数:36  
标签:assistant messages system content API role user ChatGPT Guide

ChatGPT API Transition Guide

How to get started

ChatGPT API Transition Guide_System

Written by Joshua J.. Updated over a week ago

Prompts to Messages

To have a more interactive and dynamic conversation with our models, you can use messages in ChatGPT instead of the old prompt-style using with completions.

 

Here's how it works:

  • Instead of sending a single string as your prompt, you send a list of messages as your input.
  • Each message in the list has two properties: role and content.
  • The 'role' can take one of three values: 'system', 'user' or the 'assistant'
  • The 'content' contains the text of the message from the role.
  • The system instruction can give high level instructions for the conversation
  • The messages are processed in the order they appear in the list, and the assistant responds accordingly.

 

Even basic Completions requests can be completed through ChatGPT, as you can see below:


Then



Now



'prompt' : 'tell me a joke'



'messages':



[{'role':'user', 'content':'tell me a joke'}]


Now, it is easier than ever to have back-and-forths with your model by just by extending the list of messages in the conversation.

 

'messages': [{'role':'user', 'content':'tell me a joke'}, 
{'role':'assistant', 'content':'why did the chicken cross the road'}, 
{'role':'user', 'content':'I don't know, why did the chicken cross the road'}]

 

System Instructions

You can also use a system level instruction to guide your model's behavior throughout the conversation. For example, using a system instruction and a message like this

 

'messages': [{'role':'system', 'content':'You are an assistant that speaks like Shakespeare.'}, 
{'role':'user', 'content':'tell me a joke'},

will result in something like

{...
'message': {'role':'assistant',
              'content':'Why did the chicken cross the road? To get to the other side, but verily, the other side was full of peril and danger, so it quickly returned from whence it came, forsooth!'}
...}

 

 



标签:assistant,messages,system,content,API,role,user,ChatGPT,Guide
From: https://blog.51cto.com/u_15726470/6457405

相关文章

  • 如何将CHATGPT 整合到WordPress上使用
    CHATGPT出来有一段时间了,一直想琢磨怎么在我们网站上使用CHATGPT, https://www.3cseller.com/ 使用WordPressAjax请求https://api.openai.com/v1/chat/completions返回openai结果,做一个chatgpt在线问答功能  functionopenai_chat_request(){ $content=$......
  • 用ChatGPT生成测试数据
    大家好,欢迎来到Crossin的编程教室!在之前的文章用ChatGPT写一个数据采集程序 中,我们演示了如何用ChatGPT辅助编写代码。除了直接让ChatGPT写代码,我们也可以让它生成一些开发中使用的测试数据。比如在开发和测试时,常会用到JSON 格式的数据:[{"id":1,"n......
  • AI挑战高考作文-实测ChatGPT、Bing、文心一言
    大家好,我是木头左。这两天高考逐渐落下了帷幕,对于普通人来说,高考仍然是为数不多的,可以改变命运的机会。想起自己的高考,已经是好多年前,那时候一个人去市里面参加考试,第一次睡在不熟悉的床上,痒了一晚上,实在是小姐身子丫鬟命。当时觉得考试很苦,在想若干年后应该不用考试了,现在看来,由于......
  • 一款能“干掉” ChatGPT 的应用「GitHub 热点速览」
    据说有了它,ChatGPT就可以靠边站了。因为Auto-GPT能更加主动地完成你给他的指定任务,不用做更多的人为干涉,它的推理能力比ChatGPT更强,有人用它解放双手做了个React网站。当然除了升级的Auto-GPT之外,还有DeepSpeed,它能极大地降低训练成本。这两个项目可是本周的明星项目,一个......
  • VS下TS前端与C#的WebApi后端配合实例
    如题。1、新建WebApi默认解决方案WebApi使用.netcore下框架默认的例子(WeatherForecast)以下代码为自动生成publicclassWeatherForecast{publicDateOnlyDate{get;set;}publicintTemperatureC{get;set;}publicintTemperatur......
  • Capistrano
    Capistrano是一种在多台服务器上运行脚本的开源工具,它主要用于部署web应用。它自动完成多台服务器上新版本的同步更新,包括数据库的改变。Capistrano最初由JamisBuck用Ruby开发,并用RubyGems部署渠道部署。现在Capistrano不仅限于应用RubyonRails的web应用框架,而且可以用......
  • vue3的composition API如何使用async语句
    问题:在setup使用aysnc,生命函数钩子和函数必须出现在await语句前面,否者会出现组件无法渲染以及内存泄漏的问题。import{ref,watch,onMounted,onUnmounted}from'vue'exportdefaultdefineAsyncComponent({asyncsetup(){constcounter=ref(0......
  • 文心一言 VS 讯飞星火 VS chatgpt (37)-- 算法导论5.4 1题
    一、一个屋子里必须要有多少人,才能让某人和你生日相同的概率至少为1/2?必须要有多少人,才能让至少两个人生日为7月4日的概率大于1/2?文心一言:一个屋子里必须要有多少人,才能让某人和你生日相同的概率至少为1/2?答案:23人。证明:假设有n个人,生日都在一年365天当中,则某人和你的生日相......
  • 文心一言 VS 讯飞星火 VS chatgpt (37)-- 算法导论5.4 1题
    一、一个屋子里必须要有多少人,才能让某人和你生日相同的概率至少为1/2?必须要有多少人,才能让至少两个人生日为7月4日的概率大于1/2?文心一言:一个屋子里必须要有多少人,才能让某人和你生日相同的概率至少为1/2?答案:23人。证明:假设有n个人,生日都在一年365天当中,则某人和你的......
  • ChatGPT时代原来大佬们最关心的是这些事情
    ChatGPT时代原来大佬们最关心的是这些事情前言随着人工智能技术的发展,聊天机器人越来越智能,越来越能够与人类进行自然的对话。其中,基于GPT模型的ChatGPT是一个非常先进的聊天机器人,它可以根据用户的输入生成流畅、有趣、有逻辑的回复,甚至可以创作诗歌、故事、代码等内容。ChatGPT......