Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -12,8 +12,131 @@ from langchain_community.vectorstores import Chroma
|
|
12 |
from langchain.chains import RetrievalQA
|
13 |
import re
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
# Page Configuration
|
16 |
-
st.set_page_config(
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
# Constants
|
19 |
DEFAULT_GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|
|
|
12 |
from langchain.chains import RetrievalQA
|
13 |
import re
|
14 |
|
15 |
+
# Custom CSS Injection
|
16 |
+
def inject_custom_css():
|
17 |
+
st.markdown("""
|
18 |
+
<style>
|
19 |
+
/* Main container */
|
20 |
+
.stApp {
|
21 |
+
background: linear-gradient(135deg, #1a1a1a, #2d2d2d);
|
22 |
+
color: #e0e0e0;
|
23 |
+
}
|
24 |
+
|
25 |
+
/* Chat containers */
|
26 |
+
.stChatMessage {
|
27 |
+
padding: 1.5rem;
|
28 |
+
border-radius: 15px;
|
29 |
+
margin: 1rem 0;
|
30 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
31 |
+
}
|
32 |
+
|
33 |
+
/* User message styling */
|
34 |
+
[data-testid="stChatMessage"][aria-label="user"] {
|
35 |
+
background-color: #2d2d2d;
|
36 |
+
border: 1px solid #3d3d3d;
|
37 |
+
margin-left: 10%;
|
38 |
+
}
|
39 |
+
|
40 |
+
/* Assistant message styling */
|
41 |
+
[data-testid="stChatMessage"][aria-label="assistant"] {
|
42 |
+
background-color: #004d40;
|
43 |
+
border: 1px solid #00695c;
|
44 |
+
margin-right: 10%;
|
45 |
+
}
|
46 |
+
|
47 |
+
/* Sidebar styling */
|
48 |
+
[data-testid="stSidebar"] {
|
49 |
+
background: #121212 !important;
|
50 |
+
border-right: 2px solid #2d2d2d;
|
51 |
+
padding: 1rem;
|
52 |
+
}
|
53 |
+
|
54 |
+
/* Button styling */
|
55 |
+
.stButton>button {
|
56 |
+
background: linear-gradient(45deg, #00695c, #004d40);
|
57 |
+
color: white !important;
|
58 |
+
border: none;
|
59 |
+
border-radius: 8px;
|
60 |
+
padding: 0.8rem 1.5rem;
|
61 |
+
transition: all 0.3s;
|
62 |
+
font-weight: 500;
|
63 |
+
}
|
64 |
+
|
65 |
+
.stButton>button:hover {
|
66 |
+
transform: translateY(-2px);
|
67 |
+
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
|
68 |
+
}
|
69 |
+
|
70 |
+
/* File uploader */
|
71 |
+
[data-testid="stFileUploader"] {
|
72 |
+
border: 2px dashed #3d3d3d;
|
73 |
+
border-radius: 10px;
|
74 |
+
padding: 1rem;
|
75 |
+
background: #2d2d2d;
|
76 |
+
}
|
77 |
+
|
78 |
+
/* Input field */
|
79 |
+
.stTextInput>div>div>input {
|
80 |
+
background-color: #2d2d2d;
|
81 |
+
color: white;
|
82 |
+
border: 1px solid #3d3d3d;
|
83 |
+
border-radius: 8px;
|
84 |
+
padding: 0.8rem;
|
85 |
+
}
|
86 |
+
|
87 |
+
/* Spinner color */
|
88 |
+
.stSpinner>div>div {
|
89 |
+
border-color: #00bcd4 transparent transparent transparent;
|
90 |
+
}
|
91 |
+
|
92 |
+
/* Custom title styling */
|
93 |
+
.title-text {
|
94 |
+
background: linear-gradient(45deg, #00bcd4, #00695c);
|
95 |
+
-webkit-background-clip: text;
|
96 |
+
-webkit-text-fill-color: transparent;
|
97 |
+
font-family: 'Roboto', sans-serif;
|
98 |
+
font-size: 2.8rem;
|
99 |
+
text-align: center;
|
100 |
+
margin-bottom: 2rem;
|
101 |
+
letter-spacing: -0.5px;
|
102 |
+
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
|
103 |
+
}
|
104 |
+
|
105 |
+
/* Similar questions buttons */
|
106 |
+
.stButton>button.similar-q {
|
107 |
+
background: #2d2d2d;
|
108 |
+
border: 1px solid #00bcd4;
|
109 |
+
color: #00bcd4 !important;
|
110 |
+
white-space: normal;
|
111 |
+
height: auto;
|
112 |
+
min-height: 3rem;
|
113 |
+
transition: all 0.3s;
|
114 |
+
}
|
115 |
+
|
116 |
+
/* Hover effects */
|
117 |
+
.stButton>button.similar-q:hover {
|
118 |
+
background: #004d40 !important;
|
119 |
+
transform: scale(1.02);
|
120 |
+
}
|
121 |
+
|
122 |
+
/* Source text styling */
|
123 |
+
.source-text {
|
124 |
+
color: #00bcd4;
|
125 |
+
font-size: 0.9rem;
|
126 |
+
margin-top: 1rem;
|
127 |
+
padding-top: 0.5rem;
|
128 |
+
border-top: 1px solid #3d3d3d;
|
129 |
+
}
|
130 |
+
</style>
|
131 |
+
""", unsafe_allow_html=True)
|
132 |
+
|
133 |
# Page Configuration
|
134 |
+
st.set_page_config(
|
135 |
+
page_title="AI Law Agent",
|
136 |
+
page_icon="⚖️",
|
137 |
+
layout="centered",
|
138 |
+
initial_sidebar_state="expanded"
|
139 |
+
)
|
140 |
|
141 |
# Constants
|
142 |
DEFAULT_GROQ_API_KEY = os.getenv("GROQ_API_KEY")
|