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.0.tar.gz (6.1 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.0-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: textsage-0.1.0.tar.gz
  • Upload date:
  • Size: 6.1 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.0.tar.gz
Algorithm Hash digest
SHA256 cd5a3086e02f84fded866dec1172ff7b39f20d14a177f49c977975ddeac139dd
MD5 11fb4083612b2ffb40d247c8d416140e
BLAKE2b-256 6cc0993ff9900564d36bc89672988e3244d34d79baca3b8e8c9780d2e6d828f5

See more details on using hashes here.

File details

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

File metadata

  • Download URL: textsage-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.6 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc077a641ba339a1f9aaa224d2b67aec8eb4d7a1bedd1aaabcc1be869630c7c0
MD5 ace466bbfde75193c98b0a34cb196dfd
BLAKE2b-256 f1c2b1383a904efa51b81445169791f5f4298d304de36bc7dc465d74e592d0c0

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