Skip to content

Commit 7d92706

Browse files
authored
Merge pull request #1234 from iceljc/master
add stringfy data
2 parents 08568e7 + 2e59138 commit 7d92706

File tree

4 files changed

+486
-356
lines changed

4 files changed

+486
-356
lines changed

src/Infrastructure/BotSharp.Abstraction/Loggers/Models/InstructionLogModel.cs

Lines changed: 50 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,56 @@
22

33
namespace BotSharp.Abstraction.Loggers.Models;
44

5-
public class InstructionLogModel
5+
public class InstructionLogModel : InstructionLogBaseModel
6+
{
7+
public Dictionary<string, string> States { get; set; } = [];
8+
9+
public static InstructionLogModel From(InstructionFileLogModel log)
10+
{
11+
return new InstructionLogModel
12+
{
13+
Id = log.Id,
14+
AgentId = log.AgentId,
15+
AgentName = log.AgentName,
16+
Provider = log.Provider,
17+
Model = log.Model,
18+
TemplateName = log.TemplateName,
19+
UserMessage = log.UserMessage,
20+
SystemInstruction = log.SystemInstruction,
21+
CompletionText = log.CompletionText,
22+
UserId = log.UserId,
23+
UserName = log.UserName,
24+
CreatedTime = log.CreatedTime
25+
};
26+
}
27+
}
28+
29+
public class InstructionFileLogModel : InstructionLogBaseModel
30+
{
31+
[JsonPropertyName("states")]
32+
public Dictionary<string, JsonDocument> States { get; set; } = [];
33+
34+
public static InstructionFileLogModel From(InstructionLogModel log)
35+
{
36+
return new InstructionFileLogModel
37+
{
38+
Id = log.Id,
39+
AgentId = log.AgentId,
40+
AgentName = log.AgentName,
41+
Provider = log.Provider,
42+
Model = log.Model,
43+
TemplateName = log.TemplateName,
44+
UserMessage = log.UserMessage,
45+
SystemInstruction = log.SystemInstruction,
46+
CompletionText = log.CompletionText,
47+
UserId = log.UserId,
48+
UserName = log.UserName,
49+
CreatedTime = log.CreatedTime
50+
};
51+
}
52+
}
53+
54+
public class InstructionLogBaseModel
655
{
756
[JsonPropertyName("id")]
857
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
@@ -43,12 +92,6 @@ public class InstructionLogModel
4392
[JsonIgnore]
4493
public string? UserName { get; set; }
4594

46-
[JsonIgnore]
47-
public Dictionary<string, string> States { get; set; } = [];
48-
49-
[JsonPropertyName("states")]
50-
public Dictionary<string, JsonDocument> InnerStates { get; set; } = [];
51-
5295
[JsonPropertyName("created_time")]
5396
public DateTime CreatedTime { get; set; } = DateTime.UtcNow;
5497
}
Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
5-
using System.Threading.Tasks;
1+
namespace BotSharp.Abstraction.Repositories.Models;
62

7-
namespace BotSharp.Abstraction.Repositories.Models
3+
public class UpdateInstructionLogStatesModel
84
{
9-
public class UpdateInstructionLogStatesModel
10-
{
11-
public string LogId { get; set; }
12-
public string StateKeyPrefix { get; set; } = "new_";
13-
public Dictionary<string, string> States { get; set; }
14-
}
5+
public string LogId { get; set; } = default!;
6+
public string StateKeyPrefix { get; set; } = "new_";
7+
public Dictionary<string, string> States { get; set; } = [];
158
}

0 commit comments

Comments
 (0)