Spaces:
Sleeping
Sleeping
Stefan Ivchenko
commited on
Commit
·
c0c6c45
1
Parent(s):
adfa010
Add RAG + UI (no env, no binary DB)
Browse files- .gitignore +6 -1
- app.py +105 -2
- app_copy.py +10 -0
- data/illiad.txt +0 -0
- data/odysee.txt +0 -0
- odysee.txt +0 -0
.gitignore
CHANGED
|
@@ -1 +1,6 @@
|
|
| 1 |
-
.env
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
.env
|
| 2 |
+
rag_db/
|
| 3 |
+
.env
|
| 4 |
+
__pycache__/
|
| 5 |
+
rag_db/
|
| 6 |
+
chroma_db/
|
app.py
CHANGED
|
@@ -66,9 +66,112 @@ def respond(message, history):
|
|
| 66 |
reply = output["choices"][0]["text"].strip()
|
| 67 |
return reply
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
chat = gr.ChatInterface(
|
| 70 |
-
respond,
|
| 71 |
-
title="
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 72 |
)
|
| 73 |
|
| 74 |
if __name__ == "__main__":
|
|
|
|
| 66 |
reply = output["choices"][0]["text"].strip()
|
| 67 |
return reply
|
| 68 |
|
| 69 |
+
dark_academia_css = """
|
| 70 |
+
body {
|
| 71 |
+
background: radial-gradient(circle at top, #151521 0, #050509 55%, #000000 100%);
|
| 72 |
+
color: #e0d9c6;
|
| 73 |
+
font-family: "Georgia", "Times New Roman", serif;
|
| 74 |
+
}
|
| 75 |
+
|
| 76 |
+
/* Main container */
|
| 77 |
+
.gradio-container {
|
| 78 |
+
background: transparent !important;
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
/* Title & description */
|
| 82 |
+
h1, h2, h3, .prose h1, .prose h2, .prose h3 {
|
| 83 |
+
color: #f5f1e6 !important;
|
| 84 |
+
letter-spacing: 0.08em;
|
| 85 |
+
text-transform: uppercase;
|
| 86 |
+
}
|
| 87 |
+
|
| 88 |
+
.prose, .prose p, .dark .prose, .dark .prose p {
|
| 89 |
+
color: #e0d9c6 !important;
|
| 90 |
+
}
|
| 91 |
+
|
| 92 |
+
/* Chat box card */
|
| 93 |
+
.gr-chat-interface {
|
| 94 |
+
background: rgba(5, 5, 12, 0.85) !important;
|
| 95 |
+
border-radius: 18px !important;
|
| 96 |
+
border: 1px solid rgba(196, 164, 110, 0.4) !important;
|
| 97 |
+
box-shadow:
|
| 98 |
+
0 0 25px rgba(0, 0, 0, 0.9),
|
| 99 |
+
0 0 60px rgba(84, 63, 140, 0.4);
|
| 100 |
+
}
|
| 101 |
+
|
| 102 |
+
/* Chat messages */
|
| 103 |
+
.gr-chat-message {
|
| 104 |
+
border-radius: 12px !important;
|
| 105 |
+
border: 1px solid rgba(255, 255, 255, 0.04) !important;
|
| 106 |
+
backdrop-filter: blur(6px);
|
| 107 |
+
}
|
| 108 |
+
|
| 109 |
+
.gr-chat-message.user {
|
| 110 |
+
background: radial-gradient(circle at top left,
|
| 111 |
+
rgba(196, 164, 110, 0.16),
|
| 112 |
+
rgba(15, 15, 25, 0.95)
|
| 113 |
+
) !important;
|
| 114 |
+
border-left: 3px solid #c4a46e !important;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
.gr-chat-message.bot {
|
| 118 |
+
background: radial-gradient(circle at top left,
|
| 119 |
+
rgba(127, 90, 240, 0.18),
|
| 120 |
+
rgba(8, 8, 18, 0.96)
|
| 121 |
+
) !important;
|
| 122 |
+
border-left: 3px solid #7f5af0 !important;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
/* Input area */
|
| 126 |
+
textarea, .gr-text-input, .gr-textbox {
|
| 127 |
+
background: rgba(10, 10, 18, 0.95) !important;
|
| 128 |
+
border-radius: 999px !important;
|
| 129 |
+
border: 1px solid rgba(196, 164, 110, 0.5) !important;
|
| 130 |
+
color: #f5f1e6 !important;
|
| 131 |
+
}
|
| 132 |
+
|
| 133 |
+
/* Buttons */
|
| 134 |
+
button, .gr-button {
|
| 135 |
+
background: linear-gradient(135deg, #7f5af0, #c4a46e) !important;
|
| 136 |
+
border-radius: 999px !important;
|
| 137 |
+
border: none !important;
|
| 138 |
+
color: #fdfaf0 !important;
|
| 139 |
+
font-weight: 600 !important;
|
| 140 |
+
letter-spacing: 0.08em;
|
| 141 |
+
text-transform: uppercase;
|
| 142 |
+
box-shadow: 0 0 18px rgba(0, 0, 0, 0.8);
|
| 143 |
+
}
|
| 144 |
+
|
| 145 |
+
button:hover, .gr-button:hover {
|
| 146 |
+
filter: brightness(1.06);
|
| 147 |
+
box-shadow:
|
| 148 |
+
0 0 18px rgba(127, 90, 240, 0.7),
|
| 149 |
+
0 0 30px rgba(196, 164, 110, 0.6);
|
| 150 |
+
}
|
| 151 |
+
|
| 152 |
+
/* Scrollbar */
|
| 153 |
+
::-webkit-scrollbar {
|
| 154 |
+
width: 8px;
|
| 155 |
+
}
|
| 156 |
+
::-webkit-scrollbar-track {
|
| 157 |
+
background: transparent;
|
| 158 |
+
}
|
| 159 |
+
::-webkit-scrollbar-thumb {
|
| 160 |
+
background: rgba(196, 164, 110, 0.6);
|
| 161 |
+
border-radius: 999px;
|
| 162 |
+
}
|
| 163 |
+
"""
|
| 164 |
+
|
| 165 |
+
|
| 166 |
chat = gr.ChatInterface(
|
| 167 |
+
fn=respond,
|
| 168 |
+
title="Obsidian Oracle: Archives of Myth",
|
| 169 |
+
description=(
|
| 170 |
+
"Enter the candlelit archives of forgotten epics. "
|
| 171 |
+
"The Obsidian Oracle answers in a dark-academia tone, drawing on "
|
| 172 |
+
"the Iliad, the Odyssey, and other fragments of ancient lore."
|
| 173 |
+
),
|
| 174 |
+
css=dark_academia_css,
|
| 175 |
)
|
| 176 |
|
| 177 |
if __name__ == "__main__":
|
app_copy.py
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
import subprocess
|
| 3 |
+
import sys, platform
|
| 4 |
+
from importlib import metadata as md
|
| 5 |
+
from rag_db import *
|
| 6 |
+
# Download your GGUF from HF Hub
|
| 7 |
+
|
| 8 |
+
|
| 9 |
+
db = init_vectorstore()
|
| 10 |
+
retriever = db.as_retriever(search_kwargs={"k": 1}) # how much to retrive
|
data/illiad.txt
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
data/odysee.txt
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
odysee.txt
DELETED
|
The diff for this file is too large to render.
See raw diff
|
|
|