...
Passing a memory and/or callbacks:#
To pass any of these, just declare them in the function (or use kwargs to pass anything)
@llm_prompt()
async def write_me_short_post(topic:str, platform:str="twitter", memory:SimpleMemory = None):
    """
    {history_key}
    Write me a short header for my post about {topic} for {platform} platform. 
    It should be for {audience} audience.
    (Max 15 words)
    """
    pass
await write_me_short_post(topic="old movies")
Simplified streaming#
If we wan’t to leverage streaming:
we need to define prompt as async function
turn on the streaming on the decorator, or we can define PromptType with streaming on
capture the stream using StreamingContext
This way we just mark which prompt should be streamed, not needing to tinker with what LLM should we use, passing around the creating and distribute streaming handler into particular part of our chain… just turn the streaming on/off on prompt/prompt type…
The streaming will happen only if we call it in streaming context … there we can define a simple function to handle the stream
# this code example is complete and should run as it is
from langchain_decorators import StreamingContext, llm_prompt
# this will mark the prompt for streaming (useful if we want stream just some prompts in our app... but don't want to pass distribute the callback handlers)
# note that only async functions can be streamed (will get an error if it's not)
@llm_prompt(capture_stream=True) 
async def write_me_short_post(topic:str, platform:str="twitter", audience:str = "developers"):
    """
    Write me a short header for my post about {topic} for {platform} platform.
rtdocs_stable/api.python.langchain.com/en/stable/integrations/langchain_decorators.html