cometapi-haystack 1.0.0__tar.gz → 1.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,9 @@
1
+ # Changelog
2
+
3
+ ## [unreleased]
4
+
5
+ ### 🚀 Features
6
+
7
+ - Add CometAPI integration with CometAPIChatGenerator class and configuration (#2345)
8
+
9
+ <!-- generated by git-cliff -->
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cometapi-haystack
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: Use Comet API with Haystack to build AI applications with 500+ AI models.
5
5
  Project-URL: Documentation, https://github.com/deepset-ai/haystack-core-integrations/tree/main/integrations/cometapi#readme
6
6
  Project-URL: Issues, https://github.com/deepset-ai/haystack-core-integrations/issues
@@ -0,0 +1,28 @@
1
+ loaders:
2
+ - ignore_when_discovered:
3
+ - __init__
4
+ modules:
5
+ - haystack_integrations.components.generators.cometapi.chat.chat_generator
6
+ search_path:
7
+ - ../src
8
+ type: haystack_pydoc_tools.loaders.CustomPythonLoader
9
+ processors:
10
+ - do_not_filter_modules: false
11
+ documented_only: true
12
+ expression: null
13
+ skip_empty_modules: true
14
+ type: filter
15
+ - type: smart
16
+ - type: crossref
17
+ renderer:
18
+ description: Comet API integration for Haystack
19
+ id: integrations-cometapi
20
+ markdown:
21
+ add_member_class_prefix: false
22
+ add_method_class_prefix: true
23
+ classdef_code_block: false
24
+ descriptive_class_title: false
25
+ descriptive_module_title: true
26
+ filename: cometapi.md
27
+ title: Comet API
28
+ type: haystack_pydoc_tools.renderers.DocusaurusRenderer
@@ -85,7 +85,7 @@ module = [
85
85
  ignore_missing_imports = true
86
86
 
87
87
  [tool.ruff]
88
- target-version = "py38"
88
+ target-version = "py39"
89
89
  line-length = 120
90
90
 
91
91
  [tool.ruff.lint]
@@ -1,4 +1,4 @@
1
- from typing import Any, Dict, List, Optional, Union
1
+ from typing import Any, Optional, Union
2
2
 
3
3
  from haystack.components.generators.chat import OpenAIChatGenerator
4
4
  from haystack.dataclasses import StreamingCallbackT
@@ -16,8 +16,8 @@ class CometAPIChatGenerator(OpenAIChatGenerator):
16
16
 
17
17
  :param api_key: The API key for authenticating with the CometAPI. Defaults to
18
18
  loading from the "COMET_API_KEY" environment variable.
19
- :param model: The name of the model to use for chat generation (e.g., "gpt-4o-mini", "grok-3-mini").
20
- Defaults to "gpt-4o-mini".
19
+ :param model: The name of the model to use for chat generation (e.g., "gpt-5-mini", "grok-3-mini").
20
+ Defaults to "gpt-5-mini".
21
21
  :param streaming_callback: An optional callable that will be called with each chunk of
22
22
  a streaming response.
23
23
  :param generation_kwargs: Optional keyword arguments to pass to the underlying generation
@@ -33,14 +33,14 @@ class CometAPIChatGenerator(OpenAIChatGenerator):
33
33
  self,
34
34
  *,
35
35
  api_key: Secret = Secret.from_env_var("COMET_API_KEY"),
36
- model: str = "gpt-4o-mini",
36
+ model: str = "gpt-5-mini",
37
37
  streaming_callback: Optional[StreamingCallbackT] = None,
38
- generation_kwargs: Optional[Dict[str, Any]] = None,
38
+ generation_kwargs: Optional[dict[str, Any]] = None,
39
39
  timeout: Optional[int] = None,
40
40
  max_retries: Optional[int] = None,
41
- tools: Optional[Union[List[Union[Tool, Toolset]], Toolset]] = None,
41
+ tools: Optional[Union[list[Union[Tool, Toolset]], Toolset]] = None,
42
42
  tools_strict: bool = False,
43
- http_client_kwargs: Optional[Dict[str, Any]] = None,
43
+ http_client_kwargs: Optional[dict[str, Any]] = None,
44
44
  ):
45
45
  api_base_url = "https://api.cometapi.com/v1"
46
46
 
@@ -67,7 +67,7 @@ def mock_chat_completion():
67
67
  with patch("openai.resources.chat.completions.Completions.create") as mock_chat_completion_create:
68
68
  completion = ChatCompletion(
69
69
  id="foo",
70
- model="gpt-4o-mini",
70
+ model="gpt-5-mini",
71
71
  object="chat.completion",
72
72
  choices=[
73
73
  Choice(
@@ -90,7 +90,7 @@ class TestCometAPIChatGenerator:
90
90
  monkeypatch.setenv("COMET_API_KEY", "test-api-key")
91
91
  component = CometAPIChatGenerator()
92
92
  assert component.client.api_key == "test-api-key"
93
- assert component.model == "gpt-4o-mini"
93
+ assert component.model == "gpt-5-mini"
94
94
  assert component.api_base_url == "https://api.cometapi.com/v1"
95
95
  assert component.streaming_callback is None
96
96
  assert not component.generation_kwargs
@@ -103,12 +103,12 @@ class TestCometAPIChatGenerator:
103
103
  def test_init_with_parameters(self):
104
104
  component = CometAPIChatGenerator(
105
105
  api_key=Secret.from_token("test-api-key"),
106
- model="gpt-4o-mini",
106
+ model="gpt-5-mini",
107
107
  streaming_callback=print_streaming_chunk,
108
108
  generation_kwargs={"max_tokens": 10, "some_test_param": "test-params"},
109
109
  )
110
110
  assert component.client.api_key == "test-api-key"
111
- assert component.model == "gpt-4o-mini"
111
+ assert component.model == "gpt-5-mini"
112
112
  assert component.streaming_callback is print_streaming_chunk
113
113
  assert component.generation_kwargs == {"max_tokens": 10, "some_test_param": "test-params"}
114
114
 
@@ -124,7 +124,7 @@ class TestCometAPIChatGenerator:
124
124
 
125
125
  expected_params = {
126
126
  "api_key": {"env_vars": ["COMET_API_KEY"], "strict": True, "type": "env_var"},
127
- "model": "gpt-4o-mini",
127
+ "model": "gpt-5-mini",
128
128
  "streaming_callback": None,
129
129
  "api_base_url": "https://api.cometapi.com/v1",
130
130
  "generation_kwargs": {},
@@ -141,7 +141,7 @@ class TestCometAPIChatGenerator:
141
141
  monkeypatch.setenv("ENV_VAR", "test-api-key")
142
142
  component = CometAPIChatGenerator(
143
143
  api_key=Secret.from_env_var("ENV_VAR"),
144
- model="gpt-4o-mini",
144
+ model="gpt-5-mini",
145
145
  streaming_callback=print_streaming_chunk,
146
146
  generation_kwargs={"max_tokens": 10, "some_test_param": "test-params"},
147
147
  timeout=10,
@@ -158,7 +158,7 @@ class TestCometAPIChatGenerator:
158
158
 
159
159
  expected_params = {
160
160
  "api_key": {"env_vars": ["ENV_VAR"], "strict": True, "type": "env_var"},
161
- "model": "gpt-4o-mini",
161
+ "model": "gpt-5-mini",
162
162
  "api_base_url": "https://api.cometapi.com/v1",
163
163
  "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk",
164
164
  "generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"},
@@ -177,7 +177,7 @@ class TestCometAPIChatGenerator:
177
177
  "type": ("haystack_integrations.components.generators.cometapi.chat.chat_generator.CometAPIChatGenerator"),
178
178
  "init_parameters": {
179
179
  "api_key": {"env_vars": ["COMET_API_KEY"], "strict": True, "type": "env_var"},
180
- "model": "gpt-4o-mini",
180
+ "model": "gpt-5-mini",
181
181
  "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk",
182
182
  "generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"},
183
183
  "timeout": 10,
@@ -187,7 +187,7 @@ class TestCometAPIChatGenerator:
187
187
  },
188
188
  }
189
189
  component = CometAPIChatGenerator.from_dict(data)
190
- assert component.model == "gpt-4o-mini"
190
+ assert component.model == "gpt-5-mini"
191
191
  assert component.streaming_callback is print_streaming_chunk
192
192
  assert component.api_base_url == "https://api.cometapi.com/v1"
193
193
  assert component.generation_kwargs == {"max_tokens": 10, "some_test_param": "test-params"}
@@ -203,7 +203,7 @@ class TestCometAPIChatGenerator:
203
203
  "type": ("haystack_integrations.components.generators.cometapi.chat.chat_generator.CometAPIChatGenerator"),
204
204
  "init_parameters": {
205
205
  "api_key": {"env_vars": ["COMET_API_KEY"], "strict": True, "type": "env_var"},
206
- "model": "gpt-4o-mini",
206
+ "model": "gpt-5-mini",
207
207
  "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk",
208
208
  "generation_kwargs": {"max_tokens": 10, "some_test_param": "test-params"},
209
209
  "timeout": 10,
@@ -254,7 +254,7 @@ class TestCometAPIChatGenerator:
254
254
  assert len(results["replies"]) == 1
255
255
  message: ChatMessage = results["replies"][0]
256
256
  assert "Paris" in message.text
257
- assert "gpt-4o-mini" in message.meta["model"]
257
+ assert "gpt-5-mini" in message.meta["model"]
258
258
  assert message.meta["finish_reason"] == "stop"
259
259
 
260
260
  @pytest.mark.skipif(
@@ -290,7 +290,7 @@ class TestCometAPIChatGenerator:
290
290
  message: ChatMessage = results["replies"][0]
291
291
  assert "Paris" in message.text
292
292
 
293
- assert "gpt-4o-mini" in message.meta["model"]
293
+ assert "gpt-5-mini" in message.meta["model"]
294
294
  assert message.meta["finish_reason"] == "stop"
295
295
 
296
296
  assert callback.counter > 1
@@ -445,7 +445,6 @@ class TestCometAPIChatGenerator:
445
445
 
446
446
  # Create generator with specific configuration
447
447
  generator = CometAPIChatGenerator(
448
- model="gpt-4o-mini",
449
448
  generation_kwargs={"temperature": 0.7},
450
449
  streaming_callback=print_streaming_chunk,
451
450
  tools=[tool],
@@ -466,7 +465,7 @@ class TestCometAPIChatGenerator:
466
465
  "haystack_integrations.components.generators.cometapi.chat.chat_generator.CometAPIChatGenerator"
467
466
  ),
468
467
  "init_parameters": {
469
- "model": "gpt-4o-mini",
468
+ "model": "gpt-5-mini",
470
469
  "streaming_callback": "haystack.components.generators.utils.print_streaming_chunk",
471
470
  "api_base_url": "https://api.cometapi.com/v1",
472
471
  "organization": None,
@@ -534,7 +533,7 @@ class TestChatCompletionChunkConversion:
534
533
  ChoiceChunk(delta=ChoiceDelta(content="", role="assistant"), index=0, native_finish_reason=None)
535
534
  ],
536
535
  created=1750162525,
537
- model="gpt-4o-mini",
536
+ model="gpt-5-mini",
538
537
  object="chat.completion.chunk",
539
538
  system_fingerprint="fp_34a54ae93c",
540
539
  provider="OpenAI",
@@ -559,7 +558,7 @@ class TestChatCompletionChunkConversion:
559
558
  )
560
559
  ],
561
560
  created=1750162525,
562
- model="gpt-4o-mini",
561
+ model="gpt-5-mini",
563
562
  object="chat.completion.chunk",
564
563
  system_fingerprint="fp_34a54ae93c",
565
564
  provider="OpenAI",
@@ -583,7 +582,7 @@ class TestChatCompletionChunkConversion:
583
582
  )
584
583
  ],
585
584
  created=1750162525,
586
- model="gpt-4o-mini",
585
+ model="gpt-5-mini",
587
586
  object="chat.completion.chunk",
588
587
  system_fingerprint="fp_34a54ae93c",
589
588
  provider="OpenAI",
@@ -607,7 +606,7 @@ class TestChatCompletionChunkConversion:
607
606
  )
608
607
  ],
