Skip to content

Commit

Permalink
Fixes in docsite
Browse files Browse the repository at this point in the history
  • Loading branch information
synw committed Jan 16, 2025
1 parent 74040ee commit d05add0
Show file tree
Hide file tree
Showing 61 changed files with 236 additions and 55 deletions.
42 changes: 0 additions & 42 deletions docs/.github/workflows/static.yml

This file was deleted.

1 change: 1 addition & 0 deletions docs/404.html
1 change: 1 addition & 0 deletions docs/assets/_...all_-C3x79h6Y.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/assets/index-3CUBbFRZ.css

Large diffs are not rendered by default.

40 changes: 40 additions & 0 deletions docs/assets/index-Ch5I8FZ2.js

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions docs/assets/material-darker-B8DhjHfw.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions docs/assets/stackoverflow-light-BBYOBnBl.css
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}
9 changes: 9 additions & 0 deletions docs/assets/templates-C3s1MHtz.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions docs/assets/templates-DzkHlK4t.css
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.
5 changes: 3 additions & 2 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

<head>
<meta charset="UTF-8" />
<link rel="icon" href="/favicon.ico" />
<link rel="icon" href="/modprompt/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Doc</title>
<script type="module" crossorigin src="/modprompt/assets/index-Ch5I8FZ2.js"></script>
<link rel="stylesheet" crossorigin href="/modprompt/assets/index-3CUBbFRZ.css">
</head>

<body>
<div id="app" class="min-h-screen min-w-screen background"></div>
<script type="module" src="/src/main.ts"></script>
</body>

</html>
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.
10 changes: 0 additions & 10 deletions docs/components.d.ts → docsite/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,12 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
DefaultSidebar: typeof import('./src/components/sidebars/DefaultSidebar.vue')['default']
DispatchRoutePy: typeof import('./src/components/python/DispatchRoutePy.vue')['default']
'IEva:arrowBackOutline': typeof import('~icons/eva/arrow-back-outline')['default']
'IFa6Brands:github': typeof import('~icons/fa6-brands/github')['default']
'IFaBrands:github': typeof import('~icons/fa-brands/github')['default']
'IFaSolid:moon': typeof import('~icons/fa-solid/moon')['default']
'IFaSolid:sun': typeof import('~icons/fa-solid/sun')['default']
'INoto:crocodile': typeof import('~icons/noto/crocodile')['default']
'IPh:caretDownBold': typeof import('~icons/ph/caret-down-bold')['default']
'IPh:caretRightBold': typeof import('~icons/ph/caret-right-bold')['default']
PythonSidebar: typeof import('./src/components/sidebars/PythonSidebar.vue')['default']
RenderMd: typeof import('./src/components/markdown/RenderMd.vue')['default']
RenderMdPy: typeof import('./src/components/python/RenderMdPy.vue')['default']
RenderPyDocstring: typeof import('./src/components/python/RenderPyDocstring.vue')['default']
RouterLink: typeof import('vue-router')['RouterLink']
RouterView: typeof import('vue-router')['RouterView']
StaticPyCodeBlock: typeof import('./src/components/python/StaticPyCodeBlock.vue')['default']
TheHeader: typeof import('./src/components/TheHeader.vue')['default']
TheSidebar: typeof import('./src/components/TheSidebar.vue')['default']
}
Expand Down
16 changes: 16 additions & 0 deletions docsite/index.html
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>
3 changes: 2 additions & 1 deletion docs/package.json → docsite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"private": true,
"scripts": {
"dev": "vite",
"build_to_gh": "vite build && rm -rf ../docs/* && mv ./dist/* ../docs && cd ../docs && ln -s index.html 404.html",
"build": "vite build && cd ./dist && ln -s index.html 404.html",
"preview": "vite build && vite preview",
"wdoc": "node ./node_modules/@docdundee/docnav/bin/docnav.mjs",
Expand Down Expand Up @@ -44,4 +45,4 @@
"vite-plugin-pages": "^0.32.3"
},
"type": "module"
}
}
File renamed without changes.
23 changes: 23 additions & 0 deletions docsite/public/doc/1.install.md
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));
```
84 changes: 84 additions & 0 deletions docsite/public/doc/2.usage.md
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.
35 changes: 35 additions & 0 deletions docsite/public/doc/nav.json
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 added docsite/public/favicon.ico
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.

0 comments on commit d05add0

Please sign in to comment.