mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-10-05 05:09:40 +00:00
Added the exact token count where the provider reports it (#989)
Build and Release / Verify (push) Waiting to run
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Build and Release / Verify (push) Waiting to run
Build and Release / Determine run mode (push) Waiting to run
Build and Release / Read metadata (push) Blocked by required conditions
Build and Release / Sync Flatpak repo (push) Blocked by required conditions
Build and Release / Collect Flatpak artifacts (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-apple-darwin, osx-arm64, macos-latest, aarch64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-pc-windows-msvc.exe, win-arm64, windows-latest, aarch64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-aarch64-unknown-linux-gnu, linux-arm64, ubuntu-22.04-arm, aarch64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-apple-darwin, osx-x64, macos-latest, x86_64-apple-darwin, dmg,app,updater, dmg) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-pc-windows-msvc.exe, win-x64, windows-latest, x86_64-pc-windows-msvc, nsis,updater, nsis) (push) Blocked by required conditions
Build and Release / Build app (${{ matrix.dotnet_runtime }}) (-x86_64-unknown-linux-gnu, linux-x64, ubuntu-22.04, x86_64-unknown-linux-gnu, appimage,updater, appimage) (push) Blocked by required conditions
Build and Release / Prepare & create release (push) Blocked by required conditions
Build and Release / Publish release (push) Blocked by required conditions
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
This commit is contained in:
1 parent
82986afe62
commit
be1e6532fb
34 files changed
+1360
-104
No files matched your search
@@ -0,0 +1,59 @@
|
||||
using AIStudio.Provider;
|
||||
|
||||
namespace AIStudio.Chat;
|
||||
|
||||
/// <summary>
|
||||
/// What a conversation carries into its next request, as far as a provider has stated it.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// Two parts, and only one of them is the provider's statement. PromptTokens is what the provider
|
||||
/// counted for the request behind the last answer: the system prompt, the tools, and every message
|
||||
/// up to the question. The answer travels in the next request as well, though not in the shape the
|
||||
/// provider charged for: its completion included the model's reasoning and whatever the model wrote
|
||||
/// between think tags. So the answer comes along as the text it will be sent as, and is counted the
|
||||
/// same way every other text is.
|
||||
///
|
||||
/// That text is the answer alone. Reasoning never belongs to it, whether it was thrown away or kept
|
||||
/// to be read next to the answer: it is there for a person, and no request carries it. An answer
|
||||
/// which consists of reasoning only has no text at all, is not sent, and adds nothing to the prompt.
|
||||
///
|
||||
/// What is estimated that way is one answer, next to a prompt which holds the whole conversation
|
||||
/// before it. The error is the tokenizer's error on that one answer, not on the chat.
|
||||
/// </remarks>
|
||||
public sealed record ReportedHistory
|
||||
{
|
||||
/// <summary>
|
||||
/// The history of a conversation no report describes.
|
||||
/// </summary>
|
||||
public static readonly ReportedHistory UNKNOWN = new();
|
||||
|
||||
/// <summary>
|
||||
/// Whether a report describes the conversation. When false, nothing else here means anything.
|
||||
/// </summary>
|
||||
public bool IsKnown { get; private init; }
|
||||
|
||||
/// <summary>
|
||||
/// What the provider counted for the request behind the last answer.
|
||||
/// </summary>
|
||||
public int PromptTokens { get; private init; }
|
||||
|
||||
/// <summary>
|
||||
/// The text of the last answer, as the next request will carry it, without any reasoning.
|
||||
/// </summary>
|
||||
public string LastAnswer { get; private init; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// States what a report says about the conversation.
|
||||
/// </summary>
|
||||
/// <param name="usage">What the provider reported for the request behind the last answer.</param>
|
||||
/// <param name="lastAnswer">The text of that answer.</param>
|
||||
/// <returns>The history, or UNKNOWN when the usage states nothing.</returns>
|
||||
public static ReportedHistory Of(TokenUsage usage, string lastAnswer) => usage.IsKnown
|
||||
? new()
|
||||
{
|
||||
IsKnown = true,
|
||||
PromptTokens = usage.PromptTokens,
|
||||
LastAnswer = lastAnswer,
|
||||
}
|
||||
: UNKNOWN;
|
||||
}
|
||||
Reference in new issue
Block a user