1
0

test_prompt_validation.py 716 B

123456789101112131415161718192021
  1. # imports for guided decoding tests
  2. import re
  3. import openai
  4. import pytest
  5. from ...utils import RemoteOpenAIServer
  6. @pytest.mark.asyncio
  7. async def test_empty_prompt():
  8. model_name = "gpt2"
  9. server_args = ["--enforce-eager"]
  10. with RemoteOpenAIServer(model_name, server_args) as remote_server:
  11. client = remote_server.get_async_client()
  12. with pytest.raises(openai.BadRequestError,
  13. match=re.compile('.+Prompt cannot be empty.+')):
  14. await client.completions.create(model=model_name,
  15. prompt="",
  16. max_tokens=5,
  17. temperature=0.0)