Skip to content

Commit 96363f9

Browse files
committed
fixed top-level words
1 parent 53d2a3c commit 96363f9

3 files changed

Lines changed: 25 additions & 21 deletions

File tree

src/together/resources/audio/transcriptions.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,12 @@ def create(
104104
)
105105

106106
# Add any additional kwargs
107-
params_data.update(kwargs)
107+
# Convert boolean values to lowercase strings for proper form encoding
108+
for key, value in kwargs.items():
109+
if isinstance(value, bool):
110+
params_data[key] = str(value).lower()
111+
else:
112+
params_data[key] = value
108113

109114
try:
110115
response, _, _ = requestor.request(
@@ -235,7 +240,12 @@ async def create(
235240
)
236241

237242
# Add any additional kwargs
238-
params_data.update(kwargs)
243+
# Convert boolean values to lowercase strings for proper form encoding
244+
for key, value in kwargs.items():
245+
if isinstance(value, bool):
246+
params_data[key] = str(value).lower()
247+
else:
248+
params_data[key] = value
239249

240250
try:
241251
response, _, _ = await requestor.arequest(

src/together/types/audio_speech.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,8 +176,7 @@ class AudioTranscriptionResponse(BaseModel):
176176

177177

178178
class AudioTranscriptionVerboseResponse(BaseModel):
179-
model_config = ConfigDict(extra="allow")
180-
179+
id: Optional[str] = None
181180
language: Optional[str] = None
182181
duration: Optional[float] = None
183182
text: str

tests/integration/resources/test_transcriptions.py

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,18 @@ def validate_diarization_response(response_dict):
3636
assert "end" in word
3737
assert "speaker_id" in word
3838

39-
# Note: The top-level words field should be present in the API response but
40-
# may not be preserved by the SDK currently. We check for it but don't fail
41-
# the test if it's missing, as the speaker_segments contain all the word data.
42-
if "words" in response_dict and response_dict["words"] is not None:
43-
assert isinstance(response_dict["words"], list)
44-
assert len(response_dict["words"]) > 0
45-
46-
# Validate each word in top-level words
47-
for word in response_dict["words"]:
48-
assert "id" in word
49-
assert "word" in word
50-
assert "start" in word
51-
assert "end" in word
52-
assert "speaker_id" in word
53-
else:
54-
# Log that words field is missing (expected with current SDK)
55-
print("Note: Top-level 'words' field not preserved by SDK (known issue)")
39+
# Validate top-level words field
40+
assert "words" in response_dict
41+
assert isinstance(response_dict["words"], list)
42+
assert len(response_dict["words"]) > 0
43+
44+
# Validate each word in top-level words
45+
for word in response_dict["words"]:
46+
assert "id" in word
47+
assert "word" in word
48+
assert "start" in word
49+
assert "end" in word
50+
assert "speaker_id" in word
5651

5752

5853
class TestTogetherTranscriptions:

0 commit comments

Comments
 (0)