Using Prompts
- Establish a function decorated with
@promptwith the inference model you want to use. - Call the function as you normally would and receive structured data back.
Generator with get_generator("claude-3-5-sonnet-latest"), prepare a small template that will establish the required context and output structure, pass it into a new ChatPipeline, run the generation process, and parse the output into our structured list with ChatPipeline.then().
If you want to see the resulting Chat object, you can set that as your return value and no output parsing
tuple and include both your structured data and the Chat object.
Chat object as the second element.
You can learn more about the @prompt decorator in the Prompt Functions section.
Using Pipelines
- Get a
Generatorobject - usually withget_generator(). - Call
generator.chat()to produce aChatPipelineand ready it for generation. - Call
pipeline.run()to kick off generation and get your finalChatobject.
ChatPipeline objects hold any messages waiting to be delivered to an LLM in exchange for a new response message. These objects are also where most of the power in rigging comes from. You’ll build a generation pipeline with options, parsing, callbacks, etc. After preparation, this pipeline is used to make a final Chat which holds all messages prior to generation (.prev) and after generation (.next).
You should think of ChatPipeline objects like the configurable pre-generation step with calls like .with_(), .apply(), .until(), .using(), etc. Once you call one of the many .run()functions, the generator is used to produce the next message (or many messages) based on the prior context and any constraints you have in place. Once you have a Chat object, the interaction is complete and you can inspect and operate on the messages.
We often use functional styling chaining as most of our utility functions return the object back to you.
ChatPipeline object in the Pipelines section.
