Skip to content

Instantly share code, notes, and snippets.

@theRealNG
Created January 15, 2024 06:30
Show Gist options
  • Save theRealNG/f9be211985c0ad4fdcab20feec7d94de to your computer and use it in GitHub Desktop.
Save theRealNG/f9be211985c0ad4fdcab20feec7d94de to your computer and use it in GitHub Desktop.
Example using Length based example selector
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