A Python package that takes user-provided text input and returns structured, validated output using pattern matching to ensure consistent formatting.
- Processes text from various sources like documents or audio transcripts
- Applies a system prompt to guide the LLM and a human message to frame the query
- Uses regex patterns to extract key information reliably
- Ideal for tasks like summarizing content, categorizing feedback, or generating standardized reports
- Does not rely on markdown or HTML formatting
pip install text_structurafrom text_structura import text_structura response = text_structura("Your text input here")You can use your own LLM instance by passing it to the function:
from langchain_openai import ChatOpenAI from text_structura import text_structura llm = ChatOpenAI() response = text_structura("Your text input here", llm=llm)You can pass your LLM7 API key directly:
from text_structura import text_structura response = text_structura("Your text input here", api_key="your_api_key")Or by setting the LLM7_API_KEY environment variable. You can obtain a free API key by registering at https://token.llm7.io/.
user_input(str): The user input text to processllm(Optional[BaseChatModel]): The langchain LLM instance to use. Defaults toChatLLM7.api_key(Optional[str]): The API key for LLM7. If not provided, the defaultChatLLM7will be used.
The package uses ChatLLM7 from langchain_llm7 by default. You can find more information about ChatLLM7 here.
The default rate limits for LLM7 free tier are sufficient for most use cases of this package. If you want higher rate limits, you can pass your own API key via the api_key parameter or by setting the LLM7_API_KEY environment variable.
Contributions are welcome! Please refer to the issue tracker for potential areas of improvement.
- Eugene Evstafev - hi@euegne.plus
- Project Repository: https://github.com/chigwell/text-structura
- Submit Issues: https://github.com/chigwell/text-structura/issues
- GitHub Nickname: chigwell