Spaces:
Build error
Build error
Commit
·
cc87f36
1
Parent(s):
77a6da5
Update ui_utils.py
Browse files- ui_utils.py +8 -12
ui_utils.py
CHANGED
|
@@ -70,22 +70,18 @@ def display_query_input(client, selected_class, tokenizer, model): # Added para
|
|
| 70 |
st.write(f"Selected class type: {type(selected_class)}, Value: {selected_class}")
|
| 71 |
|
| 72 |
|
| 73 |
-
|
| 74 |
def query_tapas_with_weaviate_data(client, selected_class, question, tokenizer, model):
|
| 75 |
-
#
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
#
|
| 80 |
-
table = weaviate_utils.convert_to_tapas_format(
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
# 3. Call TAPAS with the table and the question
|
| 84 |
answers = tapas_utils.ask_llm_chunk(tokenizer, model, table, [question])
|
| 85 |
-
st.write(f"TAPAS answers: {answers}") # Logging data from TAPAS Answers
|
| 86 |
-
|
| 87 |
# Display the answers
|
| 88 |
for answer in answers:
|
| 89 |
st.write(f"Answer: {answer}")
|
| 90 |
|
| 91 |
|
|
|
|
|
|
| 70 |
st.write(f"Selected class type: {type(selected_class)}, Value: {selected_class}")
|
| 71 |
|
| 72 |
|
|
|
|
| 73 |
def query_tapas_with_weaviate_data(client, selected_class, question, tokenizer, model):
|
| 74 |
+
# Embed the question
|
| 75 |
+
question_embedding = tapas_utils.embed_table(pd.DataFrame([question], columns=["Question"]))
|
| 76 |
+
# Retrieve the most relevant table
|
| 77 |
+
table = weaviate_utils.retrieve_relevant_table(client, selected_class, question_embedding)
|
| 78 |
+
# Convert the table to TAPAS format
|
| 79 |
+
table = weaviate_utils.convert_to_tapas_format(table)
|
| 80 |
+
# Call TAPAS with the table and the question
|
|
|
|
|
|
|
| 81 |
answers = tapas_utils.ask_llm_chunk(tokenizer, model, table, [question])
|
|
|
|
|
|
|
| 82 |
# Display the answers
|
| 83 |
for answer in answers:
|
| 84 |
st.write(f"Answer: {answer}")
|
| 85 |
|
| 86 |
|
| 87 |
+
|