Skip to content

Conversation

@k11kirky
Copy link
Contributor

Extract core values from model params.

  • temperature
  • stream
  • max_completion_tokens

@k11kirky k11kirky requested a review from skoob13 January 17, 2025 23:31
Copy link
Member

@Twixes Twixes left a comment

Choose a reason for hiding this comment

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

This looks good, but we'll have to duplicate the effort in other SDKs (TypeScript), so proposing inlining into the plugin server too!

return model_params


def extract_core_model_params(kwargs: Dict[str, Any], provider: str) -> Dict[str, Any]:
Copy link
Member

Choose a reason for hiding this comment

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

Let's do this in the plugin server, so that we only have to update one place to cover all SDKs!

Extracts core model parameters from the kwargs dictionary.
"""
output = {}
if provider == "anthropic":
Copy link
Member

Choose a reason for hiding this comment

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

To track AI cost processing's case-insensitive behavior:

Suggested change
if provider == "anthropic":
if provider:
provider = provider.lower()
if provider == "anthropic":

Comment on lines +47 to +48
if "max_completion_tokens" in kwargs:
output["$ai_max_tokens"] = kwargs.get("max_completion_tokens")
Copy link
Member

Choose a reason for hiding this comment

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

Might also be clearest to standardize on max_completion_tokens (though hard to say if other providers releasing reasoning models will follow this naming)

@k11kirky k11kirky closed this Jan 20, 2025
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.

3 participants