Skip to content

Inaccurate CreatedAt returned by ToChatResponse #7186

@verdie-g

Description

@verdie-g
ChatResponseUpdate[] updates =
[
    new()
    {
        Role = ChatRole.Assistant,
        Contents = [new TextContent("Hi")],
        CreatedAt = DateTimeOffset.UtcNow,
    },
    new()
    {
        Role = ChatRole.Assistant,
        Contents = [new UsageContent { Details = new UsageDetails { TotalTokenCount = 1 } }],
        CreatedAt = DateTimeOffset.UtcNow + TimeSpan.FromMinutes(11),
    },
];
Console.WriteLine(updates.ToChatResponse().Messages[0].CreatedAt);

In this example Messages[0].CreatedAt will get the value of the second update. I think it would make more sense to get the value of the first update as the second update is not really part of the message.

In the mistral API, I noticed significant delay between the usage update and the last text update so I would like it to be reflected in the ChatResponse.

Metadata

Metadata

Labels

area-aiMicrosoft.Extensions.AI libraries

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions