Ask me

logoAnt Design X

DesignDevelopmentComponentsPlayground
  • Overview
  • Common
    • Bubble
    • Conversations
  • Wake
    • Welcome
    • Prompts
  • Express
    • Attachments
    • Sender
    • Suggestion
  • Confirm
    • ThoughtChain
  • Tools
    • useXAgent
    • useXChat
    • XStream
    • XRequest
    • XProvider

useXAgent

Used for model scheduling with Agent hooks.
Import
import{ useXAgent }from"@ant-design/x";
Sourcecomponents/use-x-agent
Docs
Edit this pageChangelog

Resources

Ant Design Charts
Ant Design Pro
Ant Design Pro Components
Ant Design Mobile
Ant Design Mini
Ant Design Landing-Landing Templates
Scaffolds-Scaffold Market
Umi-React Application Framework
dumi-Component doc generator
qiankun-Micro-Frontends Framework
ahooks-React Hooks Library
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
loading

When To Use

Connect with the backend model to provide an abstract data flow.

Examples

API

type useXAgent<AgentMessage> = (
config: XAgentConfigPreset | XAgentConfigCustom<AgentMessage>,
) => [Agent];

XAgentConfigPreset

Use preset protocol for request, protocol is not implemented yet.

PropertyDescriptionTypeDefaultVersion
baseURLRequest for server addressstring-
keyRequest keystring-
modelPreset protocol modelstring-
dangerouslyApiKey🔥 dangerouslyApiKey presents security risks. Detailed documentation on this can be found in Explanationstring--

XAgentConfigCustom

Custom request protocol.

PropertyDescriptionTypeDefaultVersion
requestConfig custom request, support streaming updateRequestFn

RequestFn

interface RequestFnInfo<Message> extends Partial<XAgentConfigPreset>, AnyObject {
messages?: Message[];
message?: Message;
}
type RequestFn<Message> = (
info: RequestFnInfo<Message>,
callbacks: {
onUpdate: (message: Message) => void;
onSuccess: (message: Message) => void;
onError: (error: Error) => void;
},
) => void;

Agent

PropertyDescriptionTypeVersion
requestCall the configured request of useXAgentRequestFn
isRequestingCheck if it is requesting() => boolean
Preset Request

We will use XRequest as the default request, and only need to configure baseURL and model

codepen icon
External Link Icon
expand codeexpand code
Custom Request

Return multiple recommended contents by customizing the ability.

codepen icon
External Link Icon
expand codeexpand code
Agent Request Log
Status-
Update Times0