109 lines
2.4 KiB
C#
109 lines
2.4 KiB
C#
using System;
|
|
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Feature.AI;
|
|
|
|
namespace BeWo.ViewModel
|
|
{
|
|
public class AiConfigVM : AbstractDCMapperVM<AiConfigDC>
|
|
{
|
|
private AiModelDC _SelectedModel;
|
|
private float _Temperature;
|
|
private float _Top_P;
|
|
private int _Max_Gen_Len;
|
|
|
|
public AiConfigVM() : this(null) { }
|
|
public AiConfigVM(AiConfigDC dc) : base(dc, dc.Oid)
|
|
{
|
|
|
|
}
|
|
|
|
public AiModelDC SelectedModel
|
|
{
|
|
get { return _SelectedModel; }
|
|
set
|
|
{
|
|
if (!AreDifferent(_SelectedModel?.Oid, value?.Oid))
|
|
return;
|
|
|
|
_SelectedModel = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.SelectedModel, value), nameof(SelectedModel));
|
|
FirePropertyChanged(nameof(SelectedModel));
|
|
}
|
|
}
|
|
|
|
public float Temperature
|
|
{
|
|
get { return _Temperature; }
|
|
set
|
|
{
|
|
if (!AreDifferent(_Temperature, value))
|
|
return;
|
|
|
|
_Temperature = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Temperature, value), nameof(Temperature));
|
|
FirePropertyChanged(nameof(Temperature));
|
|
}
|
|
}
|
|
|
|
public float Top_P
|
|
{
|
|
get { return _Top_P; }
|
|
set
|
|
{
|
|
if (!AreDifferent(_Top_P, value))
|
|
return;
|
|
|
|
_Top_P = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Top_P, value), nameof(Top_P));
|
|
FirePropertyChanged(nameof(Top_P));
|
|
}
|
|
}
|
|
|
|
public int Max_Gen_Len
|
|
{
|
|
get { return _Max_Gen_Len; }
|
|
set
|
|
{
|
|
if (!AreDifferent(_Max_Gen_Len, value))
|
|
return;
|
|
|
|
_Max_Gen_Len = value;
|
|
StoreDirtyInformation(AreDifferent(DataContract.Max_Gen_Len, value), nameof(Max_Gen_Len));
|
|
FirePropertyChanged(nameof(Max_Gen_Len));
|
|
}
|
|
}
|
|
|
|
protected override void InitByDataContract(AiConfigDC pDataContract)
|
|
{
|
|
_SelectedModel = pDataContract.SelectedModel;
|
|
_Temperature = pDataContract.Temperature;
|
|
_Top_P = pDataContract.Top_P;
|
|
_Max_Gen_Len = pDataContract.Max_Gen_Len;
|
|
}
|
|
|
|
protected override AiConfigDC MapToDataContract(AiConfigDC pDataContract, bool doCommit)
|
|
{
|
|
pDataContract.SelectedModel = _SelectedModel;
|
|
pDataContract.Temperature = _Temperature;
|
|
pDataContract.Top_P = _Top_P;
|
|
pDataContract.Max_Gen_Len = _Max_Gen_Len;
|
|
|
|
return pDataContract;
|
|
}
|
|
|
|
internal void Update(AiConfigDC pDataContract)
|
|
{
|
|
DataContract = pDataContract;
|
|
|
|
SelectedModel = pDataContract.SelectedModel;
|
|
Temperature = pDataContract.Temperature;
|
|
Top_P = pDataContract.Top_P;
|
|
Max_Gen_Len = pDataContract.Max_Gen_Len;
|
|
|
|
SetDirty(false);
|
|
}
|
|
}
|
|
}
|