|
NeoGraph 0.10.0
A C++17 Graph Agent Engine Library — LangGraph for C++
|
LLM provider for OpenAI-compatible APIs. More...
#include <openai_provider.h>
Classes | |
| struct | Config |
| Configuration for OpenAI-compatible API connections. More... | |
Public Member Functions | |
| asio::awaitable< ChatCompletion > | complete_async (const CompletionParams ¶ms) override |
| Async completion — dispatches over the owned ConnPool so successive calls reuse a kept-alive TCP+TLS connection. | |
| ChatCompletion | complete_stream (const CompletionParams ¶ms, const StreamCallback &on_chunk) override |
Sync completion is inherited from Provider::complete(), which drives complete_async via neograph::async::run_sync. | |
| std::string | get_name () const override |
| Get the provider name (e.g., "openai", "claude"). | |
| asio::awaitable< ChatCompletion > | invoke (const CompletionParams ¶ms, StreamCallback on_chunk) override |
| v1.0 single-dispatch override (Candidate 6 PR6). | |
| ~OpenAIProvider () | |
| Destructor — shuts down the long-lived HTTP loop + worker thread held alongside the ConnPool. | |
Public Member Functions inherited from neograph::Provider | |
| virtual ChatCompletion | complete (const CompletionParams ¶ms) |
| Perform a synchronous LLM completion. | |
| virtual asio::awaitable< ChatCompletion > | complete_stream_async (const CompletionParams ¶ms, const StreamCallback &on_chunk) |
| Async streaming completion. | |
Static Public Member Functions | |
| static std::unique_ptr< OpenAIProvider > | create (const Config &config) |
| Create an OpenAI provider instance. | |
| static std::shared_ptr< Provider > | create_shared (const Config &config) |
Same as create but returns a shared_ptr<Provider>. | |
LLM provider for OpenAI-compatible APIs.
Connects to any endpoint following the OpenAI chat completions API format (/v1/chat/completions). Configure via Config struct.
Definition at line 38 of file openai_provider.h.
|
overridevirtual |
Async completion — dispatches over the owned ConnPool so successive calls reuse a kept-alive TCP+TLS connection.
The previous "fresh socket per call" comment has aged out: the pool is bound to a long-lived background io_context owned by this provider, so run_sync per-call destruction no longer affects pool lifetime.
Reimplemented from neograph::Provider.
|
static |
Create an OpenAI provider instance.
| config | Connection and authentication configuration. |
|
inlineoverridevirtual |
Get the provider name (e.g., "openai", "claude").
Opaque debug identifier, not a typed dispatch key. Different subclasses pick different conventions:
OpenAIProvider always returns "openai".SchemaProvider returns whatever's in the schema's name field — could be "openai", "claude", "openai-responses", "gemini", or a user-defined schema id.RateLimitedProvider delegates to its inner provider.Code branching on the exact string (e.g. if (get_name() == "openai-responses")) is brittle — a custom schema named "openai-responses-v2" slips through, or a future rename silently breaks the branch. Use it for logging, telemetry, or version-pinning diagnostics. For typed behaviour, add a typed ProviderKind accessor or branch on the schema's actual fields.
Implements neograph::Provider.
Definition at line 104 of file openai_provider.h.
|
overridevirtual |
v1.0 single-dispatch override (Candidate 6 PR6).
Native invoke() that directly drives the ConnPool — no extra hop through complete_stream_async's default worker-thread bridge for streaming, no extra hop through complete_async for non- streaming. The 4 legacy overrides above stay as thin adapters over invoke() through the v0.9 deprecation window; v1.0 deletes them along with the base-class virtuals.
Reimplemented from neograph::Provider.