Ir para o conteúdo

openai_router

module wittgenstein_fastapi_openai.openai_router

Classes

  • ChatCompletionProxy — Abstract base class that must be implemented by any service serving chat completions.

Functions

  • create_openai_router — Create a FastAPI APIRouter preconfigured with the OpenAI Chat Completion endpoint.

wittgenstein_fastapi_openai.openai_router.ChatCompletionProxy

class ChatCompletionProxy()

Bases : ABC

Abstract base class that must be implemented by any service serving chat completions.

Methods

  • handle_chat_completion — Handle incoming OpenAI-compatible Chat Completion request and return the response.

wittgenstein_fastapi_openai.openai_router.ChatCompletionProxy.handle_chat_completion

async method ChatCompletionProxy.handle_chat_completion(self, payload: OpenAIChatCompletionsIn) → Any

Handle incoming OpenAI-compatible Chat Completion request and return the response.

wittgenstein_fastapi_openai.openai_router.create_openai_router

create_openai_router(proxy: ChatCompletionProxy) → APIRouter

Create a FastAPI APIRouter preconfigured with the OpenAI Chat Completion endpoint.

Parameters

Raises

  • HTTPException