Safe Haskell | Safe-Inferred |
---|---|
Language | Haskell2010 |
TypeChain.ChatModels.PromptTemplate
Documentation
class ToPrompt a where Source #
Typeclass used to convert generated record types into a list of messages.
Instances of this typeclass are generated by the makeTemplate
function and
should only be used if you need to construct a prompt manually.
makeTemplate :: String -> [Q PromptTemplate] -> Q [Dec] Source #
Given a typename and a list of messages, generate a data type and a function to construct it.
Example: `makeTemplate Translate [system "translate {a} to {b}.", user "{text}"]`
This generates a record named Translate
with fields a
, b
, and text
.
It also generates a function mkTranslate :: String -> String -> String -> [Message]
.
To allow for quick and easy construction of the prompt if needed. Otherwise, you can use the
generated data type in conjunction with the toPrompt
function to be more explicit.
See the example on the repo's README.md for an example of what the generated code looks like.
user :: String -> Q PromptTemplate Source #
Convert a String into a compile prompt template for the makeTemplate
function.
This particular function is for user messages.