-
Notifications
You must be signed in to change notification settings - Fork 49
feat(ph-ai): PostHog properties dict in GenerationMetadata #366
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
4 files reviewed, 1 comment
CHANGELOG.md
Outdated
| @@ -1,3 +1,7 @@ | |||
| # 6.7.15 - 2025-11-04 | |||
|
|
|||
| - feat(ph-ai): ai_billing metadata per-generation | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
syntax: Typo: should be ai_billable not ai_billing to match the actual property name used in the code ($ai_billable).
| - feat(ph-ai): ai_billing metadata per-generation | |
| - feat(ph-ai): ai_billable metadata per-generation |
Prompt To Fix With AI
This is a comment left during a code review.
Path: CHANGELOG.md
Line: 3:3
Comment:
**syntax:** Typo: should be `ai_billable` not `ai_billing` to match the actual property name used in the code (`$ai_billable`).
```suggestion
- feat(ph-ai): ai_billable metadata per-generation
```
How can I resolve this? If you propose a fix, please make it concise.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make it useful for customers and for us?
More details: https://github.com/PostHog/posthog/pull/40881/files#r2493990657
c56b79b to
edc5a47
Compare
chore: version bump
edc5a47 to
72aeea6
Compare
posthog/ai/langchain/callbacks.py
Outdated
| if billable := metadata.get("posthog_ai_billable"): | ||
| generation.billable = billable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't understand why we don't allow setting a dictionary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why would we need it to be? Previously I did that but I don't see a big reason, we are still looking into the metadata but populating the single field on the client side. Having a dict would either be for all metadata or I don't see a point introducing it for this field honestly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Taking the current path, we add our internal implementation details to the SDK, which has little value and is limiting for customers. You can achieve the desired result by allowing a dictionary to be passed in LangChain's metadata, so anyone else who wants to set similar data, but not the billing props, won't have the same problem you're currently having.
3b1874a to
99e4f12
Compare
chore(ph-ai): posthog props chore: fix tests chore: stuff
99e4f12 to
9c6ec03
Compare
skoob13
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, looks good. Left a nit, which is up to you.
Twixes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generalized version looks good
Co-authored-by: Georgiy Tarasov <gtarasov.work@gmail.com>
Problem
PostHog AI team needs to support billing certain LLM generations based on centralized logic that will live in the
posthog/hogairepository.The core idea is simple, add a
$ai_billablemetadata property that would be signaling, at generation time, wether we should flag it as billable or not.Changes
Tests
posthogrepo