Rewrites / data_utils.py
Veronika Belova
add new files
f9668b6
raw
history blame
617 Bytes
import pandas as pd
import streamlit as st
@st.cache_data
def load_data(file_path):
data = pd.read_excel(file_path)
return data
def get_random_review(data):
return data['body'].sample(n=1).iloc[0]
@st.cache_resource
def read_prompt(file_path):
try:
with open(file_path, 'r', encoding='utf-8') as file:
instruction = file.read()
return instruction
except FileNotFoundError:
st.error(f"Файл {file_path} не найден.")
st.stop()
except Exception as e:
st.error(f"Ошибка при чтении файла: {e}")
st.stop()