Skip to main content

Transformer-based sentiment analysis tool for Swarmauri with compact label-only dictionary output.

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_tool_sentimentanalysis Discord

Swarmauri Tool Sentiment Analysis

swarmauri_tool_sentimentanalysis is the Swarmauri sentiment-analysis tool built on Hugging Face transformers. It wraps the pipeline("sentiment-analysis") surface and returns a simple dictionary with a single sentiment label for the input text.

Why Use Swarmauri Tool Sentiment Analysis

  • Add fast text sentiment classification to agent and tool-calling workflows.
  • Return a compact structured output that is easy to route, log, or attach to larger decisions.
  • Use transformer-based sentiment inference without building a custom model wrapper.
  • Pair sentiment labels with entity extraction, parsing, or downstream automation in Swarmauri pipelines.

FAQ

What does this tool return?
A dictionary in the shape {"sentiment": "<LABEL>"}.

What labels should I expect?
Labels depend on the underlying Hugging Face pipeline model. In practice the current tests allow POSITIVE, NEGATIVE, or NEUTRAL.

Does it download a model on first use?
Yes. The underlying transformers pipeline downloads model assets if they are not already cached.

Can I use it inside tool-calling or orchestration workflows?
Yes. It is packaged as a Swarmauri ToolBase component.

Features

  • Transformer-backed sentiment analysis via Hugging Face pipelines.
  • Swarmauri ToolBase integration with a single text parameter.
  • Returns a compact dictionary response suitable for automation and routing.
  • Works for quick sentiment checks in text review, feedback analysis, and content classification workflows.
  • Supports Python 3.10, 3.11, 3.12, 3.13, and 3.14.

Installation

uv add swarmauri_tool_sentimentanalysis
pip install swarmauri_tool_sentimentanalysis

Usage

from swarmauri_tool_sentimentanalysis import SentimentAnalysisTool

tool = SentimentAnalysisTool()
result = tool("I love this product!")
print(result)

Examples

Analyze customer feedback

from swarmauri_tool_sentimentanalysis import SentimentAnalysisTool

tool = SentimentAnalysisTool()

print(tool("I love this product!"))
print(tool("I hate this product!"))
print(tool("This product is okay."))

Use sentiment labels for routing

from swarmauri_tool_sentimentanalysis import SentimentAnalysisTool

tool = SentimentAnalysisTool()
sentiment = tool("The latest release is disappointing.")["sentiment"]

if sentiment == "NEGATIVE":
    print("Escalate for review")

Related Packages

Swarmauri Foundations

More Documentation

Best Practices

  • Cache Hugging Face assets in CI or deployment environments to avoid repeated downloads.
  • Validate expected labels against the actual model in your deployment, because different models can emit different label vocabularies.
  • Use explicit downstream mapping if your application needs stable polarity buckets.
  • Pair sentiment output with other tools when you need richer reasoning than a single label.

License

This project is licensed under the Apache-2.0 License.

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

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

File details

Details for the file swarmauri_tool_sentimentanalysis-0.11.0.dev1.tar.gz.

File metadata

  • Download URL: swarmauri_tool_sentimentanalysis-0.11.0.dev1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_tool_sentimentanalysis-0.11.0.dev1.tar.gz
Algorithm Hash digest
SHA256 5349708f4c8a46fa4f8e47ea31b400f2523f29d12e5739404547e7520fb0bff2
MD5 a703b51f937d8ae1a6da2865d09277a3
BLAKE2b-256 1579600099728a0df61f90d0fc39ef14f3580d0a517f7ffdac73dd9839c73e0c

See more details on using hashes here.

File details

Details for the file swarmauri_tool_sentimentanalysis-0.11.0.dev1-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_tool_sentimentanalysis-0.11.0.dev1-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for swarmauri_tool_sentimentanalysis-0.11.0.dev1-py3-none-any.whl
Algorithm Hash digest
SHA256 a58db0467060cb5b8a6cd743d066c4cda93b623a457f7e6e4fa26cf164067182
MD5 00953b13404440a00c8f1baa4b9cc643
BLAKE2b-256 2b366f8ac75457d51e2b1bff795240c58e5e627af1afe394a35f2238bee4b70d

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