Skip to content

Commit f052b5b

Browse files
committed
chore: reorganize imports
1 parent f629591 commit f052b5b

File tree

9 files changed

+16
-560
lines changed

9 files changed

+16
-560
lines changed

llm_observability_examples.py

Lines changed: 1 addition & 1 deletion
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

Lines changed: 0 additions & 4 deletions
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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .callbacks import PosthogCallbackHandler
2+
3+
__all__ = ["PosthogCallbackHandler"]
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ class RunMetadata(TypedDict, total=False):
4242

4343

4444
class PosthogCallbackHandler(BaseCallbackHandler):
45+
"""
46+
A callback handler for LangChain that sends events to PostHog LLM Observability.
47+
"""
48+
4549
_client: Client
4650
"""PostHog client instance."""
4751
_distinct_id: Optional[str]

posthog/ai/openai/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
from .openai import OpenAI
2+
from .openai_async import AsyncOpenAI
3+
4+
__all__ = ["OpenAI", "AsyncOpenAI"]
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import uuid
33
from typing import Any, Dict, Optional
44

5-
import openai.resources
6-
75
try:
86
import openai
97
except ImportError:
108
raise ModuleNotFoundError("Please install the OpenAI SDK to use this feature: 'pip install openai'")
119

10+
import openai.resources
11+
1212
from posthog.ai.utils import call_llm_and_track_usage, get_model_params
1313
from posthog.client import Client as PostHogClient
1414

posthog/ai/providers/openai/openai_async.py renamed to posthog/ai/openai/openai_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
import uuid
33
from typing import Any, Dict, Optional
44

5-
import openai.resources
6-
75
try:
86
import openai
97
except ImportError:
108
raise ModuleNotFoundError("Please install the OpenAI SDK to use this feature: 'pip install openai'")
119

10+
import openai.resources
11+
1212
from posthog.ai.utils import call_llm_and_track_usage_async, get_model_params
1313
from posthog.client import Client as PostHogClient
1414

0 commit comments

Comments
 (0)