-
Notifications
You must be signed in to change notification settings - Fork 2
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
13 changed files
with
549 additions
and
71 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 |
---|---|---|
@@ -0,0 +1,88 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>AI Warp</title> | ||
</head> | ||
<body> | ||
<div> | ||
<label for="prompt-text">Prompt: </label> | ||
<textarea name="prompt text" id="prompt-text" cols="60" rows="1"></textarea> | ||
<button id="prompt-button">Prompt</button> | ||
</div> | ||
|
||
<p id="response"></p> | ||
|
||
<script> | ||
const promptText = document.getElementById('prompt-text') | ||
const responseText = document.getElementById('response') | ||
|
||
const promptButton = document.getElementById('prompt-button') | ||
promptButton.onclick = async () => { | ||
const res = await fetch('/api/v1/stream', { | ||
method: 'POST', | ||
headers: { | ||
'content-type': 'application/json' | ||
}, | ||
body: JSON.stringify({ | ||
prompt: promptText.value | ||
}) | ||
}) | ||
|
||
if (res.status !== 200) { | ||
const { message, code } = await res.json() | ||
responseText.innerHTML = `Error: ${message} (${code})` | ||
return | ||
} | ||
|
||
responseText.innerHTML = '' | ||
|
||
const reader = res.body.getReader() | ||
const decoder = new TextDecoder() | ||
while (true) { | ||
const { done, value } = await reader.read() | ||
if (done) { | ||
break | ||
} | ||
|
||
const decodedValue = decoder.decode(value) | ||
const lines = decodedValue.split('\n') | ||
|
||
let i = 0 | ||
while (i < lines.length) { | ||
const line = lines[i] | ||
if (line.length === 0) { | ||
i++ | ||
continue | ||
} | ||
|
||
if (!line.startsWith('event: ')) { | ||
responseText.innerHTML = `Unexpected event type line: ${line}` | ||
return | ||
} | ||
|
||
const dataLine = lines[i + 1] | ||
if (!dataLine.startsWith('data: ')) { | ||
responseText.innerHTML = `Unexpected data line: ${dataLine}` | ||
return | ||
} | ||
|
||
const eventType = line.substring('event: '.length) | ||
const data = dataLine.substring('data: '.length) | ||
const json = JSON.parse(data) | ||
if (eventType === 'content') { | ||
const { response } = json | ||
responseText.innerHTML += response | ||
} else if (eventType === 'error') { | ||
const { message, code } = data | ||
responseText.innerHTML = `Error: ${message} (${code})` | ||
} | ||
|
||
i += 2 | ||
} | ||
} | ||
} | ||
</script> | ||
</body> | ||
</html> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,17 @@ | ||
body { | ||
background-color: #00050B; | ||
padding: 0; | ||
margin: 0; | ||
color: white; | ||
} | ||
|
||
#navbar { | ||
padding-top: 5px; | ||
padding-bottom: 5px; | ||
width: 100%; | ||
border-bottom: 2px solid #FFFFFF26; | ||
} | ||
|
||
#navbar-logo { | ||
padding-left: 60px; | ||
} |
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,79 @@ | ||
#main-illustration { | ||
margin-top: 60px; | ||
width: 100%; | ||
text-align: center; | ||
position: absolute; | ||
} | ||
|
||
#greeting { | ||
padding-top: 450px; | ||
text-align: center; | ||
} | ||
|
||
#prompt-suggestions { | ||
width: 50%; | ||
margin-left: 25%; | ||
padding-top: 100px; | ||
display: flex; | ||
flex-wrap: wrap; | ||
justify-content: center; | ||
} | ||
|
||
.prompt-suggestion { | ||
border: 1px solid #FFFFFF4D; | ||
border-radius: 4px; | ||
margin: 8px; | ||
margin-left: 12px; | ||
width: 45%; | ||
} | ||
|
||
.prompt-suggestion p { | ||
margin-left: 8px; | ||
margin-right: 8px; | ||
} | ||
|
||
.prompt-suggestion-title { | ||
margin-top: 8px; | ||
} | ||
|
||
.prompt-suggestion-subtitle { | ||
color: #FFFFFFB2; | ||
margin-bottom: 8px; | ||
} | ||
|
||
.prompt-suggestion-subtitle a { | ||
float: right; | ||
} | ||
|
||
#prompt-input { | ||
width: 50%; | ||
display: flex; | ||
margin-top: 50px; | ||
margin-left: 25%; | ||
justify-content: center; | ||
} | ||
|
||
#prompt-input input { | ||
width: 90%; | ||
background-color: rgba(0, 0, 0, 0); | ||
color: #FFFFFF; | ||
padding: 10px; | ||
border: 1px solid #FFFFFFB2; | ||
border-radius: 4px; | ||
} | ||
|
||
#see-docs { | ||
margin-top: 30px; | ||
text-align: center; | ||
} | ||
|
||
#see-docs a { | ||
padding-top: 12px; | ||
padding-bottom: 12px; | ||
padding-left: 8px; | ||
padding-right: 8px; | ||
border: 1px solid #FFFFFFB2; | ||
border-radius: 4px; | ||
text-decoration: none; | ||
color: #FFFFFF; | ||
} |