You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(ai): add Prompt variables and Skill download support, align with Java SDK, update version to 3.2.0 (#322)
* feat(ai): add Prompt variables and Skill download support, align with Java SDK
- Add PromptVariable model with defaultValue support
- Enhance Prompt.render() to merge default values from variables
- Add Skill download module (model, util, HTTP endpoint)
- Add HTTP variables parsing in AiHttpClientProxy
- Add Client-Version/User-Agent headers to HTTP requests
- Change RpcClient.start() to not throw on gRPC connect failure
- Normalize context_path handling with build_context_prefix()
- Unify exception types to NacosException in skill download
- Bump version to 3.2.0
- Update README/README_CN with Prompt and Skill documentation
- Add 32 unit tests for Prompt variables and Skill utilities
* docs(ai): add transport mode description for AI Client
-**Prompt** supports both gRPC and HTTP transport. By default, gRPC is used. If the gRPC port is unreachable, the AI client will still start normally (gRPC reconnects asynchronously in the background), and Prompt operations can fall back to HTTP.
330
+
-**Skill download** always uses HTTP, regardless of gRPC availability.
331
+
-**MCP Server / Agent Card** management uses gRPC.
332
+
326
333
### MCP Server Management
327
334
328
335
Nacos provides management capabilities for MCP (Model Context Protocol) Server, including registration, discovery, and subscription, supporting dynamic registration and service discovery of MCP servers.
*`param`*GetPromptParam* Parameter for retrieving prompt information.
575
+
*`prompt_key` - Key of the prompt to query (required).
576
+
*`version` - Version of the prompt (optional).
577
+
*`label` - Label of the prompt (optional).
578
+
*`return` Prompt if success or an exception will be raised.
579
+
580
+
#### Render Prompt with Variables
581
+
582
+
The `Prompt` object supports template rendering with `{{variableName}}` placeholders. Variables defined in the prompt may include default values via `PromptVariable.defaultValue`. When rendering, default values are applied first, then overridden by user-provided values.
583
+
584
+
```python
585
+
# Render the prompt template with variable substitution
586
+
result = prompt.render({"name": "Alice", "place": "Nacos"})
587
+
print(result) # e.g. "Hello Alice, welcome to Nacos!"
588
+
589
+
# Variables with defaultValue will be used automatically if not overridden
590
+
# For example, if the prompt has a variable: PromptVariable(name="lang", defaultValue="en")
591
+
# Calling render without providing "lang" will use "en" as the value
592
+
result = prompt.render({"name": "Alice"})
593
+
```
594
+
595
+
*`param`*variables* - A dict of variable name to value mappings (optional). Overrides default values defined in `PromptVariable.defaultValue`.
596
+
*`return` Rendered string with all `{{variableName}}` placeholders replaced.
597
+
598
+
#### Subscribe Prompt
599
+
600
+
```python
601
+
from v2.nacos.ai.model.ai_param import SubscribePromptParam
0 commit comments