Alfred is a sophisticated Perl-based AI assistant that leverages the Ollama API to provide intelligent responses with memory capabilities. Built with modern Perl features (5.38+), it offers a robust and extensible framework for AI interactions.
- Intelligent Memory System: Stores and retrieves relevant past interactions using Qdrant vector database
- Context-Aware Responses: Generates responses based on previous conversations
- Concept Extraction: Automatically identifies key concepts from prompts
- Configurable: Easy to customize through environment variables
- Modern Perl: Utilizes Perl 5.38+ features including experimental class syntax
- Perl 5.38 or higher
- Ollama server running locally or accessible via network
- Qdrant vector database (via Docker)
- Required Perl modules (see Installation)
- Clone the repository:
git clone https://github.com/yourusername/alfred.git
cd alfred
- Install dependencies:
cpan install LWP::UserAgent JSON HTTP::Request Dotenv
- Start Qdrant using Docker:
docker run -p 6333:6333 \
-v $(pwd)/qdrant_data:/qdrant/storage \
qdrant/qdrant
- Configure your environment:
cp .env.example .env
# Edit .env with your configuration
Create a .env
file with the following settings:
OLLAMA_BASE_URL=http://localhost:11434
OLLAMA_DEFAULT_MODEL=llama2
OLLAMA_TEMPERATURE=0.7
OLLAMA_TOP_P=0.9
OLLAMA_MAX_TOKENS=4096
# Qdrant Configuration
QDRANT_HOST=http://localhost
QDRANT_PORT=6333
QDRANT_COLLECTION=memories
QDRANT_VECTOR_SIZE=384
QDRANT_DISTANCE=Cosine
Run Alfred with a prompt:
perl bin/alfred.pl "Your question here"
alfred/
├── bin/
│ └── alfred.pl # Main executable
├── lib/
│ └── Alfred/
│ ├── Config.pm # Configuration management
│ ├── HttpClient.pm # HTTP client wrapper
│ ├── MemoryService.pm # Memory and concept management
│ ├── OllamaClient.pm # Ollama API client
│ └── Qdrant/
│ └── Client.pm # Qdrant vector database client
├── .env # Environment configuration
└── Makefile.PL # Build configuration
- Stores and retrieves conversation history using Qdrant
- Extracts key concepts from prompts
- Calculates similarity between prompts
- Provides context for new queries
- Interfaces with Qdrant vector database
- Manages vector storage and retrieval
- Handles similarity searches
- Configurable distance metrics
- Interfaces with Ollama API
- Handles text generation
- Manages model interactions
- Configurable generation parameters
- Manages HTTP requests
- Handles API communication
- Provides error handling
- Supports custom configurations
- Centralizes configuration management
- Loads environment variables
- Provides default values
- Validates settings
- Install development dependencies:
cpanm --installdeps .
- Run tests:
prove -l t/
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Ollama for providing the AI backend
- Qdrant for vector database capabilities
- Perl community for modern language features
- Contributors and maintainers