orxtra v0.13.0 /transport.src.orxtra.transport.providers._openai
On this page

OpenAIProvider: Provider implementation for the OpenAI chat completions API -- builds requests, accumulates streamed tool-call deltas, and formats tool results.

#transport.src.orxtra.transport.providers._openai

#transport.src.orxtra.transport.providers._openai

#OpenAIProvider

#build_request

python
def build_request(self, messages: list[dict[str, Any]], tools: list[dict[str, Any]], system: str, model: str) -> dict[str, Any]

#parse_response

python
def parse_response(self, response: dict[str, Any]) -> list[ContentBlock]

#parse_stream

python
async def parse_stream(self, byte_stream: AsyncIterator[bytes]) -> AsyncIterator[TransportEvent]

#extract_usage

python
def extract_usage(self, response: dict[str, Any]) -> Usage

#format_tool_result

python
def format_tool_result(self, tool_use_id: str, content: str, is_error: bool) -> dict[str, Any]

#wrap_tool_results

python
def wrap_tool_results(self, results: list[dict[str, Any]]) -> list[dict[str, Any]]

#format_assistant_message

python
def format_assistant_message(self, blocks: list[ContentBlock]) -> dict[str, Any]

#_format_openai_tool

python
def _format_openai_tool(tool: dict[str, Any]) -> dict[str, Any]

Format a tool spec for the OpenAI API.

Deferred tools get a compact spec with empty parameters and a description hint telling the model to call load_tools first.

Search