bmedia commited on
Commit
f0bf0ae
·
1 Parent(s): 0fdcdbc

Add 2 files

Browse files
Files changed (2) hide show
  1. index.html +60 -19
  2. main.js +34 -0
index.html CHANGED
@@ -1,19 +1,60 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <html><head><link href="https://cdn.jsdelivr.net/npm/daisyui@3.1.6/dist/full.css" rel="stylesheet" type="text/css" /><script defer src="https://cdn.jsdelivr.net/npm/alpinejs@3.x.x/dist/cdn.min.js"></script><script src="https://cdn.tailwindcss.com?plugins=forms,typography,aspect-ratio"></script><script defer src="https://cdnjs.cloudflare.com/ajax/libs/three.js/0.156.1/three.min.js"></script><script type="module" src="main.js"></script><title>Bedtime Stories Generator</title></head><body>
2
+ <div class="bg-black h-screen w-screen"></div>
3
+ <div class="flex h-screen top-0 bg-white">
4
+ <div class="flex-1">
5
+ <div class="object-contain pull-left overflow-auto p-5 lg:h-64" x-data="{{ foo: 'bar' }}">
6
+ <svg viewBox="0 0 800 200" width="100%" fill="white" xmlns="http://www.w3.org/2000/svg">
7
+ <path d="M 0 0 0 150 200 150 200 0 z"></path>
8
+ <text y="140" x="100" stroke="#FF0000" fill="red" font-family="Helvetica" font-size="30" letter-spacing="16" text-anchor="middle">{ foo }</text>
9
+ </svg>
10
+ </div>
11
+ <div class="m-10 p-5 bg-white w-3/4">
12
+ <div class="flex justify-center pt-10 font-h1">
13
+ <h1 class="text-indigo-500 font-bold text-xl">Story Time!</h1>
14
+ </div>
15
+ <p class="font-body mx-2">Welcome to DaisyUI's Story Time! Here you can create your own infinite bedtime stories using DaisyUI's unlimited flow and the power of OpenAI's GPT-3!</p>
16
+ </div>
17
+ <div class="m-10 p-5 bg-white w-3/4">
18
+ <form x-data="{ open: false }">
19
+ <div class="relative group">
20
+ <div class="absolute remove compatible top-0 left-0 appearance w-full bg-black">
21
+ <div class="h-full w-full opacity-0 items-center justify-items-center p-5 bg-gray-500">
22
+ <span class="w-5 h-5">
23
+ <svg viewBox="0 0 24 24" fill="white" xmlns="http://www.w3.org/2000/svg">
24
+ <path d="M0 0h24v24H0z" fill="none"></path><path d="M6.72 16l-2.49-2.49 1.41-1.41 2.49 2.49 4.95-4.95-4.95-4.96-2.689 2.689zm3.213-2.056l-.589 1.902 1.063-2.056-1.746-1.117 1.388-1.388c-2.496-.12-4.786-.347-6.697.2-1.986 1.315-2.653 2.485-2.963 4.982l-.89 1.41zm3.708-3.708l2.596 2.596-.89 1.41-2.596-2.596L9.6 12.594l2.813 1.41 2.19-2.19zm-2.957 3.332l1.41 1.41L5.376 17.361 2.89 15.796l2.689 2.689zm16.99-5.348l-1.41-1.41 2.49-2.49-1.41-1.41-2.49-2.49L9.6 2.798l-2.81-1.41L11.354 0z"></path>
25
+ </svg>
26
+ </span>
27
+ </div>
28
+ </div>
29
+ <div class="flex items-center">
30
+ <input type="text" class="mr-3 form-input w-full appearance-none" placeholder="Enter your prompt..." @focus="open = !open" @blur="open = !open">
31
+ <div class="bg-gray-500 appearance-none block showed" x-show="open"><button class="btn btn-primary">Generate Story</button></div>
32
+ </div>
33
+ </div>
34
+ </form>
35
+ </div>
36
+ </div>
37
+ <div class="flex-1">
38
+ <div class="object-center mx-auto w-full">
39
+ <div class="ardinator"></div>
40
+ <div class="pl-5 pr-10 p-5 lg:w-8/12">
41
+ <p class="font-body mx-2">Your story will appear here!</p>
42
+ </div>
43
+ </div>
44
+ </div>
45
+ </div>
46
+ <div class="flex bottom-0 w-full m-10 p-5 bg-black text-white">
47
+ <div class="flex-1">
48
+ <div class="object-contain pull-left overflow-auto p-5 lg:h-64">
49
+ <svg viewBox="0 0 800 200" width="100%" fill="white" xmlns="http://www.w3.org/2000/svg">
50
+ <path d="M 0 0 0 150 200 150 200 0 z"></path>
51
+ <text y="140" x="100" stroke="#FF8040" fill="whitesmoke" font-family="Helvetica" font-size="30" letter-spacing="16" text-anchor="middle">Powered by OpenAI and DaisyUI</text>
52
+ </svg>
53
+ </div>
54
+ <div class="m-10 p-5 bg-black w-3/4">
55
+ <h1 class="text-indigo-500 font-bold text-xl">Powered by OpenAI and DaisyUI</h1>
56
+ <p class="font-body mx-2">DaisyUI is powered by OpenAI's GPT-3 which is used to generate the stories based on your prompt. This is just a proof of concept, so please use it responsibly and have fun!</p>
57
+ </div>
58
+ </div>
59
+ </div>
60
+ </body></html>
main.js ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import { AlpineJS } from 'https://cdn.skypack.dev/alpinejs'
2
+ import { createEditor } from 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/codemirror.min.js'
3
+ import 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/addons/edit/matchbrackets.min.js'
4
+ import 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/keymap/sublime.min.js'
5
+ import 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/theme/monokai.min.js'
6
+ import 'https://cdnjs.cloudflare.com/ajax/libs/codemirror/5.0.0/theme/twilight.min.js'
7
+
8
+ AlpineJS.start()
9
+
10
+ const editor = createEditor(document.querySelector('#editor'), {
11
+ mode: 'xml',
12
+ lineNumbers: true,
13
+ styleActiveLine: true,
14
+ theme: 'twilight',
15
+ keyMap: 'sublime',
16
+ matchBrackets: true,
17
+ });
18
+
19
+ editor.on('change', () => {
20
+ let story = editor.getValue()
21
+ const token = 'aabbccddeeff' // Replace with your own API token
22
+ const requestOptions = {
23
+ method: 'POST',
24
+ mode: "cors",
25
+ headers: { 'Content-Type': 'application/json' },
26
+ body: JSON.stringify({ story })
27
+ };
28
+ fetch('https://api.openai.com/v1/engines/davinci-codex/completions', requestOptions)
29
+ .then(response => response.json())
30
+ .then(data => {
31
+ const { choices } = data.data.choices
32
+ console.log(choices)
33
+ })
34
+ });