Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -15,7 +15,6 @@ import time
|
|
15 |
import zipfile
|
16 |
import huggingface_hub
|
17 |
import dotenv
|
18 |
-
|
19 |
from audio_recorder_streamlit import audio_recorder
|
20 |
from bs4 import BeautifulSoup
|
21 |
from collections import deque
|
@@ -30,7 +29,7 @@ from xml.etree import ElementTree as ET
|
|
30 |
from PIL import Image
|
31 |
from urllib.parse import quote # Ensure this import is included
|
32 |
|
33 |
-
# Set page
|
34 |
st.set_page_config(
|
35 |
page_title="ππGraphicNovelAI",
|
36 |
page_icon="ππ",
|
@@ -43,39 +42,12 @@ st.set_page_config(
|
|
43 |
}
|
44 |
)
|
45 |
|
46 |
-
|
47 |
-
documentHTML5='''
|
48 |
-
<!DOCTYPE html>
|
49 |
-
<html>
|
50 |
-
<head>
|
51 |
-
<title>Read It Aloud</title>
|
52 |
-
<script type="text/javascript">
|
53 |
-
function readAloud() {
|
54 |
-
const text = document.getElementById("textArea").value;
|
55 |
-
const speech = new SpeechSynthesisUtterance(text);
|
56 |
-
window.speechSynthesis.speak(speech);
|
57 |
-
}
|
58 |
-
</script>
|
59 |
-
</head>
|
60 |
-
<body>
|
61 |
-
<h1>π Read It Aloud</h1>
|
62 |
-
<textarea id="textArea" rows="10" cols="80">
|
63 |
-
'''
|
64 |
-
documentHTML5 = documentHTML5 + result
|
65 |
-
documentHTML5 = documentHTML5 + '''
|
66 |
-
</textarea>
|
67 |
-
<br>
|
68 |
-
<button onclick="readAloud()">π Read Aloud</button>
|
69 |
-
</body>
|
70 |
-
</html>
|
71 |
-
'''
|
72 |
-
components.html(documentHTML5, width=1280, height=300)
|
73 |
-
|
74 |
PromptPrefix = 'Create a graphic novel story with streamlit markdown outlines and tables with appropriate emojis for graphic novel rules defining the method steps of play. Use story structure architect rules using plan, structure and top three dramatic situations matching the theme for topic of '
|
75 |
PromptPrefix2 = 'Create a streamlit python user app with full code listing to create a UI implementing the usable choose your own adventure graphic novel rules and story using streamlit, session_state, file_uploader, camera_input, on_change = funcction callbacks, randomness and dice rolls using emojis and st.markdown, st.expander, st.columns and other UI controls in streamlit as a game interface and create inline data tables for entities implemented as variables with python list dictionaries for the game rule entities and stats. Design it as a fun data driven app and show full python code listing for this ruleset and thematic story plot line: '
|
76 |
PromptPrefix3 = 'Create a HTML5 aframe and javascript app. Show full code listing. Create a UI implementing storytelling, features using use three emoji appropriate text detailed plot twists and recurring interesting named characters with genius traits and file IO, randomness, ten point choice lists, math distribution tradeoffs, witty humorous dilemnas with emoji , rewards, variables, reusable functions with parameters, and data driven app with python libraries and streamlit components for Javascript and HTML5. Use appropriate emojis for labels to summarize and list parts, function, conditions for topic:'
|
77 |
|
78 |
-
|
79 |
st.markdown('''### πβ¨π GraphicNovelAI ''')
|
80 |
with st.expander("Help / About π", expanded=False):
|
81 |
st.markdown('''
|
@@ -85,7 +57,7 @@ with st.expander("Help / About π", expanded=False):
|
|
85 |
- π **Query Use:** Input `?q=Palindrome` or `?query=Anagram` in URL for new challenges.
|
86 |
''')
|
87 |
|
88 |
-
|
89 |
roleplaying_glossary = {
|
90 |
"π¨βπ©βπ§βπ¦ Top Graphic Novel Plot Themes": {
|
91 |
"Epic Fantasy": [
|
@@ -150,6 +122,38 @@ roleplaying_glossary = {
|
|
150 |
]
|
151 |
}
|
152 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
153 |
|
154 |
|
155 |
# 9. Sidebar with UI controls to review and re-run prompts and continue responses
|
|
|
15 |
import zipfile
|
16 |
import huggingface_hub
|
17 |
import dotenv
|
|
|
18 |
from audio_recorder_streamlit import audio_recorder
|
19 |
from bs4 import BeautifulSoup
|
20 |
from collections import deque
|
|
|
29 |
from PIL import Image
|
30 |
from urllib.parse import quote # Ensure this import is included
|
31 |
|
32 |
+
# Set initial page and app customization and configuration -------------------------
|
33 |
st.set_page_config(
|
34 |
page_title="ππGraphicNovelAI",
|
35 |
page_icon="ππ",
|
|
|
42 |
}
|
43 |
)
|
44 |
|
45 |
+
# Prompts for App, for App Product, and App Product Code
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
PromptPrefix = 'Create a graphic novel story with streamlit markdown outlines and tables with appropriate emojis for graphic novel rules defining the method steps of play. Use story structure architect rules using plan, structure and top three dramatic situations matching the theme for topic of '
|
47 |
PromptPrefix2 = 'Create a streamlit python user app with full code listing to create a UI implementing the usable choose your own adventure graphic novel rules and story using streamlit, session_state, file_uploader, camera_input, on_change = funcction callbacks, randomness and dice rolls using emojis and st.markdown, st.expander, st.columns and other UI controls in streamlit as a game interface and create inline data tables for entities implemented as variables with python list dictionaries for the game rule entities and stats. Design it as a fun data driven app and show full python code listing for this ruleset and thematic story plot line: '
|
48 |
PromptPrefix3 = 'Create a HTML5 aframe and javascript app. Show full code listing. Create a UI implementing storytelling, features using use three emoji appropriate text detailed plot twists and recurring interesting named characters with genius traits and file IO, randomness, ten point choice lists, math distribution tradeoffs, witty humorous dilemnas with emoji , rewards, variables, reusable functions with parameters, and data driven app with python libraries and streamlit components for Javascript and HTML5. Use appropriate emojis for labels to summarize and list parts, function, conditions for topic:'
|
49 |
|
50 |
+
# Title and Help/About
|
51 |
st.markdown('''### πβ¨π GraphicNovelAI ''')
|
52 |
with st.expander("Help / About π", expanded=False):
|
53 |
st.markdown('''
|
|
|
57 |
- π **Query Use:** Input `?q=Palindrome` or `?query=Anagram` in URL for new challenges.
|
58 |
''')
|
59 |
|
60 |
+
# MoE Context Glossary
|
61 |
roleplaying_glossary = {
|
62 |
"π¨βπ©βπ§βπ¦ Top Graphic Novel Plot Themes": {
|
63 |
"Epic Fantasy": [
|
|
|
122 |
]
|
123 |
}
|
124 |
}
|
125 |
+
# Set initial page and app configs ------------------------------------------
|
126 |
+
|
127 |
+
|
128 |
+
# HTML5 based Speech Synthesis (Text to Speech in Browser)
|
129 |
+
def SpeechSynthesis(result):
|
130 |
+
documentHTML5='''
|
131 |
+
<!DOCTYPE html>
|
132 |
+
<html>
|
133 |
+
<head>
|
134 |
+
<title>Read It Aloud</title>
|
135 |
+
<script type="text/javascript">
|
136 |
+
function readAloud() {
|
137 |
+
const text = document.getElementById("textArea").value;
|
138 |
+
const speech = new SpeechSynthesisUtterance(text);
|
139 |
+
window.speechSynthesis.speak(speech);
|
140 |
+
}
|
141 |
+
</script>
|
142 |
+
</head>
|
143 |
+
<body>
|
144 |
+
<h1>π Read It Aloud</h1>
|
145 |
+
<textarea id="textArea" rows="10" cols="80">
|
146 |
+
'''
|
147 |
+
documentHTML5 = documentHTML5 + result
|
148 |
+
documentHTML5 = documentHTML5 + '''
|
149 |
+
</textarea>
|
150 |
+
<br>
|
151 |
+
<button onclick="readAloud()">π Read Aloud</button>
|
152 |
+
</body>
|
153 |
+
</html>
|
154 |
+
'''
|
155 |
+
components.html(documentHTML5, width=1280, height=300)
|
156 |
+
|
157 |
|
158 |
|
159 |
# 9. Sidebar with UI controls to review and re-run prompts and continue responses
|