Skip to content

Commit 6883e99

Browse files
Shyam Namboodiripadjoperezr
authored andcommitted
Merged PR 48250: [internal/release/9.3] Fix report generation
The .NET side code for the `ScenarioRunResult` was recently changed (##5998) to include `ChatResponse` (which can contain multiple `ChatMessage`s) in place of a single `ChatMessage`. Unfortunately, we missed updating the TypeScript reporting code to account for this. This change fixes the problem by updating the deserialization code in TypeScript to match what .NET code serializes. Cherry-picked from commit `41bbedd0` (#6061)
1 parent 3ebaddf commit 6883e99

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/components/EvalTypes.d.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@ type ScenarioRunResult = {
1313
executionName: string;
1414
creationTime?: string;
1515
messages: ChatMessage[];
16-
modelResponse: ChatMessage;
16+
modelResponse: ChatResponse;
1717
evaluationResult: EvaluationResult;
1818
};
1919

20+
type ChatResponse = {
21+
messages: ChatMessage[];
22+
}
23+
2024
type ChatMessage = {
2125
authorName?: string;
2226
role: string;

src/Libraries/Microsoft.Extensions.AI.Evaluation.Reporting/TypeScript/components/Summary.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ const isTextContent = (content: AIContent): content is TextContent => {
145145
return (content as TextContent).text !== undefined;
146146
};
147147

148-
export const getPromptDetails = (messages: ChatMessage[], modelResponse?: ChatMessage): {history:string, response: string}=> {
148+
export const getPromptDetails = (messages: ChatMessage[], modelResponse?: ChatResponse): {history:string, response: string}=> {
149149
let history: string = "";
150150
if (messages.length === 1) {
151151
history = messages[0].contents.map(c => (c as TextContent).text).join("\n");
@@ -163,7 +163,7 @@ export const getPromptDetails = (messages: ChatMessage[], modelResponse?: ChatMe
163163
history = historyItems.join("\n\n");
164164
}
165165

166-
const response: string = modelResponse?.contents.map(c => (c as TextContent).text).join("\n") ?? "";
166+
const response: string = modelResponse?.messages.map(m => m.contents.map(c => (c as TextContent).text).join("\n") ?? "").join("\n") ?? "";
167167

168168
return { history, response };
169169
};

0 commit comments

Comments
 (0)