File size: 769 Bytes
b1a88ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
import streamlit as st
import pandas as pd

@st.cache_data 
def load_posts_context(csv_path="linkedin_sample_posts.csv"):
    try:
        df = pd.read_csv(csv_path)
        required_columns = ["post", "type", "language"]
        if not all(col in df.columns for col in required_columns):
            raise ValueError(f"CSV file must contain the following columns: {required_columns}")

        posts_list = df.to_dict(orient='records')
        return posts_list
    except FileNotFoundError:
        st.warning(f"Warning: '{csv_path}' not found. No sample posts will be used for context.")
        return []
    except Exception as e:
        st.error(f"Error loading or processing sample posts from {csv_path}: {e}")
        return []