Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,16 +1,16 @@
|
|
1 |
-
|
2 |
-
import os
|
3 |
-
os.environ['VECTARA_API_KEY'] = 'zwt_MD0gpPStP7DARQICFDZ4XIolYlRvi7qYm61HcA'
|
4 |
-
os.environ['VECTARA_CORPUS_ID'] = '5'
|
5 |
-
os.environ['VECTARA_CUSTOMER_ID']='809312420'
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
import os
|
11 |
import json
|
12 |
import requests
|
13 |
import streamlit as st
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
def vectara_query(query: str, config: dict) -> None:
|
16 |
|
@@ -91,19 +91,30 @@ config = {
|
|
91 |
}
|
92 |
|
93 |
# Streamlit app
|
94 |
-
st.title("
|
95 |
|
96 |
# Input for the query
|
97 |
-
query = st.text_input("Enter your query:", "What does
|
98 |
|
99 |
# Button to trigger the query
|
100 |
if st.button("Run Query"):
|
101 |
results, summary = vectara_query(query, config)
|
102 |
|
103 |
-
|
104 |
-
st.header("Results")
|
105 |
-
st.write(results)
|
106 |
|
107 |
# Display summary
|
108 |
st.header("Summary")
|
109 |
-
st.write(summary)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import os
|
2 |
import json
|
3 |
import requests
|
4 |
import streamlit as st
|
5 |
+
import pandas as pd
|
6 |
+
from sentence_transformers import CrossEncoder
|
7 |
+
import numpy as np
|
8 |
+
|
9 |
+
np.set_printoptions(suppress=True, precision=4)
|
10 |
+
|
11 |
+
model = CrossEncoder('vectara/hallucination_evaluation_model')
|
12 |
+
pd.set_option('display.width', 100)
|
13 |
+
pd.set_option('display.max_colwidth', None) # Use None to display full content without truncation
|
14 |
|
15 |
def vectara_query(query: str, config: dict) -> None:
|
16 |
|
|
|
91 |
}
|
92 |
|
93 |
# Streamlit app
|
94 |
+
st.title("Vectara Query App")
|
95 |
|
96 |
# Input for the query
|
97 |
+
query = st.text_input("Enter your query:", "What does Vectara do?")
|
98 |
|
99 |
# Button to trigger the query
|
100 |
if st.button("Run Query"):
|
101 |
results, summary = vectara_query(query, config)
|
102 |
|
103 |
+
|
|
|
|
|
104 |
|
105 |
# Display summary
|
106 |
st.header("Summary")
|
107 |
+
st.write(summary)
|
108 |
+
|
109 |
+
# Additional processing
|
110 |
+
st.header("Additional Processing")
|
111 |
+
|
112 |
+
# Get texts and scores
|
113 |
+
texts = [r[0] for r in results[:5]]
|
114 |
+
scores = [model.predict([text, summary]) for text in texts]
|
115 |
+
|
116 |
+
# Create DataFrame
|
117 |
+
df = pd.DataFrame({'fact': texts, 'HHEM score': scores})
|
118 |
+
|
119 |
+
# Display DataFrame
|
120 |
+
st.write(df)
|