This commit is contained in:
femsci 2023-11-18 16:31:51 +01:00
parent 51d188f2ed
commit a714da0ca7
Signed by: femsci
GPG key ID: 08F7911F0E650C67
7 changed files with 13 additions and 33 deletions

View file

@ -2,7 +2,7 @@ namespace Nyanlabs.Umogen.Core.Models;
public record ApiRequest public record ApiRequest
{ {
public string Model { get; set; } = "gpt-3.5-turbo"; public string Model { get; set; } = "gpt-4";
public float Temperature { get; set; } = 0.7f; public float Temperature { get; set; } = 0.7f;
public ICollection<GptMessage> Messages { get; set; } = new List<GptMessage>(); public ICollection<GptMessage> Messages { get; set; } = new List<GptMessage>();
public bool Stream { get; set; } public bool Stream { get; set; }

View file

@ -16,7 +16,7 @@ public record Person(string Name, string Surname, string IdC, string Pesel, Date
public DateTime? DoB { get; set; } = DoB; public DateTime? DoB { get; set; } = DoB;
[JsonIgnore] [JsonIgnore]
public virtual ICollection<LegalEntity> Companies { get; set; } public virtual ICollection<LegalEntity> Companies { get; set; } = default!;
public string GetName() public string GetName()
{ {

View file

@ -5,13 +5,13 @@ namespace Nyanlabs.Umogen.Core.Models;
public class UmoAnalModel public class UmoAnalModel
{ {
[JsonPropertyName("c_type")] [JsonPropertyName("c_type")]
public string ContractType { get; set; } public string ContractType { get; set; } = default!;
[JsonPropertyName("j_pos")] [JsonPropertyName("j_pos")]
public string JobPosition { get; set; } public string JobPosition { get; set; } = default!;
[JsonPropertyName("k_lit")] [JsonPropertyName("k_lit")]
public string ValueLiteral { get; set; } public string ValueLiteral { get; set; } = default!;
[JsonPropertyName("conds")] [JsonPropertyName("conds")]
public ICollection<string> Conditions { get; set; } public ICollection<string> Conditions { get; set; } = default!;
public UmoDoctype Doctype => UmoDoctypeBindings.GetFromName(ContractType).Value; public UmoDoctype Doctype => UmoDoctypeBindings.GetFromName(ContractType)!.Value;
} }

View file

@ -32,7 +32,7 @@ public class UmoDocumentResult(UmoDoctype? type, Person employee, IEntity employ
.Replace(ENACT_DATE, DateTime.Now.ToString("dd.MM.yyyy")) .Replace(ENACT_DATE, DateTime.Now.ToString("dd.MM.yyyy"))
.Replace(ISSUE_DATE, DateTime.Now.ToString("dd.MM.yyyy")) .Replace(ISSUE_DATE, DateTime.Now.ToString("dd.MM.yyyy"))
.Replace(PAYMENT_LIT, Anal.ValueLiteral) .Replace(PAYMENT_LIT, Anal.ValueLiteral)
.Replace(PAYMENT, Payment.Value.ToString()) .Replace(PAYMENT, Payment!.Value.ToString())
.Replace(WORK_TYPE, Anal.JobPosition) .Replace(WORK_TYPE, Anal.JobPosition)
.Replace(DYNAMIC_DATA, string.Join(", ", Anal.Conditions)); .Replace(DYNAMIC_DATA, string.Join(", ", Anal.Conditions));
string tmp = Path.GetTempFileName(); string tmp = Path.GetTempFileName();

View file

@ -71,7 +71,7 @@
private string _validityText = ""; private string _validityText = "";
private async Task ChgValidity(ChangeEventArgs e) private void ChgValidity(ChangeEventArgs e)
{ {
string val = (string)e.Value!; string val = (string)e.Value!;
_validityText = val; _validityText = val;
@ -129,11 +129,11 @@
} }
var anal = System.Text.Json.JsonSerializer.Deserialize<UmoAnalModel>(output, Umogen.JSON_OPTS); var anal = System.Text.Json.JsonSerializer.Deserialize<UmoAnalModel>(output, Umogen.JSON_OPTS);
UmoDocumentResult res = new(null, employee, employer, _validity, _payment, UmoDocumentResult res = new(null, employee!, employer!, _validity, _payment,
anal); anal!);
var bytes = await res.ProcessPdf(Path.Combine(Environment.GetEnvironmentVariable("UMO_TEMPLATES")!, var bytes = await res.ProcessPdf(Path.Combine(Environment.GetEnvironmentVariable("UMO_TEMPLATES")!,
anal.Doctype.TemplateDoc())); anal!.Doctype.TemplateDoc()));
await js.InvokeVoidAsync("blobby", bytes); await js.InvokeVoidAsync("blobby", bytes);
disB = false; disB = false;

View file

@ -8,24 +8,4 @@ public class GenerationTests
private Person ModelEmployer => new("Kotek", "Miauczyński", "CBS4327563", "04281308999", new DateTime(2004, 08, 13)); private Person ModelEmployer => new("Kotek", "Miauczyński", "CBS4327563", "04281308999", new DateTime(2004, 08, 13));
private Person ModelEmployee => new("Miau", "Kotczyński", "CBS69696969", "76011694336", new DateTime(1976, 1, 16)); private Person ModelEmployee => new("Miau", "Kotczyński", "CBS69696969", "76011694336", new DateTime(1976, 1, 16));
[Fact]
public async Task Meow4Me()
{
// Given
var rootDir = Environment.CurrentDirectory.Replace("test/Nyanlabs.Umogen.WebTests/bin/Debug/net8.0", "");
UmoEngine eng = new(Path.Combine(rootDir, Core.Umogen.DEFAULT_API_KEY_FILE));
// When
UmoDocument doc = new(UmoDoctype.CONTR_EMPLOYMENT, ModelEmployer, ModelEmployee);
UmoProcess proc = new(eng);
// var enu = proc.Ask("I would like to employ Jan Kowalski ID NO CBS3727348 for part time job as a shopkeeper and pay 1400zł.");
// await foreach (var str in enu)
// {
// Console.Write(str);
// }
}
} }

View file

@ -31,7 +31,7 @@ public class PdfTest
} }
var anal = JsonSerializer.Deserialize<UmoAnalModel>(sb.ToString(), Core.Umogen.JSON_OPTS); var anal = JsonSerializer.Deserialize<UmoAnalModel>(sb.ToString(), Core.Umogen.JSON_OPTS);
UmoDocumentResult r = new(null, ModelEmployer, ModelEmployee, ValidTime.Invalid, 2137, anal); UmoDocumentResult r = new(null, ModelEmployer, ModelEmployee, ValidTime.Invalid, 2137, anal!);
// When // When
byte[] b = await r.ProcessPdf(Path.Combine(root, $"templates/{r.DocType.TemplateDoc()}")); byte[] b = await r.ProcessPdf(Path.Combine(root, $"templates/{r.DocType.TemplateDoc()}"));