OpenAI-Compatible Provider
OpenAI-Compatible Provider Plugin (plugins/providers/openai/python/openai_provider.py)
Minimal provider for OpenAI-compatible Chat Completions endpoints (e.g., Ollama at /v1). Loads configuration only from the provided config dict (no environment variable usage).
OpenAICompatibleProvider
OpenAICompatibleProvider()
Bases: ProviderPlugin
Source code in core/python/plugins/openai_provider.py
53 54 55 | |
extract_delta
extract_delta(native_chunk)
Extract a provider-native delta dictionary from a streaming chunk.
Returns the first choice object when present, or an empty dict.
Source code in core/python/plugins/openai_provider.py
426 427 428 429 430 431 432 433 434 | |
finalize
finalize(native_messages, state)
Finalize streaming by emitting the accumulated partial as a final.
When streaming was used, state["partial"] holds the merged assistant
message (content, role, reasoning, tool_calls, etc.) built up across
chunks by the provider and any extensions. Non-streaming calls leave it
as None.
Source code in core/python/plugins/openai_provider.py
500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 | |
from_native_messages
from_native_messages(native_messages, state)
Convert provider-native finals to core messages.
This provider-level conversion intentionally ignores any provider-specific reasoning fields. Reasoning content should be surfaced by dedicated extensions (e.g., thinking extensions) via message metadata rather than as a top-level field.
Source code in core/python/plugins/openai_provider.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | |
get_models
get_models(config)
Return minimal model descriptors for this provider.
Currently returns the configured model (if any) as a single
ModelDescriptor with only an id field.
Source code in core/python/plugins/openai_provider.py
105 106 107 108 109 110 111 112 113 114 | |
get_tags
get_tags(config, models)
Return capability tags for the OpenAI-compatible provider.
This implementation is intentionally simple and conservative; it assumes chat-completions style models with tool calling and streaming support.
Source code in core/python/plugins/openai_provider.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 | |
process_chunk
process_chunk(native_chunk, native_messages, state)
Process a streaming chunk into provider-native partials.
Pattern:
- Extract a delta from the chunk
- Reduce it into a partial fragment and update the accumulator
- Do not emit finals or modify history; :meth:finalize is responsible
for producing the final message from the accumulated partial.
Source code in core/python/plugins/openai_provider.py
476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 | |
process_delta
process_delta(delta, accumulated)
Reduce a delta dict into a new partial and accumulator.
Returns the current partial fragment from this chunk and an updated
accumulator used later by :meth:finalize to build the final message.
Source code in core/python/plugins/openai_provider.py
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 | |