Skip to content

Commit 841b49c

Browse files
authored
Merge pull request #471 from TencentCloudBase/feature/prompt-skill-install-pages
docs(prompts): 🧭 simplify skill prompt pages
2 parents cafa293 + 40e71d1 commit 841b49c

29 files changed

Lines changed: 262 additions & 11293 deletions

config/source/guideline/cloudbase/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ If the platform supports long-term memory, persist these scenarios so the agent
180180

181181
Prefer long-term memory when available: write the scenarios and working rules there so the agent always applies them. When configuring the workspace (e.g. `AGENTS.md`) or long-term memory, add reminders like:
182182

183-
- **CloudBase skills** → Run `npx skills add tencentcloudbase/skills -y` to install; use `cloudbase-guidelines` and log in to CloudBase (MCP auth, device-code) for full-stack development.
183+
- **CloudBase skills** → Run `npx skills add tencentcloudbase/cloudbase-skills -y` to install; use `cloudbase-guidelines` and log in to CloudBase (MCP auth, device-code) for full-stack development.
184184
- **CloudBase = MCP, understand tools first** → When managing or deploying CloudBase, you MUST use MCP and MUST understand tool details first. Before calling any CloudBase tool, run `npx mcporter describe cloudbase --all-parameters` (or equivalent in your IDE) to inspect the server config and get full parameter details.
185185
- **mcporter call format** → `npx mcporter call cloudbase.<tool> key=value`, e.g. `npx mcporter call cloudbase.auth action=status --output json`.
186186
- **CloudBase development and deployment** → Use MCP to automate (environment, functions, database, hosting, etc.).

