本文主要是介绍Python调用GPT4,GPT3.5,gpt-4-all(全功能模型),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
使用地址:openai-api
调用3.5代码
# coding=gbk
import openai
openai.api_base = 'https://api.chuanchuan.cloud/v1'
openai.api_key = 'sk-8fNMAI5HqltUroio74A1D72dB2524487B2D59f675940Bd39'messages = [{"role": "user", "content": "你好,你是什么模型?"}
]res = openai.ChatCompletion.create(model="gpt-3.5-turbo-16k",messages=messages,stream=False,
)print(res['choices'][0]['message']['content'])
回答如下:
调用4代码
只需要修改model即可:
# coding=gbk
import openai
openai.api_base = 'https://api.chuanchuan.cloud/v1'
openai.api_key = 'sk-8fNMAI5HqltUroio74A1D72dB2524487B2D59f675940Bd39'messages = [{"role": "user", "content": "你好,你是什么模型?"}
]res = openai.ChatCompletion.create(model="gpt-4",messages=messages,stream=False,
)print(res['choices'][0]['message']['content'])
如下所示:
gpt-4-all(文件分析,绘图,联网)
# coding=gbk
import openai
openai.api_base = 'https://api.chuanchuan.cloud/v1'
openai.api_key = 'sk-8fNMAI5HqltUroio74A1D72dB2524487B2D59f675940Bd39'messages = [{"role": "user", "content": "画一只猫"}
]res = openai.ChatCompletion.create(model="gpt-4-all",messages=messages,stream=False,
)print(res['choices'][0]['message']['content'])
如下所示:
这篇关于Python调用GPT4,GPT3.5,gpt-4-all(全功能模型)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!