About

Simple project to generate posts for LinkedIn using the OpenAI SDK. This is to help creating engaging posts for LinkedIn while learning about Agentic AI libraries and Frameworks.

Website: https://linkedin-generator-lake.vercel.app/

Note: The generate endpoint is rate limited so you might need to try a few times before it works.

Stack

The web app was built using Vue.js with TypeScript and Tailwind CSS. This was the hardest part of the stack, I decided to go with Vue.js since it’s a lot easier to work with than Next.js and I didn’t need server side rendering for this small project.

The api was built using Flask and deployed to Render. The API has 2 endpoints, one to get a list of the latest posts in this website (homepage) and another one to generate a post for LinkedIn. To get the posts, the API gets the html of the homepage and then parses it to extract the title, description and URL of each post using BeautifulSoup.

The post generation is done using the OpenAI SDK that sends a prompt to a LLM with the content of the post and the response of the LLM is sent to the frontend.

Learning

OpenAI SDK is a Python library that provides a simple interface to the OpenAI API. It allows developers to easily integrate OpenAI’s powerful language models into their applications. In this project, to generate the post, we use the following code:

1
2
3
4
5
6
7
8
9
response = client.chat.completions.create(
    model=model,
    messages=[{"role": "user", "content": prompt}],
)

if not response.choices[0].message.content:
    return "No content returned", 404

return response.choices[0].message.content

Next Steps

The app can be improved by adding better error handling, loading animations/placeholders and adding unit testing. The backend might need a better folder structure and more modular code.