diff --git a/posthog/hogql/ai.py b/posthog/hogql/ai.py index 8bc181f2cc56f..4d7661713e348 100644 --- a/posthog/hogql/ai.py +++ b/posthog/hogql/ai.py @@ -1,5 +1,5 @@ from typing import TYPE_CHECKING, Optional -from openai import OpenAI +import openai from openai.types.chat import ChatCompletionMessageParam from posthog.event_usage import report_user_action from posthog.hogql.context import HogQLContext @@ -102,7 +102,7 @@ def write_sql_from_prompt(prompt: str, *, current_query: Optional[str] = None, t prompt_tokens_total, completion_tokens_total = 0, 0 for _ in range(3): # Try up to 3 times in case the generated SQL is not valid HogQL attempt_count += 1 - result = OpenAI().chat.completions.create( + result = openai.chat.completions.create( model="gpt-3.5-turbo", temperature=0.8, messages=messages, diff --git a/posthog/session_recordings/session_summary/summarize_session.py b/posthog/session_recordings/session_summary/summarize_session.py index 5e6c78e2d00e4..85e0891ccde52 100644 --- a/posthog/session_recordings/session_summary/summarize_session.py +++ b/posthog/session_recordings/session_summary/summarize_session.py @@ -3,7 +3,7 @@ from typing import List, Dict, Any -from openai import OpenAI +import openai from prometheus_client import Histogram @@ -291,7 +291,7 @@ def summarize_recording(recording: SessionRecording, user: User, team: Team): instance_region = get_instance_region() or "HOBBY" with timer("openai_completion"): - result = OpenAI().chat.completions.create( + result = openai.chat.completions.create( # model="gpt-4-1106-preview", # allows 128k tokens model="gpt-4", # allows 8k tokens temperature=0.7,