From 199e43f214529eb9b1d354f60768b4ef07064b06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Muris=20Sladi=C4=87?= <72603967+msladic1@users.noreply.github.com> Date: Tue, 19 Dec 2023 11:39:12 +0100 Subject: [PATCH] Updating code to work with openai -v >= 1.0 --- LinuxSSHbot.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/LinuxSSHbot.py b/LinuxSSHbot.py index accff22..971a25e 100644 --- a/LinuxSSHbot.py +++ b/LinuxSSHbot.py @@ -50,14 +50,15 @@ def main(): logs = open("history.txt", "a+", encoding="utf-8") try: - res = openai.ChatCompletion.create( + res = openai.chat.completions.create( model="gpt-3.5-turbo-16k", messages = messages, temperature = 0.0, max_tokens = 800 ) - message = res["choices"][0]["message"].to_dict() + msg = res.choices[0].message.content + message = {"content": msg, "role": 'assistant'} if "$cd" in message["content"] or "$ cd" in message["content"]: message["content"] = message["content"].split("\n")[1]