HamedMP / CursorLens

An open-source dashboard for Cursor.sh IDE. Log AI code generations, track usage, and control AI models (including local ones). Run locally or use upcoming hosted version.
https://www.cursorlens.com
GNU Affero General Public License v3.0
104 stars 11 forks source link

feat: cost configuration and calculations for stats page #5

Closed gruckion closed 4 weeks ago

gruckion commented 1 month ago
HamedMP commented 4 weeks ago

This looks awesome @gruckion 🔥

HamedMP commented 4 weeks ago

I wonder why I am still seeing $0

image

Tried logging the costData but I can't be fully sure of the numbers, not all models that have a cost !=0 have been used e.g. babbage.

image
gruckion commented 4 weeks ago

I wonder why I am still seeing $0 image

Tried logging the costData but I can't be fully sure of the numbers, not all models that have a cost !=0 have been used e.g. babbage.

image

What is the name of your model. The model name key is the important property. Will also need to add additional config to cover the new models you've introduced.

We can run into an issue, since the user can freely put the model name I can put OpenAI gpt 3-5 or any other combination. We will need to have this locked down to a selector instead of free form text / templates.

HamedMP commented 4 weeks ago

Hmm, in the latest version the model name is chosen from a dropdown, can we unify them together?

gruckion commented 4 weeks ago

Hmm, in the latest version the model name is chosen from a dropdown, can we unify them together?

Perfect, I will align with this.

gruckion commented 4 weeks ago

Updated:

CleanShot 2024-08-20 at 08 44 47@2x

CleanShot 2024-08-20 at 08 45 44@2x

Cost information is shown.

And configurations still works as expected.

CleanShot 2024-08-20 at 08 46 25@2x

  1. Refactored to a single source of truth for the model / provider configuration.
import { getModelConfigurations } from "@/lib/model-config";
  1. Refactored the actions.ts for the getConfigurationCost() to make use of this single source of truth object.
  2. Refactored the configurations page to make use of the single source of truth.

Also left a TODO comment, we can improve the UX with a toaster.

  // TODO: Implement proper handling when turning off a default configuration
  // - Prevent turning off the last default configuration
  // - Show a toast message explaining why the action is not allowed
  // - Implement logic to ensure at least one configuration is always set as default

{/* TODO: Add an "Actions" column for edit functionality */}
HamedMP commented 4 weeks ago

Oh beautiful, testing it now 😍