-
Notifications
You must be signed in to change notification settings - Fork 7
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
1 parent
056eb6d
commit b58e6e8
Showing
4 changed files
with
54 additions
and
16 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,2 +1,4 @@ | ||
target | ||
.spin | ||
dist | ||
web4.js |
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,28 @@ | ||
import html from '@web/rollup-plugin-html'; | ||
import { terser } from 'rollup-plugin-terser'; | ||
import { readFileSync, readdirSync, unlinkSync, writeFileSync } from 'fs'; | ||
|
||
export default { | ||
input: ['./web/index.html'], | ||
output: { dir: 'dist' }, | ||
plugins: [html({ minify: true }), terser(), { | ||
name: 'inline-js', | ||
closeBundle: () => { | ||
const js = readFileSync('dist/main.js').toString(); | ||
const html = readFileSync('dist/index.html').toString() | ||
.replace(`<script src="main.js" type="module"></script>`, `<script type="module">${js}</script>`); | ||
|
||
writeFileSync('web4.js', ` | ||
export function web4_get() { | ||
env.value_return(JSON.stringify({ | ||
contentType: 'text/html; charset=UTF-8', | ||
body: '${Buffer.from(html).toString('base64')}' | ||
}) | ||
); | ||
} | ||
`); | ||
|
||
} | ||
}], | ||
}; |
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 |
---|---|---|
@@ -1,34 +1,39 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>OpenAI Proxy Streaming</title> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>OpenAI Proxy Streaming</title> | ||
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" | ||
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous"> | ||
</head> | ||
|
||
<body> | ||
<div class="container"> | ||
<div class="mb-3"> | ||
<label for="conversation_id" class="form-label">Conversation id ( generated )</label> | ||
<input id="conversation_id" class="form-control" readonly /> | ||
</div> | ||
<button id="startConversationButton" class="btn btn-primary">Start conversation</button> | ||
|
||
<div id="messages"></div> | ||
<div class="mb-3"> | ||
<label for="question" class="form-label">Question</label> | ||
<textarea id="question" class="form-control" disabled rows="4" placeholder="Type your question here..."></textarea> | ||
<button id="askAIButton" class="btn btn-primary" disabled>Ask AI</button> | ||
<label for="question" class="form-label">Question</label> | ||
<textarea id="question" class="form-control" disabled rows="4" | ||
placeholder="Type your question here..."></textarea> | ||
<button id="askAIButton" class="btn btn-primary" disabled>Ask AI</button> | ||
</div> | ||
<button id="refundButton" class="btn btn-primary">Stop conversation and refund tokens</button><br /> | ||
<div style="width: 100%"> | ||
<pre> | ||
<pre> | ||
<code id="refund_message" style="white-space: wrap;"></code> | ||
</pre> | ||
</div> | ||
</div> | ||
<script async src="https://ga.jspm.io/npm:[email protected]/dist/es-module-shims.js" crossorigin="anonymous"></script> | ||
<script type="importmap"> | ||
<script async src="https://ga.jspm.io/npm:[email protected]/dist/es-module-shims.js" | ||
crossorigin="anonymous"></script> | ||
<script type="importmap"> | ||
{ | ||
"imports": { | ||
"near-api-js": "https://ga.jspm.io/npm:[email protected]/lib/browser-index.js" | ||
|
@@ -107,8 +112,10 @@ | |
} | ||
} | ||
</script> | ||
<script src="main.js" type="module"> | ||
</script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script> | ||
<script src="main.js" type="module"></script> | ||
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" | ||
integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" | ||
crossorigin="anonymous"></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