ワンクリックで
x-chat-provider
Focus on implementing custom Chat Provider, helping to adapt any streaming interface to Antdv Next X standard format
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Focus on implementing custom Chat Provider, helping to adapt any streaming interface to Antdv Next X standard format
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
跨仓库 PR 同步追踪技能。当用户需要追踪一个上游仓库(如 ant-design)的 fix/feature 变更,并同步到下游移植仓库(如 antdv-next)时使用此技能。 触发场景:用户给出一个起始 commit SHA,需要列出从该 commit 往后所有需要同步的 PR, 并生成带优先级排序的同步表格和 checklist 模板。 也适用于:两个仓库之间的变更追踪、上下游组件库同步分析、跨框架移植任务管理。 如果用户提到"同步上游"、"追踪 PR"、"从某个 commit 开始"、"移植 fix"、"同步 issue" 等关键词,务必使用此技能。 特别地:若用户只说"同步仓库"、"继续同步"、"sync",应优先读取下游仓库根目录的 .sync-upstream.json 文件,从中获取上次同步位置,无需用户再次提供任何参数。
Focus on explaining how to use the useXChat Hook, including custom Provider integration, message management, error handling, etc.
Use when building or reviewing Markdown rendering with @antdv-next/x-markdown, including streaming Markdown, custom component mapping, plugins, themes, and chat-oriented rich content.
Focus on explaining the practical configuration and usage of XRequest, providing accurate configuration instructions based on official documentation
专注讲解如何使用 useXChat Hook,包括自定义 Provider 的集成、消息管理、错误处理等
专注于自定义 Chat Provider 的实现,帮助将任意流式接口适配为 Antdv Next X 标准格式
| name | x-chat-provider |
| version | 0.0.1 |
| description | Focus on implementing custom Chat Provider, helping to adapt any streaming interface to Antdv Next X standard format |
This skill focuses on solving one problem: How to quickly adapt your streaming interface to Antdv Next X's Chat Provider.
Not involved: useXChat usage tutorial (that's another skill).
| Layer | Package Name | Core Purpose | Typical Usage Scenarios |
|---|---|---|---|
| UI Layer | @antdv-next/x | Vue 3 UI component library | Build chat interfaces, bubbles, input boxes |
| Logic Layer | @antdv-next/x-sdk | Development toolkit | Data flow management, Provider, Hook |
| Render Layer | @antdv-next/x-markdown | Markdown renderer | Content display, code highlighting |
⚠️ Important Reminder: These three packages have different functional positioning, please import required features from the correct package
// ✅ Correct import examples import { Bubble } from "@antdv-next/x"; // UI component import { AbstractChatProvider } from "@antdv-next/x-sdk"; // Provider base class import { XRequest } from "@antdv-next/x-sdk"; // Request tool
graph LR
A[Original API Interface] -->|Adapt| B[Chat Provider]
B -->|Provide Data| C[useXChat Hook]
C -->|Render| D[Antdv Next X UI]
E[XRequest] -->|Network Request| B
| Concept | Role Positioning | Core Responsibility | Usage Scenario |
|---|---|---|---|
| Chat Provider | 🔄 Data Adapter | Convert any interface format to Antdv Next X standard format | Private API adaptation, format conversion |
| useXChat | 🧩 Vue 3 Composable | Manage conversation state, message flow, request control | Build AI conversation interface |
| XRequest | 🌐 Request Tool | Handle all network communication, authentication, error handling | Unified request management |
| Package | Version Requirement | Auto Install | Purpose |
|---|---|---|---|
| @antdv-next/x-sdk | ≥0.0.1 | ✅ | Core SDK, includes Provider and Hook |
| @antdv-next/x | Latest version | ✅ | UI component library, build chat interface |
# Auto check and fix version
npm ls @antdv-next/x-sdk
# If version doesn't match, auto prompt:
npm install @antdv-next/x-sdk@latest
| SDK Version | Supported Features | Compatibility |
|---|---|---|
| ≥0.0.1 | Full Provider functionality | ✅ Recommended |
graph TD
A[Start] --> B{Use Standard API?}
B -->|Yes| C[Use Built-in Provider]
B -->|No| D{Private API?}
D -->|Yes| E[Custom Provider]
D -->|No| F{Special Format?}
F -->|Yes| E
F -->|No| C
C --> G[OpenAI/DeepSeek Provider]
E --> H[Four Steps to Create Custom Provider]
| Provider Type | Applicable Scenario | Usage Method |
|---|---|---|
| OpenAI Provider | Standard OpenAI API | Direct import use |
| DeepSeek Provider | Standard DeepSeek API | Direct import use |
| Scenario | Recommended Solution | Example |
|---|---|---|
| Call official OpenAI | Built-in OpenAI Provider | new OpenAIProvider() |
| Call official DeepSeek | Built-in DeepSeek Provider | new DeepSeekProvider() |
| Company internal API | Custom Provider | See four-step implementation |
| Third-party non-standard API | Custom Provider | See four-step implementation |
journey
title Custom Provider Implementation Path
section Analysis Phase
Interface Analysis: 2: User
section Development Phase
Create Class: 5: User
Check Validation: 1: User
section Integration Phase
Configure Usage: 1: User
| Information Type | Example Value | Your Interface |
|---|---|---|
| Interface URL | https://your-api.com/chat | _____________ |
| Request Method | POST | _____________ |
| Request Format | JSON | _____________ |
| Response Format | Server-Sent Events | _____________ |
| Authentication Method | Bearer Token | _____________ |
// Your actual request format
interface MyAPIRequest {
query: string; // User question
context?: string; // Conversation history (optional)
model?: string; // Model selection (optional)
stream?: boolean; // Whether streaming (optional)
}
// Streaming response format
// Actual response: data: {"content": "answer content"}
interface MyAPIResponse {
content: string; // Answer fragment
finish_reason?: string; // End marker
}
// End marker: data: [DONE]
// MyChatProvider.ts
import { AbstractChatProvider } from "@antdv-next/x-sdk";
// ====== 1st modification: Define your interface types ======
interface MyInput {
query: string;
context?: string;
model?: string;
stream?: boolean;
}
interface MyOutput {
content: string;
finish_reason?: string;
}
interface MyMessage {
content: string;
role: "user" | "assistant";
timestamp: number;
}
// ====== 2nd modification: Modify class name ======
export class MyChatProvider extends AbstractChatProvider<
MyMessage,
MyInput,
MyOutput
> {
// Parameter conversion: convert useXChat parameters to your API parameters
transformParams(
requestParams: Partial<MyInput>,
options: XRequestOptions<MyInput, MyOutput, MyMessage>,
): MyInput {
if (typeof requestParams !== "object") {
throw new Error("requestParams must be an object");
}
return {
query: requestParams.query || "",
context: requestParams.context,
model: "gpt-3.5-turbo", // Adjust according to your API
stream: true,
...(options?.params || {}),
};
}
// Local message: user sent message format
transformLocalMessage(requestParams: Partial<MyInput>): MyMessage {
return {
content: requestParams.query || "",
role: "user",
timestamp: Date.now(),
};
}
// ====== 3rd modification: Response data conversion ======
transformMessage(info: {
originMessage: MyMessage;
chunk: MyOutput;
}): MyMessage {
const { originMessage, chunk } = info;
// Handle end marker
if (!chunk?.content || chunk.content === "[DONE]") {
return { ...originMessage, status: "success" as const };
}
// Accumulate response content
return {
...originMessage,
content: `${originMessage.content || ""}${chunk.content || ""}`,
role: "assistant" as const,
status: "loading" as const,
};
}
}
| Check Item | Status | Description |
|---|---|---|
| Correct class name | ⏳ | MyChatProvider → Your class name |
| Type matching | ⏳ | Interface types match actual API |
| Complete methods | ⏳ | All 3 methods implemented |
| No request method | ⏳ | Confirm no request method implemented |
| Type check passed | ⏳ | tsc --noEmit no errors |
# Run type check
npx tsc --noEmit MyChatProvider.ts
# Expected result: no error output
// 1. Import dependencies
import { MyChatProvider } from "./MyChatProvider";
import { XRequest } from "@antdv-next/x-sdk";
// 2. Configure XRequest (handled by x-request skill)
const request = XRequest("https://your-api.com/chat", {
// Authentication configuration
headers: {
Authorization: "Bearer your-token-here",
"Content-Type": "application/json",
},
// Default parameters
params: {
model: "gpt-3.5-turbo",
max_tokens: 1000,
temperature: 0.7,
},
// Streaming configuration
manual: true,
});
// 3. Create Provider instance
const provider = new MyChatProvider({
request, // Must pass XRequest instance
});
// 4. Now can be used with useXChat
// This part is handled by use-x-chat skill
export { provider };
| Scenario Type | Difficulty | Example Link | Description |
|---|---|---|---|
| Standard OpenAI | 🟢 Simple | Built-in Provider Example | Direct use of built-in Provider |
| Standard DeepSeek | 🟢 Simple | Built-in Provider Example | Direct use of built-in Provider |
| Private API | 🟡 Medium | Custom Provider Details | Need four-step implementation |
📖 Complete Examples: EXAMPLES.md contains complete code for all actual scenarios
graph TD
User[Developer] --> A{Choose Solution}
A -->|Standard API| B[Built-in Provider]
A -->|Private API| C[Custom Provider]
B --> D[use-x-chat]
C --> E[x-chat-provider]
E --> D
D --> F[x-request]
F --> G[Final Application]
| Skill Role | Skill Name | Prerequisites | Core Responsibility | Usage Scenario |
|---|---|---|---|---|
| 🏗️ Creator | x-chat-provider | None | Create custom Provider | Adapt private/non-standard APIs |
| 🧩 User | use-x-chat | Needs Provider | Build AI conversation interface | Vue 3 component development |
| 🔧 Configurer | x-request | None | Configure request parameters authentication | Unified network request management |
Applicable: Build complete AI conversation product from scratch
sequenceDiagram
participant Dev as Developer
participant CP as x-chat-provider
participant UX as use-x-chat
participant XR as x-request
Dev->>CP: 1. Create custom Provider
CP->>Dev: Return adapted Provider
Dev->>XR: 2. Configure XRequest parameters
XR->>Dev: Return configured request
Dev->>UX: 3. Use Provider to build interface
UX->>Dev: Complete AI conversation application
Implementation Steps:
Applicable: Provide Provider for other frameworks or teams
graph LR
A[Private API] -->|Adapt| B[Custom Provider]
B -->|Export| C[Other Framework Usage]
B -->|Publish| D[NPM Package]
Core Value:
Applicable: Quick prototype development or standard API calls
graph LR
A[Standard API] -->|Built-in| B[OpenAI/DeepSeek Provider]
B -->|Direct Use| C[use-x-chat]
C -->|Configure| D[x-request]
D --> E[Quick Launch]
Advantages:
Mandatory Requirements:
request method in Provider❌ Serious Error (Absolutely Prohibited):
// ❌ Serious error: implement request method yourself
class MyProvider extends AbstractChatProvider {
async request(params: any) {
// Prohibit writing network request logic!
const response = await fetch(this.url, { ... });
return response;
}
}
✅ Mandatory Requirement (Only Correct Way):
// ✅ Mandatory requirement: use XRequest, prohibit implementing request method
class MyProvider extends AbstractChatProvider {
// Prohibit implementing request method!
transformParams(params) {
/* ... */
}
transformLocalMessage(params) {
/* ... */
}
transformMessage(info) {
/* ... */
}
}
// Mandatory use of XRequest:
const provider = new MyProvider({
request: XRequest("https://your-api.com/chat"),
});
Before creating Provider, confirm:
After completion:
tsc --noEmit to ensure no type errors