Spaces:
Sleeping
Sleeping
Update main.py to limit max turns in streamed responses to 2 and modify model version in linkedin_assistant.py from "gemini-2.5-flash-preview-05-20" to "gemini-2.5-flash" for consistency and improved performance.
1b6c234 Download agent/linkedin_assistant.py from Coding-With-Raptor/Likendin-Agent: direct link, hf CLI and curl.
- Browser
- Download file 3.76 kB
-
https://huggingface.co/spaces/Coding-With-Raptor/Likendin-Agent/resolve/main/agent/linkedin_assistant.py
- Command line
-
hf download hf://spaces/Coding-With-Raptor/Likendin-Agent/agent/linkedin_assistant.py
-
curl -L -o linkedin_assistant.py https://huggingface.co/spaces/Coding-With-Raptor/Likendin-Agent/resolve/main/agent/linkedin_assistant.py
3.76 kB
| # from mcp_client_tools.mcp_client import get_mcp_weather_client, get_mcp_linkedin_client | |
| from tools.linkedin_post_links import create_post_links_image | |
| from tools.linkedin_posts import post_content_linkedin | |
| from tools.linkedin_userinfo import get_user_info | |
| from agents import Agent, OpenAIChatCompletionsModel | |
| from dotenv import load_dotenv, find_dotenv | |
| from openai import AsyncOpenAI | |
| import os | |
| LINKEDIN_ACCESS_TOKEN = os.getenv("LINKEDIN_ACCESS_TOKEN") | |
| load_dotenv(find_dotenv()) | |
| GOOGLE_API_KEY = os.getenv("GOOGLE_API_KEY") | |
| gemini_client = AsyncOpenAI( | |
| api_key=GOOGLE_API_KEY, | |
| base_url="https://generativelanguage.googleapis.com/v1beta/openai/", | |
| ) | |
| async def create_assistant_agent(): | |
| # mcp_server_linkedin = await get_mcp_linkedin_client() | |
| # mcp_server_weather = await get_mcp_weather_client() | |
| return Agent( | |
| name="LinkedIn Assistant", | |
| instructions=( | |
| """ | |
| # LinkedIn Assistant Guide | |
| You are a LinkedIn profile assistant that helps users manage their professional presence. Here's how you operate: | |
| TOOLS AND THEIR USAGE: | |
| 1. get_user_info: Use this to fetch and display user's LinkedIn profile information when they ask about their profile details. | |
| 2. post_content_linkedin: Use this for creating text-only posts. When a user wants to make a post without images/links. | |
| 3. create_post_links_image: Use this when users want to create posts with images or links. Requires: | |
| - image_path: Path to the image file or URL | |
| - post_text: You will automatically generate engaging and professional post content | |
| 4. get_weather: Use this to fetch current weather data for any city. Useful for creating weather-related posts or checking conditions. | |
| WORKFLOW: | |
| - Only call one tool per request. | |
| - For profile queries: Call `get_user_info` and do not combine with any other tools. | |
| - For text-only posts: Use `post_content_linkedin` with self-generated content | |
| - For posts with images/links: Use `create_post_links_image` with self-generated content | |
| - For weather information: Call `get_weather` separately with the city name. | |
| FORMAT: | |
| - Headers with # for main titles and ## for subtitles | |
| - **bold** for emphasis | |
| - *italic* for secondary emphasis | |
| - Bullet points with - or * for lists | |
| - Code blocks with ``` for technical content | |
| - Links with [text](url) format | |
| - Tables using | and - for structured data | |
| - Images with  format | |
| - Always return in format | |
| GUIDELINES: | |
| - Maintain a professional and helpful tone | |
| - Focus on LinkedIn-related tasks and weather information | |
| - Generate engaging and relevant post content automatically | |
| - Create posts immediately without asking for confirmation | |
| - Provide clear feedback after actions are completed | |
| - Write posts in first person as if you are the user | |
| - Use weather data to create relevant professional posts when appropriate | |
| - Never combine tool names like `get_user_infoget_weather` — only one tool per call. | |
| """ | |
| ), | |
| model=OpenAIChatCompletionsModel( | |
| model="gemini-2.5-flash", openai_client=gemini_client | |
| ), | |
| # mcp_servers=[mcp_server_linkedin, mcp_server_weather], | |
| tools=[post_content_linkedin, create_post_links_image, get_user_info], | |
| ) | |