Metadata-Version: 2.4
Name: gptsession
Version: 1.0.0
Summary: simple, stateful conversations with OpenAI's chat models, including truncation and token metering
Author-email: Lion Kimbro <lionkimbro@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/LionKimbro/gptsession
Project-URL: Bug Tracker, https://github.com/LionKimbro/gptsession/issues
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
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: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: openai
Requires-Dist: tiktoken
Dynamic: license-file

# gptsession

**Simple, stateful conversations with OpenAI's chat models, including truncation and token metering.**

`gptsession` is a lightweight Python module for managing structured, multi-turn conversations with OpenAI’s ChatGPT models. It supports multiple concurrent sessions, automatic token tracking, message truncation, and full conversation recording.

---

## 📦 Installation

```bash
pip install gptsession
```

---

## ✨ Features

- Supports multiple parallel chat sessions
- Token-aware truncation based on model limits
- Tracks actual tokens sent and received
- Maintains full untruncated conversation history
- Clean, minimal API: `setup()`, `say()`, `system()`, `model()`, etc.

---

## 🚀 Quick Start

```python
import gptsession

gptsession.setup(open("mykey.txt").read().strip())
gptsession.new()
gptsession.model("gpt-3.5-turbo")
gptsession.system("You are a helpful assistant.")

reply = gptsession.say("Hello! Can you explain recursion?")
print("ChatGPT:", reply)

if gptsession.truncated():
    print("[Note: Earlier messages were removed to stay within token limits.]")
```

---

## 🔄 Multiple Sessions Example

```python
import gptsession as gpt

gpt.setup(open("mykey.txt").read().strip())

s1 = gpt.new()
gpt.system("You are a bird.")

s2 = gpt.new()
gpt.system("You are a robot.")

gpt.sel(s1)
print(gpt.say("Where do you live?"))

gpt.sel(s2)
print(gpt.say("Where do you live?"))
```

---

## 📄 License

MIT License  
© 2025 Lion Kimbro

---

## 🌐 Project Links

- [Homepage](https://github.com/LionKimbro/gptsession)
- [Bug Tracker](https://github.com/LionKimbro/gptsession/issues)
