# This gives this field an id    # When configuring the end runnable, we can then use this id to configure this field    ConfigurableField(id="prompt"),    # This sets a default_key.    # If we specify this key, the default LLM (ChatAnthropic initialized above) will be used    default_key="joke",    # This adds a new option, with name `poem`    poem=PromptTemplate.from_template("Write a short poem about {topic}"),    # You can add more configuration options here)chain = prompt | llm# By default it will write a jokechain.invoke({"topic": "bears"})    AIMessage(content=" Here's a silly joke about bears:\n\nWhat do you call a bear with no teeth?\nA gummy bear!")# We can configure it write a poemchain.with_config(configurable={"prompt": "poem"}).invoke({"topic": "bears"})    AIMessage(content=' Here is a short poem about bears:\n\nThe bears awaken from their sleep\nAnd lumber out into the deep\nForests filled with trees so tall\nForaging for food before nightfall \nTheir furry coats and claws so sharp\nSniffing for berries and fish to nab\nLumbering about without a care\nThe mighty grizzly and black bear\nProud creatures, wild and free\nRuling their domain majestically\nWandering the woods they call their own\nBefore returning to their dens alone')With Prompts and LLMs‚ÄãWe can also have multiple things configurable!
Oftentimes you may want to experiment with, or even expose to the end user, multiple different ways of doing things.
Oftentimes you may want to experiment with, or even expose to the end user, multiple different ways of doing things. ->: # This gives this field an id    # When configuring the end runnable, we can then use this id to configure this field    ConfigurableField(id="prompt"),    # This sets a default_key.    # If we specify this key, the default LLM (ChatAnthropic initialized above) will be used    default_key="joke",    # This adds a new option, with name `poem`    poem=PromptTemplate.from_template("Write a short poem about {topic}"),    # You can add more configuration options here)chain = prompt | llm# By default it will write a jokechain.invoke({"topic": "bears"})    AIMessage(content=" Here's a silly joke about bears:\n\nWhat do you call a bear with no teeth?\nA gummy bear!")# We can configure it write a poemchain.with_config(configurable={"prompt": "poem"}).invoke({"topic": "bears"})    AIMessage(content=' Here is a short poem about bears:\n\nThe bears awaken from their sleep\nAnd lumber out into the deep\nForests filled with trees so tall\nForaging for food before nightfall \nTheir furry coats and claws so sharp\nSniffing for berries and fish to nab\nLumbering about without a care\nThe mighty grizzly and black bear\nProud creatures, wild and free\nRuling their domain majestically\nWandering the woods they call their own\nBefore returning to their dens alone')With Prompts and LLMs‚ÄãWe can also have multiple things configurable!