Skip to main content

A simple library to set up Ollama and summarize text using local LLMs.

Project description

TextSage

TextSage is a Python library that sets up Ollama and local LLMs for users and provides simple functions to summarize text, with support for Python, Pandas, and PySpark workflows.

Features

  • Automated Ollama Setup:

    • Checks if Ollama is installed and running
    • Installs Ollama if not found
    • Downloads specified LLM models for summarization
  • Multiple Integration Options:

    • Pure Python text summarization
    • Pandas DataFrame column summarization
    • PySpark DataFrame column summarization

Installation

pip install textsage

For development:

pip install -e .

Usage

Basic Text Summarization

from textsage import summarize_text

text = "This is a long text that needs summarization."
summary = summarize_text(text, model_name="mistral", word_count=10)
print(summary)

Pandas DataFrame Summarization

import pandas as pd
from textsage import summarize_dataframe

# Create a sample DataFrame
df = pd.DataFrame({
    'text': ['This is a long text that needs summarization.']
})

# Summarize the 'text' column
result_df = summarize_dataframe(df, 'text', model_name='mistral')
print(result_df['summary'])

PySpark DataFrame Summarization

from pyspark.sql import SparkSession
from textsage import summarize_spark_dataframe

# Create a Spark session
spark = SparkSession.builder.getOrCreate()

# Create a sample DataFrame
data = [("This is a long text that needs summarization.",)]
spark_df = spark.createDataFrame(data, ["text"])

# Summarize the 'text' column
result_df = summarize_spark_dataframe(spark_df, 'text', model_name='mistral')
result_df.show()

Supported Models

By default, textsage uses the 'mistral' model, but you can specify any model supported by Ollama:

  • mistral
  • llama2
  • codellama
  • phi
  • neural-chat
  • And more...

Requirements

  • Python 3.8+
  • Ollama (automatically installed if missing)
  • pandas (optional, for DataFrame support)
  • pyspark (optional, for Spark support)

License

This project is licensed under the MIT License.

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

textsage-0.1.1.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

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

textsage-0.1.1-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file textsage-0.1.1.tar.gz.

File metadata

  • Download URL: textsage-0.1.1.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for textsage-0.1.1.tar.gz
Algorithm Hash digest
SHA256 46ed7cdf7d115d930430e6665a7adb447b3d48946fbba27fa1a3d450de51b8db
MD5 c9a1842a2ecf895572b398d10453e036
BLAKE2b-256 657dec968b6049e20d1d29503ba52780ea5fd45890b0819aaf1bd64852b890a1

See more details on using hashes here.

File details

Details for the file textsage-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: textsage-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for textsage-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 4882862b3c9e20c04da3346582a9af284e9da3d838397717f2e5ab3132b20dce
MD5 594088a69fb3528fba8f191e92afd783
BLAKE2b-256 efa75f5c47dfce891f1fa638dcad91d4ee9267402bad33f4dbc470e8176b8b8f

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