Skip to content

Commit 038114b

Browse files
implement chat protocal
1 parent 7e47c11 commit 038114b

File tree

4 files changed

+16
-5
lines changed

4 files changed

+16
-5
lines changed

app/SharedWebComponents/Components/Answer.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
</ChildContent>
5757
</MudTabPanel>
5858
<MudTabPanel Icon="@Icons.Material.Filled.TextSnippet" Text="Supporting Content"
59-
ToolTip="Show the supporting content." Disabled="@(Retort is { Context.DataPoints: null } or { Context.DataPoints.Length: 0 })">
59+
ToolTip="Show the supporting content." Disabled="@(Retort is { Context.DataPoints.Text: null } or { Context.DataPoints.Text.Length: 0 })">
6060
<ChildContent>
6161
<MudPaper Class="pa-2" Elevation="3">
6262
<SupportingContent DataPoints="Retort.Context.DataPointsContent" Images="Retort.Context.DataPointsImages ?? []" />

app/backend/Properties/launchSettings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"ASPNETCORE_ENVIRONMENT": "Development"
1717
},
1818
"dotnetRunMessages": true,
19-
"applicationUrl": "https://localhost:7181;http://localhost:5167"
19+
"applicationUrl": "https://localhost:7181"
2020
},
2121
"Docker": {
2222
"commandName": "Docker",

app/backend/Services/ReadRetrieveReadChatService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ You answer needs to be a json object with the following format.
229229
followUpQuestionList = followUpQuestionsList.ToArray();
230230
}
231231

232-
var responseMessage = new ResponseMessage(ans, "assistant");
232+
var responseMessage = new ResponseMessage("assistant", ans);
233233
var responseContext = new ResponseContext(
234234
DataPointsContent: documentContentList.Select(x => new SupportingContentRecord(x.Title, x.Content)).ToArray(),
235235
DataPointsImages: images?.Select(x => new SupportingImageRecord(x.Title, x.Url)).ToArray(),

app/shared/Shared/Models/ResponseChoice.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,17 @@ public record SupportingContentRecord(string Title, string Content);
99

1010
public record SupportingImageRecord(string Title, string Url);
1111

12+
public record DataPoints
13+
{
14+
public DataPoints(string[] text)
15+
{
16+
this.Text = text;
17+
}
18+
19+
[JsonPropertyName("text")]
20+
public string[] Text { get; set; }
21+
}
22+
1223
public record Thoughts
1324
{
1425
public Thoughts(string Title, string Description, params (string, string)[] props)
@@ -51,7 +62,7 @@ public ResponseContext(SupportingContentRecord[]? DataPointsContent, SupportingI
5162
public Thoughts[] Thoughts { get; set; }
5263

5364
[JsonPropertyName("data_points")]
54-
public string[] DataPoints { get => DataPointsContent?.Select(x => $"{x.Title}: {x.Content}").ToArray() ?? Array.Empty<string>(); }
65+
public DataPoints DataPoints { get => new DataPoints(DataPointsContent?.Select(x => $"{x.Title}: {x.Content}").ToArray() ?? Array.Empty<string>()); }
5566

5667
public string ThoughtsString { get => string.Join("\n", Thoughts.Select(x => $"{x.Title}: {x.Description}")); }
5768
}
@@ -75,7 +86,7 @@ public ResponseMessage(string role, string content)
7586

7687
public record ResponseChoice
7788
{
78-
public ResponseChoice(int Index, ResponseMessage message, ResponseContext context, string CitationBaseUrl, string? followupQuestion)
89+
public ResponseChoice(int Index, ResponseMessage message, ResponseContext context, string CitationBaseUrl)
7990
{
8091
this.Index = Index;
8192
this.Message = message;

0 commit comments

Comments
 (0)