The package uses structured pattern matching to interpret user requests for language translation, extracting the source and target languages along with the text to translate. It then returns a detaile
Project description
transword-matcher
A Python package that uses structured pattern matching to interpret user requests for language translation, extracting the source and target languages along with the text to translate. It returns a detailed, organized response including the translated text, original text, and detected source and target languages.
Installation
pip install transword_matcher
Usage
from transword_matcher import transword_matcher
# Example usage with default LLM (ChatLLM7)
response = transword_matcher(
user_input="Translate 'hello' from English to Spanish"
)
print(response)
Using a Custom LLM
You can pass your own LangChain-compatible LLM instance:
from langchain_openai import ChatOpenAI
from transword_matcher import transword_matcher
llm = ChatOpenAI()
response = transword_matcher(
user_input="Translate this text to French",
llm=llm
)
from langchain_anthropic import ChatAnthropic
from transword_matcher import transword_matcher
llm = ChatAnthropic()
response = transword_matcher(
user_input="How do you say 'thank you' in Japanese?",
llm=llm
)
from langchain_google_genai import ChatGoogleGenerativeAI
from transword_matcher import transword_matcher
llm = ChatGoogleGenerativeAI()
response = transword_matcher(
user_input="Translate from German to English: 'Guten Tag'",
llm=llm
)
Using Custom API Key
from transword_matcher import transword_matcher
response = transword_matcher(
user_input="Translate to Italian",
api_key="your_llm7_api_key_here"
)
Parameters
user_input(str): The user input text to processllm(Optional[BaseChatModel]): LangChain LLM instance (defaults to ChatLLM7)api_key(Optional[str]): API key for LLM7 service (if using default LLM)
Default LLM
The package uses ChatLLM7 from langchain_llm7 by default. The free tier rate limits are sufficient for most use cases.
To get a free API key for LLM7, register at: https://token.llm7.io/
Error Handling
The function raises a RuntimeError if the LLM call fails or pattern matching is unsuccessful.
Development
Issues and contributions welcome at: https://github.com/chigwell/transword-matcher
Author
Eugene Evstafev
hi@euegne.plus
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file transword_matcher-2025.12.21084344.tar.gz.
File metadata
- Download URL: transword_matcher-2025.12.21084344.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34efea6055d4671f248ec88be4cd68d96cd292449eb462a30ebfae5114f76a75
|
|
| MD5 |
5690ac8fdac634497bfa35ddd92c8ad9
|
|
| BLAKE2b-256 |
1a5c5486c738d02d05e06a0ec589fcc3ac2443bbc0acfb54e27a3b22f011fd13
|
File details
Details for the file transword_matcher-2025.12.21084344-py3-none-any.whl.
File metadata
- Download URL: transword_matcher-2025.12.21084344-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bb60c6e5e046aa1713f6ccf5fa1fb7b6516ed42f723612f2d203bdb4917ff058
|
|
| MD5 |
4b7e373b89ebb659f0e6c115a043dd4b
|
|
| BLAKE2b-256 |
97bbc4f1aa8818ecbffa8ea755ea8a9597326b9ad95f76ee0fea0ab14c43da66
|