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

feat(ai): add error handling to python ai sdk #174

Merged
merged 7 commits into from
Jan 24, 2025

Conversation

k11kirky
Copy link
Contributor

Add $ai_error and $ai_is_error properties to LangChain callback handler, OpenAI, and Anthropic.

@k11kirky k11kirky requested review from Twixes and skoob13 January 24, 2025 06:20
Comment on lines +180 to +182
client = OpenAI(api_key="test-key", posthog_client=mock_client)
with pytest.raises(Exception):
client.chat.completions.create(model="gpt-4", messages=[{"role": "user", "content": "Hello"}])
Copy link
Member

Choose a reason for hiding this comment

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

If it's an HTTP error, say a 400, do we still capture the $ai_error content then?

Copy link
Contributor

Choose a reason for hiding this comment

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

@k11kirky k11kirky requested a review from Twixes January 24, 2025 19:01
Comment on lines +180 to +182
client = OpenAI(api_key="test-key", posthog_client=mock_client)
with pytest.raises(Exception):
client.chat.completions.create(model="gpt-4", messages=[{"role": "user", "content": "Hello"}])
Copy link
Contributor

Choose a reason for hiding this comment

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

@k11kirky k11kirky merged commit 0f8b10b into master Jan 24, 2025
2 checks passed
@k11kirky k11kirky deleted the feat/ai-error-handling branch January 24, 2025 21:09
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