Use OpenAI by default make LiteLLM optional (#488)

This commit is contained in:
Farkhod Sadykov
2024-02-22 03:43:56 +01:00
committed by GitHub
parent 779749f304
commit 90f3f4c294
10 changed files with 87 additions and 48 deletions
+7 -7
View File
@@ -9,7 +9,7 @@ from .utils import app, cmd_args, comp_args, mock_comp, runner
role = SystemRole.get(DefaultRoles.CODE.value)
@patch("litellm.completion")
@patch("sgpt.handlers.handler.completion")
def test_code_generation(completion):
completion.return_value = mock_comp("print('Hello World')")
@@ -23,7 +23,7 @@ def test_code_generation(completion):
@patch("sgpt.printer.TextPrinter.live_print")
@patch("sgpt.printer.MarkdownPrinter.live_print")
@patch("litellm.completion")
@patch("sgpt.handlers.handler.completion")
def test_code_generation_no_markdown(completion, markdown_printer, text_printer):
completion.return_value = mock_comp("print('Hello World')")
@@ -36,7 +36,7 @@ def test_code_generation_no_markdown(completion, markdown_printer, text_printer)
text_printer.assert_called()
@patch("litellm.completion")
@patch("sgpt.handlers.handler.completion")
def test_code_generation_stdin(completion):
completion.return_value = mock_comp("# Hello\nprint('Hello')")
@@ -51,7 +51,7 @@ def test_code_generation_stdin(completion):
assert "print('Hello')" in result.stdout
@patch("litellm.completion")
@patch("sgpt.handlers.handler.completion")
def test_code_chat(completion):
completion.side_effect = [
mock_comp("print('hello')"),
@@ -92,7 +92,7 @@ def test_code_chat(completion):
# TODO: Code chat can be recalled without --code option.
@patch("litellm.completion")
@patch("sgpt.handlers.handler.completion")
def test_code_repl(completion):
completion.side_effect = [
mock_comp("print('hello')"),
@@ -124,7 +124,7 @@ def test_code_repl(completion):
assert "print('world')" in result.stdout
@patch("litellm.completion")
@patch("sgpt.handlers.handler.completion")
def test_code_and_shell(completion):
args = {"--code": True, "--shell": True}
result = runner.invoke(app, cmd_args(**args))
@@ -134,7 +134,7 @@ def test_code_and_shell(completion):
assert "Error" in result.stdout
@patch("litellm.completion")
@patch("sgpt.handlers.handler.completion")
def test_code_and_describe_shell(completion):
args = {"--code": True, "--describe-shell": True}
result = runner.invoke(app, cmd_args(**args))