609
608
  created=1750162525,
610
- model="gpt-4o-mini",
609
+ model="gpt-5-mini",
611
610
  object="chat.completion.chunk",
612
611
  system_fingerprint="fp_34a54ae93c",
613
612
  provider="OpenAI",
@@ -631,7 +630,7 @@ class TestChatCompletionChunkConversion:
631
630
  )
632
631
  ],
633
632
  created=1750162525,
634
- model="gpt-4o-mini",
633
+ model="gpt-5-mini",
635
634
  object="chat.completion.chunk",
636
635
  system_fingerprint="fp_34a54ae93c",
637
636
  provider="OpenAI",
@@ -655,7 +654,7 @@ class TestChatCompletionChunkConversion:
655
654
  )
656
655
  ],
657
656
  created=1750162525,
658
- model="gpt-4o-mini",
657
+ model="gpt-5-mini",
659
658
  object="chat.completion.chunk",
660
659
  system_fingerprint="fp_34a54ae93c",
661
660
  provider="OpenAI",
@@ -680,7 +679,7 @@ class TestChatCompletionChunkConversion:
680
679
  )
681
680
  ],
682
681
  created=1750162525,
683
- model="gpt-4o-mini",
682
+ model="gpt-5-mini",
684
683
  object="chat.completion.chunk",
