Skip to content

Feature: Phase 5 - Provider Layer with LLM and Retriever Adapters#7

Merged
himanshu231204 merged 2 commits into
mainfrom
feature/phase-5-providers
Jul 8, 2026
Merged

Feature: Phase 5 - Provider Layer with LLM and Retriever Adapters#7
himanshu231204 merged 2 commits into
mainfrom
feature/phase-5-providers

Conversation

@himanshu231204

Copy link
Copy Markdown
Contributor

Summary

Implement Phase 5 (Providers) for OpenAgent Eval - a complete provider layer with LLM and Retriever interfaces, adapters for 6 LLM providers and 1 retriever, and comprehensive unit tests.

Motivation

Phase 5 is required to enable the evaluation pipeline to interact with external LLM services and vector databases. The provider layer follows the adapter pattern, allowing the framework to be framework-agnostic while supporting multiple LLM providers and retrieval backends.

Files Modified

New Files

  • openagent_eval/providers/base/llm.py - LLMProvider ABC with async generate() and get_token_count()
  • openagent_eval/providers/base/retriever.py - Retriever ABC with async retrieve()
  • openagent_eval/providers/models.py - LLMResponse, Document, TokenUsage Pydantic v2 models
  • openagent_eval/providers/llm/openai.py - OpenAI adapter with tiktoken
  • openagent_eval/providers/llm/gemini.py - Gemini adapter with google-genai SDK
  • openagent_eval/providers/llm/anthropic.py - Anthropic adapter with anthropic SDK
  • openagent_eval/providers/llm/groq.py - Groq adapter with groq SDK
  • openagent_eval/providers/llm/openrouter.py - OpenRouter adapter with httpx
  • openagent_eval/providers/llm/ollama.py - Ollama adapter with httpx
  • openagent_eval/providers/retrievers/chroma.py - ChromaRetriever with chromadb
  • 8 test files under ests/unit/test_providers/

Modified Files

  • openagent_eval/providers/init.py - Added exports
  • openagent_eval/providers/base/init.py - Added exports
  • openagent_eval/providers/llm/init.py - Added all LLM provider exports
  • openagent_eval/providers/retrievers/init.py - Added ChromaRetriever export

Architectural Decisions

  1. Async-first interface - All provider methods are async for parallel evaluation (per D006)
  2. Adapter pattern - LLMProvider and Retriever are outbound ports, adapters implement them (per AGENT.md)
  3. Dependency injection - All external dependencies injected via constructor
  4. Pydantic v2 models - Immutable models with field validators for type safety
  5. Token counting - All LLM providers implement get_token_count() for cost tracking

Breaking Changes

None - this is a new module addition.

Testing

  • 138 new unit tests (all passing)
  • All external dependencies mocked (no real API calls)
  • Both success and error paths tested
  • ABCs verified to be non-instantiable
  • Model validation tests for all Pydantic models

Remaining TODOs

None - Phase 5 is complete.

Assumptions & Limitations

  • OpenRouter uses simple whitespace-based token estimation (no tiktoken)
  • Ollama token tracking uses API response metadata
  • All providers require API keys via constructor or environment variables

- Define LLMProvider ABC with async generate() and get_token_count() methods
- Define Retriever ABC with async retrieve() method
- Define LLMResponse, Document, and TokenUsage Pydantic v2 models
- Implement OpenAI adapter with tiktoken token counting
- Implement Gemini adapter with google-genai SDK
- Implement Anthropic adapter with anthropic SDK
- Implement Groq adapter with groq SDK
- Implement OpenRouter adapter with httpx (OpenAI-compatible API)
- Implement Ollama adapter with httpx (local REST API)
- Implement ChromaRetriever adapter with chromadb
- Add 138 unit tests covering all providers (ABCs, models, adapters)
- All tests passing, linting passes (ruff)
Copilot AI review requested due to automatic review settings July 8, 2026 12:46

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@himanshu231204 himanshu231204 self-assigned this Jul 8, 2026
@himanshu231204 himanshu231204 merged commit 2fb32fc into main Jul 8, 2026
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