https://github.com/yashukun/fs-ldin
AI-powered LinkedIn comment generator with FastAPI, Selenium-based post extraction, and multiple model strategies.
https://github.com/yashukun/fs-ldin
fastapi huggingface linkedin openai selenium-python
Last synced: 2 months ago
JSON representation
AI-powered LinkedIn comment generator with FastAPI, Selenium-based post extraction, and multiple model strategies.
- Host: GitHub
- URL: https://github.com/yashukun/fs-ldin
- Owner: yashukun
- Created: 2025-06-13T20:18:05.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-06-16T17:14:50.000Z (about 1 year ago)
- Last Synced: 2025-06-16T18:31:23.796Z (about 1 year ago)
- Topics: fastapi, huggingface, linkedin, openai, selenium-python
- Language: Python
- Homepage:
- Size: 6.84 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LinkedIn Comment Generator
This project provides an automated system to generate thoughtful, professional comments for LinkedIn posts using AI models (OpenAI or HuggingFace). It includes a FastAPI backend, LinkedIn post caption extraction via Selenium, and multiple comment generation strategies.
## Features
- **Extract LinkedIn Post Captions:** Uses Selenium (with stealth options) to fetch post content.
- **AI-Powered Comment Generation:** Supports both OpenAI (e.g., GPT-4o) and HuggingFace (e.g., Mixtral-8x7B) models.
- **REST API:** FastAPI endpoint for easy integration.
- **Customizable Prompts:** Generates comments with different tones and perspectives.
- **Command-Line & Script Usage:** Includes scripts for direct use and testing.
## Requirements
- Python 3.8+
- Google Chrome (for Selenium)
- The following Python packages (see `requirements.txt`):
- fastapi
- uvicorn
- pydantic
- requests
- openai
- torch
- transformers
- selenium
- selenium-stealth
- undetected-chromedriver
## Setup
1. **Install dependencies:**
```bash
pip install -r requirements.txt
```
2. **Set up ChromeDriver:**
Ensure ChromeDriver is installed and matches your Chrome version.
3. **API Keys:**
- For OpenAI: Get your API key from [OpenAI](https://platform.openai.com/).
- For HuggingFace: Get your token from [HuggingFace](https://huggingface.co/settings/tokens).
## Usage
### 1. Run the FastAPI Server
```bash
uvicorn main:app --reload
```
- **Endpoint:** `POST /linkedin-comment`
- **Request Body:**
```json
{
"post_url": "LINKEDIN_POST_URL_HERE",
"provider": "openai" or "hf",
"token": "YOUR_API_TOKEN"
}
```
### 2. Command-Line Script
Generate a comment directly:
```bash
python generate_comment.py --post_url "LINKEDIN_POST_URL" --provider openai --token YOUR_API_TOKEN
```
## File Overview
- `main.py` - FastAPI backend for comment generation.
- `generate_comment.py` - Functions for generating comments using OpenAI or HuggingFace.
- `get_post_caption.py` - Extracts post captions from LinkedIn using Selenium.
## Notes
- LinkedIn’s HTML structure may change; update selectors in `get_post_caption.py` as needed.
- For best results, use valid API tokens and ensure your environment supports Selenium.
## License
MIT License