Add experimental AI/LLM provider abstraction with local Ollama support - #52
Merged
Conversation
Starter slice for AI features: a provider abstraction, an OpenAI-compatible local backend, config/CLI wiring, and a safe connectivity check. Defaults to a local, self-hosted backend since forensic case data often cannot leave the examiner's machine; cloud providers (Anthropic, OpenAI) are opt-in placeholders only. No case-data-touching feature ships in this slice. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018MrbNYDqa5eLQdKyvYuTjD
Owner
Author
|
Experimental AI/ML pluggable provider |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR introduces an experimental, pluggable LLM provider abstraction to YAFT with a working local backend (Ollama and OpenAI-compatible servers) and full CLI/configuration wiring. AI features are disabled by default and default to local-only execution to ensure forensic case data never leaves the examiner's machine unless explicitly configured.
Key Changes
AI Configuration System (
src/yaft/core/ai_config.py): Pydantic models for AI provider configuration with validation. Supports Ollama (default, local), Anthropic, and OpenAI (placeholders, not yet implemented). Configuration loaded fromconfig/ai.tomlwith sensible defaults.Provider Factory & Base Types (
src/yaft/ai/factory.py,src/yaft/ai/providers/base.py): Factory function to build configured providers. Base protocol definesis_available()andsummarize()interface.OpenAI-Compatible Provider (
src/yaft/ai/providers/openai_compatible.py): Working implementation for Ollama, llama.cpp, LM Studio, LocalAI, and vLLM. Includes minimal audit logging (timestamps, latency, success/failure only—never logs prompt/response content).Exception Hierarchy (
src/yaft/ai/exceptions.py): Clear error types for disabled features, unimplemented providers, and provider failures.CLI Commands (
src/yaft/cli.py):ai-configure: Configure provider, model, base URL, and enable/disable AI featuresai-status: Check configuration and test connectivity (no case data sent)CoreAPI Integration (
src/yaft/core/api.py):_load_ai_config(): Loads and merges TOML configuration with defaultsget_llm_provider(): Public API to retrieve configured provider instanceConfiguration File (
config/ai.toml): Example configuration with detailed comments explaining the local-first, opt-in design.Comprehensive Tests (
tests/test_ai_config.py,tests/test_ai_providers.py):Documentation (
docs/YaFT.md,README.md): Usage examples and design rationale.Notable Implementation Details
AIProviderNotImplementedErrorif selected, with a clear message directing users to the local backend.https://claude.ai/code/session_018MrbNYDqa5eLQdKyvYuTjD