<svg xmlns="http://www.w3.org/2000/svg" style="display: none;"> <path stroke-linecap="round" d="M5,0 0,2.5 5,5z" id="raphael-marker-block" style="-webkit-tap-highlight-color: rgba(0, 0, 0, 0);"></path> </svg> <p>诸神缄默不语-个人CSDN博文目录</p>
讯享网
OpenAI platform:https://platform.openai.com/overview
关于怎么才能上ChatGPT、怎么才能获取API额度等等信息,建议直接见我的medium账号。
因为这不是能在内网发的内容。
本文不涉及相关网络问题。
我本来想靠问ChatGPT来做的,然后发现ChatGPT给我讲的代码也过时了……
这种时候果然还是得靠自己啊!
OpenAI官网上给的好多示例代码也是过期代码,是不是很无语,就是很无语
为什么不写GPT-4:因为我还在排队列表里,我还没排到API。
openai包安装方式:
需要注意的是,如果你用的是比较老的Python版本(如我的阿里云服务器自带3.6.8版本),那openai就会安装比较老的版本,然后可能下面有一些封装好的功能就没有……
这是正常现象,建议改用requests(下面同样给出代码示例)。
如何查看一句话算多少个token:https://platform.openai.com/tokenizer
ChatGPT使用BPE tokenizer tiktoken(官方GitHub项目:openai/tiktoken: tiktoken is a fast BPE tokeniser for use with OpenAI’s models.)
讯享网
在response中也能看到每次调用所使用的总token数,见下面第2节的任务代码示例。
如何查看账户还剩多少token的余额:https://platform.openai.com/account/usage
https://platform.openai.com/docs/guides/completion
使用官方提供的openai包:
输出:(之前还会有两个回车,我也不知道为什么会有这玩意啊)
一个responce的输出格式:
讯享网
使用requests:
的输出:
讯享网
(显然回答是错的,但这不重要)
https://platform.openai.com/docs/guides/chat
使用openai包:
使用requests包:
讯享网
输出是:
其实我想问的是ChatGPT的API,不知道它觉得是什么的……
2.2.1 function calling
https://platform.openai.com/docs/guides/gpt/function-calling
https://platform.openai.com/docs/guides/images
https://platform.openai.com/docs/guides/fine-tuning
建议有几百个示例。
https://platform.openai.com/docs/guides/embeddings/what-are-embeddings
https://platform.openai.com/docs/guides/speech-to-text
https://platform.openai.com/docs/guides/rate-limits/overview
- 解决方案:
指数退避:参考我撰写的博文Python3:在访问不可靠服务时的重试策略(持续更新ing…) - 批输入
https://platform.openai.com/docs/guides/error-codes/api-errors
- 你的尝试次数太多,超过了速率限制
- 整个网络上用这个模型的人太多了,把你的请求给卡掉了:
这个问题我查了一下,从1月开始就有人喷了:Status code 503: That model is currently overloaded with other requests - API - OpenAI Developer Forum
https://platform.openai.com/docs/guides/production-best-practices
https://platform.openai.com/docs/models
文本生成表现最好的就是Davinci (text-davinci-003),最便宜的是Ada (ada):

讯享网
但是推荐用GPT 3.5这个chat模型来实现文本补完,因为效果好(上面给出示例了)
https://platform.openai.com/docs/api-reference/introduction
- temperature越高,多样性越大
- 输入长度:对于大多数模型,单个 API 请求在提示和完成之间最多只能处理 4,096 个token。
- max_tokens
- python - ‘latin-1’ codec can’t encode characters - Stack Overflow
- Python/Json:Expecting property name enclosed in double quotes - Stack Overflow
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/209687.html