InferenceAI

Enter at least two characters to search.

Start free
Repository challenges

Separate model-provider adapters

Refactoring · Intermediate · AI engineering · 35 minutes

Engineering ticket

Refactor route(provider, text) to delegate to AlphaAdapter or BetaAdapter in adapters.py. AlphaAdapter.generate(text) returns "alpha:" + text.strip(); BetaAdapter.generate(text) returns "beta:" + text.strip(). Unknown providers raise ValueError. Preserve behavior and expose both classes in adapters.py.

Review rubric

  • Correctness on documented inputs
  • Tests and edge cases
  • Clear explanation of trade-offs

Reading the ticket and starter files is public. Sign in to save edits, run tests and submit evidence. Code-review quality requires human review.

Starter repository

README.md
# InferenceAI engineering lab

Read the ticket, inspect the files, reproduce the issue and implement the contract. Run visible tests while working. Submit checks protected cases. Explain your changes and limitations.
service.py
def route(provider, text):
    if provider == "alpha":
        return "alpha:" + text.strip()
    if provider == "beta":
        return "beta:" + text.strip()
    raise ValueError("Unknown provider")
adapters.py
# Implement the two adapter classes here.
tests/test_service.py
import unittest
from service import *

class ContractTest(unittest.TestCase):
    def test_example(self):
        self.assertEqual(route("alpha", " hello "), "alpha:hello")