DeepVen commited on
Commit
1a5de94
β€’
1 Parent(s): 98cdbe9

Upload 3 files

Browse files
Files changed (3) hide show
  1. .streamlit/config.toml +9 -5
  2. streamapp.py +67 -17
  3. test-logo.png +0 -0
.streamlit/config.toml CHANGED
@@ -9,10 +9,14 @@
9
  #secondaryBackgroundColor = '#55B2FF' # Lighter Blue
10
 
11
 
12
- primaryColor="#ff4b4b"
13
- backgroundColor="#00325B"
14
- secondaryBackgroundColor="#262730"
15
- textColor="#fafafa"
16
- font="monospace"
17
 
18
 
 
 
 
 
 
9
  #secondaryBackgroundColor = '#55B2FF' # Lighter Blue
10
 
11
 
12
+ #primaryColor="#ff4b4b"
13
+ #backgroundColor="#00325B"
14
+ #secondaryBackgroundColor="#262730"
15
+ #textColor="#fafafa"
16
+ #font="monospace"
17
 
18
 
19
+
20
+ base="light"
21
+ primaryColor="#efa729"
22
+ textColor="#3a0aa6"
streamapp.py CHANGED
@@ -32,8 +32,15 @@ import pandas as pd
32
  # from sklearn import datasets
33
  # from sklearn.ensemble import RandomForestClassifier
34
 
 
 
 
35
  global trace_df
36
 
 
 
 
 
37
  @st.cache_resource
38
  def tracer_config():
39
  #phoenix setup
@@ -42,15 +49,17 @@ def tracer_config():
42
  tracer = OpenInferenceTracer()
43
  # If no tracer is specified, a tracer is constructed for you
44
  LangChainInstrumentor(tracer).instrument()
45
- time.sleep(10)
46
  print(session.url)
47
 
48
  tracer_config()
49
 
50
- tab1, tab2 = st.tabs(["πŸ“ˆ RAG", "πŸ—ƒ FactVsHallucinate" ])
51
 
52
 
53
 
 
 
 
54
 
55
  os.environ["HUGGINGFACEHUB_API_TOKEN"] = "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"
56
 
@@ -156,11 +165,21 @@ def _load_docs(path: str):
156
 
157
 
158
  def rag_response(response):
159
- st.markdown("""<hr style="height:10px;border:none;color:#333;background-color:#333;" /> """, unsafe_allow_html=True)
160
- st.subheader('RAG response')
161
- st.text_area(label="user query", value=response["query"], height=30)
162
- st.text_area(label="RAG output", value=response["result"])
163
- st.text_area(label="Augmented knowledge", value=response["source_documents"])
 
 
 
 
 
 
 
 
 
 
164
 
165
  #st.button("Check Hallucination")
166
 
@@ -182,7 +201,8 @@ def hallu_eval(question: str, answer: str, context: str):
182
  }
183
  )
184
  print("got hallu score")
185
- st.text_area(label="Hallucinated?", value=hallucination_score, height=30)
 
186
  #return {"hallucination_score": hallucination_score}
187
  #time.sleep(10)
188
 
@@ -215,12 +235,32 @@ with tab1:
215
 
216
  #print("lenght in tab1, ", len(vectorstore.serialize_to_bytes()))
217
  options = ["true", "false"]
218
- question = st.text_input(label="user question", value="", label_visibility="visible", disabled=False)
219
- evaluate = st.selectbox(label="Evaluation",options=options, index=0, placeholder="Choose an option", disabled=False, label_visibility="visible")
220
-
221
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
 
223
- if st.form_submit_button("RAG with evaluation"):
224
  print("retrie ,", retriever)
