From 346c3fcb41ac768f75d9dd3738cd39bd32ba5a3d Mon Sep 17 00:00:00 2001 From: Krish Dholakia Date: Tue, 8 Aug 2023 11:05:10 -0700 Subject: [PATCH 1/2] adding support for claude, azure, llama2 and cohere --- terminalgpt/chat_utils.py | 2 +- terminalgpt/conversations.py | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/terminalgpt/chat_utils.py b/terminalgpt/chat_utils.py index 0d23c64..cbab6ec 100644 --- a/terminalgpt/chat_utils.py +++ b/terminalgpt/chat_utils.py @@ -106,7 +106,7 @@ def get_user_answer(messages, model): color="blue", side="right", ): - answer = openai.ChatCompletion.create(model=model, messages=messages) + answer = completion(model=model, messages=messages) return answer except openai.InvalidRequestError as error: if "Please reduce the length of the messages" in str(error): diff --git a/terminalgpt/conversations.py b/terminalgpt/conversations.py index db4d99f..c358696 100644 --- a/terminalgpt/conversations.py +++ b/terminalgpt/conversations.py @@ -5,6 +5,8 @@ import time import openai +import litellm +from litellm import completion from colorama import Back, Style from terminalgpt import config, print_utils @@ -79,7 +81,7 @@ def get_system_answer(messages): while True: try: - answer = openai.ChatCompletion.create( + answer = completion( model=config.DEFAULT_MODEL, messages=messages ) return answer From 97ef9470611e0bed94b41108253d23ac2f141bb2 Mon Sep 17 00:00:00 2001 From: Krish Dholakia Date: Tue, 8 Aug 2023 11:08:07 -0700 Subject: [PATCH 2/2] fixes --- terminalgpt/chat_utils.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/terminalgpt/chat_utils.py b/terminalgpt/chat_utils.py index cbab6ec..0c4d59e 100644 --- a/terminalgpt/chat_utils.py +++ b/terminalgpt/chat_utils.py @@ -3,7 +3,8 @@ import os import sys import time - +import litellm +from litellm import completion import openai import tiktoken from colorama import Back, Fore, Style