Files
Josh Knapp d67625cd5a Phase 5: AI provider system with local and cloud support
- Implement AIProvider base interface with chat() and is_available()
- Add LocalProvider connecting to bundled llama-server via OpenAI SDK
- Add OpenAIProvider for direct OpenAI API access
- Add AnthropicProvider for Anthropic Claude API
- Add LiteLLMProvider for multi-provider gateway
- Build AIProviderService with provider routing, auto-selection,
  and transcript context injection
- Add ai.chat IPC handler supporting chat, list_providers, set_provider,
  and configure actions
- Add ai_chat, ai_list_providers, ai_configure Tauri commands
- Build interactive AIChatPanel with message history, quick actions
  (Summarize, Action Items), and transcript context awareness
- Tests: 30 Python, 6 Rust, 0 Svelte errors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 16:25:10 -08:00

67 lines
2.0 KiB
Python

"""Main entry point for the Voice to Notes Python sidecar."""
from __future__ import annotations
import signal
import sys
from voice_to_notes.ipc.handlers import (
HandlerRegistry,
hardware_detect_handler,
make_ai_chat_handler,
make_diarize_handler,
make_export_handler,
make_pipeline_handler,
make_transcribe_handler,
ping_handler,
)
from voice_to_notes.ipc.messages import ready_message
from voice_to_notes.ipc.protocol import read_message, write_message
def create_registry() -> HandlerRegistry:
"""Set up the message handler registry."""
registry = HandlerRegistry()
registry.register("ping", ping_handler)
registry.register("transcribe.start", make_transcribe_handler())
registry.register("hardware.detect", hardware_detect_handler)
registry.register("diarize.start", make_diarize_handler())
registry.register("pipeline.start", make_pipeline_handler())
registry.register("export.start", make_export_handler())
registry.register("ai.chat", make_ai_chat_handler())
return registry
def main() -> None:
"""Main loop: read messages from stdin, dispatch to handlers, write responses to stdout."""
# Handle clean shutdown
def shutdown(signum: int, frame: object) -> None:
print("[sidecar] Shutting down...", file=sys.stderr, flush=True)
sys.exit(0)
signal.signal(signal.SIGTERM, shutdown)
signal.signal(signal.SIGINT, shutdown)
registry = create_registry()
# Signal to Rust that we're ready
write_message(ready_message())
print("[sidecar] Ready and waiting for messages", file=sys.stderr, flush=True)
# Message loop
while True:
msg = read_message()
if msg is None:
# EOF — parent closed stdin, time to exit
print("[sidecar] EOF on stdin, exiting", file=sys.stderr, flush=True)
break
response = registry.handle(msg)
if response is not None:
write_message(response)
if __name__ == "__main__":
main()