Rm bedrock anthropic error (#11403)

pull/11421/head
Bagatur 11 months ago committed by GitHub
parent c9986bc3a9
commit 58b7a3ba16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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

@ -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)

Loading…
Cancel
Save