mirror of
https://github.com/hwchase17/langchain.git
synced 2025-08-31 18:38:48 +00:00
Add add_example method to all ExampleSelector classes, with tests (#178)
Also updated docs, and noticed an issue with the add_texts method on VectorStores that I had missed before -- the metadatas arg should be required to match the classmethod which initializes the VectorStores (the add_example methods break otherwise in the ExampleSelectors)
This commit is contained in:
committed by
GitHub
parent
780ef84cf0
commit
09f301cd38
@@ -29,6 +29,15 @@ def test_dynamic_prompt_valid(selector: LengthBasedExampleSelector) -> None:
|
||||
assert output == EXAMPLES
|
||||
|
||||
|
||||
def test_dynamic_prompt_add_example(selector: LengthBasedExampleSelector) -> None:
|
||||
"""Test dynamic prompt can add an example."""
|
||||
new_example = {"question": "Question: what are you?\nAnswer: bar"}
|
||||
selector.add_example(new_example)
|
||||
short_question = "Short question?"
|
||||
output = selector.select_examples({"question": short_question})
|
||||
assert output == EXAMPLES + [new_example]
|
||||
|
||||
|
||||
def test_dynamic_prompt_trims_one_example(selector: LengthBasedExampleSelector) -> None:
|
||||
"""Test dynamic prompt can trim one example."""
|
||||
long_question = """I am writing a really long question,
|
||||
|
Reference in New Issue
Block a user