Files
Luna/Luna.Core/Session/TokenEstimator.cs
T
darman 2f5841a1b9 Add Luna.Core server with SignalR hub, session management, and tool system
Implement the core application server as an ASP.NET web host with:
- SignalR ChatHub for real-time client communication
- Session management with token estimation for context windowing
- Extensible tool system with attribute-based tool discovery
- Chat stream update builder for streaming AI responses
- App configuration with appsettings for development and production
2026-04-04 04:10:58 +02:00

11 lines
308 B
C#

using Microsoft.Extensions.AI;
namespace Luna.Core.Session;
public static class TokenEstimator
{
public static int EstimateTokens(string text)
=> text.Length / 4;
public static int EstimateTokens(IReadOnlyList<ChatMessage> messages)
=> messages.Sum(m => EstimateTokens(m.Text));
}