国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

python代碼

2023-06-13 13:45 作者:岑今6666  | 我要投稿

#.env內(nèi)容為API_KEY=sk-寫(xiě)自己的

import openai

from dotenv import dotenv_values


class ChatBox:

? ? def __init__(self):

? ? ? ? config = dotenv_values(".env")

? ? ? ? openai.api_key = config["API_KEY"]

? ? ? ? self.model = "text-davinci-003"

? ? ? ? self.chat_history = []


? ? def add_chat(self, message):

? ? ? ? response = openai.Completion.create(

? ? ? ? ? ? model=self.model,

? ? ? ? ? ? prompt=message,

? ? ? ? ? ? max_tokens=200

? ? ? ? )

? ? ? ? answer = response.choices[0].text.strip()

? ? ? ? self.chat_history.append((message, answer))

? ? ? ? return answer


? ? def get_chat_history(self):

? ? ? ? return self.chat_history


? ? def clear_chat_history(self):

? ? ? ? self.chat_history = []

chatbox = ChatBox()


while True:

? ? user_input = input("User: ")

? ? if user_input.lower() == "exit":

? ? ? ? break

? ? answer = chatbox.add_chat(user_input)

? ? print("ChatGPT:", answer)


python代碼的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
包头市| 信宜市| 章丘市| 九龙县| 仪陇县| 通海县| 夹江县| 涟源市| 汉川市| 济源市| 潜山县| 蕉岭县| 滨州市| 临泉县| 武汉市| 苏州市| 黎川县| 南漳县| 泰安市| 瓦房店市| 海原县| 天等县| 磐安县| 永安市| 宿州市| 张家界市| 法库县| 棋牌| 梁山县| 广德县| 卓尼县| 庆元县| 延庆县| 义马市| 嘉义市| 镇平县| 凉山| 文山县| 灵武市| 彭山县| 洮南市|