0.0.2 • Published 2 years ago

@quentinlintz/chatml v0.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

ChatML

ChatML (Chat Markup Language) is a package that prevents prompt injection attacks by prepending your prompts with a conversation.

Installation

pnpm add @quentinlintz/chatml
npm i @quentinlintz/chatml
yarn add @quentinlintz/chatml

Setup

The .chatml.yaml file must be at the root of your project and formatted correctly. Here is an example of correct formatting:

messages:
  - role: system
    content: You are a helpful assistant.
  - role: user
    content: Who won the world series in 2020?
  - role: assistant
    content: The Los Angeles Dodgers won the World Series in 2020.

The configuration file must contain a messages array, which is a list of messages that will be prepended to your prompt. Each message must have a role property, which can be one of system, user, or assistant, and a content property, which is the message text.

Usage

Import the prepend function and assign it to the messages parameter in your payload to warmup the model.

import { prepend } from "@quentinlintz/chatml";

const completion = await openai.createChatCompletion({
  model: "gpt-3.5-turbo",
  messages: prepend("What kind of drinks do you have?"),
});

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Please make sure to update tests as appropriate.

License

MIT

0.0.2

2 years ago

0.0.1

2 years ago