eaglelandsonce commited on
Commit
1947481
1 Parent(s): 61817f9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +62 -38
app.py CHANGED
@@ -129,42 +129,66 @@ def vectara_query(query: str, config: dict):
129
  res = [[r['text'], r['score']] for r in responses]
130
  return res, summary
131
 
132
- # Streamlit UI setup
133
- st.title("Vectara Content Query Interface")
134
-
135
- # User inputs
136
- query = st.text_input("Enter your query here", "")
137
- lambda_val = st.slider("Lambda Value", min_value=0.0, max_value=1.0, value=0.5)
138
- top_k = st.number_input("Top K Results", min_value=1, max_value=50, value=10)
139
-
140
- if st.button("Query Vectara"):
141
- config = {
142
-
143
- "api_key": os.environ.get("VECTARA_API_KEY", ""),
144
- "customer_id": os.environ.get("VECTARA_CUSTOMER_ID", ""),
145
- "corpus_id": os.environ.get("VECTARA_CORPUS_ID", ""),
146
-
147
- "lambda_val": lambda_val,
148
- "top_k": top_k,
149
- }
150
-
151
- results, summary = vectara_query(query, config)
152
-
153
- if results:
154
- st.subheader("Summary")
155
- st.write(summary)
156
-
157
- st.subheader("Top Results")
158
-
159
- # Extract texts from results
160
- texts = [r[0] for r in results[:5]]
161
-
162
- # Compute HHEM scores
163
- scores = compute_hhem_scores(texts, summary)
164
-
165
- # Prepare and display the dataframe
166
- df = pd.DataFrame({'Fact': texts, 'HHEM Score': scores})
167
- st.dataframe(df)
168
- else:
169
- st.write("No results found.")
170
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  res = [[r['text'], r['score']] for r in responses]
130
  return res, summary
131
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
+ # Create the main app with three tabs
134
+ tab1, tab2, tab3 = st.tabs(["Synthetic Data", "Data Query", "HHEM-Victara Query Tuner"])
135
+
136
+ with tab1:
137
+ st.header("Synthetic Data")
138
+ # Placeholder for Synthetic Data functionality
139
+ st.write("Here you can generate or manage synthetic data.")
140
+
141
+ with tab2:
142
+ st.header("Data Query")
143
+ # Placeholder for Data Query functionality
144
+ st.write("Here you can perform data queries.")
145
+ # Example of a simple query input
146
+ query_input = st.text_input("Enter your query here")
147
+ if st.button("Execute Query"):
148
+ # Placeholder for query execution logic
149
+ st.write(f"Executing query: {query_input}")
150
+
151
+ with tab3:
152
+ st.header("HHEM-Victara Query Tuner")
153
+
154
+
155
+ # Streamlit UI setup
156
+ st.title("HHEM-Vectara Query Tuning")
157
+
158
+ # User inputs
159
+ query = st.text_input("Enter your query here", "")
160
+ lambda_val = st.slider("Lambda Value", min_value=0.0, max_value=1.0, value=0.5)
161
+ top_k = st.number_input("Top K Results", min_value=1, max_value=50, value=10)
162
+
163
+
164
+ if st.button("Query Vectara"):
165
+ config = {
166
+
167
+ "api_key": os.environ.get("VECTARA_API_KEY", ""),
168
+ "customer_id": os.environ.get("VECTARA_CUSTOMER_ID", ""),
169
+ "corpus_id": os.environ.get("VECTARA_CORPUS_ID", ""),
170
+
171
+ "lambda_val": lambda_val,
172
+ "top_k": top_k,
173
+ }
174
+
175
+ results, summary = vectara_query(query, config)
176
+
177
+ if results:
178
+ st.subheader("Summary")
179
+ st.write(summary)
180
+
181
+ st.subheader("Top Results")
182
+
183
+ # Extract texts from results
184
+ texts = [r[0] for r in results[:5]]
185
+
186
+ # Compute HHEM scores
187
+ scores = compute_hhem_scores(texts, summary)
188
+
189
+ # Prepare and display the dataframe
190
+ df = pd.DataFrame({'Fact': texts, 'HHEM Score': scores})
191
+ st.dataframe(df)
192
+ else:
193
+ st.write("No results found.")
194
+