Skip to content

Commit

Permalink
adjustments for video
Browse files Browse the repository at this point in the history
  • Loading branch information
petersalomonsen committed Dec 25, 2024
1 parent 9ef8efd commit 1b7fcbf
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 44 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ emsdk
/blob-report/
/playwright/.cache/
bin

*.mp4
7 changes: 5 additions & 2 deletions examples/aiproxy/playwright-tests/aiproxy.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,12 @@ test('ask question', async ({ page }) => {
const questionArea = await page.getByPlaceholder('Type your question here...');
await expect(questionArea).toBeEnabled();
questionArea.fill("Hello!");
await page.waitForTimeout(500);
await page.getByRole('button', { name: 'Ask AI' }).click();
await expect(await page.getByText("I am just a mockserver")).toBeVisible();
await expect(await page.getByText("Hello! How can I assist you today?")).toBeVisible();

await page.waitForTimeout(500);
await page.locator("#refundButton").click();

await expect(await page.locator("#refund_message")).toContainText(`[\"EVENT_JSON:{\\\"standard\\\":\\\"nep141\\\",\\\"version\\\":\\\"1.0.0\\\",\\\"event\\\":\\\"ft_transfer\\\",\\\"data\\\":[{\\\"old_owner_id\\\":\\\"${contractId}\\\",\\\"new_owner_id\\\":\\\"${accountId}\\\",\\\"amount\\\":\\\"127999973\\\"}]}\",\"refunded 127999973 to ${accountId}\",\"\\n\"]`)
await expect(await page.locator("#refund_message")).toContainText(`EVENT_JSON:{"standard":"nep141","version":"1.0.0","event":"ft_transfer","data":[{"old_owner_id":"${contractId}","new_owner_id":"${accountId}","amount":"127999973"}]}\nrefunded 127999973 to ${accountId}`);
});
2 changes: 1 addition & 1 deletion examples/aiproxy/playwright-tests/openaimockserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const server = createServer((req, res) => {
choices: [
{
delta: {
content: "I am just a mockserver\n",
content: "Hello! How can I assist you today?\n",
},
},
],
Expand Down
55 changes: 16 additions & 39 deletions examples/aiproxy/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,53 +4,29 @@
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>OpenAI Proxy Streaming</title>
<style>
body {
font-family: Arial, sans-serif;
max-width: 600px;
margin: 2em auto;
padding: 1em;
border: 1px solid #ccc;
border-radius: 8px;
}
#messages {
border: 1px solid #ddd;
padding: 1em;
min-height: 200px;
margin-bottom: 1em;
white-space: pre-wrap;
}
#question-container {
display: flex;
flex-direction: column;
gap: 0.5em;
}
textarea {
width: 100%;
}
button {
align-self: flex-end;
}
</style>
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
</head>
<body>
<h1>OpenAI Proxy Streaming UI</h1>
<input id="conversation_id" readonly ="conversation id" />
<button id="startConversationButton">Start conversation</button>"
<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 id="question-container">

<textarea id="question" disabled rows="4" placeholder="Type your question here..."></textarea>
<button id="askAIButton" disabled>Ask AI</button>

<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>
</div>
<button id="refundButton">Stop conversation and refund tokens</button><br />
<div>
<button id="refundButton" class="btn btn-primary">Stop conversation and refund tokens</button><br />
<div style="width: 100%">
<pre>
<code id="refund_message"></code>
<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">
{
Expand Down Expand Up @@ -133,5 +109,6 @@ <h1>OpenAI Proxy Streaming UI</h1>
</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>
2 changes: 1 addition & 1 deletion examples/aiproxy/web/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ async function refund() {
...refundMessage
}
});
refund_message.innerHTML = JSON.stringify(result.receipts_outcome[0].outcome.logs);
refund_message.innerHTML = result.receipts_outcome[0].outcome.logs.join("\n");
}

async function startConversation() {
Expand Down

0 comments on commit 1b7fcbf

Please sign in to comment.