Ant Design X of React
Following the Ant Design specification, we developed a React UI library @ant-design/x
that Crafting AI-driven interfaces with React, seamlessly integrating smart chat components and API services at your fingertips.
We recommend using npm or yarn or pnpm or bun to install, it not only makes development easier, but also allow you to take advantage of the rich ecosystem of Javascript packages and tooling.
$ npm install @ant-design/x --save
If you are in a bad network environment, you can try other registries and tools like cnpm.
Add script
and link
tags in your browser and use the global variable antd
.
We provide antdx.js
, antdx.min.js
, and antdx.min.js.map
in the dist
directory of the npm package.
Based on the RICH interaction paradigm, we provide numerous atomic components for various stages of interaction to help you flexibly build your AI dialogue applications:
Bubble
- Message bubble, Conversations
- Conversation managementWelcome
- Welcome messages, Prompts
- Prompt setsSender
- Input box, Attachment
- Attachments, Suggestion
- Quick commandsThoughtChain
- Thought chainsBelow is an example of using atomic components to create a simple chatbot interface:
import React from 'react';import {// Message bubbleBubble,// Input boxSender,} from '@ant-design/x';const messages = [{content: 'Hello, Ant Design X!',role: 'user',},];const App = () => (<div><Bubble.List items={messages} /><Sender /></div>);export default App;
With the useXAgent
runtime tool, we make it easy to connect with model inference services that adhere to OpenAI standards.
Here’s an example of using useXAgent
:
import React from 'react';import { useXAgent, Sender } from '@ant-design/x';const App = () => {const [agent] = useXAgent({// Model inference service URLbaseURL: 'https://your.api.host',// Model namemodel: 'gpt-3.5',});function chatRequest(text: string) {agent.request({// Messagemessages: [{content: text,role: 'user',},],// Enable streamingstream: true,});}return <Sender onSubmit={chatRequest} />;};export default App;
Using the useXChat
runtime tool, you can easily manage data flows in AI dialogue applications:
import React from 'react';import { useXChat, useXAgent } from '@ant-design/x';const App = () => {const [agent] = useXAgent({// Model inference service URLbaseURL: 'https://your.api.host',// Model namemodel: 'gpt-3.5',});const {// Initiate a chat requestonRequest,// Message listmessages,} = useXChat({ agent });return (<div><Bubble.List items={messages} /><Sender onSubmit={onRequest} /></div>);};export default App;
@ant-design/x
supports ES modules tree shaking by default.
@ant-design/x
provides a built-in ts definition.
Ant Design X is widely used in AI-driven user interfaces within Ant Group. If your company and products use Ant Design X, feel free to leave a comment here.
Please read our CONTRIBUTING.md first.
If you'd like to help us improve antd, just create a Pull Request. Feel free to report bugs and issues here.
If you're new to posting issues, we ask that you read How To Ask Questions The Smart Way and How to Ask a Question in Open Source Community and How to Report Bugs Effectively prior to posting. Well written bug reports help us help you!
If you encounter any issues while using Ant Design X, you can seek help through the following channels. We also encourage experienced users to assist newcomers via these platforms.
When asking questions on GitHub Discussions, it's recommended to use the Q&A
tag.