Skip to main content

A new package that analyzes social media post text to extract structured insights about audience engagement patterns, such as identifying common themes in highly liked content or predicting potential

Project description

socialtextlytics

PyPI version License: MIT Downloads LinkedIn

socialtextlytics is a Python package that analyzes social‑media post text and returns structured insights about audience engagement patterns. It can identify common themes in highly liked content, suggest language that may drive subscriber growth, and more—without handling media files directly.

Features

  • Extracts categorized feedback from post text, comments, or descriptions.
  • Uses a powerful LLM (ChatLLM7 by default) with regex‑based extraction for reliable outputs.
  • Easily replace the LLM with any LangChain‑compatible model (OpenAI, Anthropic, Google, etc.).
  • Simple, typed API.

Installation

pip install socialtextlytics

Quick Start

from socialtextlytics import socialtextlytics

# Example social‑media post text
user_input = """
Just launched our new feature! 🎉 10k likes already.
What do you think? #innovation #tech
"""

# Call the analyzer with default LLM (ChatLLM7)
results = socialtextlytics(user_input)

print(results)
# → ['...extracted insight strings...']

Advanced Usage – Providing Your Own LLM

If you prefer to use a different language model, pass a LangChain BaseChatModel instance:

OpenAI

from langchain_openai import ChatOpenAI
from socialtextlytics import socialtextlytics

llm = ChatOpenAI()          # configure with your OpenAI key as usual
response = socialtextlytics(user_input, llm=llm)
print(response)

Anthropic

from langchain_anthropic import ChatAnthropic
from socialtextlytics import socialtextlytics

llm = ChatAnthropic()
response = socialtextlytics(user_input, llm=llm)
print(response)

Google Generative AI

from langchain_google_genai import ChatGoogleGenerativeAI
from socialtextlytics import socialtextlytics

llm = ChatGoogleGenerativeAI()
response = socialtextlytics(user_input, llm=llm)
print(response)

Parameters

Name Type Description
user_input str The text to analyze (post, comment, description, etc.).
llm Optional[BaseChatModel] A LangChain LLM instance. If omitted, the package creates a default ChatLLM7 instance.
api_key Optional[str] API key for ChatLLM7. If not supplied, the function reads LLM7_API_KEY from the environment.

Default LLM – ChatLLM7

When no llm is given, socialtextlytics creates a ChatLLM7 instance:

from langchain_llm7 import ChatLLM7
resolved_llm = ChatLLM7(
    api_key=api_key,
    base_url="https://..."
)

ChatLLM7 is available on PyPI: https://pypi.org/project/langchain-llm7/ (link provided in the source).
The free tier’s rate limits are sufficient for typical usage. For higher limits, supply your own API key via the LLM7_API_KEY environment variable or the api_key argument.

You can obtain a free API key by registering at https://token.llm7.io/.

How It Works

  1. Prompt Construction – The package builds system and human prompts (system_prompt, human_prompt).
  2. LLM Call – The LLM processes the prompts and returns a raw response.
  3. Regex Extractionllmatch validates the response against a predefined regular expression (pattern) and extracts the structured data.
  4. Result – A list of extracted insight strings is returned, or an empty list on failure.

Error Handling

If the LLM call fails or the response does not match the expected pattern, a RuntimeError is raised with an informative message.

Contributing & Issues

Bug reports, feature requests, and pull requests are welcome! Please open an issue at: https://github.com/chigwell/socialtextlytics/issues

License

This project is licensed under the MIT License.

Author

Eugene Evstafev
Email: hi@euegne.plus
GitHub: https://github.com/chigwell


Enjoy extracting insights from your social media content with socialtextlytics!

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

socialtextlytics-2025.12.21131030.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

socialtextlytics-2025.12.21131030-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file socialtextlytics-2025.12.21131030.tar.gz.

File metadata

File hashes

Hashes for socialtextlytics-2025.12.21131030.tar.gz
Algorithm Hash digest
SHA256 98d17b0763427306a78547c615226d6cbe2be8162b41498dd70dc74117d5eb10
MD5 a82e98800c0c4db89d2e0e6b22dab79a
BLAKE2b-256 befdfede2575d4d3985ff939d0c48254175f248ec9244138d5bf56daa7ca05d3

See more details on using hashes here.

File details

Details for the file socialtextlytics-2025.12.21131030-py3-none-any.whl.

File metadata

File hashes

Hashes for socialtextlytics-2025.12.21131030-py3-none-any.whl
Algorithm Hash digest
SHA256 92edfd77b189df23a4598bf5bb4ab29c531ff107c7ca2bc1f76513150b8a156c
MD5 7b4549319a3bf2c971209cb7087313ef
BLAKE2b-256 47667903b9f8b68a4b035adf3c2f3ef0631931191bc0a44e21ef4e24e41a4817

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