Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: work in progress for exploration of how to show token usage #840

Closed
wants to merge 0 commits into from

Conversation

Stijnus
Copy link

@Stijnus Stijnus commented Dec 19, 2024

image image image

Token Usage Stats Feature

Overview

The Token Usage Stats component provides a detailed view of AI model usage and token consumption in your chat interface. It displays real-time statistics for all models used in the conversation.

Current Features

  • Quick Overview: Shows total models used and token count at a glance
  • Detailed Breakdown: Click "Details" to view comprehensive statistics
  • Per Model Stats:
    • Model name and provider
    • Usage count
    • Token distribution (input/output)
    • Percentage of total tokens used
  • Total Usage Summary:
    • Combined token count across all models
    • Input/Output token distribution
    • Visual progress bar for token distribution

UI/UX

  • Clean, modern interface with light/dark mode support
  • Collapsible view for space efficiency
  • Scrollable content for multiple model entries
  • Responsive tooltip with backdrop blur effect

Technical Details

  • Built with React and TypeScript
  • Uses Tailwind CSS for styling
  • Implements @radix-ui/react-tooltip for tooltip functionality
  • Real-time token calculation via useTokenUsage hook

Upcoming Features

Cost Analysis

  • 💰 Cost calculation based on model pricing
  • 📊 Estimated cost per conversation
  • 🔄 Cost comparison between different models
  • 💵 Monthly/daily cost tracking

Usage Analytics

  • 📈 Interactive graphs for token usage trends
  • 📅 Historical usage patterns over time
  • ⚠️ Usage limits and warning notifications
  • 📉 Usage optimization suggestions

Performance Optimizations

  • ⚡ Caching of token calculations
  • 🖼️ Lazy loading of provider icons
  • 📜 Virtualization for large message histories
  • 🚀 Optimized rendering for real-time updates

Enhanced UI Features

  • 🎨 Custom themes for visualizations
  • 📱 Responsive mobile-first design
  • ⬇️ Export usage statistics to CSV/JSON
  • 🔍 Advanced filtering and sorting options

Advanced Statistics

  • ⚖️ Average tokens per message
  • 📊 Token efficiency metrics
  • 🎯 Context window utilization
  • ⏱️ Response time analytics
  • 🔄 Model performance comparisons

Integration Features

  • 🔌 API for external usage tracking
  • 📊 Dashboard integration
  • 🔄 Real-time sync with other tools
  • 📱 Mobile app support

Technical Roadmap

  1. Q1: Cost analysis implementation
  2. Q2: Usage analytics and visualization
  3. Q3: Performance optimizations
  4. Q4: Advanced statistics and integrations

@wonderwhy-er
Copy link
Collaborator

I think it should be closed by default.

I also think that it should not be in chat scrolling with messages.
Also that hover popup and accordion kinda duplicate each other.
Feels like I would remove one of them.

Maybe we should move just usage + details to header? So that its chat characteristic?

@Stijnus
Copy link
Author

Stijnus commented Dec 21, 2024

I have changed the position to the right wit an icon and an extra sidebar.

image image

@Stijnus Stijnus changed the title (Work In Progress) for Exploration of how to show token usage Work In Progress for Exploration of how to show token usage Dec 22, 2024
@Stijnus
Copy link
Author

Stijnus commented Dec 22, 2024

Add new feature :

image image image

@Stijnus Stijnus changed the title Work In Progress for Exploration of how to show token usage feat: Work In Progress for Exploration of how to show token usage Dec 22, 2024
@Stijnus Stijnus changed the title feat: Work In Progress for Exploration of how to show token usage feat: work in progress for exploration of how to show token usage Dec 22, 2024
@wonderwhy-er
Copy link
Collaborator

Hm, is in settings across all chats?
I think I only care about current chat.

I see you are showing price, its probably not gonna work across all providers?

@wonderwhy-er
Copy link
Collaborator

Also, it seems something is not working locally for me.
Looks like node code is being bundled for client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants