import streamlit as st from github import Github, Auth from transformers import pipeline def generate_post(readme_content, project_name, repo_url): summarizer = pipeline("summarization", model="facebook/bart-large-cnn") summary = summarizer(readme_content, max_length=150, min_length=50, do_sample=False)[0]['summary_text'] linkedin_post = f"""Excited to share my latest project: {project_name}! 🚀 {summary} Check it out on GitHub for more details and how to get started: {repo_url} """ return linkedin_post # Streamlit app st.title("GitHub to LinkedIn Post Generator") # Get GitHub token from environment variable import os api_key = os.getenv("GITHUB_KEY") auth = Auth.Token(api_key) # User input repo_input = st.text_input("Enter GitHub repository (username/repo_name):") if st.button("Generate Post"): if repo_input: try: with Github(auth=auth) as g: repo = g.get_repo(repo_input) readme_content = repo.get_readme().decoded_content.decode() project_name = repo.name repo_url = repo.html_url linkedin_post = generate_post(readme_content, project_name, repo_url) st.subheader("Generated LinkedIn Post:") st.text_area("Copy this text:", linkedin_post, height=300) except Exception as e: st.error(f"An error occurred: {str(e)}") else: st.warning("Please enter a GitHub repository.")