Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,11 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import os
|
| 3 |
import json
|
|
|
|
|
|
|
| 4 |
from PIL import Image
|
| 5 |
from urllib.parse import quote # Ensure this import is included
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
# Imports
|
| 12 |
import base64
|
| 13 |
import glob
|
|
@@ -37,8 +35,6 @@ from templates import bot_template, css, user_template
|
|
| 37 |
from xml.etree import ElementTree as ET
|
| 38 |
import streamlit.components.v1 as components # Import Streamlit Components for HTML5
|
| 39 |
|
| 40 |
-
|
| 41 |
-
|
| 42 |
# Set page configuration with a title and favicon
|
| 43 |
st.set_page_config(
|
| 44 |
page_title="🗺️🛠️ RolePlayAI",
|
|
@@ -62,7 +58,6 @@ with st.expander("Help / About 📚", expanded=False):
|
|
| 62 |
- 🧙♂️ **Your Journey:** Become a linguistic mage, mastering language arts.
|
| 63 |
- 🎮 **How to Play:** Start your quest with URL challenges, like `?q=Cyberpunk` or `?query=Dungeons and Dragons`.
|
| 64 |
''')
|
| 65 |
-
|
| 66 |
|
| 67 |
# 9. Sidebar with UI controls to review and re-run prompts and continue responses
|
| 68 |
@st.cache_resource
|
|
@@ -205,7 +200,7 @@ FileSidebar()
|
|
| 205 |
|
| 206 |
|
| 207 |
# ---- Art Card Sidebar with Random Selection of image------------------------------
|
| 208 |
-
|
| 209 |
def get_image_as_base64(url):
|
| 210 |
response = requests.get(url)
|
| 211 |
if response.status_code == 200:
|
|
@@ -218,12 +213,12 @@ def create_download_link(filename, base64_str):
|
|
| 218 |
href = f'<a href="data:file/png;base64,{base64_str}" download="{filename}">Download Image</a>'
|
| 219 |
return href
|
| 220 |
|
| 221 |
-
# List of image URLs
|
| 222 |
image_urls = [
|
| 223 |
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/o1FI3G_BueAAanLBeqoo3.png",
|
| 224 |
-
|
| 225 |
-
|
| 226 |
-
|
| 227 |
]
|
| 228 |
|
| 229 |
# Select a random URL from the list
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import os
|
| 3 |
import json
|
| 4 |
+
import random
|
| 5 |
+
|
| 6 |
from PIL import Image
|
| 7 |
from urllib.parse import quote # Ensure this import is included
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
# Imports
|
| 10 |
import base64
|
| 11 |
import glob
|
|
|
|
| 35 |
from xml.etree import ElementTree as ET
|
| 36 |
import streamlit.components.v1 as components # Import Streamlit Components for HTML5
|
| 37 |
|
|
|
|
|
|
|
| 38 |
# Set page configuration with a title and favicon
|
| 39 |
st.set_page_config(
|
| 40 |
page_title="🗺️🛠️ RolePlayAI",
|
|
|
|
| 58 |
- 🧙♂️ **Your Journey:** Become a linguistic mage, mastering language arts.
|
| 59 |
- 🎮 **How to Play:** Start your quest with URL challenges, like `?q=Cyberpunk` or `?query=Dungeons and Dragons`.
|
| 60 |
''')
|
|
|
|
| 61 |
|
| 62 |
# 9. Sidebar with UI controls to review and re-run prompts and continue responses
|
| 63 |
@st.cache_resource
|
|
|
|
| 200 |
|
| 201 |
|
| 202 |
# ---- Art Card Sidebar with Random Selection of image------------------------------
|
| 203 |
+
# Image Prompt for Midjourney: Living grid shelf of Monsters Miniatures with a grid arranged with set of living diorama with D&D Monsters! 28MM Scale Fantasy MINIS, Painted, Photorealistic 3D Dungeons and Dragons Miniatures. 64 small 28mm minis (1-1.5"); Dragon (~6"), 3 large figures- Sharkenbear, Lamia, Arch Devi, Dungeons & Dragons book covers: Men & Magic, Monsters & Treasure, Underworld & Wilderness Adventures, Greyhawk, Blackmoor, Eldritch Wizardry, Gods, Demi-Gods & Heroes, Swords & Spells, Basic Set, Dungeon Masters Guidde, Playerr's Handbook, Deities and Demigods, Legends & Lore, Unearthed Arcana, Monster Manual, Fiend Folio, Monster Manual II, The Rogues Gallery, Oriental Adventures, DragonLance Adventures, Greyhawk Adventures. --v 6.0 --ar 1:9
|
| 204 |
def get_image_as_base64(url):
|
| 205 |
response = requests.get(url)
|
| 206 |
if response.status_code == 200:
|
|
|
|
| 213 |
href = f'<a href="data:file/png;base64,{base64_str}" download="{filename}">Download Image</a>'
|
| 214 |
return href
|
| 215 |
|
| 216 |
+
# List of image URLs - These can be copied and pasted from clipboard to get commit URL of autosaved image base64 as png link
|
| 217 |
image_urls = [
|
| 218 |
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/o1FI3G_BueAAanLBeqoo3.png",
|
| 219 |
+
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/ZRZXM6kXqct-IKs6xqD5n.png",
|
| 220 |
+
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/PBV0gDGYzCwYIN6iv0rXL.png",
|
| 221 |
+
"https://cdn-uploads.huggingface.co/production/uploads/620630b603825909dcbeba35/nbZOuPUdXJ7OJZeT23rbE.png"
|
| 222 |
]
|
| 223 |
|
| 224 |
# Select a random URL from the list
|