oc_chat
Loading...
Searching...
No Matches
__init__.py
Go to the documentation of this file.
1#!/usr/bin/env python3
2# -*- coding: utf-8 -*-
3# providers/example/__init__.py
4
5"""
6Example provider bundle — minimal working template.
7
8Purpose
9-------
10Importing this package registers :class:`ExampleProvider` into the
11module-level registry at ``oc_chat.core.provider_plugin.registry``.
12The rest of the app then retrieves it via ``registry.get("example")``.
13
14This bundle is intentionally tiny: it returns deterministic stubbed
15responses ("echo: <last user message>") so it can run *without any
16SDK or network access*. It still uses canonical Option C tooling
17(``oc_diagnostics`` for ``_dbg``) — no provider bundle is exempt
18from project-wide diagnostics coverage.
19
20Use it as:
21
22* A copy template when starting a new provider — every required file
23 is present, every abstract method is implemented with the simplest
24 possible body, and DeepSeek-specific quirks (prefix-cache sentinel,
25 ``extra_body.thinking`` shape, ``OrderedDict`` payload ordering)
26 are documented in comments rather than baked in.
27* A test harness — integration tests that need a working
28 :class:`ProviderPlugin` without hitting a real API can ``import
29 providers.example`` and select it via ``OC_CHAT_PROVIDER=example``.
30 This is the H.2c ``MockProviderPlugin``.
31
32See ``providers/README.md`` for the full bundle layout reference and
33``providers/example/README.md`` for the per-step "make it your own"
34recipe.
35
36Responsibilities
37----------------
38- Self-register :class:`ExampleProvider` on import.
39- Re-export :class:`ExampleProvider` for direct access.
40
41Diagnostics
42-----------
43Domain: OC_CHAT.CLIENT
44Levels:
45 L2 — lifecycle events
46 L3 — semantic details
47 L4 — deep tracing
48
49Contracts
50---------
51- Side effect on import: ``ExampleProvider.register()`` runs once.
52- The bundle must remain *SDK-free* and *network-free* so it works
53 as a fast test harness. Importing ``oc_diagnostics`` is fine —
54 it's first-party Option C tooling, not a foreign dependency.
55- ``__all__`` exposes only the provider class.
56
57Dependencies
58------------
59- oc_diagnostics (structured debug logging via _dbg)
60- providers.example.provider (ExampleProvider, registered and re-exported on import)
61"""
62from oc_diagnostics import _dbg
63
64from .provider import ExampleProvider
65
66ExampleProvider.register()
67
68_dbg("OC_CHAT.CLIENT", "module", "loaded", 4)
69
70__all__ = ["ExampleProvider"]