admin 管理员组文章数量: 887031
到ChatGPT官网 登录
保存这个key
然后去google搜索colab
pip install openai
import openai
API_KEY = '你的OpenAIkey'
openai.api_key = API_KEY
model_id = 'gpt-3.5-turbo'
def ChatGPT_conversation(conversation):
response = openai.ChatCompletion.create(
model=model_id,
messages=conversation
)
# api_usage = response['usage']
# print('Total token consumed: {0}'.format(api_usage['total_tokens']))
# stop means complete
# print(response['choices'][0].finish_reason)
# print(response['choices'][0].index)
conversation.append({'role': response.choices[0].message.role, 'content': response.choices[0].message.content})
return conversation
conversation = []
conversation.append({'role': 'system', 'content': 'How may I help you?'})
conversation = ChatGPT_conversation(conversation)
print('{0}: {1}\n'.format(conversation[-1]['role'].strip(), conversation[-1]['content'].strip()))
while True:
prompt = input('User:')
conversation.append({'role': 'user', 'content': prompt})
conversation = ChatGPT_conversation(conversation)
print('{0}: {1}\n'.format(conversation[-1]['role'].strip(), conversation[-1]['content'].strip()))
直接使用chatBox
gitHub-chatBox
版权声明:本文标题:chatGPT-如何解决拒绝访问的问题 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.freenas.com.cn/jishu/1724991894h846038.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论