Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 7.8.2 - 2026-02-04

fix(llma): fix prompts default url

# 7.8.1 - 2026-02-03

fix(llma): small fixes for prompt management
Expand Down
6 changes: 3 additions & 3 deletions posthog/ai/prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

log = logging.getLogger("posthog")

APP_ENDPOINT = "https://app.posthog.com"
APP_ENDPOINT = "https://us.posthog.com"
Copy link
Contributor

Choose a reason for hiding this comment

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

[P1] Default cloud host likely shouldn’t change from app.posthog.com to us.posthog.com.

Changing APP_ENDPOINT to https://us.posthog.com alters the default API base for anyone who previously relied on the implicit default (including EU Cloud users). If the intent is to fix the prompts API specifically, consider either keeping APP_ENDPOINT as app.posthog.com or deriving the prompts base from an existing canonical host constant used elsewhere in the SDK (or documenting that host must be set for non-US regions).

Prompt To Fix With AI
This is a comment left during a code review.
Path: posthog/ai/prompts.py
Line: 18:18

Comment:
[P1] Default cloud host likely shouldn’t change from `app.posthog.com` to `us.posthog.com`.

Changing `APP_ENDPOINT` to `https://us.posthog.com` alters the default API base for anyone who previously relied on the implicit default (including EU Cloud users). If the intent is to fix the *prompts* API specifically, consider either keeping `APP_ENDPOINT` as `app.posthog.com` or deriving the prompts base from an existing canonical host constant used elsewhere in the SDK (or documenting that `host` must be set for non-US regions).

How can I resolve this? If you propose a fix, please make it concise.

DEFAULT_CACHE_TTL_SECONDS = 300 # 5 minutes

PromptVariables = Dict[str, Union[str, int, float, bool]]
Expand Down Expand Up @@ -50,11 +50,11 @@ class Prompts:
from posthog.ai.prompts import Prompts

# With PostHog client
posthog = Posthog('phc_xxx', host='https://app.posthog.com', personal_api_key='phx_xxx')
posthog = Posthog('phc_xxx', host='https://us.posthog.com', personal_api_key='phx_xxx')
prompts = Prompts(posthog)

# Or with direct options (no PostHog client needed)
prompts = Prompts(personal_api_key='phx_xxx', host='https://app.posthog.com')
prompts = Prompts(personal_api_key='phx_xxx', host='https://us.posthog.com')

# Fetch with caching and fallback
template = prompts.get('support-system-prompt', fallback='You are a helpful assistant.')
Expand Down
8 changes: 4 additions & 4 deletions posthog/test/ai/test_prompts.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TestPrompts(unittest.TestCase):
}

def create_mock_posthog(
self, personal_api_key="phx_test_key", host="https://app.posthog.com"
self, personal_api_key="phx_test_key", host="https://us.posthog.com"
):
Comment on lines 35 to 37
Copy link
Contributor

Choose a reason for hiding this comment

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

[P2] Test helper default host hard-codes US cloud.

create_mock_posthog(..., host="https://us.posthog.com") bakes a region-specific assumption into most tests, which makes it harder to catch regressions where host handling differs between regions / self-hosted. It’d be more robust to keep the default host aligned with the SDK default (or parameterize host in the specific assertions that care about it).

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: posthog/test/ai/test_prompts.py
Line: 35:37

Comment:
[P2] Test helper default host hard-codes US cloud.

`create_mock_posthog(..., host="https://us.posthog.com")` bakes a region-specific assumption into most tests, which makes it harder to catch regressions where `host` handling differs between regions / self-hosted. It’d be more robust to keep the default host aligned with the SDK default (or parameterize host in the specific assertions that care about it).

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

"""Create a mock PostHog client."""
mock = MagicMock()
Expand Down Expand Up @@ -61,7 +61,7 @@ def test_successfully_fetch_a_prompt(self, mock_get_session):
call_args = mock_get.call_args
self.assertEqual(
call_args[0][0],
"https://app.posthog.com/api/environments/@current/llm_prompts/name/test-prompt/",
"https://us.posthog.com/api/environments/@current/llm_prompts/name/test-prompt/",
)
self.assertIn("Authorization", call_args[1]["headers"])
self.assertEqual(
Expand Down Expand Up @@ -333,7 +333,7 @@ def test_url_encode_prompt_names_with_special_characters(self, mock_get_session)
call_args = mock_get.call_args
self.assertEqual(
call_args[0][0],
"https://app.posthog.com/api/environments/@current/llm_prompts/name/prompt%20with%20spaces%2Fand%2Fslashes/",
"https://us.posthog.com/api/environments/@current/llm_prompts/name/prompt%20with%20spaces%2Fand%2Fslashes/",
)

@patch("posthog.ai.prompts._get_session")
Expand All @@ -350,7 +350,7 @@ def test_work_with_direct_options_no_posthog_client(self, mock_get_session):
call_args = mock_get.call_args
self.assertEqual(
call_args[0][0],
"https://app.posthog.com/api/environments/@current/llm_prompts/name/test-prompt/",
"https://us.posthog.com/api/environments/@current/llm_prompts/name/test-prompt/",
)
self.assertEqual(
call_args[1]["headers"]["Authorization"], "Bearer phx_direct_key"
Expand Down
2 changes: 1 addition & 1 deletion posthog/version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = "7.8.1"
VERSION = "7.8.2"

if __name__ == "__main__":
print(VERSION, end="") # noqa: T201
Loading