Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -89,4 +89,25 @@ else:
|
|
89 |
rows_info = [f"Row {coordinate[0] + 1}, Column '{df.columns[coordinate[1]]}' with value {cell}"
|
90 |
for coordinate, cell in zip(coordinates, cells)]
|
91 |
rows_description = " and ".join(rows_info)
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
rows_info = [f"Row {coordinate[0] + 1}, Column '{df.columns[coordinate[1]]}' with value {cell}"
|
90 |
for coordinate, cell in zip(coordinates, cells)]
|
91 |
rows_description = " and ".join(rows_info)
|
92 |
+
|
93 |
+
base_sentence += f" This includes the following data: {rows_description}."
|
94 |
+
|
95 |
+
# Generate a fluent response using the T5 model, rephrasing the base sentence
|
96 |
+
input_text = f"Given the question: '{question}', generate a more human-readable response: {base_sentence}"
|
97 |
+
|
98 |
+
# Tokenize the input and generate a fluent response using T5
|
99 |
+
inputs = t5_tokenizer.encode(input_text, return_tensors="pt", max_length=512, truncation=True)
|
100 |
+
summary_ids = t5_model.generate(inputs, max_length=150, num_beams=4, early_stopping=True)
|
101 |
+
|
102 |
+
# Decode the generated text
|
103 |
+
generated_text = t5_tokenizer.decode(summary_ids[0], skip_special_tokens=True)
|
104 |
+
|
105 |
+
# Display the final generated response
|
106 |
+
st.markdown("<p style='font-family:sans-serif;font-size: 0.9rem;'> Final Generated Response with LLM: </p>", unsafe_allow_html=True)
|
107 |
+
st.success(generated_text)
|
108 |
+
|
109 |
+
except Exception as e:
|
110 |
+
st.warning(f"Error processing question or generating answer: {str(e)}")
|
111 |
+
st.warning("Please retype your question and make sure to use the column name and cell value correctly.")
|
112 |
+
|
113 |
+
st.balloons()
|