Created
January 15, 2024 06:30
-
-
Save theRealNG/f9be211985c0ad4fdcab20feec7d94de to your computer and use it in GitHub Desktop.
Example using Length based example selector
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from langchain.prompts.example_selector import LengthBasedExampleSelector | |
example_selector = LengthBasedExampleSelector( | |
examples=examples, | |
example_prompt=example_prompt, | |
max_length=50 # this sets the max length that examples should be | |
) | |
dynamic_prompt_template = FewShotPromptTemplate( | |
example_selector=example_selector, # use example_selector instead of examples | |
example_prompt=example_prompt, | |
prefix=prefix, | |
suffix=suffix, | |
input_variables=["query"], | |
example_separator="\n" | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment