Titanic - Machine Learning from Disaster
참고 : 요청받은 프롬프트와 결과를 캐시로 저장한다.
from pandasai.llm.local_llm import LocalLLM
import streamlit as st
model = LocalLLM(
api_base="<http://localhost:11434/v1>",
model="llama3"
)
#st.UI-타이틀
st.title("Data analysis with PandasAl Agent")
#st.UI-데이터 세트로드
uploaded_file = st.sidebar.file_uploader(
"upload a CSV file",
type=['csv']
)
...
#st.UI-read & write
if uploaded_file is not None:
data = pd.read_csv(uploaded_file)
st.write(data.head(3))
agent = Agent(data, config={"llm":model})
prompt = st.text_area("Enter your prompt:")
if st.button("Generate"):
if prompt:
with st.spinner("Generating response..."):
st.write(agent.chat(prompt))