-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatResponse.cs
More file actions
51 lines (47 loc) · 2.24 KB
/
Copy pathChatResponse.cs
File metadata and controls
51 lines (47 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
namespace OperationsCopilot.Domain.Chat;
/// <summary>The agent's reply, with everything needed to audit how it was produced.</summary>
/// <param name="Answer">Natural-language answer for the user.</param>
/// <param name="ConversationId">Pass to the next request to continue this conversation.</param>
/// <param name="Citations">Knowledge-base passages the answer draws on, best match first.</param>
/// <param name="ToolCalls">Tools the agent chose to call, in invocation order.</param>
/// <param name="LatencyMs">Wall-clock time for the whole request, in milliseconds.</param>
public sealed record ChatResponse(
string Answer,
string ConversationId,
IReadOnlyList<Citation> Citations,
IReadOnlyList<ToolInvocation> ToolCalls,
long LatencyMs)
{
/// <summary>Token usage, when the model reported it.</summary>
public TokenUsage? Usage { get; init; }
}
/// <summary>A knowledge-base passage the agent retrieved while answering.</summary>
/// <param name="Reference">Stable citation marker used in the answer text, e.g. <c>[1]</c>.</param>
/// <param name="Excerpt">Trimmed passage text, for showing the user why the answer says what it says.</param>
/// <param name="Score">Cosine similarity of this passage to the query, in [0, 1].</param>
public sealed record Citation(
string Reference,
string SourceFile,
string DocumentTitle,
string Heading,
string Excerpt,
double Score);
/// <summary>One tool the agent invoked, with its own timing.</summary>
/// <param name="Arguments">Arguments the model supplied, as name/value pairs rendered for display.</param>
/// <param name="Succeeded">False when the tool threw; <paramref name="Error"/> then carries the reason.</param>
public sealed record ToolInvocation(
string PluginName,
string FunctionName,
IReadOnlyDictionary<string, string?> Arguments,
long DurationMs,
bool Succeeded,
string? Error = null)
{
/// <summary>Fully qualified tool name, e.g. <c>Operations.GetLowStockProducts</c>.</summary>
public string Name => $"{PluginName}.{FunctionName}";
}
/// <summary>Model token usage for one request.</summary>
public sealed record TokenUsage(int PromptTokens, int CompletionTokens)
{
public int TotalTokens => PromptTokens + CompletionTokens;
}