Overview

Docs

Getting Started

How to get started with Keymaker.

Models in Keymaker

Various Keymaker models.

Streaming and Decoding

Streaming Completions and Custom Decoding Parameters In this section, we will explore the usage of streaming completions and custom decoding parameters in Keymaker. Streaming Completions Keymaker allows you to access completion generation as it happens by passing an asynchronous function to the complete method. This can be useful for situations where you want to display the generated text in real-time, such as in a chat application. Here’s an example of streaming completions:

Accessing Completions and Working with Chat Models

Accessing Completions and Working with Chat Models In this section, we will explore how to access completions and work with chat models in Keymaker. Accessing Completions When you generate completions with Keymaker, you can access them through the completions attribute of a Prompt object. Here’s an example of how to access both named and unnamed completions: from keymaker import Prompt from keymaker.models import chatgpt from keymaker.constraints import RegexConstraint # Initialize the model chat_model = chatgpt() # Create a prompt prompt = Prompt("The weather is ") # Generate an unnamed completion constraint1 = RegexConstraint(pattern=r"sunny|rainy|cloudy") prompt = await prompt.

Advanced Usage and Customization

Advanced Usage and Customization In this section, we will explore more advanced usage of Keymaker, including working with multiple models, custom constraints, and custom models. Working with Multiple Models Keymaker allows you to use multiple models in a single prompt. You can switch between models when generating completions to take advantage of their specific capabilities. Here’s an example of using both a chat model and a custom model: from keymaker import Prompt from keymaker.

Contributing

Keymaker is an open source project and there is lots of room and tons of ways to contribute. Contributing Code Currently the project does not have a rigid set of contribution rules but here are some tips. The CI that runs for PRs uses the commands make lint and make test. Once those are passing locally, PR checks should also pass. If you want early feedback on a branch before it’s ready, it can be useful to open a PR as a draft and link to it in an open issue.

Formatting and Control FLow

Advanced Prompt Formatting and Control Flow In this section, we will explore advanced prompt formatting and plain control flow with Keymaker. Advanced Prompt Formatting Keymaker provides powerful and flexible ways to format prompts. You can use the .format() method to generate completions based on the order of arguments, named arguments, or even dynamic arguments using callables and generators. Here’s an example: from keymaker import Prompt, Completion, CompletionConfig from keymaker.models import chatgpt from keymaker.

Using Constraints

Using Constraints Keymaker provides several out-of-the-box constraints that can be applied when completing prompts. Keymaker is also designed to make it as simple as possible for you to Add Your Own Constraint Let’s go through some of the built-in constraint types and how to use them. RegexConstraint RegexConstraint allows you to constrain the generated text based on a regex pattern. from keymaker.constraints import RegexConstraint constraint = RegexConstraint( pattern=r"I (would|could) eat [0-9]{1,2} (burgers|burger)\.