225
  chain = RetrievalQA.from_chain_type(
226
  llm=llm,
@@ -260,9 +300,9 @@ with tab2:
260
 
261
 
262
  #print("lenght in tab2, ", len(vectorstore.serialize_to_bytes()))
263
- question = st.text_input(label="question", value="", label_visibility="visible", disabled=False)
264
- answer = st.text_input(label="answer", value="", label_visibility="visible", disabled=False)
265
- context = st.text_input(label="context", value="", label_visibility="visible", disabled=False)
266
 
267
 
268
  if st.form_submit_button("Evaluate"):
@@ -347,4 +387,14 @@ def rag():
347
  #st.write("Doing more optional stuff")
348
 
349
 
350
- return(response)
 
 
 
 
 
 
 
 
 
 
 
32
  # from sklearn import datasets
33
  # from sklearn.ensemble import RandomForestClassifier
34
 
35
+ from PIL import Image
36
+
37
+
38
  global trace_df
39
 
40
+ # Page config
41
+ st.set_page_config(page_title="RAG PoC", layout="wide")
42
+ st.sidebar.image(Image.open("./test-logo.png"), use_column_width=True)
43
+
44
  @st.cache_resource
45
  def tracer_config():
46
  #phoenix setup
 
49
  tracer = OpenInferenceTracer()
50
  # If no tracer is specified, a tracer is constructed for you
51
  LangChainInstrumentor(tracer).instrument()
52
+ time.sleep(3)
53
  print(session.url)
54
 
55
  tracer_config()
56
 
 
57
 
58
 
59
 
60
+ tab1, tab2 = st.tabs(["πŸ“ˆ **RAG**", "πŸ—ƒ FactVsHallucinate" ])
61
+
62
+
63
 
64
  os.environ["HUGGINGFACEHUB_API_TOKEN"] = "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"
65
 
 
165
 
166
 
167
  def rag_response(response):
168
+ #st.markdown("""<hr style="height:10px;border:none;color:#333;background-color:#333;" /> """, unsafe_allow_html=True)
169
+
170
+ #st.markdown(".stTextInput > label {font-size:105%; font-weight:bold; color:blue;} ",unsafe_allow_html=True) #for all text-input label sections
171
+
172
+ question_title = '<h1 style="color:#33ff33;font-size:24px;">Question</h1>'
173
+
174
+
175
+
176
+ st.markdown('<h1 style="color:#100170;font-size:48px;text-align:center;">RAG Response</h1>', unsafe_allow_html=True)
177
+ st.markdown('<h1 style="color:#100170;font-size:24px;">Question</h1>', unsafe_allow_html=True)
178
+ st.text_area(label="", value=response["query"], height=30)
179
+ st.markdown('<h1 style="color:#100170;font-size:24px;">RAG Output</h1>', unsafe_allow_html=True)
180
+ st.text_area(label="", value=response["result"])
181
+ st.markdown('<h1 style="color:#100170;font-size:24px;">Augmented knowledge</h1>', unsafe_allow_html=True)
182
+ st.text_area(label="", value=response["source_documents"])
183
 
184
  #st.button("Check Hallucination")
185
 
 
201
  }
202
  )
203
  print("got hallu score")
204
+ st.markdown('<h1 style="color:#100170;font-size:24px;">Hallucinated?</h1>', unsafe_allow_html=True)
205
+ st.text_area(label=" ", value=hallucination_score, height=30)
206
  #return {"hallucination_score": hallucination_score}
207
  #time.sleep(10)
208
 
 
235
 
236
  #print("lenght in tab1, ", len(vectorstore.serialize_to_bytes()))
237
  options = ["true", "false"]
238
+
239
+ st.markdown('<h1 style="color:#100170;font-size:24px;">User Query</h1>', unsafe_allow_html=True)
240
+
241
+ question = st.text_input(label="", value="", placeholder="Type in question",label_visibility="visible", disabled=False)
242
+ #st.markdown('<h2 style="color:#3a0aa6;font-size:24px;">Evaluation</h2>', unsafe_allow_html=True)
243
+ evaluate = st.selectbox(label="***Perform Evaluation?***",options=options, index=1, placeholder="Choose an option", disabled=False, label_visibility="visible")
244
+
245
+ m = st.markdown("""
246
+ <style>
247
+ div.stButton > button:first-child {
248
+ background-color: #100170;
249
+ color:#ffffff;
250
+ }
251
+ div.stButton > button:hover {
252
+ background-color: #00ff00;
253
+ color:#ff0000;
254
+ }
255
+ </style>""", unsafe_allow_html=True)
256
+
257
+ #st.markdown("----", unsafe_allow_html=True)
258
+ columns = st.columns([2,1,2])
259
+
260
+ if columns[1].form_submit_button(" Start RAG "):
261
+
262
+ st.markdown("""<hr style="height:10px;border:none;color:#333;background-color: #100170;" /> """, unsafe_allow_html=True)
263
 
 
264
  print("retrie ,", retriever)
265
  chain = RetrievalQA.from_chain_type(
266
  llm=llm,
 
300
 
301
 
302
  #print("lenght in tab2, ", len(vectorstore.serialize_to_bytes()))
303
+ question = st.text_input(label="**Question**", value="", label_visibility="visible", disabled=False)
304
+ answer = st.text_input(label="**answer**", value="", label_visibility="visible", disabled=False)
305
+ context = st.text_input(label="**context**", value="", label_visibility="visible", disabled=False)
306
 
307
 
308
  if st.form_submit_button("Evaluate"):
 
387
  #st.write("Doing more optional stuff")
388
 
389
 
390
+ return(response)
391
+
392
+
393
+ a = st.markdown("""
394
+ <style>
395
+ div.stTextArea > textarea {
396
+ background-color: #0099ff;
397
+ height: 1400px;
398
+ width: 800px;
399
+ }
400
+ </style>""", unsafe_allow_html=True)
test-logo.png ADDED