Skip to content

modelMapper

@waldiez/react v0.4.8


const modelMapper: object

Defined in: src/waldiez/models/mappers/model/modelMapper.ts:33

modelMapper is a utility object that provides methods to import and export models, as well as convert them to and from node format. It includes methods to import a model from JSON, export a model to JSON, and convert a WaldiezModel instance to a WaldiezNodeModel instance.

Type declarationΒΆ

asNode()ΒΆ

asNode: (model, position?) => WaldiezNodeModel

Converts a WaldiezModel instance to a WaldiezNodeModel instance. It sets the position based on the provided coordinates or defaults to (0, 0).

ParametersΒΆ
modelΒΆ

WaldiezModel

position?ΒΆ
xΒΆ

number

yΒΆ

number

ReturnsΒΆ

WaldiezNodeModel

A new instance of WaldiezNodeModel representing the model.

exportModel()ΒΆ

exportModel: (modelNode, replaceSecrets) => object

Exports a model to JSON. If replaceSecrets is true, it replaces sensitive information with "REPLACE_ME".

ParametersΒΆ
modelNodeΒΆ

WaldiezNodeModel

replaceSecretsΒΆ

boolean

ReturnsΒΆ

object

A JSON representation of the model.

createdAtΒΆ

createdAt: string = modelNode.data.createdAt

dataΒΆ

data: object

data.apiKeyΒΆ

apiKey: null | string

data.apiTypeΒΆ

apiType: WaldiezModelAPIType = modelNode.data.apiType

data.apiVersionΒΆ

apiVersion: null | string = modelNode.data.apiVersion

data.awsΒΆ

aws: undefined | null | WaldiezModelAWS | {[key: string]: undefined | null | string; }

data.baseUrlΒΆ

baseUrl: null | string = modelNode.data.baseUrl

data.defaultHeadersΒΆ

defaultHeaders: {[key: string]: unknown; } | {[key: string]: unknown; }

data.extrasΒΆ

extras: {[key: string]: unknown; } | {[key: string]: unknown; }

data.maxTokensΒΆ

maxTokens: null | number = modelNode.data.maxTokens

data.priceΒΆ

price: WaldiezModelPrice = modelNode.data.price

data.temperatureΒΆ

temperature: null | number = modelNode.data.temperature

data.topPΒΆ

topP: null | number = modelNode.data.topP

descriptionΒΆ

description: string = modelNode.data.description

idΒΆ

id: string = modelNode.id

nameΒΆ

name: string = modelNode.data.label

requirementsΒΆ

requirements: string[] = modelNode.data.requirements

tagsΒΆ

tags: string[] = modelNode.data.tags

typeΒΆ

type: string = "model"

updatedAtΒΆ

updatedAt: string = modelNode.data.updatedAt

importModel()ΒΆ

importModel: (json) => WaldiezModel

Imports a model from JSON. If the JSON is invalid or missing, it creates a new model with default values.

ParametersΒΆ
jsonΒΆ

unknown

ReturnsΒΆ

WaldiezModel

A new instance of WaldiezModel.

SeeΒΆ

WaldiezModel