logoAnt Design X

DesignDevelopmentComponentsPlayground
  • Ant Design X of React
  • Changelog
    v1.6.0
  • Model Integration
    • OpenAI
    • Qwen
    • Others
  • Agent Integration
    • Tbox
      Updated
  • Basic Usage
    • Usage with create-react-app
    • Usage with Vite
    • Usage with Next.js
    • Usage with Umi
    • Usage with Rsbuild
  • Other
    • Contributing
    • dangerouslyApiKey Explanation
    • FAQ

Tbox

Resources

Ant Design
Ant Design Charts
Ant Design Pro
Pro Components
Ant Design Mobile
Ant Design Mini
Ant Design Web3
Ant Design Landing-Landing Templates
Scaffolds-Scaffold Market
Umi-React Application Framework
dumi-Component doc generator
qiankun-Micro-Frontends Framework
Ant Motion-Motion Solution
China Mirror 🇨🇳

Community

Awesome Ant Design
Medium
Twitter
yuque logoAnt Design in YuQue
Ant Design in Zhihu
Experience Cloud Blog
seeconf logoSEE Conf-Experience Tech Conference

Help

GitHub
Change Log
FAQ
Bug Report
Issues
Discussions
StackOverflow
SegmentFault

Ant XTech logoMore Products

yuque logoYuQue-Document Collaboration Platform
AntV logoAntV-Data Visualization
Egg logoEgg-Enterprise Node.js Framework
Kitchen logoKitchen-Sketch Toolkit
Galacean logoGalacean-Interactive Graphics Solution
xtech logoAnt Financial Experience Tech
Theme Editor
Made with ❤ by
Ant Group and Ant Design Community

This guide will introduce how to integrate the agent service provided by Tbox into an application built with Ant Design X.

Documentation

  • Tbox Open platform - https://alipaytbox.yuque.com/sxs0ba/doc/tbox_open_overview
  • Tbox Open Token - https://alipaytbox.yuque.com/sxs0ba/doc/tbox_open_token
  • OpenAPI - https://alipaytbox.yuque.com/sxs0ba/doc/tbox_openapi_overview

Use Open API

tsx
import { TboxClient } from 'tbox-nodejs-sdk';
import { useXAgent, useXChat, Sender, Bubble } from '@ant-design/x';
const tboxClient = new TboxClient({
httpClientConfig: {
authorization: 'TBox-Token-xxx', // 替换真实 token
},
});
const ChatDemo = () => {
const [agent] = useXAgent({
request: async ({ message }, { onUpdate, onSuccess }) => {
const stream = tboxClient.chat({
appId: '2025*****xxx', // 替换真实 AppID
query: message,
userId: '用户唯一标识',
});
let content = '';
stream.on('data', (data) => {
content += JSON.stringify(data);
onUpdate(content);
});
stream.on('end', () => onSuccess(content));
},
});
const { onRequest, messages } = useXChat({ agent });
return (
<div style={{ maxWidth: 800, margin: '0 auto' }}>
<Bubble.List
items={messages.map((msg) => ({
key: msg.id,
content: msg.message,
}))}
/>
<Sender onSubmit={onRequest} />
</div>
);
};