From 475144e5b7f81fd06fcef95c9f4189f4cedadf5b Mon Sep 17 00:00:00 2001 From: Krrish Dholakia Date: Wed, 3 Apr 2024 15:23:01 -0700 Subject: [PATCH] fix(openai.py): support passing prompt as list instead of concat string --- litellm/llms/openai.py | 2 +- litellm/tests/test_text_completion.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/litellm/llms/openai.py b/litellm/llms/openai.py index 93f4c2d95..2065a724b 100644 --- a/litellm/llms/openai.py +++ b/litellm/llms/openai.py @@ -1033,7 +1033,7 @@ class OpenAITextCompletion(BaseLLM): ): prompt = messages[0]["content"] else: - prompt = " ".join([message["content"] for message in messages]) # type: ignore + prompt = [message["content"] for message in messages] # type: ignore # don't send max retries to the api, if set diff --git a/litellm/tests/test_text_completion.py b/litellm/tests/test_text_completion.py index 84e3bb5de..0b4103ca0 100644 --- a/litellm/tests/test_text_completion.py +++ b/litellm/tests/test_text_completion.py @@ -3775,12 +3775,12 @@ def test_completion_openai_prompt(): try: print("\n text 003 test\n") response = text_completion( - model="gpt-3.5-turbo-instruct", prompt="What's the weather in SF?" + model="gpt-3.5-turbo-instruct", + prompt=["What's the weather in SF?", "How is Manchester?"], ) print(response) + assert len(response.choices) == 2 response_str = response["choices"][0]["text"] - # print(response.choices[0]) - # print(response.choices[0].text) except Exception as e: pytest.fail(f"Error occurred: {e}")