Skip to main content

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

PyPI version License: MIT Downloads LinkedIn

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 process
  • llm (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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

transword_matcher-2025.12.21084344.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

transword_matcher-2025.12.21084344-py3-none-any.whl (5.3 kB view details)

Uploaded Python 3

File details

Details for the file transword_matcher-2025.12.21084344.tar.gz.

File metadata

File hashes

Hashes for transword_matcher-2025.12.21084344.tar.gz
Algorithm Hash digest
SHA256 34efea6055d4671f248ec88be4cd68d96cd292449eb462a30ebfae5114f76a75
MD5 5690ac8fdac634497bfa35ddd92c8ad9
BLAKE2b-256 1a5c5486c738d02d05e06a0ec589fcc3ac2443bbc0acfb54e27a3b22f011fd13

See more details on using hashes here.

File details

Details for the file transword_matcher-2025.12.21084344-py3-none-any.whl.

File metadata

File hashes

Hashes for transword_matcher-2025.12.21084344-py3-none-any.whl
Algorithm Hash digest
SHA256 bb60c6e5e046aa1713f6ccf5fa1fb7b6516ed42f723612f2d203bdb4917ff058
MD5 4b7e373b89ebb659f0e6c115a043dd4b
BLAKE2b-256 97bbc4f1aa8818ecbffa8ea755ea8a9597326b9ad95f76ee0fea0ab14c43da66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page