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(llm-observability): add langchain integration #159

Merged
merged 11 commits into from
Jan 13, 2025
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
- name: Check formatting with black
run: |
black --check .

- name: Lint with flake8
run: |
flake8 posthog --ignore E501
Expand All @@ -51,10 +51,10 @@ jobs:
with:
fetch-depth: 1

- name: Set up Python 3.8
Copy link
Member

Choose a reason for hiding this comment

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

Why the Python version change? Just wanna be sure we aren't silently dropping older Python versions. Though 3.8 should be fine to drop as it's EoL – we should just be explicit about that event if it happens. (To be honest also surprised we don't use a matrix of Python versions for this Actions job)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

langchain-community requires Python >=3.9, so the CI was failing on 3.8. It is listed under test requirements, so no package will be installed for people not using the AI integration.

- name: Set up Python 3.9
uses: actions/setup-python@v2
with:
python-version: 3.8
python-version: 3.9

- name: Install requirements.txt dependencies with pip
run: |
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ posthog-analytics
.idea
.python-version
.coverage
pyrightconfig.json
pyrightconfig.json
.env
2 changes: 1 addition & 1 deletion llm_observability_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import uuid

import posthog
from posthog.ai import AsyncOpenAI, OpenAI
from posthog.ai.openai import AsyncOpenAI, OpenAI

# Example credentials - replace these with your own or use environment variables
posthog.project_api_key = os.getenv("POSTHOG_PROJECT_API_KEY", "your-project-api-key")
Expand Down
4 changes: 0 additions & 4 deletions posthog/ai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
from .providers.openai.openai import OpenAI
from .providers.openai.openai_async import AsyncOpenAI

__all__ = ["OpenAI", "AsyncOpenAI"]
3 changes: 3 additions & 0 deletions posthog/ai/langchain/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from .callbacks import PosthogCallbackHandler

__all__ = ["PosthogCallbackHandler"]
Loading
Loading