访问 OpenAI 网站并获取您的 OpenAI API 密钥。现在安装 OpenAI
库并导入它。
1
pip install openai
1 2
import openai openai.api_key = <Your_API_Key>
步骤
3:将 bard 请求结果连接到 gpt-3.5-turbo 模型并设计提示
这里的关键部分是设计将 Bard 结果集成到 ChatGPT API
函数中所需的提示。因此,我为此制定了一个方法:
1 2 3 4 5 6 7 8 9 10 11 12
query = input("Your query") bard_result = bard.get_answer(query)['content'] completion = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ {"role": "system", "content": "Act as an AI chatbot with access to the internet."}, {"role": "user", "content": "Provide a well structured and easily readable text by analyzing this: The first content below is the user's query and the second content below is the result obtained by accessing the internet with the help of google's search alogoritm. Provide the well structured and good mannered answer by processing the user's query and the result from Google search algorithm. /n"+query+' /n '+ bard_result}
from bardapi import Bard import openai openai.api_key = <Your Key> token = <Your Key> bard = Bard(token=token) query = input("Your query: ") bard_result = bard.get_answer(query)['content'] completion = openai.ChatCompletion.create( model="gpt-3.5-turbo", messages=[ {"role": "system", "content": "Act as an AI chatbot with access to the internet."}, {"role": "user", "content": "Provide a well structured and easily readable text by analyzing this: The first content below is the user's query and the second content below is the result obtained by accessing the internet with the help of google's search alogoritm. Provide the well structured and good mannered answer by processing the user's query and the result from Google search algorithm. /n"+query+' /n '+ bard_result}