Skip to main content

LLM Dialog Manager

A Python package for managing AI chat conversation history with support for multiple LLM providers (OpenAI, Anthropic, Google, X.AI) and convenient conversation management features.

Features

  • Support for multiple AI providers:
    • OpenAI (GPT-3.5, GPT-4)
    • Anthropic (Claude)
    • Google (Gemini)
    • X.AI (Grok)
  • Intelligent message role management (system, user, assistant)
  • Conversation history tracking and validation
  • Load balancing across multiple API keys
  • Error handling and retry mechanisms
  • Conversation saving and loading
  • Memory management options
  • Conversation search and indexing
  • Rich conversation display options

Installation

pip install llm-dialog-manager

Quick Start

Basic Usage

from llm_dialog_manager import ChatHistory

# Initialize with a system message
history = ChatHistory("You are a helpful assistant")

# Add messages
history.add_user_message("Hello!")
history.add_assistant_message("Hi there! How can I help you today?")

# Print conversation
print(history)

Using the AI Agent

from llm_dialog_manager import Agent

# Initialize an agent with a specific model
agent = Agent("claude-2.1", memory_enabled=True)

# Add messages and generate responses
agent.add_message("system", "You are a helpful assistant")
agent.add_message("user", "What is the capital of France?")
response = agent.generate_response()

# Save conversation
agent.save_conversation()

Advanced Features

Managing Multiple API Keys

from llm_dialog_manager import Agent

# Use specific API key
agent = Agent("gpt-4", api_key="your-api-key")

# Or use environment variables
# OPENAI_API_KEY_1=key1
# OPENAI_API_KEY_2=key2
# The system will automatically handle load balancing

Conversation Management

from llm_dialog_manager import ChatHistory

history = ChatHistory()

# Add messages with role validation
history.add_message("Hello system", "system")
history.add_message("Hello user", "user")
history.add_message("Hello assistant", "assistant")

# Search conversations
results = history.search_for_keyword("hello")

# Get conversation status
status = history.conversation_status()
history.display_conversation_status()

# Get conversation snippets
snippet = history.get_conversation_snippet(1)
history.display_snippet(1)

Environment Variables

Create a .env file in your project root:

# OpenAI
OPENAI_API_KEY_1=your-key-1
OPENAI_API_BASE_1=https://api.openai.com/v1

# Anthropic
ANTHROPIC_API_KEY_1=your-anthropic-key
ANTHROPIC_API_BASE_1=https://api.anthropic.com

# Google
GEMINI_API_KEY=your-gemini-key

# X.AI
XAI_API_KEY=your-x-key

Development

Running Tests

pytest tests/

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

For support, please open an issue in the GitHub repository or contact the maintainers.

Release files for llm-dialog-manager 0.1.750

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llm-dialog-manager 0.1.750
File Size Uploaded
llm_dialog_manager-0.1.750.tar.gz 11.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llm-dialog-manager 0.1.750
File Interpreter ABI Platform
llm_dialog_manager-0.1.750-py3-none-any.whl Python 3 none any Details

Total release size: 21.8 kB

Release files / llm_dialog_manager-0.1.750.tar.gz

Download URL llm_dialog_manager-0.1.750.tar.gz
Size 11.6 kB
Tags Source
SHA-256 checksum
How to use checksums
fa7030427018eef5a28b415c429427f84d7e9a3d2dec98b1a995a8e4f699fe62
BLAKE2b-256 checksum
How to use checksums
7e7cd9ac1528b838d0f4e7d1026e428e143b2d7b9c8701d576ac6b87f9e11b04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release files / llm_dialog_manager-0.1.750-py3-none-any.whl

Download URL llm_dialog_manager-0.1.750-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9b72eae75a076a86dae8c766b0eb785127f1ba8c125928006b4fbbb4c7c072b7
BLAKE2b-256 checksum
How to use checksums
5e9f1ec5b4e0a88d09d40dbcde466b87b6397ecdcdb447dbb678a79bab72c0de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.7

Release history Release notifications | RSS feed

0.5.3

2 release files

0.5.0

2 release files

0.4.7

2 release files

0.4.6

2 release files

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.2

2 release files

0.3.1

2 release files

0.2.14

2 release files

0.2.7

2 release files

0.2.6

2 release files

0.2.4

2 release files

0.2.2

2 release files

0.2.1

2 release files

This release

0.1.750 This release

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page