685
684
  service_tier=None,
686
685
  system_fingerprint="fp_34a54ae93c",
@@ -707,7 +706,7 @@ class TestChatCompletionChunkConversion:
707
706
  )
708
707
  ],
709
708
  created=1750162525,
710
- model="gpt-4o-mini",
709
+ model="gpt-5-mini",
711
710
  object="chat.completion.chunk",
712
711
  system_fingerprint="fp_34a54ae93c",
713
712
  provider="OpenAI",
@@ -731,7 +730,7 @@ class TestChatCompletionChunkConversion:
731
730
  )
732
731
  ],
733
732
  created=1750162525,
734
- model="gpt-4o-mini",
733
+ model="gpt-5-mini",
735
734
  object="chat.completion.chunk",
736
735
  system_fingerprint="fp_34a54ae93c",
737
736
  provider="OpenAI",
@@ -755,7 +754,7 @@ class TestChatCompletionChunkConversion:
755
754
  )
756
755
  ],
757
756
  created=1750162525,
758
- model="gpt-4o-mini",
757
+ model="gpt-5-mini",
759
758
  object="chat.completion.chunk",
760
759
  system_fingerprint="fp_34a54ae93c",
761
760
  provider="OpenAI",
@@ -779,7 +778,7 @@ class TestChatCompletionChunkConversion:
779
778
  )
