Skip to content

Commit 32dcaca

Browse files
authored
chore: explictly support Python 3.9 in Together AI integration (#2355)
* chore: explictly support Python 3.9 in Together AI integration * replace pipe operator
1 parent 4583d3b commit 32dcaca

3 files changed

Lines changed: 14 additions & 13 deletions

File tree

.github/workflows/together_ai.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
fail-fast: false
3333
matrix:
3434
os: [ubuntu-latest, windows-latest, macos-latest]
35-
python-version: ["3.10", "3.13"]
35+
python-version: ["3.9", "3.13"]
3636

3737
steps:
3838
- name: Support longpaths
@@ -50,11 +50,11 @@ jobs:
5050
- name: Install Hatch
5151
run: pip install --upgrade hatch
5252
- name: Lint
53-
if: matrix.python-version == '3.10' && runner.os == 'Linux'
53+
if: matrix.python-version == '3.9' && runner.os == 'Linux'
5454
run: hatch run fmt-check && hatch run test:types
5555

5656
- name: Generate docs
57-
if: matrix.python-version == '3.10' && runner.os == 'Linux'
57+
if: matrix.python-version == '3.9' && runner.os == 'Linux'
5858
run: hatch run docs
5959

6060
- name: Run tests

integrations/together_ai/pyproject.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ name = "together-ai-haystack"
77
dynamic = ["version"]
88
description = 'An integration between the Together AI framework and Haystack'
99
readme = "README.md"
10-
requires-python = ">=3.10"
10+
requires-python = ">=3.9"
1111
license = "Apache-2.0"
1212
keywords = []
1313
authors = [{ name = "deepset GmbH", email = "info@deepset.ai" }]
@@ -16,6 +16,7 @@ classifiers = [
1616
"License :: OSI Approved :: Apache Software License",
1717
"Development Status :: 4 - Beta",
1818
"Programming Language :: Python",
19+
"Programming Language :: Python :: 3.9",
1920
"Programming Language :: Python :: 3.10",
2021
"Programming Language :: Python :: 3.11",
2122
"Programming Language :: Python :: 3.12",

integrations/together_ai/src/haystack_integrations/components/generators/together_ai/generator.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
from typing import Any, Dict, Optional, cast
5+
from typing import Any, Dict, Optional, Union, cast
66

77
from haystack import component, default_to_dict, logging
88
from haystack.dataclasses import ChatMessage, StreamingCallbackT
@@ -141,9 +141,9 @@ def run( # type: ignore[override]
141141
self,
142142
*,
143143
prompt: str,
144-
system_prompt: str | None = None,
145-
streaming_callback: StreamingCallbackT | None = None,
146-
generation_kwargs: dict[str, Any] | None = None,
144+
system_prompt: Optional[str] = None,
145+
streaming_callback: Optional[StreamingCallbackT] = None,
146+
generation_kwargs: Optional[dict[str, Any]] = None,
147147
) -> dict[str, Any]:
148148
"""
149149
Generate text completions synchronously.
@@ -179,9 +179,9 @@ async def run_async( # type: ignore[override]
179179
self,
180180
*,
181181
prompt: str,
182-
system_prompt: str | None = None,
183-
streaming_callback: StreamingCallbackT | None = None,
184-
generation_kwargs: dict[str, Any] | None = None,
182+
system_prompt: Optional[str] = None,
183+
streaming_callback: Optional[StreamingCallbackT] = None,
184+
generation_kwargs: Optional[dict[str, Any]] = None,
185185
) -> dict[str, Any]:
186186
"""
187187
Generate text completions asynchronously.
@@ -211,7 +211,7 @@ async def run_async( # type: ignore[override]
211211
replies = chat_response["replies"]
212212
return self._convert_chat_response_to_generator_format(replies)
213213

214-
def _prepare_messages(self, prompt: str, system_prompt: str | None = None) -> list[ChatMessage]:
214+
def _prepare_messages(self, prompt: str, system_prompt: Optional[str] = None) -> list[ChatMessage]:
215215
"""
216216
Convert prompt and system_prompt to ChatMessage format.
217217
@@ -228,7 +228,7 @@ def _prepare_messages(self, prompt: str, system_prompt: str | None = None) -> li
228228

229229
def _convert_chat_response_to_generator_format(
230230
self, chat_messages: list[ChatMessage]
231-
) -> dict[str, list[str] | list[dict[str, Any]]]:
231+
) -> dict[str, Union[list[str], list[dict[str, Any]]]]:
232232
"""
233233
Convert ChatGenerator response format to Generator format.
234234

0 commit comments

Comments
 (0)