diff --git a/src/symposium/core/api.py b/src/symposium/core/api.py index 34bf3d4..9ed2bac 100644 --- a/src/symposium/core/api.py +++ b/src/symposium/core/api.py @@ -65,7 +65,11 @@ def __init__(self, api_key: str, **kwargs): **kwargs: Additional configuration (model, temperature, max_tokens, etc.) """ super().__init__(api_key, **kwargs) - self.client = OpenAI(api_key=api_key, base_url="https://api.perplexity.ai") + self.client = OpenAI( + api_key=api_key, + base_url="https://api.perplexity.ai", + default_headers={"X-Pplx-Integration": "symposium"}, + ) self.model = kwargs.get("model", "sonar") self.temperature = kwargs.get("temperature", 0.7) self.max_tokens = kwargs.get("max_tokens", 2000) diff --git a/tests/test_core/test_api.py b/tests/test_core/test_api.py index 3e51f98..58cb019 100644 --- a/tests/test_core/test_api.py +++ b/tests/test_core/test_api.py @@ -60,7 +60,11 @@ def test_init(self, mock_openai): provider = PerplexityProvider("test_key") assert provider.api_key == "test_key" assert provider.model == "sonar" - mock_openai.assert_called_once() + mock_openai.assert_called_once_with( + api_key="test_key", + base_url="https://api.perplexity.ai", + default_headers={"X-Pplx-Integration": "symposium"}, + ) @patch("symposium.core.api.OpenAI") def test_get_response(self, mock_openai): @@ -101,6 +105,7 @@ def test_init(self, mock_openai): assert provider.api_key == "test_key" assert provider.model == "anthropic/claude-3.5-sonnet" mock_openai.assert_called_once() + assert "default_headers" not in mock_openai.call_args.kwargs @patch("symposium.core.api.OpenAI") def test_get_response(self, mock_openai):