logoAnt Design X

useXAgent

Used for model scheduling with Agent hooks.
Import
import{ useXAgent }from"@ant-design/x";

When To Use

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

Examples

Agent Request Log
Status-
Update Times0

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

codepen icon
External Link Icon
expand codeexpand code

    Return multiple recommended contents by customizing the ability.

    codepen icon
    External Link Icon
    expand codeexpand code

    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
    Ask me