Skip to content

Commit e51b883

Browse files
authored
feat(llm-observability): add langchain integration (#159)
* feat(ai): LangChain integration v0.1 * test: langchain integration tests * test: langchain-openai for v2 and v3 * chore: reorganize imports * fix: ci * fix: set python on ci to 3.9 * fix: upgrade ci for python 3.9 * fix: fallback for distinct_id * fix: personless events for omitted distinct_ids * fix: review comments * feat: base url retrieval
1 parent 66101c9 commit e51b883

15 files changed

+1065
-18
lines changed

.github/workflows/ci.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
- name: Check formatting with black
3434
run: |
3535
black --check .
36-
36+
3737
- name: Lint with flake8
3838
run: |
3939
flake8 posthog --ignore E501
@@ -51,10 +51,10 @@ jobs:
5151
with:
5252
fetch-depth: 1
5353

54-
- name: Set up Python 3.8
54+
- name: Set up Python 3.9
5555
uses: actions/setup-python@v2
5656
with:
57-
python-version: 3.8
57+
python-version: 3.9
5858

5959
- name: Install requirements.txt dependencies with pip
6060
run: |

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ posthog-analytics
1515
.idea
1616
.python-version
1717
.coverage
18-
pyrightconfig.json
18+
pyrightconfig.json
19+
.env

llm_observability_examples.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import uuid
33

44
import posthog
5-
from posthog.ai import AsyncOpenAI, OpenAI
5+
from posthog.ai.openai import AsyncOpenAI, OpenAI
66

77
# Example credentials - replace these with your own or use environment variables
88
posthog.project_api_key = os.getenv("POSTHOG_PROJECT_API_KEY", "your-project-api-key")

posthog/ai/__init__.py

-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +0,0 @@
1-
from .providers.openai.openai import OpenAI
2-
from .providers.openai.openai_async import AsyncOpenAI
3-
4-
__all__ = ["OpenAI", "AsyncOpenAI"]

posthog/ai/langchain/__init__.py

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .callbacks import CallbackHandler
2+
3+
__all__ = ["CallbackHandler"]

0 commit comments

Comments
 (0)