add palm stream testing

This commit is contained in:
ishaan-jaff 2023-09-26 12:32:59 -07:00
parent d1692e89dd
commit 804bfee1a2

View file

@ -398,6 +398,35 @@ def test_completion_claude_stream():
# test_completion_claude_stream()
def test_completion_palm_stream():
try:
messages = [
{"role": "system", "content": "You are a helpful assistant."},
{
"role": "user",
"content": "how does a court case get to the Supreme Court?",
},
]
print("testing palm streaming")
response = completion(
model="palm/chat-bison", messages=messages, stream=True
)
complete_response = ""
# Add any assertions here to check the response
for idx, chunk in enumerate(response):
chunk, finished = streaming_format_tests(idx, chunk)
if finished:
break
complete_response += chunk
if complete_response.strip() == "":
raise Exception("Empty response received")
print(f"completion_response: {complete_response}")
except Exception as e:
pytest.fail(f"Error occurred: {e}")
# test_completion_palm_stream()
def test_completion_claude_stream_bad_key():
try:
api_key = "bad-key"