diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000000000000000000000000000000000000..94a25f7f4cb416c083d265558da75d457237d671 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/chat_bot_opencat.py b/chat_bot_opencat.py new file mode 100644 index 0000000000000000000000000000000000000000..d39ca62fd5a389ff5b105fee8253ab2126c4299d --- /dev/null +++ b/chat_bot_opencat.py @@ -0,0 +1,22 @@ +import os +from langchain.chat_models import ChatOpenAI +from langchain.schema import ( + AIMessage, + HumanMessage, + SystemMessage +) + +os.environ["OPENAI_API_KEY"] = '70846324f01c4e5cb3cc11da28a1e091' +os.environ["OPENAI_API_BASE"] = 'https://opencatgpt.openai.azure.com/' +os.environ["OPENAI_API_TYPE"] = 'azure' +os.environ["OPENAI_API_VERSION"] = '2023-05-15' + +chat = ChatOpenAI(model_name="gpt-35-turbo", engine="gpt-35-turbo") + +history = [SystemMessage(content="你是一个聊天机器人,请回答下列问题。\n")] +while True: + question = input("请输入问题:\n") + history.append(HumanMessage(content=question)) + res = chat(history) + print(res.content) + history.append(res)