mirror of
https://github.com/BerriAI/litellm.git
synced 2026-11-16 09:22:22 +00:00
feat: make guide an editable markdown document
This commit is contained in:
parent
6da7ef2fe4
commit
4ba4e607ab
5 changed files with 172 additions and 86 deletions
|
|
@ -22,34 +22,12 @@
|
|||
</header>
|
||||
|
||||
<section class="workspace">
|
||||
<aside class="docs">
|
||||
<p class="section-label">GUIDE.md</p>
|
||||
<h2>Prove the connection</h2>
|
||||
<p>
|
||||
Cmd-click <code>build_proof</code> in <code>main.rs</code>. The editor opens its
|
||||
definition in <code>proof.rs</code>. Hover <code>litellm_core::Error</code> for
|
||||
dependency type information
|
||||
</p>
|
||||
<h3>What this uses</h3>
|
||||
<dl>
|
||||
<div>
|
||||
<dt>Editor</dt>
|
||||
<dd>CodeMirror 6</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Language server</dt>
|
||||
<dd>rust-analyzer over WebSocket</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Dependency</dt>
|
||||
<dd>In-repo litellm-core path dependency</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt>Proc macro</dt>
|
||||
<dd>Serde Serialize and Deserialize derives</dd>
|
||||
</div>
|
||||
</dl>
|
||||
<p class="hint">The source is saved in this browser. Reset restores the checked-in example</p>
|
||||
<aside class="docs" aria-label="Markdown document">
|
||||
<div class="docbar">
|
||||
<span>GUIDE.md</span>
|
||||
<span class="document-language">Markdown</span>
|
||||
</div>
|
||||
<div id="markdown-editor"></div>
|
||||
</aside>
|
||||
|
||||
<section class="editor-panel" aria-label="Rust editor">
|
||||
|
|
|
|||
104
playground/package-lock.json
generated
104
playground/package-lock.json
generated
|
|
@ -6,6 +6,7 @@
|
|||
"": {
|
||||
"name": "litellm-rust-playground-proof",
|
||||
"dependencies": {
|
||||
"@codemirror/lang-markdown": "^6.5.2",
|
||||
"@codemirror/lang-rust": "^6.0.2",
|
||||
"@codemirror/lsp-client": "^6.2.5",
|
||||
"@codemirror/theme-one-dark": "^6.1.3",
|
||||
|
|
@ -41,6 +42,66 @@
|
|||
"@lezer/common": "^1.1.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lang-css": {
|
||||
"version": "6.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-css/-/lang-css-6.3.1.tgz",
|
||||
"integrity": "sha512-kr5fwBGiGtmz6l0LSJIbno9QrifNMUusivHbnA1H6Dmqy4HZFte3UAICix1VuKo0lMPKQr2rqB+0BkKi/S3Ejg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.0.0",
|
||||
"@codemirror/language": "^6.0.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@lezer/common": "^1.0.2",
|
||||
"@lezer/css": "^1.1.7"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lang-html": {
|
||||
"version": "6.4.12",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-html/-/lang-html-6.4.12.tgz",
|
||||
"integrity": "sha512-pw2ReWKUqSkbvh76RAT4NYxiogRu+PWkR2ukAwO9uOgrm8uipkzjtKKtNpyeAQwHOqxEeSvAXZ6vr3AfyB9y/w==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.0.0",
|
||||
"@codemirror/lang-css": "^6.0.0",
|
||||
"@codemirror/lang-javascript": "^6.0.0",
|
||||
"@codemirror/language": "^6.4.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.17.0",
|
||||
"@lezer/common": "^1.0.0",
|
||||
"@lezer/css": "^1.1.0",
|
||||
"@lezer/html": "^1.3.12"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lang-javascript": {
|
||||
"version": "6.2.5",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-javascript/-/lang-javascript-6.2.5.tgz",
|
||||
"integrity": "sha512-zD4e5mS+50htS7F+TYjBPsiIFGanfVqg4HyUz6WNFikgOPf2BgKlx+TQedI1w6n/IqRBVBbBWmGFdLB/7uxO4A==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.0.0",
|
||||
"@codemirror/language": "^6.6.0",
|
||||
"@codemirror/lint": "^6.0.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.17.0",
|
||||
"@lezer/common": "^1.0.0",
|
||||
"@lezer/javascript": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lang-markdown": {
|
||||
"version": "6.5.2",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-markdown/-/lang-markdown-6.5.2.tgz",
|
||||
"integrity": "sha512-AwBOdkWYuA//WcM0xO5PfHPUcmz/O2i5o0Nsg1U69SII/loCJlFI1Romd9xp2HYb1kYJRGZotyqRghuHH5n8Kw==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@codemirror/autocomplete": "^6.7.1",
|
||||
"@codemirror/lang-html": "^6.0.0",
|
||||
"@codemirror/language": "^6.3.0",
|
||||
"@codemirror/state": "^6.0.0",
|
||||
"@codemirror/view": "^6.0.0",
|
||||
"@lezer/common": "^1.2.1",
|
||||
"@lezer/markdown": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@codemirror/lang-rust": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@codemirror/lang-rust/-/lang-rust-6.0.2.tgz",
|
||||
|
|
@ -558,6 +619,17 @@
|
|||
"integrity": "sha512-sxQE460fPZyU3sdc8lafxiPwJHBzZRy/udNFynGQky1SePYBdhkBl1kOagA9uT3pxR8K09bOrmTUqA9wb/PjSQ==",
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@lezer/css": {
|
||||
"version": "1.3.6",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/css/-/css-1.3.6.tgz",
|
||||
"integrity": "sha512-YJE78Wcg+zX8f10hiHWQ4Az48Qr/c13eId0VtRQYLBpxHDmDeSrXIlkbl+fJGW42rWC/uoUco9mhBZeVWP/A1g==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.2.0",
|
||||
"@lezer/highlight": "^1.0.0",
|
||||
"@lezer/lr": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/highlight": {
|
||||
"version": "1.2.3",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/highlight/-/highlight-1.2.3.tgz",
|
||||
|
|
@ -567,6 +639,28 @@
|
|||
"@lezer/common": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/html": {
|
||||
"version": "1.3.13",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/html/-/html-1.3.13.tgz",
|
||||
"integrity": "sha512-oI7n6NJml729m7pjm9lvLvmXbdoMoi2f+1pwSDJkl9d68zGr7a9Btz8NdHTGQZtW2DA25ybeuv/SyDb9D5tseg==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.2.0",
|
||||
"@lezer/highlight": "^1.0.0",
|
||||
"@lezer/lr": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/javascript": {
|
||||
"version": "1.5.4",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.4.tgz",
|
||||
"integrity": "sha512-vvYx3MhWqeZtGPwDStM2dwgljd5smolYD2lR2UyFcHfxbBQebqx8yjmFmxtJ/E6nN6u1D9srOiVWm3Rb4tmcUA==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.2.0",
|
||||
"@lezer/highlight": "^1.1.3",
|
||||
"@lezer/lr": "^1.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/lr": {
|
||||
"version": "1.4.10",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.10.tgz",
|
||||
|
|
@ -576,6 +670,16 @@
|
|||
"@lezer/common": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/markdown": {
|
||||
"version": "1.7.2",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.7.2.tgz",
|
||||
"integrity": "sha512-iTkYvoVcKt3WkeL7qUDyXHONZEwLio4wj8KTNi2dnjQEXBZKMV63BpQrPqfsM+OkvuRbiSTAcycYAsQzLhRNoQ==",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@lezer/common": "^1.5.0",
|
||||
"@lezer/highlight": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@lezer/rust": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/@lezer/rust/-/rust-1.0.2.tgz",
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@
|
|||
"build": "vite build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@codemirror/lang-markdown": "^6.5.2",
|
||||
"@codemirror/lang-rust": "^6.0.2",
|
||||
"@codemirror/lsp-client": "^6.2.5",
|
||||
"@codemirror/theme-one-dark": "^6.1.3",
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
import { rust } from '@codemirror/lang-rust';
|
||||
import { markdown } from '@codemirror/lang-markdown';
|
||||
import {
|
||||
languageServerExtensions,
|
||||
jumpToDefinition,
|
||||
|
|
@ -14,6 +15,22 @@ import { EditorView, basicSetup } from 'codemirror';
|
|||
import './style.css';
|
||||
|
||||
const STORAGE_KEY = 'litellm-rust-playground-files';
|
||||
const GUIDE_PATH = 'GUIDE.md';
|
||||
const DEFAULT_GUIDE = `# Prove the connection
|
||||
|
||||
Cmd-click \`build_proof\` in \`src/main.rs\`. The Rust editor opens its definition in \`src/proof.rs\`.
|
||||
|
||||
Hover \`litellm_core::Error\` for dependency type information.
|
||||
|
||||
## What this uses
|
||||
|
||||
- **Editor:** CodeMirror 6
|
||||
- **Language server:** rust-analyzer over WebSocket
|
||||
- **Dependency:** in-repo \`litellm-core\` path dependency
|
||||
- **Proc macro:** Serde \`Serialize\` and \`Deserialize\` derives
|
||||
|
||||
> This Markdown and the Rust source are saved in this browser. Reset restores the example.
|
||||
`;
|
||||
|
||||
type PlaygroundFile = {
|
||||
path: string;
|
||||
|
|
@ -108,6 +125,7 @@ const resetButton = requireElement<HTMLButtonElement>('reset-button');
|
|||
const runStatus = requireElement<HTMLSpanElement>('run-status');
|
||||
const output = requireElement<HTMLPreElement>('output');
|
||||
const editorsParent = requireElement<HTMLDivElement>('editors');
|
||||
const markdownEditorParent = requireElement<HTMLDivElement>('markdown-editor');
|
||||
const fileNav = requireElement<HTMLElement>('file-nav');
|
||||
const activePath = requireElement<HTMLSpanElement>('active-path');
|
||||
|
||||
|
|
@ -183,6 +201,10 @@ const loadStoredFiles = (): StoredFiles => {
|
|||
}
|
||||
};
|
||||
|
||||
const saveStoredFile = (path: string, source: string) => {
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify({ ...loadStoredFiles(), [path]: source }));
|
||||
};
|
||||
|
||||
const main = async () => {
|
||||
const info = await loadInfo();
|
||||
const storedFiles = loadStoredFiles();
|
||||
|
|
@ -191,6 +213,22 @@ const main = async () => {
|
|||
const buttons = new Map<string, HTMLButtonElement>();
|
||||
let activeUri = info.files[0]?.uri ?? '';
|
||||
|
||||
const markdownView = new EditorView({
|
||||
doc: storedFiles[GUIDE_PATH] ?? DEFAULT_GUIDE,
|
||||
extensions: [
|
||||
basicSetup,
|
||||
markdown(),
|
||||
oneDark,
|
||||
EditorView.lineWrapping,
|
||||
EditorView.updateListener.of(update => {
|
||||
if (update.docChanged) {
|
||||
saveStoredFile(GUIDE_PATH, update.state.doc.toString());
|
||||
}
|
||||
}),
|
||||
],
|
||||
parent: markdownEditorParent,
|
||||
});
|
||||
|
||||
const showFile = (uri: string) => {
|
||||
const view = views.get(uri);
|
||||
if (!view) {
|
||||
|
|
@ -256,13 +294,7 @@ const main = async () => {
|
|||
if (!update.docChanged) {
|
||||
return;
|
||||
}
|
||||
const saved = Object.fromEntries(
|
||||
[...views.entries()].map(([uri, editor]) => [
|
||||
info.files.find(candidate => candidate.uri === uri)?.path ?? uri,
|
||||
editor.state.doc.toString(),
|
||||
]),
|
||||
);
|
||||
localStorage.setItem(STORAGE_KEY, JSON.stringify({ ...saved, [file.path]: update.state.doc.toString() }));
|
||||
saveStoredFile(file.path, update.state.doc.toString());
|
||||
}),
|
||||
],
|
||||
parent: container,
|
||||
|
|
@ -299,6 +331,9 @@ const main = async () => {
|
|||
const view = views.get(file.uri);
|
||||
view?.dispatch({ changes: { from: 0, to: view.state.doc.length, insert: file.source } });
|
||||
});
|
||||
markdownView.dispatch({
|
||||
changes: { from: 0, to: markdownView.state.doc.length, insert: DEFAULT_GUIDE },
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,6 @@ h1 {
|
|||
}
|
||||
|
||||
.eyebrow,
|
||||
.section-label,
|
||||
.output-header {
|
||||
color: #c96f43;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
|
|
@ -140,63 +139,31 @@ h1 {
|
|||
}
|
||||
|
||||
.docs {
|
||||
display: grid;
|
||||
grid-template-rows: auto 1fr;
|
||||
grid-row: 1 / 3;
|
||||
overflow: auto;
|
||||
padding: 1.5rem;
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
border-right: 1px solid #292e36;
|
||||
background: rgba(18, 21, 26, 0.76);
|
||||
}
|
||||
|
||||
.docs h2 {
|
||||
margin-bottom: 0.75rem;
|
||||
font-size: 1.45rem;
|
||||
letter-spacing: -0.03em;
|
||||
}
|
||||
|
||||
.docs h3 {
|
||||
margin-top: 2rem;
|
||||
margin-bottom: 0.75rem;
|
||||
font-size: 0.9rem;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.docs p,
|
||||
.docs dd {
|
||||
color: #aeb4bd;
|
||||
font-size: 0.96rem;
|
||||
line-height: 1.65;
|
||||
}
|
||||
|
||||
.docs code {
|
||||
color: #efb08f;
|
||||
.docbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
min-height: 2.5rem;
|
||||
padding: 0.55rem 0.9rem;
|
||||
border-bottom: 1px solid #292e36;
|
||||
background: #111419;
|
||||
color: #d6dae0;
|
||||
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
font-size: 0.78rem;
|
||||
}
|
||||
|
||||
.docs dl {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.docs dl div {
|
||||
padding: 0.75rem 0;
|
||||
border-top: 1px solid #292e36;
|
||||
}
|
||||
|
||||
.docs dt {
|
||||
margin-bottom: 0.2rem;
|
||||
color: #777f8b;
|
||||
font-size: 0.75rem;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.docs dd {
|
||||
margin: 0;
|
||||
color: #e2e5e9;
|
||||
}
|
||||
|
||||
.hint {
|
||||
margin-top: 2rem;
|
||||
padding-left: 0.75rem;
|
||||
border-left: 2px solid #bd5b2f;
|
||||
.document-language {
|
||||
color: #686f7a;
|
||||
}
|
||||
|
||||
.editor-panel,
|
||||
|
|
@ -236,6 +203,7 @@ h1 {
|
|||
}
|
||||
|
||||
#editors,
|
||||
#markdown-editor,
|
||||
.editor-container,
|
||||
.cm-editor {
|
||||
height: 100%;
|
||||
|
|
@ -355,7 +323,7 @@ h1 {
|
|||
}
|
||||
|
||||
.docs {
|
||||
max-height: none;
|
||||
height: 45vh;
|
||||
border-right: 0;
|
||||
border-bottom: 1px solid #292e36;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue