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

fix(api-models): usage unit to optional #1073

Merged
merged 1 commit into from
Jan 14, 2025
Merged

fix(api-models): usage unit to optional #1073

merged 1 commit into from
Jan 14, 2025

Conversation

hassiebp
Copy link
Contributor

@hassiebp hassiebp commented Jan 14, 2025

Important

Make unit field optional in Model class in model.py.

  • Models:
    • In model.py, changed unit field in Model class to be optional with a default of None.

This description was created by Ellipsis for 9ebeaf1. It will automatically update as commits are pushed.

@hassiebp hassiebp merged commit 0703b5a into main Jan 14, 2025
7 of 8 checks passed
@hassiebp hassiebp deleted the fix-api-models branch January 14, 2025 09:27
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disclaimer: Experimental PR review

PR Summary

Makes the unit field optional in the Model class, allowing model definitions without a specified usage unit in the Langfuse Python SDK.

  • Modified langfuse/api/resources/commons/types/model.py to make unit field optional with typing.Optional[ModelUsageUnit]
  • Potential breaking change for code that assumes unit is always present
  • Aligns with CreateModelRequest where unit was already optional
  • Impacts model usage tracking and cost calculations where unit type is required

1 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +34 to 37
unit: typing.Optional[ModelUsageUnit] = pydantic_v1.Field(default=None)
"""
Unit used by this model.
"""
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Making unit optional could cause issues if any code relies on unit being present for cost calculations. Consider adding validation to ensure unit is present when input_price, output_price, or total_price are set.

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.

1 participant