mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-13 16:36:06 +00:00
Rm bedrock anthropic error (#11403)
This commit is contained in:
parent
c9986bc3a9
commit
58b7a3ba16
@ -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…
Reference in New Issue
Block a user