Update index.html
Browse files- index.html +101 -24
index.html
CHANGED
|
@@ -1,10 +1,10 @@
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
-
<html>
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
-
<title>
|
| 7 |
-
<meta name="description" content="
|
| 8 |
|
| 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" />
|
|
@@ -14,6 +14,7 @@
|
|
| 14 |
margin: 0;
|
| 15 |
padding: 0;
|
| 16 |
height: 100%;
|
|
|
|
| 17 |
}
|
| 18 |
</style>
|
| 19 |
</head>
|
|
@@ -21,36 +22,112 @@
|
|
| 21 |
<gradio-lite>
|
| 22 |
<gradio-file name="app.py" entrypoint>
|
| 23 |
import gradio as gr
|
|
|
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
-
def
|
| 28 |
-
|
| 29 |
-
|
|
|
|
|
|
|
| 30 |
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
)
|
| 37 |
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
-
|
| 42 |
-
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
-
|
| 49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 50 |
|
| 51 |
<gradio-requirements>
|
| 52 |
-
|
| 53 |
-
scikit-image
|
| 54 |
</gradio-requirements>
|
| 55 |
</gradio-lite>
|
| 56 |
</body>
|
|
|
|
| 1 |
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
<head>
|
| 4 |
<meta charset="utf-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1">
|
| 6 |
+
<title>Knowledge AI Studio β Nobel Literary & Werewolf Book Studio</title>
|
| 7 |
+
<meta name="description" content="Private AI co-writing and visual illustration workspace for crafting award-winning werewolf novels, book covers, and cinematic book trailers.">
|
| 8 |
|
| 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" />
|
|
|
|
| 14 |
margin: 0;
|
| 15 |
padding: 0;
|
| 16 |
height: 100%;
|
| 17 |
+
background-color: #f9fafb;
|
| 18 |
}
|
| 19 |
</style>
|
| 20 |
</head>
|
|
|
|
| 22 |
<gradio-lite>
|
| 23 |
<gradio-file name="app.py" entrypoint>
|
| 24 |
import gradio as gr
|
| 25 |
+
from huggingface_hub import InferenceClient
|
| 26 |
|
| 27 |
+
SYSTEM_PROMPT = (
|
| 28 |
+
"You are a master Nobel-caliber book writer and werewolf fiction co-author. "
|
| 29 |
+
"Write atmospheric, emotionally gripping, literary prose with rich world-building, "
|
| 30 |
+
"strictly maintaining pack lore and narrative continuity."
|
| 31 |
+
)
|
| 32 |
|
| 33 |
+
def write_chapter(prompt, history, hf_token, temp):
|
| 34 |
+
if not hf_token or not hf_token.strip():
|
| 35 |
+
return "π Please enter your Hugging Face Access Token in the top bar to start writing."
|
| 36 |
+
if not prompt or not prompt.strip():
|
| 37 |
+
return "Please enter a scene prompt or chapter instruction."
|
| 38 |
|
| 39 |
+
client = InferenceClient(token=hf_token.strip())
|
| 40 |
+
messages = [{"role": "system", "content": SYSTEM_PROMPT}]
|
| 41 |
+
for user_msg, bot_msg in history:
|
| 42 |
+
messages.append({"role": "user", "content": user_msg})
|
| 43 |
+
messages.append({"role": "assistant", "content": bot_msg})
|
| 44 |
+
messages.append({"role": "user", "content": prompt})
|
| 45 |
|
| 46 |
+
try:
|
| 47 |
+
response = client.chat_completion(
|
| 48 |
+
model="inclusionAI/Ling-3.1-flash",
|
| 49 |
+
messages=messages,
|
| 50 |
+
max_tokens=2048,
|
| 51 |
+
temperature=temp,
|
| 52 |
+
)
|
| 53 |
+
return response.choices.message.content
|
| 54 |
+
except Exception as e:
|
| 55 |
+
return f"β οΈ Notice: {str(e)}"
|
| 56 |
|
| 57 |
+
def generate_scene_art(scene_prompt, hf_token):
|
| 58 |
+
if not hf_token or not hf_token.strip():
|
| 59 |
+
raise gr.Error("Please enter your Hugging Face Access Token in the top bar first.")
|
| 60 |
+
if not scene_prompt or not scene_prompt.strip():
|
| 61 |
+
return None
|
| 62 |
|
| 63 |
+
client = InferenceClient(token=hf_token.strip())
|
| 64 |
+
image = client.text_to_image(
|
| 65 |
+
prompt=f"Nobel literary book cover illustration, werewolf lore, cinematic natural lighting, clean painterly style, {scene_prompt}",
|
| 66 |
+
model="black-forest-labs/FLUX.1-schnell",
|
| 67 |
+
)
|
| 68 |
+
return image
|
| 69 |
+
|
| 70 |
+
def generate_book_trailer(video_prompt, hf_token):
|
| 71 |
+
if not hf_token or not hf_token.strip():
|
| 72 |
+
raise gr.Error("Please enter your Hugging Face Access Token in the top bar first.")
|
| 73 |
+
if not video_prompt or not video_prompt.strip():
|
| 74 |
+
return None
|
| 75 |
+
|
| 76 |
+
client = InferenceClient(token=hf_token.strip())
|
| 77 |
+
video_bytes = client.text_to_video(
|
| 78 |
+
prompt=f"Cinematic literary novel book trailer shot, luminous atmosphere, {video_prompt}",
|
| 79 |
+
model="Wan-AI/Wan2.1-T2V-14B",
|
| 80 |
+
)
|
| 81 |
+
output_path = "trailer_clip.mp4"
|
| 82 |
+
with open(output_path, "wb") as f:
|
| 83 |
+
f.write(video_bytes)
|
| 84 |
+
return output_path
|
| 85 |
|
| 86 |
+
with gr.Blocks(theme=gr.themes.Soft(), title="Knowledge AI Studio") as demo:
|
| 87 |
+
gr.Markdown("# π Knowledge AI Studio")
|
| 88 |
+
gr.Markdown("Nobel-caliber literary co-writing and visual studio powered by **Ling 3.1 Flash**, **FLUX.1**, and **Wan 2.1**.")
|
| 89 |
+
|
| 90 |
+
with gr.Accordion("π Author Access Key (Required)", open=True):
|
| 91 |
+
token_box = gr.Textbox(
|
| 92 |
+
label="Access Key",
|
| 93 |
+
type="password",
|
| 94 |
+
placeholder="Paste your hf_... access key here",
|
| 95 |
+
)
|
| 96 |
+
|
| 97 |
+
with gr.Tab("βοΈ Chapter & Lore Writer"):
|
| 98 |
+
temp_slider = gr.Slider(0.5, 1.2, value=0.9, label="Creativity (Temperature)")
|
| 99 |
+
gr.ChatInterface(
|
| 100 |
+
fn=write_chapter,
|
| 101 |
+
additional_inputs=[token_box, temp_slider],
|
| 102 |
+
examples=[
|
| 103 |
+
["Write an opening chapter where an ancient alpha discovers a forgotten treaty under a silver full moon.", "", 0.9],
|
| 104 |
+
["Create a rich cultural history and lineage for three noble werewolf clans.", "", 0.85],
|
| 105 |
+
],
|
| 106 |
+
)
|
| 107 |
+
|
| 108 |
+
with gr.Tab("π¨ Book Cover & Character Art"):
|
| 109 |
+
art_input = gr.Textbox(
|
| 110 |
+
label="Describe your character or scene",
|
| 111 |
+
placeholder="Silver-furred werewolf standing on a sunlit mountain ridge overlooking an ancient valley..."
|
| 112 |
+
)
|
| 113 |
+
art_btn = gr.Button("Generate Artwork", variant="primary")
|
| 114 |
+
art_output = gr.Image(label="Generated Book Art")
|
| 115 |
+
art_btn.click(fn=generate_scene_art, inputs=[art_input, token_box], outputs=art_output)
|
| 116 |
+
|
| 117 |
+
with gr.Tab("π¬ Book Trailer Video"):
|
| 118 |
+
vid_input = gr.Textbox(
|
| 119 |
+
label="Describe the trailer motion scene",
|
| 120 |
+
placeholder="Slow sweeping camera through a misty northern pine forest at dawn..."
|
| 121 |
+
)
|
| 122 |
+
vid_btn = gr.Button("Generate Video Clip", variant="primary")
|
| 123 |
+
vid_output = gr.Video(label="Generated Trailer Clip")
|
| 124 |
+
vid_btn.click(fn=generate_book_trailer, inputs=[vid_input, token_box], outputs=vid_output)
|
| 125 |
+
|
| 126 |
+
demo.launch()
|
| 127 |
+
</gradio-file>
|
| 128 |
|
| 129 |
<gradio-requirements>
|
| 130 |
+
huggingface-hub>=0.26.0
|
|
|
|
| 131 |
</gradio-requirements>
|
| 132 |
</gradio-lite>
|
| 133 |
</body>
|