-
Notifications
You must be signed in to change notification settings - Fork 48
feat(llma): send number of web searches #359
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
base: master
Are you sure you want to change the base?
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.
8 files reviewed, no comments
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.
💡 Codex Review
posthog-python/posthog/ai/openai/openai_converter.py
Lines 417 to 419 in 312b9c8
| if provider_type == "chat": | |
| if not hasattr(chunk, "usage") or not chunk.usage: | |
| return usage |
For chat completions, extract_openai_usage_from_chunk immediately returns when a chunk lacks usage. The call to extract_openai_web_search_count() is placed after this guard, so any streaming chunk that contains web search indicators (citations, web_search_call, etc.) but no usage is ignored and $ai_web_search_count will never be reported. OpenAI can emit citations before the final chunk where token usage is provided, meaning web searches won’t be captured for such streams. Extract the web search count before the early return or separate it from the usage check so non‑usage chunks can still contribute to the count.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
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.
lgtm apart form merge conflict but approving so no delay once that sorted
|
@andrewm4894 Thank you! For everyone: please do not merge, I need to run a couple of sanity checks before I merge. |
This now track web search tool calls across various providers, and sends the web search count as an event property (
$ai_web_search_count) to be used in calculating the LLM costs, where applicable.