Spaces:
Sleeping
Sleeping
Refactor application structure by removing backend directory and integrating main.py directly. Update Dockerfile to reflect new entry point and streamline dependencies. Implement FastAPI with CORS support and asynchronous agent handling for improved functionality.
01038c9 Download tools/linkedin_group_posts.py from Coding-With-Raptor/Likendin-Agent: direct link, hf CLI and curl.
- Browser
- Download file 1.31 kB
-
https://huggingface.co/spaces/Coding-With-Raptor/Likendin-Agent/resolve/01038c98dc6b2f8820d116a3918a7ebfdf3d0aa1/tools/linkedin_group_posts.py
- Command line
-
hf download hf://spaces/Coding-With-Raptor/Likendin-Agent@01038c98dc6b2f8820d116a3918a7ebfdf3d0aa1/tools/linkedin_group_posts.py
-
curl -L -o linkedin_group_posts.py https://huggingface.co/spaces/Coding-With-Raptor/Likendin-Agent/resolve/01038c98dc6b2f8820d116a3918a7ebfdf3d0aa1/tools/linkedin_group_posts.py
1.31 kB
| import requests | |
| from agents import function_tool | |
| from dotenv import find_dotenv, load_dotenv | |
| import os | |
| # Constants | |
| LINKEDIN_ACCESS_TOKEN = os.getenv("LINKEDIN_ACCESS_TOKEN") | |
| load_dotenv(find_dotenv()) | |
| HEADERS = { | |
| "Authorization": f"Bearer {LINKEDIN_ACCESS_TOKEN}", | |
| "Content-Type": "application/json", | |
| } | |
| def post_group_content_linkedin(content: str, group_id: str): | |
| """ | |
| Share content in a LinkedIn group. | |
| Args: | |
| params (PostGroupContentParams): Parameters for the group post. | |
| Returns: | |
| dict: API response or None if an error occurs. | |
| """ | |
| url = "https://api.linkedin.com/v2/ugcPosts" | |
| payload = { | |
| "author": f"urn:li:group:{group_id}", | |
| "lifecycleState": "PUBLISHED", | |
| "specificContent": { | |
| "com.linkedin.ugc.ShareContent": { | |
| "shareCommentary": {"text": content}, | |
| "shareMediaCategory": "NONE", | |
| } | |
| }, | |
| "visibility": {"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"}, | |
| } | |
| try: | |
| response = requests.post(url, headers=HEADERS, json=payload) | |
| response.raise_for_status() | |
| return response.json() | |
| except requests.exceptions.RequestException as e: | |
| print(f"Error posting content to group: {e}") | |
| return None | |