AssistantUsage Class

Assembly: CodeEffects.Rule.Repository.dll
Namespace: CodeEffects.Rule.Repository

Summary

Describes the tokens that one model call of the AI Assistant or the AI Rule Editor used. It is given to the OnUsage callback of AssistantSettings after the call.

Syntax

public class AssistantUsage

Remarks

You never create this class. The repository creates one for each model call and passes it to OnUsage, so you can log the numbers, bill by them, or chart them. The repository keeps the same numbers either way. The token counts are whatever the vendor reported; a count the vendor did not report is 0.

Properties

  • AgentId

    Type: System.String

    Gets or sets the assistant's agent ID, which is AgentId of AssistantSettings.

  • CacheWriteTokens

    Type: System.Int64

    Gets or sets how many of the InputTokens the vendor wrote to its prompt cache, for vendors that bill them apart (Anthropic, above the input price) and whose client reports them. It is 0 otherwise.

  • CachedInputTokens

    Type: System.Int64

    Gets or sets how many of the InputTokens the vendor read from its prompt cache, which it bills at its cached price. It is 0 when the vendor reported none.

  • ConversationId

    Type: System.Int64

    Gets or sets the ID of the conversation.

  • InputTokens

    Type: System.Int64

    Gets or sets the input tokens that the vendor reported. It is 0 when the vendor reported none. It includes CachedInputTokens and CacheWriteTokens.

  • ModelKey

    Type: System.String

    Gets or sets the Key of the AssistantModel that was called.

  • On

    Type: System.DateTime

    Gets or sets when the call ended, in UTC.

  • OutputTokens

    Type: System.Int64

    Gets or sets the output tokens that the vendor reported. It is 0 when the vendor reported none.

  • RuleEditor

    Type: System.Boolean

    Gets or sets whether the call was made for the AI Rule Editor (true) rather than for the AI Assistant (false).

  • UserId

    Type: System.String

    Gets or sets the ID of the user that the call was made for.

    Example

      using System;
      using CodeEffects.Rule.Repository;
    
      var settings = new AssistantSettings
      {
      	OnUsage = usage => Console.WriteLine(
      		usage.On.ToString("u") + " " + usage.UserId + " " + usage.ModelKey + ": " +
      		usage.InputTokens + " in (" + usage.CachedInputTokens + " cached), " + usage.OutputTokens + " out")
      };
    

Ask on Stack Overflow - Yes, it's still active
Ask in GitHub Discussions

p102

l097 --

l102

p101

×