780
779
  ],
781
780
  created=1750162525,
782
- model="gpt-4o-mini",
781
+ model="gpt-5-mini",
783
782
  object="chat.completion.chunk",
784
783
  system_fingerprint="fp_34a54ae93c",
785
784
  provider="OpenAI",
@@ -795,7 +794,7 @@ class TestChatCompletionChunkConversion:
795
794
  )
796
795
  ],
797
796
  created=1750162525,
798
- model="gpt-4o-mini",
797
+ model="gpt-5-mini",
799
798
  object="chat.completion.chunk",
800
799
  system_fingerprint="fp_34a54ae93c",
801
800
  provider="OpenAI",
@@ -810,7 +809,7 @@ class TestChatCompletionChunkConversion:
810
809
  )
811
810
  ],
812
811
  created=1750162525,
813
- model="gpt-4o-mini",
812
+ model="gpt-5-mini",
814
813
  object="chat.completion.chunk",
815
814
  usage=CompletionUsage(
816
815
  completion_tokens=42,
@@ -840,7 +839,7 @@ class TestChatCompletionChunkConversion:
840
839
  assert result.tool_calls[1].arguments == {"city": "Berlin"}
841
840
 
842
841
  # Verify meta information
843
- assert result.meta["model"] == "gpt-4o-mini"
842
+ assert result.meta["model"] == "gpt-5-mini"
844
843
  assert result.meta["finish_reason"] == "tool_calls"
845
844
  assert result.meta["index"] == 0
846
845
  assert result.meta["completion_start_time"] is not None
@@ -60,7 +60,7 @@ def mock_async_chat_completion():
60
60
  ) as mock_chat_completion_create:
61
61
  completion = ChatCompletion(
62
62
  id="foo",
63
- model="openai/gpt-4o-mini",
63
+ model="openai/gpt-5-mini",
64
64
  object="chat.completion",
65
65
  choices=[
66
66
  Choice(
@@ -139,7 +139,7 @@ class TestCometAPIChatGeneratorAsync:
139
139
  assert len(results["replies"]) == 1
140
140
  message: ChatMessage = results["replies"][0]
141
141
  assert "Paris" in message.text
142
- assert "gpt-4o-mini" in message.meta["model"]
142
+ assert "gpt-5-mini" in message.meta["model"]
143
143
  assert message.meta["finish_reason"] == "stop"
144
144
 
145
145
  @pytest.mark.skipif(
@@ -165,7 +165,7 @@ class TestCometAPIChatGeneratorAsync:
165
165
  message: ChatMessage = results["replies"][0]
166
166
  assert "Paris" in message.text
167
167
 
168
- assert "gpt-4o-mini" in message.meta["model"]
168
+ assert "gpt-5-mini" in message.meta["model"]
169
169
  assert message.meta["finish_reason"] == "stop"
170
170
 
171
171
  assert counter > 1
@@ -1 +0,0 @@
1
- # Changelog