Spaces:
Sleeping
Sleeping
Stefan Ivchenko
commited on
Commit
·
165047d
1
Parent(s):
c0c6c45
pics
Browse files
app.py
CHANGED
|
@@ -33,7 +33,7 @@ llm = Llama(
|
|
| 33 |
def respond(message, history):
|
| 34 |
# 1. Retrieve Context
|
| 35 |
context = ask(message, retriver_moedel=retriever)
|
| 36 |
-
print(context)
|
| 37 |
|
| 38 |
# 2. Define System/Contextual Prompt
|
| 39 |
system_instruction = (
|
|
@@ -73,25 +73,121 @@ body {
|
|
| 73 |
font-family: "Georgia", "Times New Roman", serif;
|
| 74 |
}
|
| 75 |
|
| 76 |
-
/*
|
| 77 |
-
.
|
| 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 |
-
|
| 89 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
}
|
| 91 |
|
| 92 |
/* Chat box card */
|
| 93 |
.gr-chat-interface {
|
| 94 |
-
background: rgba(5, 5, 12, 0.
|
| 95 |
border-radius: 18px !important;
|
| 96 |
border: 1px solid rgba(196, 164, 110, 0.4) !important;
|
| 97 |
box-shadow:
|
|
@@ -163,16 +259,37 @@ button:hover, .gr-button:hover {
|
|
| 163 |
"""
|
| 164 |
|
| 165 |
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
if __name__ == "__main__":
|
| 178 |
chat.launch()
|
|
|
|
| 33 |
def respond(message, history):
|
| 34 |
# 1. Retrieve Context
|
| 35 |
context = ask(message, retriver_moedel=retriever)
|
| 36 |
+
print("---------------------- CONTEXT FOUND --------------------",context)
|
| 37 |
|
| 38 |
# 2. Define System/Contextual Prompt
|
| 39 |
system_instruction = (
|
|
|
|
| 73 |
font-family: "Georgia", "Times New Roman", serif;
|
| 74 |
}
|
| 75 |
|
| 76 |
+
/* Optional: classical-looking font for headings */
|
| 77 |
+
@import url('https://fonts.googleapis.com/css2?family=Cardo:wght@400;700&display=swap');
|
|
|
|
|
|
|
| 78 |
|
|
|
|
| 79 |
h1, h2, h3, .prose h1, .prose h2, .prose h3 {
|
| 80 |
+
font-family: "Cardo", "Georgia", serif;
|
| 81 |
color: #f5f1e6 !important;
|
| 82 |
letter-spacing: 0.08em;
|
| 83 |
text-transform: uppercase;
|
| 84 |
}
|
| 85 |
|
| 86 |
+
/* Main container */
|
| 87 |
+
.gradio-container {
|
| 88 |
+
background: transparent !important;
|
| 89 |
+
}
|
| 90 |
+
|
| 91 |
+
/* Hero section with pillars / image */
|
| 92 |
+
.hero {
|
| 93 |
+
position: relative;
|
| 94 |
+
margin: 0 auto 1.5rem auto;
|
| 95 |
+
max-width: 900px;
|
| 96 |
+
padding: 1.8rem 1.6rem 1.6rem 1.6rem;
|
| 97 |
+
border-radius: 22px;
|
| 98 |
+
border: 1px solid rgba(196, 164, 110, 0.5);
|
| 99 |
+
background:
|
| 100 |
+
radial-gradient(circle at top, rgba(196,164,110,0.12), rgba(5,5,10,0.96)),
|
| 101 |
+
linear-gradient(135deg, rgba(10,10,18,0.9), rgba(3,3,7,0.98));
|
| 102 |
+
box-shadow:
|
| 103 |
+
0 0 30px rgba(0, 0, 0, 0.9),
|
| 104 |
+
0 0 80px rgba(84, 63, 140, 0.55);
|
| 105 |
+
overflow: hidden;
|
| 106 |
+
}
|
| 107 |
+
|
| 108 |
+
/* Faded pillars on each side using pseudo-elements */
|
| 109 |
+
.hero::before,
|
| 110 |
+
.hero::after {
|
| 111 |
+
content: "";
|
| 112 |
+
position: absolute;
|
| 113 |
+
top: -10%;
|
| 114 |
+
width: 110px;
|
| 115 |
+
height: 140%;
|
| 116 |
+
background-image: url("https://i0.wp.com/www.bookofthrees.com/wp-content/uploads/2005/02/parthenon.jpg?w=1600&ssl=1");
|
| 117 |
+
background-size: contain;
|
| 118 |
+
background-repeat: no-repeat;
|
| 119 |
+
opacity: 0.12;
|
| 120 |
+
filter: grayscale(1);
|
| 121 |
+
mix-blend-mode: screen;
|
| 122 |
+
pointer-events: none;
|
| 123 |
+
}
|
| 124 |
+
|
| 125 |
+
.hero::before {
|
| 126 |
+
left: -10px;
|
| 127 |
+
}
|
| 128 |
+
|
| 129 |
+
.hero::after {
|
| 130 |
+
right: -10px;
|
| 131 |
+
transform: scaleX(-1);
|
| 132 |
+
}
|
| 133 |
+
|
| 134 |
+
/* Inner hero content so text doesn’t sit under pillars */
|
| 135 |
+
.hero-inner {
|
| 136 |
+
position: relative;
|
| 137 |
+
z-index: 1;
|
| 138 |
+
display: flex;
|
| 139 |
+
gap: 1.2rem;
|
| 140 |
+
align-items: center;
|
| 141 |
+
}
|
| 142 |
+
|
| 143 |
+
/* Circle “medallion” with a statue/Greek image */
|
| 144 |
+
.hero-image {
|
| 145 |
+
flex-shrink: 0;
|
| 146 |
+
width: 96px;
|
| 147 |
+
height: 96px;
|
| 148 |
+
border-radius: 999px;
|
| 149 |
+
overflow: hidden;
|
| 150 |
+
border: 2px solid rgba(196, 164, 110, 0.7);
|
| 151 |
+
box-shadow: 0 0 24px rgba(0, 0, 0, 0.9);
|
| 152 |
+
background: radial-gradient(circle at top, rgba(255,255,255,0.1), rgba(5,5,10,1));
|
| 153 |
+
}
|
| 154 |
+
|
| 155 |
+
.hero-image img {
|
| 156 |
+
width: 100%;
|
| 157 |
+
height: 100%;
|
| 158 |
+
object-fit: cover;
|
| 159 |
+
}
|
| 160 |
+
|
| 161 |
+
/* Hero title + subtitle */
|
| 162 |
+
.hero-text h1 {
|
| 163 |
+
margin: 0 0 0.35rem 0;
|
| 164 |
+
font-size: 1.3rem;
|
| 165 |
+
letter-spacing: 0.12em;
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
.hero-text p {
|
| 169 |
+
margin: 0;
|
| 170 |
+
font-size: 0.92rem;
|
| 171 |
+
color: #e0d9c6;
|
| 172 |
+
line-height: 1.5;
|
| 173 |
+
}
|
| 174 |
+
|
| 175 |
+
/* Subtle Greek key (meander) line under hero */
|
| 176 |
+
.hero-keyline {
|
| 177 |
+
margin-top: 0.9rem;
|
| 178 |
+
height: 1px;
|
| 179 |
+
background-image: linear-gradient(
|
| 180 |
+
90deg,
|
| 181 |
+
rgba(196,164,110,0),
|
| 182 |
+
rgba(196,164,110,0.8),
|
| 183 |
+
rgba(196,164,110,0)
|
| 184 |
+
);
|
| 185 |
+
opacity: 0.7;
|
| 186 |
}
|
| 187 |
|
| 188 |
/* Chat box card */
|
| 189 |
.gr-chat-interface {
|
| 190 |
+
background: rgba(5, 5, 12, 0.88) !important;
|
| 191 |
border-radius: 18px !important;
|
| 192 |
border: 1px solid rgba(196, 164, 110, 0.4) !important;
|
| 193 |
box-shadow:
|
|
|
|
| 259 |
"""
|
| 260 |
|
| 261 |
|
| 262 |
+
with gr.Blocks(css=dark_academia_css) as demo:
|
| 263 |
+
gr.HTML(
|
| 264 |
+
"""
|
| 265 |
+
<div class="hero">
|
| 266 |
+
<div class="hero-inner">
|
| 267 |
+
<div class="hero-image">
|
| 268 |
+
<img src="https://preview.redd.it/ancient-greek-marble-statue-of-in-a-toga-v0-ajlvj2xddwec1.jpg?width=640&crop=smart&auto=webp&s=9bf7b1439ea460e824e188c63633fe4bda87056f" alt="Homer">
|
| 269 |
+
</div>
|
| 270 |
+
<div class="hero-text">
|
| 271 |
+
<h1>Expert of the Iliad and the Odyssey</h1>
|
| 272 |
+
<p>
|
| 273 |
+
I am well read on Homer's most famous works – The Iliad and The Odyssey.
|
| 274 |
+
Ask me of heroes, gods, and monsters.
|
| 275 |
+
</p>
|
| 276 |
+
</div>
|
| 277 |
+
</div>
|
| 278 |
+
<div class="hero-keyline"></div>
|
| 279 |
+
</div>
|
| 280 |
+
"""
|
| 281 |
+
)
|
| 282 |
+
chat = gr.ChatInterface(
|
| 283 |
+
fn=respond,
|
| 284 |
+
title="Expert of the Iliad and the Odyssey",
|
| 285 |
+
description=(
|
| 286 |
+
"I am well read on Homer's most famous works - The Iliad and The Odyssey. "
|
| 287 |
+
"Ask me about these, or other mythological questions you may have. "
|
| 288 |
+
"I am older than the trees, and the goblins that live inside them, "
|
| 289 |
+
"and even the ghouls that haunt them. Tread lightly."
|
| 290 |
+
),
|
| 291 |
+
css=dark_academia_css,
|
| 292 |
+
)
|
| 293 |
|
| 294 |
if __name__ == "__main__":
|
| 295 |
chat.launch()
|
rag_db.py
CHANGED
|
@@ -34,7 +34,7 @@ def load_and_chunk():
|
|
| 34 |
|
| 35 |
# 2. Chunk them
|
| 36 |
splitter = RecursiveCharacterTextSplitter(
|
| 37 |
-
chunk_size=
|
| 38 |
chunk_overlap=150
|
| 39 |
)
|
| 40 |
return splitter.split_documents(docs)
|
|
|
|
| 34 |
|
| 35 |
# 2. Chunk them
|
| 36 |
splitter = RecursiveCharacterTextSplitter(
|
| 37 |
+
chunk_size=1200,
|
| 38 |
chunk_overlap=150
|
| 39 |
)
|
| 40 |
return splitter.split_documents(docs)
|