Skip to main content

An agentic AI assistant built on top of the Llama language model, designed to provide intelligent assistance through a robust function calling system. It offers seamless integration of chat capabilities with file operations and memory management.

Project description

Lucius Assistant

PyPI version

Lucius Assistant is an agentic AI assistant built on top of the Llama language model, designed to provide intelligent assistance through a robust function calling system. It offers seamless integration of chat capabilities with file operations and memory management.

Features

  • Intelligent Model Selection: Automatically selects the most suitable Llama model (3.1, 3.2, or others) with preference for 8b parameter versions
  • File Operations:
    • Directory listing with safety checks
    • File reading and writing with path validation
    • File and folder copying with automatic directory creation
  • Memory System:
    • Store and retrieve text memories with UUID-based identification
    • Contextual memory search with relevance scoring
    • Memory management (add, remove, search)
  • Event-Driven Architecture:
    • Real-time streaming text processing
    • Separate handling of chat and function calls
    • Automated response generation
  • Safety Features:
    • Path validation to prevent directory traversal
    • Relative path enforcement
    • Graceful error handling
    • Automatic parent directory creation

Installation

pip install luciusassistant

Requirements

Usage

Basic Usage

from luciusassistant import LuciusAssistant, get_builtin_function_calls

# Initialize Lucius with built-in functions
lucius = LuciusAssistant()
lucius.set_function_calls(get_builtin_function_calls()) # Contains a built-in function to list the current directory and read files

# Chat with Lucius
response = lucius.chat("Hello, can you take a look at the current project?")

File Operations

from luciusassistant import LuciusAssistant, get_builtin_function_calls

# Initialize with built-in functions
lucius = LuciusAssistant()
lucius.set_function_calls(get_builtin_function_calls())

# List directory contents
lucius.chat("List the contents of the current directory")

# Read a file
lucius.chat("Read the contents of config.json")

# Write to a file
lucius.chat("Create a new file named example.txt with 'Hello World' content")

Memory System

from luciusassistant import LuciusAssistant, get_builtin_function_calls

# Initialize with built-in functions
lucius = LuciusAssistant()
lucius.set_function_calls(get_builtin_function_calls()) # Contains a built-in function to store and retrieve memories

# Store a memory
lucius.chat("Remember this phone number for support: 1-800-SUPPORT")

# Long conversation later...

# Search memories
lucius.chat("Find any stored support contact information")

# Lucius finds the support phone number memory

# Remove a memory
lucius.chat("Remove that memory")

Creating Custom Functions

You can extend Lucius's capabilities by creating custom functions:

from luciusassistant import LuciusAssistant, FunctionCall, get_builtin_function_calls

# Create a custom function
class WeatherFunctionCall(FunctionCall):
    def __init__(self):
        super().__init__(
            name="get_weather",
            parameters={
                "city": "Name of the city",
                "country": "Country code (e.g., US, UK)"
            },
            description="Get the current weather for a specified city"
        )

    def invoke(self, city: str, country: str = "US"):
        try:
            # Implement your weather API call here
            return f"Weather information for {city}, {country}"
        except Exception as e:
            return f"Failed to get weather: {str(e)}"

# Initialize Lucius with both built-in and custom functions
lucius = LuciusAssistant()
function_calls = get_builtin_function_calls()
function_calls.append(WeatherFunctionCall())
lucius.set_function_calls(function_calls) # Very impotant you call this function at the start because this will clear the conversation history

# Use the custom function
lucius.chat("What's the weather like in San Francisco?")

Architecture

Lucius Assistant is built with a modular architecture:

  1. Core Engine: Based on chatollama, utilizing Llama models for text generation
  2. Function Call System: XML-like format for structured function invocation
  3. Event System: Handles streaming, function results, and response generation
  4. Memory Management: In-memory storage with UUID-based retrieval
  5. Safety Layer: Input validation and path safety checks

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

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

Acknowledgments

  • Built on top of the Llama language model
  • Uses chatollama for core functionality

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

luciusassistant-0.3.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

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

luciusassistant-0.3-py3-none-any.whl (12.5 kB view details)

Uploaded Python 3

File details

Details for the file luciusassistant-0.3.tar.gz.

File metadata

  • Download URL: luciusassistant-0.3.tar.gz
  • Upload date:
  • Size: 13.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for luciusassistant-0.3.tar.gz
Algorithm Hash digest
SHA256 dad06b0dece566594480c8ff322d95233c4eb22c2ee18f0d951f9fb04952ebad
MD5 c020a20f57179dcc9d475ab086238ef7
BLAKE2b-256 e91c403ba6cebf559f581ba29e389dbe0f301fcb3bf654e984285f66c26ab4b7

See more details on using hashes here.

File details

Details for the file luciusassistant-0.3-py3-none-any.whl.

File metadata

  • Download URL: luciusassistant-0.3-py3-none-any.whl
  • Upload date:
  • Size: 12.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for luciusassistant-0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 688d78e9900fa7af6d8061c649346ba0d09b9e4966cc64ed25b677db7e81002b
MD5 01ea3b08f18ba5de9ba0799d121067d9
BLAKE2b-256 ce36a44240d719c95fabbbb4b003a6fd4eb0fe9d2e2654f2f23c41672bdf16fa

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