WhatsApp LinkCraft is a Python package designed to generate structured and validated WhatsApp chat links from user-provided phone numbers. It leverages language models to ensure correct formatting and automatically handle common input variations and errors, providing a clickable WhatsApp URL ready for use.
Install the package via pip:
pip install whatsapp_linkcraftHere's a basic example of how to use the package:
from whatsapp_linkcraft import whatsapp_linkcraft
# Example user input
user_input = "+1 234 567 8901"
# Generate WhatsApp link (uses default LLM)
links = whatsapp_linkcraft(user_input)
print(links)You can also pass your own LLM instance if desired. The default uses ChatLLM7 from langchain_llm7, which is compatible with various LLM providers.
The package enables you to specify your preferred language model. For example:
from langchain_openai import ChatOpenAI
from whatsapp_linkcraft import whatsapp_linkcraft
llm = ChatOpenAI()
response = whatsapp_linkcraft(user_input, llm=llm)from langchain_anthropic import ChatAnthropic
from whatsapp_linkcraft import whatsapp_linkcraft
llm = ChatAnthropic()
response = whatsapp_linkcraft(user_input, llm=llm)from langchain_google_genai import ChatGoogleGenerativeAI
from whatsapp_linkcraft import whatsapp_linkcraft
llm = ChatGoogleGenerativeAI()
response = whatsapp_linkcraft(user_input, llm=llm)- user_input (
str): The text input from the user containing the phone number to process. - llm (
Optional[BaseChatModel]): An instance of a language model. Defaults toChatLLM7. - api_key (
Optional[str]): API key for LLM7. If not provided, the package attempts to fetch from environment variableLLM7_API_KEY. To use a custom key, pass it directly or set the environment variable.
- Relies on
ChatLLM7fromlangchain_llm7by default. You may replace it with other language model instances from LangChain. - Default rate limits of LLM7 free tier are generally sufficient; for higher limits, provide your own API key.
This project is maintained by Eugene Evstafev.
Email: hi@eugene.plus
GitHub: chigwell
For issues or suggestions, visit: GitHub Issues