-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
61 changed files
with
236 additions
and
55 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
index.html |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}/*! | ||
Theme: StackOverflow Light | ||
Description: Light theme as used on stackoverflow.com | ||
Author: stackoverflow.com | ||
Maintainer: @Hirse | ||
Website: https://github.com/StackExchange/Stacks | ||
License: MIT | ||
Updated: 2021-05-15 | ||
Updated for @stackoverflow/stacks v0.64.0 | ||
Code Blocks: /blob/v0.64.0/lib/css/components/_stacks-code-blocks.less | ||
Colors: /blob/v0.64.0/lib/css/exports/_stacks-constants-colors.less | ||
*/.hljs{color:#2f3337;background:#f6f6f6}.hljs-subst{color:#2f3337}.hljs-comment{color:#656e77}.hljs-keyword,.hljs-selector-tag,.hljs-meta .hljs-keyword,.hljs-doctag,.hljs-section,.hljs-attr{color:#015692}.hljs-attribute{color:#803378}.hljs-name,.hljs-type,.hljs-number,.hljs-selector-id,.hljs-quote,.hljs-template-tag{color:#b75501}.hljs-selector-class{color:#015692}.hljs-string,.hljs-regexp,.hljs-symbol,.hljs-variable,.hljs-template-variable,.hljs-link,.hljs-selector-attr{color:#54790d}.hljs-meta,.hljs-selector-pseudo{color:#015692}.hljs-built_in,.hljs-title,.hljs-literal{color:#b75501}.hljs-bullet,.hljs-code{color:#535a60}.hljs-meta .hljs-string{color:#54790d}.hljs-deletion{color:#c02d2e}.hljs-addition{color:#2f6f44}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.code-exec-btn svg{display:inline!important} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" href="/favicon.ico" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Doc</title> | ||
</head> | ||
|
||
<body> | ||
<div id="app" class="min-h-screen min-w-screen background"></div> | ||
<script type="module" src="/src/main.ts"></script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Install | ||
|
||
```bash | ||
npm i modprompt | ||
``` | ||
|
||
## Quickstart | ||
|
||
```ts | ||
import { templates, PromptTemplate } from "modprompt"; | ||
|
||
console.log("Available templates:", Object.keys(templates)); | ||
|
||
// load a template | ||
const tpl = new PromptTemplate("chatml"); | ||
|
||
// render the template | ||
console.log(tpl.render()); | ||
|
||
// render with a prompt | ||
const prompt = "List the planets of the solar system"; | ||
console.log(tpl.prompt(prompt)); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
# Usage | ||
|
||
## Initialization | ||
|
||
First, you need to create a new instance of `PromptTemplate`. You can do this by providing either the name of the template to load or an instance of `LmTemplate`. | ||
|
||
```typescript | ||
const tpl = new PromptTemplate('alpaca'); // Loads the 'alpaca' template | ||
``` | ||
|
||
## Cloning Templates | ||
|
||
You can clone an existing `PromptTemplate` instance to create a new one with the same settings. | ||
|
||
```typescript | ||
const clonedTpl = tpl.cloneTo('chatml'); // Clones the current template to the 'chatml' template | ||
``` | ||
|
||
## Converting to JSON | ||
|
||
You can convert the current `PromptTemplate` instance to a JSON object. | ||
|
||
```typescript | ||
const json = tpl.toJson(); | ||
console.log(json); | ||
``` | ||
|
||
## Manipulating System Blocks | ||
|
||
You can replace or append messages to the system block. | ||
|
||
```typescript | ||
tpl.replaceSystem('You are a javascript expert'); // Replaces the system block with a new message | ||
tpl.afterSystem('You are a javascript expert'); // Appends a message after the system block | ||
``` | ||
|
||
## Manipulating Prompt Blocks | ||
|
||
You can replace the `{prompt}` placeholder in the user message with a new message. | ||
|
||
```typescript | ||
tpl.replacePrompt(fix this invalid json:\n\n```json\n{prompt}\n```); | ||
``` | ||
|
||
## Adding Shots | ||
|
||
You can add new shots (user-assistant interactions) to the template. | ||
|
||
```typescript | ||
tpl.addShot('Is it raining?', 'No, it is sunny.'); // Adds a single shot | ||
``` | ||
|
||
You can also add multiple shots at once. | ||
|
||
```typescript | ||
tpl.addShots([ | ||
{ user: 'What is the weather like?', assistant: 'It is sunny today!' }, | ||
{ user: 'What is the weather like tomorrow?', assistant: 'I am sorry, but I can\'t predict the future.' } | ||
]); | ||
``` | ||
|
||
## Rendering Templates | ||
|
||
You can render the template into a string representation. | ||
|
||
```typescript | ||
const rendered = tpl.render(); | ||
console.log(rendered); | ||
``` | ||
|
||
You can also render the template with a specific message replacing the `{prompt}` placeholder. | ||
|
||
```typescript | ||
const prompted = tpl.prompt("list the planets in the solar system"); | ||
console.log(prompted); | ||
``` | ||
|
||
## Pushing to History | ||
|
||
You can push a turn into the history of the template. | ||
|
||
```typescript | ||
tpl.pushToHistory({ user: 'What is the weather like?', assistant: 'It is sunny today!' }); | ||
``` |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
{ | ||
"name": "doc", | ||
"children": [], | ||
"title": "Doc", | ||
"content": [ | ||
{ | ||
"name": "install", | ||
"title": "Install", | ||
"filename": "1.install.md", | ||
"url": "/install", | ||
"docpath": "/1.install.md", | ||
"type": "markdown" | ||
}, | ||
{ | ||
"name": "usage", | ||
"title": "Usage", | ||
"filename": "2.usage.md", | ||
"url": "/usage", | ||
"docpath": "/2.usage.md", | ||
"type": "markdown" | ||
}, | ||
{ | ||
"name": "templates", | ||
"title": "Templates", | ||
"filename": "3.templates.cmp", | ||
"url": "/templates", | ||
"docpath": "/3.templates.cmp", | ||
"type": "component" | ||
} | ||
], | ||
"docstrings": [], | ||
"url": "", | ||
"has_md_index": false, | ||
"docpath": "" | ||
} |
Binary file not shown.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.