doc/components/prompts.json

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,18 @@
4949
"在 iOS 应用中使用 CloudBase HTTP API 实现用户注册和登录"
5050
]
5151
},
52+
{
53+
"id": "auth-nodejs",
54+
"title": "身份认证:Node.js 服务端",
55+
"description": "使用 CloudBase Node SDK 进行服务端身份认证",
56+
"shortDescription": "Node.js 服务端身份认证",
57+
"category": "auth",
58+
"order": 5,
59+
"prompts": [
60+
"帮我实现一个云函数,验证用户身份并获取用户信息",
61+
"创建一个 Node.js 后端服务,使用 CloudBase Auth 进行用户认证"
62+
]
63+
},
5264
{
5365
"id": "no-sql-web-sdk",
5466
"title": "文档数据库:Web SDK",
@@ -97,6 +109,18 @@
97109
"在 Web 应用中使用 CloudBase 关系型数据库 SDK 实现数据查询和操作"
98110
]
99111
},
112+
{
113+
"id": "data-model-creation",
114+
"title": "数据库:数据模型创建",
115+
"description": "使用 AI 创建复杂数据模型",
116+
"shortDescription": "复杂数据模型设计",
117+
"category": "database",
118+
"order": 5,
119+
"prompts": [
120+
"帮我创建一个用户和订单的数据模型",
121+
"设计一个博客系统的数据模型"
122+
]
123+
},
100124
{
101125
"id": "database-http-api",
102126
"title": "数据库:App 集成",

doc/prompts/ai-model-nodejs.mdx

Lines changed: 7 additions & 233 deletions
Original file line numberDiff line numberDiff line change
@@ -18,244 +18,18 @@ import AIDevelopmentPrompt from '../components/AIDevelopmentPrompt';
1818

1919
<AIDevelopmentPrompt ruleId="ai-model-nodejs" />
2020

21-
## Skill
21+
## 安装与查看
2222

23-
````markdown title="rule.md"
24-
## When to use this skill
25-
26-
Use this skill for **calling AI models in Node.js backend or CloudBase cloud functions** using `@cloudbase/node-sdk`.
27-
28-
**Use it when you need to:**
29-
30-
- Integrate AI text generation in backend services
31-
- Generate images with Hunyuan Image model
32-
- Call AI models from CloudBase cloud functions
33-
- Server-side AI processing
34-
35-
**Do NOT use for:**
36-
37-
- Browser/Web apps → use `ai-model-web` skill
38-
- WeChat Mini Program → use `ai-model-wechat` skill
39-
- HTTP API integration → use `http-api` skill
40-
41-
---
42-
43-
## Available Providers and Models
44-
45-
CloudBase provides these built-in providers and models:
46-
47-
| Provider | Models | Recommended |
48-
|----------|--------|-------------|
49-
| `hunyuan-exp` | `hunyuan-turbos-latest`, `hunyuan-t1-latest`, `hunyuan-2.0-thinking-20251109`, `hunyuan-2.0-instruct-20251111` |`hunyuan-2.0-instruct-20251111` |
50-
| `deepseek` | `deepseek-r1-0528`, `deepseek-v3-0324`, `deepseek-v3.2` |`deepseek-v3.2` |
51-
52-
---
53-
54-
## Installation
23+
如果需要安装全部 CloudBase Skills,可执行:
5524

5625
```bash
57-
npm install @cloudbase/node-sdk
26+
npx skills add tencentcloudbase/cloudbase-skills
5827
```
5928

60-
⚠️ **AI feature requires version 3.16.0 or above.** Check with `npm list @cloudbase/node-sdk`.
61-
62-
---
63-
64-
## Initialization
65-
66-
### In Cloud Functions
67-
68-
```js
69-
const tcb = require('@cloudbase/node-sdk');
70-
const app = tcb.init({ env: '&lt;YOUR_ENV_ID&gt;' });
71-
72-
exports.main = async (event, context) =&gt; {
73-
const ai = app.ai();
74-
// Use AI features
75-
};
76-
```
29+
如果只安装当前 Skill,可执行:
7730

78-
### Cloud Function Configuration for AI Models
79-
80-
⚠️ **Important:** When creating cloud functions that use AI models (especially `generateImage()` and large language model generation), set a longer timeout as these operations can be slow.
81-
82-
**Using MCP Tool `manageFunctions(action="createFunction")`:**
83-
84-
Legacy compatibility: if an older prompt still says `createFunction`, keep the same payload shape but execute it through `manageFunctions(action="createFunction")`.
85-
86-
Set the `timeout` parameter in the `func` object:
87-
88-
- **Parameter**: `func.timeout` (number)
89-
- **Unit**: seconds
90-
- **Range**: 1 - 900
91-
- **Default**: 20 seconds (usually too short for AI operations)
92-
93-
**Recommended timeout values:**
94-
- **Text generation (`generateText`)**: 60-120 seconds
95-
- **Streaming (`streamText`)**: 60-120 seconds
96-
- **Image generation (`generateImage`)**: 300-900 seconds (recommended: 900s)
97-
- **Combined operations**: 900 seconds (maximum allowed)
98-
99-
### In Regular Node.js Server
100-
101-
```js
102-
const tcb = require('@cloudbase/node-sdk');
103-
const app = tcb.init({
104-
env: '&lt;YOUR_ENV_ID&gt;',
105-
secretId: '&lt;YOUR_SECRET_ID&gt;',
106-
secretKey: '&lt;YOUR_SECRET_KEY&gt;'
107-
});
108-
109-
const ai = app.ai();
110-
```
111-
112-
---
113-
114-
## generateText() - Non-streaming
115-
116-
```js
117-
const model = ai.createModel("hunyuan-exp");
118-
119-
const result = await model.generateText({
120-
model: "hunyuan-2.0-instruct-20251111", // Recommended model
121-
messages: [{ role: "user", content: "你好,请你介绍一下李白" }],
122-
});
123-
124-
console.log(result.text); // Generated text string
125-
console.log(result.usage); // { prompt_tokens, completion_tokens, total_tokens }
126-
console.log(result.messages); // Full message history
127-
console.log(result.rawResponses); // Raw model responses
128-
```
129-
130-
---
131-
132-
## Error Handling Pattern
133-
134-
```js
135-
const model = ai.createModel("deepseek");
136-
137-
try {
138-
const result = await model.generateText({
139-
model: "deepseek-v3.2",
140-
messages: [{ role: "user", content: "Summarize today's deployment logs" }],
141-
});
142-
143-
console.log(result.text);
144-
} catch (error) {
145-
console.error("AI request failed", error);
146-
}
147-
```
148-
149-
---
150-
151-
## streamText() - Streaming
152-
153-
```js
154-
const model = ai.createModel("hunyuan-exp");
155-
156-
const res = await model.streamText({
157-
model: "hunyuan-2.0-instruct-20251111", // Recommended model
158-
messages: [{ role: "user", content: "你好,请你介绍一下李白" }],
159-
});
160-
161-
// Option 1: Iterate text stream (recommended)
162-
for await (let text of res.textStream) {
163-
console.log(text); // Incremental text chunks
164-
}
165-
166-
// Option 2: Iterate data stream for full response data
167-
for await (let data of res.dataStream) {
168-
console.log(data); // Full response chunk with metadata
169-
}
170-
171-
// Option 3: Get final results
172-
const messages = await res.messages; // Full message history
173-
const usage = await res.usage; // Token usage
174-
```
175-
176-
---
177-
178-
## generateImage() - Image Generation
179-
180-
⚠️ **Image generation is only available in Node SDK**, not in JS SDK (Web) or WeChat Mini Program.
181-
182-
```js
183-
const imageModel = ai.createImageModel("hunyuan-image");
184-
185-
const res = await imageModel.generateImage({
186-
model: "hunyuan-image",
187-
prompt: "一只可爱的猫咪在草地上玩耍",
188-
size: "1024x1024",
189-
version: "v1.9",
190-
});
191-
192-
console.log(res.data[0].url); // Image URL (valid 24 hours)
193-
console.log(res.data[0].revised_prompt);// Revised prompt if revise=true
194-
```
195-
196-
### Image Generation Parameters
197-
198-
```ts
199-
interface HunyuanGenerateImageInput {
200-
model: "hunyuan-image"; // Required
201-
prompt: string; // Required: image description
202-
version?: "v1.8.1" | "v1.9"; // Default: "v1.8.1"
203-
size?: string; // Default: "1024x1024"
204-
negative_prompt?: string; // v1.9 only
205-
style?: string; // v1.9 only
206-
revise?: boolean; // Default: true
207-
n?: number; // Default: 1
208-
footnote?: string; // Watermark, max 16 chars
209-
seed?: number; // Range: [1, 4294967295]
210-
}
211-
212-
interface HunyuanGenerateImageOutput {
213-
id: string;
214-
created: number;
215-
data: Array&lt;{
216-
url: string; // Image URL (24h valid)
217-
revised_prompt?: string;
218-
}&gt;;
219-
}
31+
```bash
32+
npx skills add https://github.com/tencentcloudbase/skills --skill ai-model-nodejs
22033
```
22134

222-
---
223-
224-
## Type Definitions
225-
226-
```ts
227-
interface BaseChatModelInput {
228-
model: string; // Required: model name
229-
messages: Array&lt;ChatModelMessage&gt;; // Required: message array
230-
temperature?: number; // Optional: sampling temperature
231-
topP?: number; // Optional: nucleus sampling
232-
}
233-
234-
type ChatModelMessage =
235-
| { role: "user"; content: string }
236-
| { role: "system"; content: string }
237-
| { role: "assistant"; content: string };
238-
239-
interface GenerateTextResult {
240-
text: string; // Generated text
241-
messages: Array&lt;ChatModelMessage&gt;; // Full message history
242-
usage: Usage; // Token usage
243-
rawResponses: Array&lt;unknown&gt;; // Raw model responses
244-
error?: unknown; // Error if any
245-
}
246-
247-
interface StreamTextResult {
248-
textStream: AsyncIterable&lt;string&gt;; // Incremental text stream
249-
dataStream: AsyncIterable&lt;DataChunk&gt;; // Full data stream
250-
messages: Promise&lt;ChatModelMessage[]&gt;;// Final message history
251-
usage: Promise&lt;Usage&gt;; // Final token usage
252-
error?: unknown; // Error if any
253-
}
254-
255-
interface Usage {
256-
prompt_tokens: number;
257-
completion_tokens: number;
258-
total_tokens: number;
259-
}
260-
```
261-
````
35+
当前 Skill 在线查看: [ai-model-nodejs](https://skills.sh/tencentcloudbase/skills/ai-model-nodejs)

0 commit comments

Comments
 (0)