Rm bedrock anthropic error (#11403)

This commit is contained in:
Bagatur 2023-10-04 23:31:51 -04:00 committed by GitHub
parent c9986bc3a9
commit 58b7a3ba16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 3 deletions

View File

@ -1,4 +1,5 @@
import json import json
import warnings
from abc import ABC from abc import ABC
from typing import Any, Dict, Iterator, List, Mapping, Optional from typing import Any, Dict, Iterator, List, Mapping, Optional
@ -42,12 +43,12 @@ def _human_assistant_format(input_text: str) -> str:
if count % 2 == 0: if count % 2 == 0:
count += 1 count += 1
else: else:
raise ValueError(ALTERNATION_ERROR + f" Received {input_text}") warnings.warn(ALTERNATION_ERROR + f" Received {input_text}")
if input_text[i : i + len(ASSISTANT_PROMPT)] == ASSISTANT_PROMPT: if input_text[i : i + len(ASSISTANT_PROMPT)] == ASSISTANT_PROMPT:
if count % 2 == 1: if count % 2 == 1:
count += 1 count += 1
else: else:
raise ValueError(ALTERNATION_ERROR + f" Received {input_text}") warnings.warn(ALTERNATION_ERROR + f" Received {input_text}")
if count % 2 == 1: # Only saw Human, no Assistant if count % 2 == 1: # Only saw Human, no Assistant
input_text = input_text + ASSISTANT_PROMPT # SILENT CORRECTION input_text = input_text + ASSISTANT_PROMPT # SILENT CORRECTION

View File

@ -245,7 +245,7 @@ Assistant:""",
def test__human_assistant_format() -> None: def test__human_assistant_format() -> None:
for input_text, expected_output in TEST_CASES.items(): for input_text, expected_output in TEST_CASES.items():
if expected_output == ALTERNATION_ERROR: if expected_output == ALTERNATION_ERROR:
with pytest.raises(ValueError): with pytest.warns(UserWarning, match=ALTERNATION_ERROR):
_human_assistant_format(input_text) _human_assistant_format(input_text)
else: else:
output = _human_assistant_format(input_text) output = _human_assistant_format(input_text)