Skip to content

feat: provider abstraction layer — BaseProvider ABC + ProviderFactory [GSoC 2026 Draft]#108

Open
vanshjohri09-collab wants to merge 1 commit intosugarlabs:mainfrom
vanshjohri09-collab:gsoc2026-provider-prototype
Open

feat: provider abstraction layer — BaseProvider ABC + ProviderFactory [GSoC 2026 Draft]#108
vanshjohri09-collab wants to merge 1 commit intosugarlabs:mainfrom
vanshjohri09-collab:gsoc2026-provider-prototype

Conversation

@vanshjohri09-collab
Copy link
Copy Markdown

@vanshjohri09-collab vanshjohri09-collab commented Mar 28, 2026

GSoC 2026 — Provider Abstraction Layer: Foundation

This draft PR introduces the foundational files for the provider
abstraction layer proposed in my GSoC 2026 application.

What this adds

  • app/providers/base.pyBaseProvider ABC with generate(),
    chat(), stream(), health_check() abstract methods
  • app/providers/factory.pyget_provider() reading AI_PROVIDER
    from .env, defaulting to huggingface_local (zero regression)
  • app/providers/__init__.py — package init

Design decisions

Default is huggingface_local — existing behaviour is fully
preserved. No deployment breaks if AI_PROVIDER is not set.

RAGAgent integration point: app/routes/api.py currently calls
RAGAgent(model=settings.DEFAULT_MODEL). After this project, that
becomes:

provider = get_provider()
agent = RAGAgent(provider=provider)

This PR establishes the interface that makes that change possible.

What comes next (GSoC scope)

  • HuggingFaceLocalProvider — wraps existing inference code
  • OllamaProvider — local offline inference via /api/generate
  • HuggingFaceAPIProvider — Inference API with token
  • CustomProvider — any OpenAI-compatible endpoint
  • Fallback chain with health_check() caching
  • Full pytest + mock test suite (no real API needed in CI)

Related

GSoC 2026 proposal: provider abstraction layer for sugar-ai
Fixes known bug: extract_answer_from_output() breaks with
non-HuggingFace model output format (verified with llama3, mistral)


Draft — interface design open for mentor feedback before
implementation begins.

@vanshjohri09-collab
Copy link
Copy Markdown
Author

vanshjohri09-collab commented Apr 15, 2026

Hi @chimosky I've finalized the BaseProvider ABC and the Factory pattern This forms the foundation for my GSoC proposal Looking forward to your initial feedback on the architecture ,@walterbender @sum2it since you both have a great bird's-eye view of the project, I’d love your thoughts on whether this abstraction fits well with the upcoming UI features Ready for review!

@chimosky
Copy link
Copy Markdown
Member

Seeing as it's a GSoC project idea, I won't review this and would rather it be worked on within GSoC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants