bee-sdk 0.2.2__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {bee_sdk-0.2.2 → bee_sdk-0.3.0}/PKG-INFO +2 -2
- {bee_sdk-0.2.2 → bee_sdk-0.3.0}/README.md +1 -1
- {bee_sdk-0.2.2 → bee_sdk-0.3.0}/bee_sdk/__init__.py +1 -1
- {bee_sdk-0.2.2 → bee_sdk-0.3.0}/bee_sdk/client.py +26 -7
- {bee_sdk-0.2.2 → bee_sdk-0.3.0}/bee_sdk/mcp.py +37 -6
- bee_sdk-0.3.0/mcpb/pyproject.toml +8 -0
- {bee_sdk-0.2.2 → bee_sdk-0.3.0}/pyproject.toml +1 -1
- {bee_sdk-0.2.2 → bee_sdk-0.3.0}/.gitignore +0 -0
- {bee_sdk-0.2.2 → bee_sdk-0.3.0}/bee_sdk/types.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: bee-sdk
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Official Python client + MCP server for the Bee Intelligence Engine — domain-specialized LoRA-routed LLM by CUI Labs.
|
|
5
5
|
Project-URL: Homepage, https://bee.cuilabs.io
|
|
6
6
|
Project-URL: Documentation, https://bee.cuilabs.io/docs/sdks
|
|
@@ -41,7 +41,7 @@ Official Python client + MCP server for the **Bee Intelligence Engine** — a do
|
|
|
41
41
|
|
|
42
42
|
<!-- mcp-name: io.github.cuilabs/bee -->
|
|
43
43
|
|
|
44
|
-
SDK version: `0.
|
|
44
|
+
SDK version: `0.3.0` — adds per-call/`BEE_MODEL` model-tier selection (bee-cell … bee-swarm; access follows your key's plan) and MCP tool annotations.
|
|
45
45
|
|
|
46
46
|
Includes a hosted **Model Context Protocol** server: `pip install bee-sdk` then
|
|
47
47
|
run `bee-mcp` (stdio) to expose Bee's 11 domain tools to Claude Desktop, Cursor,
|
|
@@ -4,7 +4,7 @@ Official Python client + MCP server for the **Bee Intelligence Engine** — a do
|
|
|
4
4
|
|
|
5
5
|
<!-- mcp-name: io.github.cuilabs/bee -->
|
|
6
6
|
|
|
7
|
-
SDK version: `0.
|
|
7
|
+
SDK version: `0.3.0` — adds per-call/`BEE_MODEL` model-tier selection (bee-cell … bee-swarm; access follows your key's plan) and MCP tool annotations.
|
|
8
8
|
|
|
9
9
|
Includes a hosted **Model Context Protocol** server: `pip install bee-sdk` then
|
|
10
10
|
run `bee-mcp` (stdio) to expose Bee's 11 domain tools to Claude Desktop, Cursor,
|
|
@@ -27,7 +27,7 @@ VS Code, …) this package ships a hosted MCP server — run ``bee-mcp``
|
|
|
27
27
|
from .client import Bee, AsyncBee, BeeError, RateLimitError, BeeAPIError
|
|
28
28
|
from .types import ChatMessage, ChatResponse, Domain, ModelTier
|
|
29
29
|
|
|
30
|
-
__version__ = "0.
|
|
30
|
+
__version__ = "0.3.0"
|
|
31
31
|
__all__ = [
|
|
32
32
|
"Bee",
|
|
33
33
|
"AsyncBee",
|
|
@@ -36,6 +36,16 @@ DEFAULT_TIMEOUT = 60
|
|
|
36
36
|
DEFAULT_RETRIES = 3
|
|
37
37
|
RETRYABLE_STATUS = {429, 500, 502, 503, 504}
|
|
38
38
|
|
|
39
|
+
# Model tier sent in the request body. Which tiers an API key may use is
|
|
40
|
+
# decided by the key's plan at the gateway (403 model_access_denied when the
|
|
41
|
+
# plan doesn't include it). bee-cell is the free tier, so it's the safe
|
|
42
|
+
# default; override per-call or via BEE_MODEL.
|
|
43
|
+
DEFAULT_MODEL = "bee-cell"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _resolve_model(model: Optional[str]) -> str:
|
|
47
|
+
return model or os.environ.get("BEE_MODEL") or DEFAULT_MODEL
|
|
48
|
+
|
|
39
49
|
|
|
40
50
|
class BeeError(Exception):
|
|
41
51
|
"""Base error class for the SDK."""
|
|
@@ -69,7 +79,7 @@ class _BaseClient:
|
|
|
69
79
|
h = {
|
|
70
80
|
"Content-Type": "application/json",
|
|
71
81
|
"Accept": "application/json",
|
|
72
|
-
"User-Agent": "bee-sdk/0.
|
|
82
|
+
"User-Agent": "bee-sdk/0.3.0",
|
|
73
83
|
}
|
|
74
84
|
if self.api_key:
|
|
75
85
|
h["Authorization"] = f"Bearer {self.api_key}"
|
|
@@ -122,16 +132,21 @@ class Bee(_BaseClient):
|
|
|
122
132
|
max_tokens: int = 512,
|
|
123
133
|
temperature: float = 0.3,
|
|
124
134
|
system: Optional[str] = None,
|
|
135
|
+
model: Optional[str] = None,
|
|
125
136
|
) -> str:
|
|
126
137
|
"""Single-turn chat. Returns the assistant text only.
|
|
127
138
|
|
|
128
|
-
|
|
139
|
+
`model` picks the Bee tier (bee-cell … bee-swarm); which tiers your
|
|
140
|
+
key may use is governed by its plan. Defaults to BEE_MODEL env or
|
|
141
|
+
bee-cell. For multi-turn or detailed metadata, use `chat_messages`.
|
|
129
142
|
"""
|
|
130
143
|
msgs: list[ChatMessage] = []
|
|
131
144
|
if system:
|
|
132
145
|
msgs.append(ChatMessage(role="system", content=system))
|
|
133
146
|
msgs.append(ChatMessage(role="user", content=message))
|
|
134
|
-
return self.chat_messages(
|
|
147
|
+
return self.chat_messages(
|
|
148
|
+
msgs, domain=domain, max_tokens=max_tokens, temperature=temperature, model=model
|
|
149
|
+
).content
|
|
135
150
|
|
|
136
151
|
def chat_messages(
|
|
137
152
|
self,
|
|
@@ -139,6 +154,7 @@ class Bee(_BaseClient):
|
|
|
139
154
|
domain: Domain = "general",
|
|
140
155
|
max_tokens: int = 512,
|
|
141
156
|
temperature: float = 0.3,
|
|
157
|
+
model: Optional[str] = None,
|
|
142
158
|
) -> ChatResponse:
|
|
143
159
|
# Switch domain first (the Bee API has explicit /domain/switch).
|
|
144
160
|
try:
|
|
@@ -148,7 +164,7 @@ class Bee(_BaseClient):
|
|
|
148
164
|
# that domain's adapter, fall through and serve from current.
|
|
149
165
|
pass
|
|
150
166
|
body = {
|
|
151
|
-
"model":
|
|
167
|
+
"model": _resolve_model(model),
|
|
152
168
|
"messages": [{"role": m.role, "content": m.content} for m in messages],
|
|
153
169
|
"max_tokens": max_tokens,
|
|
154
170
|
"temperature": temperature,
|
|
@@ -174,6 +190,7 @@ class Bee(_BaseClient):
|
|
|
174
190
|
max_tokens: int = 512,
|
|
175
191
|
temperature: float = 0.3,
|
|
176
192
|
system: Optional[str] = None,
|
|
193
|
+
model: Optional[str] = None,
|
|
177
194
|
) -> Iterator[str]:
|
|
178
195
|
"""Stream tokens as they're generated.
|
|
179
196
|
|
|
@@ -190,7 +207,7 @@ class Bee(_BaseClient):
|
|
|
190
207
|
msgs.append({"role": "system", "content": system})
|
|
191
208
|
msgs.append({"role": "user", "content": message})
|
|
192
209
|
body = {
|
|
193
|
-
"model":
|
|
210
|
+
"model": _resolve_model(model),
|
|
194
211
|
"messages": msgs,
|
|
195
212
|
"max_tokens": max_tokens,
|
|
196
213
|
"temperature": temperature,
|
|
@@ -267,6 +284,7 @@ class AsyncBee(_BaseClient):
|
|
|
267
284
|
max_tokens: int = 512,
|
|
268
285
|
temperature: float = 0.3,
|
|
269
286
|
system: Optional[str] = None,
|
|
287
|
+
model: Optional[str] = None,
|
|
270
288
|
) -> str:
|
|
271
289
|
import httpx
|
|
272
290
|
msgs: list[dict] = []
|
|
@@ -279,7 +297,7 @@ class AsyncBee(_BaseClient):
|
|
|
279
297
|
except httpx.HTTPError:
|
|
280
298
|
pass
|
|
281
299
|
r = await cl.post(f"{self.base_url}/chat/completions", json={
|
|
282
|
-
"model":
|
|
300
|
+
"model": _resolve_model(model),
|
|
283
301
|
"messages": msgs,
|
|
284
302
|
"max_tokens": max_tokens,
|
|
285
303
|
"temperature": temperature,
|
|
@@ -295,6 +313,7 @@ class AsyncBee(_BaseClient):
|
|
|
295
313
|
max_tokens: int = 512,
|
|
296
314
|
temperature: float = 0.3,
|
|
297
315
|
system: Optional[str] = None,
|
|
316
|
+
model: Optional[str] = None,
|
|
298
317
|
) -> AsyncIterator[str]:
|
|
299
318
|
import httpx
|
|
300
319
|
msgs: list[dict] = []
|
|
@@ -307,7 +326,7 @@ class AsyncBee(_BaseClient):
|
|
|
307
326
|
except httpx.HTTPError:
|
|
308
327
|
pass
|
|
309
328
|
async with cl.stream("POST", f"{self.base_url}/chat/completions", json={
|
|
310
|
-
"model":
|
|
329
|
+
"model": _resolve_model(model),
|
|
311
330
|
"messages": msgs,
|
|
312
331
|
"max_tokens": max_tokens,
|
|
313
332
|
"temperature": temperature,
|
|
@@ -50,6 +50,18 @@ except Exception: # not installed (running from source) — fall back
|
|
|
50
50
|
# fallback when the client omits it.
|
|
51
51
|
DEFAULT_PROTOCOL_VERSION = "2024-11-05"
|
|
52
52
|
|
|
53
|
+
# Production model tiers — mirror of bee_sdk.types.ModelTier (customer-
|
|
54
|
+
# selectable ladder; enclave/ignite are not public-selectable). Which tiers a
|
|
55
|
+
# key may use is decided by its plan at the gateway; bee-cell is the free tier.
|
|
56
|
+
MODELS = [
|
|
57
|
+
"bee-cell",
|
|
58
|
+
"bee-brood",
|
|
59
|
+
"bee-comb",
|
|
60
|
+
"bee-buzz",
|
|
61
|
+
"bee-hive",
|
|
62
|
+
"bee-swarm",
|
|
63
|
+
]
|
|
64
|
+
|
|
53
65
|
# Authoritative domain list — mirror of bee_sdk.types.Domain (itself a
|
|
54
66
|
# mirror of the private core's bee/domains.py TIER_1_DOMAINS). Kept inline
|
|
55
67
|
# so the tool enum doesn't depend on the private core being importable.
|
|
@@ -72,12 +84,13 @@ TOOLS = [
|
|
|
72
84
|
{
|
|
73
85
|
"name": "bee_chat",
|
|
74
86
|
"description": (
|
|
75
|
-
"Ask Bee a question. Bee
|
|
76
|
-
"per-domain LoRA
|
|
77
|
-
"cybersecurity, quantum computing, fintech,
|
|
78
|
-
"infrastructure, research methodology, and
|
|
79
|
-
"
|
|
80
|
-
"
|
|
87
|
+
"Ask Bee a question. Bee — The Progressive Intelligence Engine — "
|
|
88
|
+
"is a tiered LLM platform with per-domain LoRA specialisation: "
|
|
89
|
+
"programming, AI/ML, cybersecurity, quantum computing, fintech, "
|
|
90
|
+
"blockchain, cloud infrastructure, research methodology, and "
|
|
91
|
+
"business operations. Optionally pick a model tier (bee-cell free "
|
|
92
|
+
"… bee-swarm premium); tier access follows the API key's plan. "
|
|
93
|
+
"Bee is honest about uncertainty rather than fabricating."
|
|
81
94
|
),
|
|
82
95
|
"inputSchema": {
|
|
83
96
|
"type": "object",
|
|
@@ -89,6 +102,15 @@ TOOLS = [
|
|
|
89
102
|
"enum": DOMAINS,
|
|
90
103
|
"default": "general",
|
|
91
104
|
},
|
|
105
|
+
"model": {
|
|
106
|
+
"type": "string",
|
|
107
|
+
"description": (
|
|
108
|
+
"Bee model tier. Access is governed by the API key's plan "
|
|
109
|
+
"(403 if the plan doesn't include it). Default: BEE_MODEL "
|
|
110
|
+
"env or bee-cell (free tier)."
|
|
111
|
+
),
|
|
112
|
+
"enum": MODELS,
|
|
113
|
+
},
|
|
92
114
|
"max_tokens": {"type": "integer", "description": "Max response tokens", "default": 512},
|
|
93
115
|
},
|
|
94
116
|
"required": ["message"],
|
|
@@ -238,6 +260,13 @@ TOOLS = [
|
|
|
238
260
|
},
|
|
239
261
|
]
|
|
240
262
|
|
|
263
|
+
# MCP ToolAnnotations (behaviour hints; required by directory reviewers).
|
|
264
|
+
# Every Bee tool is identical on these axes: read-only (it forwards a prompt
|
|
265
|
+
# to the hosted gateway and modifies nothing on the user's machine) and
|
|
266
|
+
# open-world (it talks to an external service).
|
|
267
|
+
for _tool in TOOLS:
|
|
268
|
+
_tool["annotations"] = {"readOnlyHint": True, "openWorldHint": True}
|
|
269
|
+
|
|
241
270
|
RESOURCES = [
|
|
242
271
|
{
|
|
243
272
|
"uri": "bee://status",
|
|
@@ -266,6 +295,8 @@ def handle_tool_call(client: Bee, name: str, arguments: dict[str, Any]) -> str:
|
|
|
266
295
|
message=arguments["message"],
|
|
267
296
|
domain=domain,
|
|
268
297
|
max_tokens=arguments.get("max_tokens", 512),
|
|
298
|
+
# None falls through to BEE_MODEL env / bee-cell in the client.
|
|
299
|
+
model=arguments.get("model"),
|
|
269
300
|
system=(
|
|
270
301
|
f"You are Bee, a domain-specialized AI expert in {domain}. "
|
|
271
302
|
"Be precise and thorough. Admit uncertainty rather than fabricate."
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "bee-sdk"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
description = "Official Python client + MCP server for the Bee Intelligence Engine — domain-specialized LoRA-routed LLM by CUI Labs."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
File without changes
|
|
File without changes
|