Write async def complete(prompt, providers, timeout). providers is a list of async functions
provider(prompt) -> str, in order of preference. Call them one at a time:
timeout seconds, return {"text": ..., "provider": index}.{"text": None, "provider": None}.The harness builds fake providers with fixed delays and failures.
Implement complete. Input: prompt: str, providers: list of async callables, timeout: float. Returns: dict.
This code runs before yours (fake clients, clocks and the test harness). You can use its names; don't edit them.
import asyncio
def _make(spec):
async def provider(prompt):
await asyncio.sleep(spec["delay"])
if spec.get("error"):
raise RuntimeError(spec["error"])
return f"{spec['name']}: {prompt}"
return provider
async def __harness__(fn, prompt, specs, timeout):
return await fn(prompt, [_make(s) for s in specs], timeout)
import asyncio
async def complete(prompt: str, providers: list, timeout: float) -> dict:
return {"text": await providers[0](prompt), "provider": 0}
Run executes the public tests. Submit grades against public and hidden tests.
Write async def complete(prompt, providers, timeout). providers is a list of async functions
provider(prompt) -> str, in order of preference. Call them one at a time:
timeout seconds, return {"text": ..., "provider": index}.{"text": None, "provider": None}.The harness builds fake providers with fixed delays and failures.
Implement complete. Input: prompt: str, providers: list of async callables, timeout: float. Returns: dict.
This code runs before yours (fake clients, clocks and the test harness). You can use its names; don't edit them.
import asyncio
def _make(spec):
async def provider(prompt):
await asyncio.sleep(spec["delay"])
if spec.get("error"):
raise RuntimeError(spec["error"])
return f"{spec['name']}: {prompt}"
return provider
async def __harness__(fn, prompt, specs, timeout):
return await fn(prompt, [_make(s) for s in specs], timeout)
import asyncio
async def complete(prompt: str, providers: list, timeout: float) -> dict:
return {"text": await providers[0](prompt), "provider": 0}
Run executes the public tests. Submit grades against public and hidden tests.