Options
All
  • Public
  • Public/Protected
  • All
Menu

This class supports creating persona models and managing it.
Do not create it directly; Get it from AinftJs instance.

Hierarchy

Index

Constructors

  • new PersonaModels(baseUrl: string, route: null | string, ain: default, ainize?: default): PersonaModels

Properties

ain: default

The Ain object for sign and send transaction to AIN blockchain.

ainize?: default

The Ainize object for send request to AIN blockchain.

baseUrl: string = ''

The base url of api server of AINFT Factory.

route: string

The subpath of api server request url.

Methods

  • chat(modelId: string, appId: string, userId: string, message: string, messageId?: string): Promise<ChatResponse>
  • Chats with your persona model.

    Parameters

    • modelId: string

      The ID of persona model.

    • appId: string

      The ID of app.

    • userId: string

      The ID of user who want to chat with persona model.

    • message: string

      The message the user wants to send.

    • Optional messageId: string

      (Optional) The ID of message. If you want to manage the message ID separately, set it up.

    Returns Promise<ChatResponse>

    Returns response of persona model.

  • create(appId: string, userId: string, modelName: string, coreBeliefs: string): Promise<CreatePersonaModelInfo>
  • Creates persona model.

    Parameters

    • appId: string

      The ID of app.

    • userId: string

      The ID of user who create persona model.

    • modelName: string

      The name of persona model.

    • coreBeliefs: string

      This is the central content of the persona model. The model reflects this with the highest priority.

    Returns Promise<CreatePersonaModelInfo>

    Returns the information of the persona model created.

  • Gets credit info with connected persona model.

    Parameters

    • appId: string

      The ID of app.

    • modelId: string

      The ID of persona model.

    Returns Promise<null | PersonaModelCreditInfo>

    If set, returns credit and burn amount information.

  • sendFormRequest(method: POST | PUT, trailingUrl: string, stringFields: {}, fileFields: {}): Promise<any>
  • Sends request that include form to api server of AINFT Factory. Used to upload asset data.

    Parameters

    • method: POST | PUT

      The method of Http request.

    • trailingUrl: string

      The suffix of request url.

    • stringFields: {}

      The string fields of form.

      • [key: string]: string
    • fileFields: {}

      The file fields of form.

      • [key: string]: { buffer: Buffer; filename: string }
        • buffer: Buffer
        • filename: string

    Returns Promise<any>

    Returns response of api request.

  • sendRequest(method: HttpMethod, trailingUrl: string, data?: Record<string, any>): Promise<any>
  • Sends request to api server of AINFT Factory. Authenticate by signing data.

    Parameters

    • method: HttpMethod

      The method of Http request.

    • trailingUrl: string

      The suffix of request url.

    • Optional data: Record<string, any>

      The data to be included in the api request.

    Returns Promise<any>

    Returns response of api request.

  • sendRequestWithoutSign(method: HttpMethod, trailingUrl: string, data?: Record<string, any>, headers?: AxiosRequestHeaders): Promise<any>
  • Sends request to api server of AINFT Factory. Used when authentication is not required.

    Parameters

    • method: HttpMethod

      The method of Http request.

    • trailingUrl: string

      The suffix of request url.

    • Optional data: Record<string, any>

      The data to be included in the api request.

    • Optional headers: AxiosRequestHeaders

      The headers of Http api request.

    Returns Promise<any>

    Returns response of api request.

  • setBaseUrl(baseUrl: string): void
  • signData(data: any): string | Promise<string>
  • Sign the data with the private key that the user has registered.

    Parameters

    • data: any

      The data to sign.

    Returns string | Promise<string>

    Returns signature string.

Generated using TypeDoc