Update app.py
Browse files
app.py
CHANGED
|
@@ -124,17 +124,29 @@ if submitted:
|
|
| 124 |
input_text = make_query(description, question)
|
| 125 |
try:
|
| 126 |
input_ids = tokenizer.encode(input_text, return_tensors="pt")
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
except Exception as e:
|
| 139 |
st.error(f"Ошибка при генерации: {str(e)}")
|
| 140 |
else:
|
|
|
|
| 124 |
input_text = make_query(description, question)
|
| 125 |
try:
|
| 126 |
input_ids = tokenizer.encode(input_text, return_tensors="pt")
|
| 127 |
+
|
| 128 |
+
animation_placeholder = st.empty()
|
| 129 |
+
|
| 130 |
+
for frame in ["⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"]:
|
| 131 |
+
animation_placeholder.markdown(f"`{frame}` Подготовка к генерации...")
|
| 132 |
+
time.sleep(0.1)
|
| 133 |
+
|
| 134 |
+
animation_placeholder.markdown("`⏳` Генерация SQL-запроса...")
|
| 135 |
+
outputs = model.generate(
|
| 136 |
+
input_ids,
|
| 137 |
+
max_length=200,
|
| 138 |
+
num_beams=5,
|
| 139 |
+
top_p=0.95,
|
| 140 |
+
early_stopping=True,
|
| 141 |
+
pad_token_id=tokenizer.eos_token_id,
|
| 142 |
+
)
|
| 143 |
+
|
| 144 |
+
animation_placeholder.empty()
|
| 145 |
+
|
| 146 |
+
generated_sql = tokenizer.decode(outputs[0], skip_special_tokens=True)
|
| 147 |
+
st.subheader("Результат:")
|
| 148 |
+
st.code(generated_sql, language="sql")
|
| 149 |
+
|
| 150 |
except Exception as e:
|
| 151 |
st.error(f"Ошибка при генерации: {str(e)}")
|
| 152 |
else:
|