An LLM-powered multi-purpose hashtag utilities library written in Python.
Hashtags are used on almost every content platform today. This makes it a vital tool for creating & analyzing content. This utilities library makes it easy to do things with hashtags. Ideally, this module is intended to be used within a larger system where more specific problems are solved.
Feel free to suggest features, ideas and improvements! If you want to contribute, feel free to fork and send a Pull Request. I'm actively working on this project.
- Hashtag Generator: Generates hashtags for a content piece.
- Hashtag Relevance: Returns the percentage relevance of a hashtag with respect to a content piece.
- Similar Hashtags: Generates hash tages similar to the provided ones.
- Hashtag Distance: Computes how close two hashtags are.
- Hashtag Definitions: Get hashtag definitions.
Make sure you add your OPENAI_API_KEY
to a .env file from the location where you're running the script.
from hashtag_utils import HashtagUtils
hg = HashtagUtils()
text = "A new study shows that eating chocolate can help you lose weight."
hashtags = hg.get_hashtags(text)
# check other methods below
Generates a list of hashtags based on the given text.
text
: The input text to generate hashtags from.temperature
: Controls the randomness of the hashtag generation. Lower values make the output more deterministic. Default is 1.0.num_tags
: The number of hashtags to generate. Default is 5.
Generates a list of hashtags that are similar to the given hashtags.
hashtags
: The input hashtags to find similar hashtags for.temperature
: Controls the randomness of the hashtag generation. Lower values make the output more deterministic. Default is 1.0.num_tags
: The number of hashtags to generate. Default is 5.
Returns the definition of the given hashtag.
hashtag
: The hashtag to get the definition for.
Returns a dictionary mapping each hashtag to its relevance to the given text.
hashtags
: The hashtags to check the relevance of.text
: The text to check the relevance against.
Returns the semantic distance between two hashtags.
hashtag1
: The first hashtag.hashtag2
: The second hashtag.
- Add
OPENAI_API_KEY
to the.env
file. - Run examples:
python example.py