AeroVortex commited on
Commit
b2ba4a1
·
verified ·
1 Parent(s): 9f6d2e4

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +82 -20
index.html CHANGED
@@ -3,28 +3,90 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>AI Studio Lite</title>
7
-
8
- <!-- Official Gradio Lite CDN -->
9
- <script type="module" crossorigin src="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.js"></script>
10
- <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@gradio/lite/dist/lite.css" />
11
  </head>
12
- <body style="margin: 0; padding: 16px; font-family: -apple-system, BlinkMacSystemFont, sans-serif;">
13
- <h3 style="text-align: center; color: #333; margin-bottom: 12px;">AI Studio Workspace</h3>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
- <gradio-lite>
16
- import gradio as gr
 
 
 
 
 
 
17
 
18
- def respond(message):
19
- return f"Received on mobile: {message}"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- demo = gr.Interface(
22
- fn=respond,
23
- inputs=gr.Textbox(label="Prompt", placeholder="Type your idea here..."),
24
- outputs=gr.Textbox(label="Response"),
25
- title="Simple Echo Demo"
26
- )
27
- demo.launch()
28
- </gradio-lite>
 
 
 
 
 
 
 
 
 
 
29
  </body>
30
- </html>
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Open-Generative-AI Studio</title>
7
+ <!-- Include Puter.js for zero-key AI and cloud features -->
8
+ <script src="https://js.puter.com/v2/"></script>
 
 
9
  </head>
10
+ <body style="margin: 0; padding: 20px; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background-color: #0b0b0f; color: #f1f1f3;">
11
+ <div style="max-width: 650px; margin: 30px auto; background: #16161e; padding: 24px; border-radius: 12px; box-shadow: 0 8px 24px rgba(0,0,0,0.5); border: 1px solid #2d2d3d;">
12
+
13
+ <div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
14
+ <h2 style="margin: 0; color: #fff; font-size: 20px;">Open-Generative-AI Studio</h2>
15
+ <button id="authBtn" onclick="toggleAuth()" style="background: #2563eb; color: #fff; border: none; padding: 6px 12px; border-radius: 6px; font-size: 12px; cursor: pointer;">Sign In</button>
16
+ </div>
17
+
18
+ <div style="margin-bottom: 16px;">
19
+ <label style="display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; color: #a1a1aa;">Prompt / Description</label>
20
+ <textarea id="promptInput" rows="3" placeholder="Describe the image or content you want to generate..." style="width: 100%; padding: 10px; box-sizing: border-box; background: #0b0b0f; border: 1px solid #2d2d3d; color: #fff; border-radius: 6px; font-size: 14px;"></textarea>
21
+ </div>
22
+
23
+ <div style="display: flex; gap: 10px; margin-bottom: 20px;">
24
+ <button onclick="generateImage()" style="flex: 1; background: #7c3aed; color: #fff; border: none; padding: 10px; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer;">Generate Image</button>
25
+ <button onclick="generateText()" style="flex: 1px; background: #2563eb; color: #fff; border: none; padding: 10px; border-radius: 6px; font-size: 14px; font-weight: 600; cursor: pointer;">Ask AI</button>
26
+ </div>
27
+
28
+ <label style="display: block; font-weight: 600; margin-bottom: 6px; font-size: 13px; color: #a1a1aa;">Output Result</label>
29
+ <div id="outputArea" style="padding: 16px; background: #0b0b0f; border: 1px solid #2d2d3d; border-radius: 6px; min-height: 100px; font-size: 14px; color: #d4d4d8; text-align: center; display: flex; align-items: center; justify-content: center;">
30
+ Ready for input...
31
+ </div>
32
+ </div>
33
+
34
+ <script>
35
+ // Check initial sign-in state
36
+ window.addEventListener('DOMContentLoaded', async () => {
37
+ if (puter.auth.isSignedIn()) {
38
+ document.getElementById('authBtn').innerText = "Connected";
39
+ }
40
+ });
41
 
42
+ async function toggleAuth() {
43
+ if (!puter.auth.isSignedIn()) {
44
+ await puter.auth.signIn();
45
+ document.getElementById('authBtn').innerText = "Connected";
46
+ } else {
47
+ alert("You are already signed in!");
48
+ }
49
+ }
50
 
51
+ async function generateImage() {
52
+ const prompt = document.getElementById('promptInput').value;
53
+ const output = document.getElementById('outputArea');
54
+
55
+ if (!prompt.trim()) {
56
+ output.innerText = "Please enter a prompt first.";
57
+ return;
58
+ }
59
+
60
+ output.innerHTML = "Generating image (processing)...";
61
+ try {
62
+ // Generates an image element directly using Puter.js
63
+ const imgElement = await puter.ai.txt2img(prompt);
64
+ output.innerHTML = "";
65
+ imgElement.style.maxWidth = "100%";
66
+ imgElement.style.borderRadius = "6px";
67
+ output.appendChild(imgElement);
68
+ } catch (err) {
69
+ output.innerText = "Error: " + err;
70
+ }
71
+ }
72
 
73
+ async function generateText() {
74
+ const prompt = document.getElementById('promptInput').value;
75
+ const output = document.getElementById('outputArea');
76
+
77
+ if (!prompt.trim()) {
78
+ output.innerText = "Please enter a prompt first.";
79
+ return;
80
+ }
81
+
82
+ output.innerHTML = "Thinking...";
83
+ try {
84
+ const response = await puter.ai.chat(prompt);
85
+ output.innerHTML = `<div style="text-align: left; width: 100%; white-space: pre-wrap;">${response}</div>`;
86
+ } catch (err) {
87
+ output.innerText = "Error: " + err;
88
+ }
89
+ }
90
+ </script>
91
  </body>
92
+ </html>