ai-model-web by tencentcloudbase/skills
npx skills add https://github.com/tencentcloudbase/skills --skill ai-model-web在浏览器/Web 应用程序中使用 @cloudbase/js-sdk 调用 AI 模型时使用此技能。
在以下情况下使用:
请勿用于:
ai-model-nodejs 技能ai-model-wechat 技能ai-model-nodejs 技能(仅限 Node SDK)http-api 技能CloudBase 提供以下内置提供商和模型:
| 提供商 |
|---|
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
| 模型 |
|---|
| 推荐 |
|---|
hunyuan-exp | hunyuan-turbos-latest, hunyuan-t1-latest, hunyuan-2.0-thinking-20251109, hunyuan-2.0-instruct-20251111 | ✅ hunyuan-2.0-instruct-20251111 |
deepseek | deepseek-r1-0528, deepseek-v3-0324, deepseek-v3.2 | ✅ deepseek-v3.2 |
npm install @cloudbase/js-sdk
import cloudbase from "@cloudbase/js-sdk";
const app = cloudbase.init({
env: "<YOUR_ENV_ID>",
accessKey: "<YOUR_PUBLISHABLE_KEY>" // 从 CloudBase 控制台获取
});
const auth = app.auth();
await auth.signInAnonymously();
const ai = app.ai();
重要说明:
accessKeyconst model = ai.createModel("hunyuan-exp");
const result = await model.generateText({
model: "hunyuan-2.0-instruct-20251111", // 推荐模型
messages: [{ role: "user", content: "你好,请你介绍一下李白" }],
});
console.log(result.text); // 生成的文本字符串
console.log(result.usage); // { prompt_tokens, completion_tokens, total_tokens }
console.log(result.messages); // 完整的消息历史记录
console.log(result.rawResponses); // 原始模型响应
const model = ai.createModel("hunyuan-exp");
const res = await model.streamText({
model: "hunyuan-2.0-instruct-20251111", // 推荐模型
messages: [{ role: "user", content: "你好,请你介绍一下李白" }],
});
// 选项 1:迭代文本流(推荐)
for await (let text of res.textStream) {
console.log(text); // 增量文本块
}
// 选项 2:迭代数据流以获取完整的响应数据
for await (let data of res.dataStream) {
console.log(data); // 包含元数据的完整响应块
}
// 选项 3:获取最终结果
const messages = await res.messages; // 完整的消息历史记录
const usage = await res.usage; // Token 使用量
interface BaseChatModelInput {
model: string; // 必需:模型名称
messages: Array<ChatModelMessage>; // 必需:消息数组
temperature?: number; // 可选:采样温度
topP?: number; // 可选:核心采样
}
type ChatModelMessage =
| { role: "user"; content: string }
| { role: "system"; content: string }
| { role: "assistant"; content: string };
interface GenerateTextResult {
text: string; // 生成的文本
messages: Array<ChatModelMessage>; // 完整的消息历史记录
usage: Usage; // Token 使用量
rawResponses: Array<unknown>; // 原始模型响应
error?: unknown; // 错误(如果有)
}
interface StreamTextResult {
textStream: AsyncIterable<string>; // 增量文本流
dataStream: AsyncIterable<DataChunk>; // 完整数据流
messages: Promise<ChatModelMessage[]>;// 最终消息历史记录
usage: Promise<Usage>; // 最终 Token 使用量
error?: unknown; // 错误(如果有)
}
interface Usage {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
}
每周安装量
536
代码仓库
GitHub Stars
38
首次出现
2026年1月22日
安全审计
安装于
opencode470
codex468
gemini-cli461
github-copilot448
cursor441
kimi-cli441
Use this skill for calling AI models in browser/Web applications using @cloudbase/js-sdk.
Use it when you need to:
Do NOT use for:
ai-model-nodejs skillai-model-wechat skillai-model-nodejs skill (Node SDK only)http-api skillCloudBase provides these built-in providers and models:
| Provider | Models | Recommended |
|---|---|---|
hunyuan-exp | hunyuan-turbos-latest, hunyuan-t1-latest, hunyuan-2.0-thinking-20251109, hunyuan-2.0-instruct-20251111 | ✅ hunyuan-2.0-instruct-20251111 |
deepseek | deepseek-r1-0528, deepseek-v3-0324, deepseek-v3.2 |
npm install @cloudbase/js-sdk
import cloudbase from "@cloudbase/js-sdk";
const app = cloudbase.init({
env: "<YOUR_ENV_ID>",
accessKey: "<YOUR_PUBLISHABLE_KEY>" // Get from CloudBase console
});
const auth = app.auth();
await auth.signInAnonymously();
const ai = app.ai();
Important notes:
accessKey from CloudBase consoleconst model = ai.createModel("hunyuan-exp");
const result = await model.generateText({
model: "hunyuan-2.0-instruct-20251111", // Recommended model
messages: [{ role: "user", content: "你好,请你介绍一下李白" }],
});
console.log(result.text); // Generated text string
console.log(result.usage); // { prompt_tokens, completion_tokens, total_tokens }
console.log(result.messages); // Full message history
console.log(result.rawResponses); // Raw model responses
const model = ai.createModel("hunyuan-exp");
const res = await model.streamText({
model: "hunyuan-2.0-instruct-20251111", // Recommended model
messages: [{ role: "user", content: "你好,请你介绍一下李白" }],
});
// Option 1: Iterate text stream (recommended)
for await (let text of res.textStream) {
console.log(text); // Incremental text chunks
}
// Option 2: Iterate data stream for full response data
for await (let data of res.dataStream) {
console.log(data); // Full response chunk with metadata
}
// Option 3: Get final results
const messages = await res.messages; // Full message history
const usage = await res.usage; // Token usage
interface BaseChatModelInput {
model: string; // Required: model name
messages: Array<ChatModelMessage>; // Required: message array
temperature?: number; // Optional: sampling temperature
topP?: number; // Optional: nucleus sampling
}
type ChatModelMessage =
| { role: "user"; content: string }
| { role: "system"; content: string }
| { role: "assistant"; content: string };
interface GenerateTextResult {
text: string; // Generated text
messages: Array<ChatModelMessage>; // Full message history
usage: Usage; // Token usage
rawResponses: Array<unknown>; // Raw model responses
error?: unknown; // Error if any
}
interface StreamTextResult {
textStream: AsyncIterable<string>; // Incremental text stream
dataStream: AsyncIterable<DataChunk>; // Full data stream
messages: Promise<ChatModelMessage[]>;// Final message history
usage: Promise<Usage>; // Final token usage
error?: unknown; // Error if any
}
interface Usage {
prompt_tokens: number;
completion_tokens: number;
total_tokens: number;
}
Weekly Installs
536
Repository
GitHub Stars
38
First Seen
Jan 22, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode470
codex468
gemini-cli461
github-copilot448
cursor441
kimi-cli441
Azure 升级评估与自动化工具 - 轻松迁移 Functions 计划、托管层级和 SKU
64,099 周安装
FlowStudio MCP 构建部署 Power Automate 云流指南 | 自动化流程开发
530 周安装
mcp2cli:无需代码,将MCP/OpenAPI/GraphQL实时转换为命令行工具
530 周安装
交互式作品集设计指南:30秒吸引招聘者,提升作品集转化率与个人品牌
530 周安装
每日销售简报AI工具 - 自动生成优先级行动计划,整合日历、CRM和邮件数据
531 周安装
生产排程实战指南:离散制造工厂的有限产能排程、换线优化与瓶颈管理
531 周安装
Angular 21 最佳实践指南:TypeScript、Signals、组件与性能优化
531 周安装
✅ deepseek-v3.2 |