"""OpenAI (and OpenAI-compatible) LLM backend. Stub — implement when needed."""
from typing import AsyncGenerator
from .base import LLMBackend, LLMChunk, LLMResponse, Message, ToolSchema
class OpenAIBackend(LLMBackend):
"""
Supports OpenAI and any OpenAI-compatible endpoint (vLLM, LM Studio, etc.).
Set base_url to point at a compatible server.
"""
def __init__(self, model: str, api_key: str, base_url: str | None = None):
self.model = model
self._api_key = api_key
self._base_url = base_url
async def complete(
self,
messages: list[Message],
tools: list[ToolSchema] | None = None,
temperature: float = 0.7,
model: str | None = None,
) -> LLMResponse:
raise NotImplementedError("OpenAI backend not yet implemented")
async def stream(
self,
messages: list[Message],
temperature: float = 0.7,
model: str | None = None,
) -> AsyncGenerator[LLMChunk, None]:
raise NotImplementedError("OpenAI backend not yet implemented")
yield # makes this a generator
async def stream_complete(
self,
messages: list[Message],
tools: list["ToolSchema"] | None = None,
temperature: float = 0.7,
model: str | None = None,
) -> AsyncGenerator[LLMChunk, None]:
raise NotImplementedError("OpenAI backend not yet implemented")
yield # makes this a generator