Metadata-Version: 2.4
Name: text-summarizer-gi
Version: 0.2.0
Summary: Context-aware, LLM-powered rolling conversation summarizer
Author-email: Dhivya <dhivyashankar27@gmail.com>
Keywords: llm,summarizer,conversation,azure,openai
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.8
Description-Content-Type: text/plain
Requires-Dist: openai>=1.0.0

================================================================================
                      CONVERSATION SUMMARIZER
================================================================================

Progressive, context-aware conversation summarizer powered by Azure LLM.
Automatically compresses long conversations into structured summaries
while preserving user intent, key decisions, and action items.

================================================================================
                              QUICK START
================================================================================

1. INSTALL DEPENDENCIES
   ──────────────────────────────────────────────────────────────────────────
   pip install -r requirements.txt

   Or manually:
   pip install openai


2. SET UP AZURE CREDENTIALS
   ──────────────────────────────────────────────────────────────────────────
   The module needs three environment variables to call Azure OpenAI:

   AZURE_OPENAI_ENDPOINT       e.g. https://my-resource.openai.azure.com/
   AZURE_OPENAI_API_KEY        Your Azure API key
   AZURE_OPENAI_DEPLOYMENT     Your model deployment name

   Set them as follows:

   Windows (PowerShell):
      $env:AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/"
      $env:AZURE_OPENAI_API_KEY="your-api-key-here"
      $env:AZURE_OPENAI_DEPLOYMENT="your-deployment-name"

   Windows (Command Prompt):
      set AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
      set AZURE_OPENAI_API_KEY=your-api-key-here
      set AZURE_OPENAI_DEPLOYMENT=your-deployment-name

   Mac/Linux:
      export AZURE_OPENAI_ENDPOINT="https://your-resource.openai.azure.com/"
      export AZURE_OPENAI_API_KEY="your-api-key-here"
      export AZURE_OPENAI_DEPLOYMENT="your-deployment-name"


3. RUN THE END-TO-END TEST
   ──────────────────────────────────────────────────────────────────────────
   This test reads sample_conversation.txt, calls your Azure LLM,
   and prints a formatted summary with sanity checks.

   From the project root:
      cd summarizer_package
      python test_summarizer.py

   Or from the workspace root (outer folder):
      python .\summarizer_package\test_summarizer.py

   Expected output:
      - Loads the sample conversation
      - Calls Azure LLM to summarize
      - Prints summary with overview, intent, decisions, and action items
      - Runs sanity checks (all should PASS)


4. RUN UNIT TESTS
   ──────────────────────────────────────────────────────────────────────────
   Unit tests use a mock LLM and do NOT require Azure credentials.

   From the project root:
      python -m pytest

   Or run test_conversation_summarizer.py directly:
      python test_conversation_summarizer.py

================================================================================
                           HOW TO USE IN CODE
================================================================================

from openai import AzureOpenAI
from conversation_summarizer import ConversationSummarizer, LLMClient
import os

# 1. Wire up your Azure client
azure_client = AzureOpenAI(
    azure_endpoint=os.environ["AZURE_OPENAI_ENDPOINT"],
    api_key=os.environ["AZURE_OPENAI_API_KEY"],
    api_version=os.environ.get("AZURE_OPENAI_API_VERSION", "2024-02-01"),
)

# 2. Create an LLMClient wrapper
llm_client = LLMClient(
    client=azure_client,
    model=os.environ["AZURE_OPENAI_DEPLOYMENT"]
)

# 3. Initialize the summarizer
summarizer = ConversationSummarizer(llm_client)

# 4. Progressive compression (auto-triggers when buffer hits threshold)
from conversation_summarizer import Message, Role
summarizer.add_message(Message(Role.USER, "Hello, I need help with X"))
summarizer.add_message(Message(Role.ASSISTANT, "Sure, tell me more..."))
# ... add more turns ...

# 5. Get context for the next LLM call
# (includes summary block + recent turns)
context = summarizer.get_context_messages()
context.append({"role": "user", "content": "What should we do next?"})
response = llm_client.complete(context)

# 6. Optionally summarize plain text directly
summary_text = summarizer.summarize_to_text(conversation_text)
print(summary_text)

================================================================================
                                 FILES
================================================================================

conversation_summarizer.py
      Core summarizer module. No Azure coupling—use any LLM backend
      by implementing the LLMClient interface.

test_summarizer.py
      End-to-end test: reads sample_conversation.txt, calls Azure LLM,
      prints summary and runs sanity checks.
      Requires: Azure credentials (see SETUP above).

test_conversation_summarizer.py
      Unit tests for ConversationSummarizer using a mock LLM.
      No Azure needed. Run with: pytest test_conversation_summarizer.py

sample_conversation.txt
      Sample conversation input. Edit with your own conversation
      using the format below.

requirements.txt
      Python package dependencies.

README.txt
      This file.

================================================================================
                          INPUT CONVERSATION FORMAT
================================================================================

Conversations should be plain text with a simple format:

   User: What do you need?
   Assistant: I need help building a leave management system.
   User: What are the requirements?
   Assistant: It should support multiple leave types, email notifications, ...

The summarizer treats "User:" and "Assistant:" as delimiters.
Edit sample_conversation.txt to test with your own sample.

================================================================================
                              CUSTOMIZATION
================================================================================

Auto-compress threshold:
   ConversationSummarizer(llm_client, auto_summarize_after=30)
   (compress after 30 messages instead of default)

Recent turns to keep in buffer:
   ConversationSummarizer(llm_client, keep_recent_turns=5)
   (retain 5 most recent messages after each compression)

Force compression:
   summary = summarizer.force_compress()
   (manually compress the entire buffer, regardless of size)

================================================================================
