Skip to content

whatsapp-linkcraft generates validated WhatsApp chat links from phone numbers using an LLM, handling formatting and errors automatically for clickable URLs.

Notifications You must be signed in to change notification settings

chigwell/whatsapp-linkcraft

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

WhatsApp LinkCraft

PyPI version License: MIT Downloads LinkedIn

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.

Installation

Install the package via pip:

pip install whatsapp_linkcraft

Usage

Here'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.

Custom LLM Usage

The package enables you to specify your preferred language model. For example:

Using OpenAI's GPT

from langchain_openai import ChatOpenAI
from whatsapp_linkcraft import whatsapp_linkcraft

llm = ChatOpenAI()
response = whatsapp_linkcraft(user_input, llm=llm)

Using Anthropic

from langchain_anthropic import ChatAnthropic
from whatsapp_linkcraft import whatsapp_linkcraft

llm = ChatAnthropic()
response = whatsapp_linkcraft(user_input, llm=llm)

Using Google Generative AI

from langchain_google_genai import ChatGoogleGenerativeAI
from whatsapp_linkcraft import whatsapp_linkcraft

llm = ChatGoogleGenerativeAI()
response = whatsapp_linkcraft(user_input, llm=llm)

Parameters

  • 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 to ChatLLM7.
  • api_key (Optional[str]): API key for LLM7. If not provided, the package attempts to fetch from environment variable LLM7_API_KEY. To use a custom key, pass it directly or set the environment variable.

Notes

  • Relies on ChatLLM7 from langchain_llm7 by 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.

License

This project is maintained by Eugene Evstafev.

Email: hi@eugene.plus

GitHub: chigwell

Issues

For issues or suggestions, visit: GitHub Issues

About

whatsapp-linkcraft generates validated WhatsApp chat links from phone numbers using an LLM, handling formatting and errors automatically for clickable URLs.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages