五月天青色头像情侣网名,国产亚洲av片在线观看18女人,黑人巨茎大战俄罗斯美女,扒下她的小内裤打屁股

歡迎光臨散文網(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ó)家法律
重庆市| 昌都县| 博白县| 县级市| 桦川县| 文成县| 宁波市| 宽甸| 西平县| 阆中市| 灵石县| 金山区| 中阳县| 凌源市| 醴陵市| 竹山县| 阳西县| 成都市| 墨玉县| 静乐县| 射阳县| 五台县| 辉县市| 卫辉市| 遵义市| 息烽县| 湖北省| 五大连池市| 满洲里市| 海城市| 丰宁| 五华县| 大埔县| 射阳县| 三门峡市| 郧西县| 胶州市| 财经| 明溪县| 罗江县| 信丰县|