Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

1 Commit

Repository files navigation

write_struct

PyPI versionLicense: MITDownloadsLinkedIn

Transform raw text into structured, formatted content for WriteFreely and beyond.

write_struct is a Python package designed to enhance content creation by automatically converting user-submitted text into well-structured, formatted output. It leverages AI-powered pattern matching to ensure consistency, readability, and publication-ready quality for articles, blog posts, social media updates, and more.


🚀 Features

  • Automated text structuring using AI-driven pattern matching.
  • Flexible LLM integration – works with default ChatLLM7 or any LangChain-compatible model.
  • Regex-based validation to enforce output consistency.
  • Lightweight and efficient for text-based content processing.
  • No multimedia handling – focuses purely on text formatting.

📦 Installation

Install via pip:

pip install write_struct

🔧 Usage

Basic Usage (Default LLM7)

fromwrite_structimportwrite_structuser_input="Your raw text here..."response=write_struct(user_input)
print(response)

Custom LLM Integration

You can replace the default ChatLLM7 with any LangChain-compatible model (e.g., OpenAI, Anthropic, Google Generative AI):

Using OpenAI:

fromlangchain_openaiimportChatOpenAIfromwrite_structimportwrite_structllm=ChatOpenAI()
response=write_struct(user_input, llm=llm)

Using Anthropic:

fromlangchain_anthropicimportChatAnthropicfromwrite_structimportwrite_structllm=ChatAnthropic()
response=write_struct(user_input, llm=llm)

Using Google Generative AI:

fromlangchain_google_genaiimportChatGoogleGenerativeAIfromwrite_structimportwrite_structllm=ChatGoogleGenerativeAI()
response=write_struct(user_input, llm=llm)

🔑 API Key Configuration

  • Default: Uses LLM7_API_KEY from environment variables.
  • Manual Override: Pass the API key directly:
    response=write_struct(user_input, api_key="your_api_key_here")
  • Free API Key: Register at https://token.llm7.io/ for LLM7.

📜 Input Parameters

ParameterTypeDescription
user_inputstrRaw text to be structured.
api_keyOptional[str]LLM7 API key (defaults to LLM7_API_KEY env var).
llmOptional[BaseChatModel]Custom LangChain LLM (e.g., ChatOpenAI, ChatAnthropic). Defaults to ChatLLM7.

📊 Rate Limits

  • LLM7 Free Tier: Sufficient for most use cases.
  • Upgrade: For higher limits, use a custom API key or switch to a paid plan.

📝 License

MIT License.


📢 Support & Issues

For bugs, feature requests, or support, open an issue on GitHub.


👤 Author

Eugene Evstafev (@chigwell) 📧 hi@euegne.plus