Skip to main content

Context management functionalities for the LlamaAI Ecosystem.

Project description

llama-context

PyPI version License Python Version CI Status

Llama Context (llama-context) is a toolkit within the LlamaSearch AI ecosystem designed for managing context in applications, particularly conversational AI or systems requiring state persistence. It likely handles storing, retrieving, and utilizing contextual information (like conversation history, user state, or session data) to inform application behavior.

Key Features

  • Context Management: Core logic for storing, updating, and retrieving context (main.py, core.py).
  • Session Tracking: Potential support for managing context across user sessions.
  • History Management: Specifically handling conversational history or sequences of events.
  • Contextualization: Using stored context to influence downstream tasks (e.g., LLM prompts, recommendations).
  • Storage Backends (Potential): May support different storage mechanisms for context (memory, DB, file).
  • Configurable: Allows defining context window size, storage options, expiration policies, etc. (config.py).

Installation

pip install llama-context
# Or install directly from GitHub for the latest version:
# pip install git+https://github.com/llamasearchai/llama-context.git

Usage

(Usage examples demonstrating how to store, retrieve, and use context will be added here.)

# Placeholder for Python client usage
# from llama_context import ContextManager, ContextConfig

# config = ContextConfig.load("config.yaml")
# context_manager = ContextManager(config)

# session_id = "user123_sessionABC"

# # Add items to context
# context_manager.add_entry(session_id, {"role": "user", "content": "Hello there!"})
# context_manager.add_entry(session_id, {"role": "assistant", "content": "Hi! How can I help?"})

# # Retrieve context
# current_context = context_manager.get_context(session_id, max_length=10)
# print(current_context)

# # Use context (e.g., for an LLM prompt)
# # prompt = build_prompt_with_context(current_context, new_user_query="Tell me a joke")
# # llm_response = llm.generate(prompt)
# # context_manager.add_entry(session_id, {"role": "user", "content": "Tell me a joke"})
# # context_manager.add_entry(session_id, {"role": "assistant", "content": llm_response})

Architecture Overview

graph TD
    A[Application / Service] --> B{Context Manager (main.py, core.py)};
    B -- Read/Write --> C[(Context Store (Memory, DB, File))];
    A -- Request Context --> B;
    B -- Returns Context --> A;
    A -- Add Context Entry --> B;

    D[Configuration (config.py)] -- Configures --> B;
    D -- Configures --> C;

    style B fill:#f9f,stroke:#333,stroke-width:2px
    style C fill:#ccf,stroke:#333,stroke-width:1px
  1. Interaction: An application interacts with the Context Manager to store or retrieve contextual information (e.g., for a specific user or session).
  2. Context Manager: Handles the logic for adding new entries, retrieving relevant context (potentially based on size limits or relevance), and managing the context lifecycle.
  3. Context Store: The actual storage backend where contextual data is persisted (e.g., in-memory dictionary, Redis, database).
  4. Configuration: Defines storage backend details, context window size, expiration rules, etc.

Configuration

(Details on configuring context storage backend (type, connection details), context length limits, expiration policies, session management, etc., will be added here.)

Development

Setup

# Clone the repository
git clone https://github.com/llamasearchai/llama-context.git
cd llama-context

# Install in editable mode with development dependencies
pip install -e ".[dev]"

Testing

pytest tests/

Contributing

Contributions are welcome! Please refer to CONTRIBUTING.md and submit a Pull Request.

License

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

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

llama_context-0.1.0.tar.gz (17.3 kB view details)

Uploaded Source

Built Distribution

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

llama_context-0.1.0-py3-none-any.whl (11.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: llama_context-0.1.0.tar.gz
  • Upload date:
  • Size: 17.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for llama_context-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a215f4ac7b455bb75464ac500d32473c60144a969f83812f708425c19b3de8b9
MD5 4676570fcb916f6af2a639bc2c2af0ff
BLAKE2b-256 d00fcb070cabbbc86c265036107a500f93a5a95b8d5afc9349cf660c1f48f621

See more details on using hashes here.

File details

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

File metadata

  • Download URL: llama_context-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 11.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for llama_context-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b64b07c7fe88b7230b96445e19d789abdeb5c64b5d8df0ee68749bbf10ae1fcb
MD5 258e136dc584d96277ba1beb532f8d8d
BLAKE2b-256 41031155bb7dfb45b55221b7838a6220e936aa4953274579958f26619452beb4

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