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
"""
6
Example provider bundle — minimal working template.
7
8
Purpose
9
-------
10
Importing this package registers :class:`ExampleProvider` into the
11
module-level registry at ``oc_chat.core.provider_plugin.registry``.
12
The rest of the app then retrieves it via ``registry.get("example")``.
13
14
This bundle is intentionally tiny: it returns deterministic stubbed
15
responses ("echo: <last user message>") so it can run *without any
16
SDK or network access*. It still uses canonical Option C tooling
17
(``oc_diagnostics`` for ``_dbg``) — no provider bundle is exempt
18
from project-wide diagnostics coverage.
19
20
Use 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
32
See ``providers/README.md`` for the full bundle layout reference and
33
``providers/example/README.md`` for the per-step "make it your own"
34
recipe.
35
36
Responsibilities
37
----------------
38
- Self-register :class:`ExampleProvider` on import.
39
- Re-export :class:`ExampleProvider` for direct access.
40
41
Diagnostics
42
-----------
43
Domain: OC_CHAT.CLIENT
44
Levels:
45
L2 — lifecycle events
46
L3 — semantic details
47
L4 — deep tracing
48
49
Contracts
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
57
Dependencies
58
------------
59
- oc_diagnostics (structured debug logging via _dbg)
60
- providers.example.provider (ExampleProvider, registered and re-exported on import)
61
"""
62
from
oc_diagnostics
import
_dbg
63
64
from
.provider
import
ExampleProvider
65
66
ExampleProvider.register()
67
68
_dbg(
"OC_CHAT.CLIENT"
,
"module"
,
"loaded"
, 4)
69
70
__all__ = [
"ExampleProvider"
]
providers
example
__init__.py
Generated by
1.15.0