Skip to content

fix: handle multiple words when using .word_search(...) #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 2, 2023
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
9 changes: 6 additions & 3 deletions assemblyai/api.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import BinaryIO, List, Optional
from urllib.parse import urlencode

import httpx

Expand Down Expand Up @@ -142,9 +143,11 @@ def word_search(
) -> types.WordSearchMatchResponse:
response = client.get(
f"/transcript/{transcript_id}/word-search",
params={
"words": words,
},
params=urlencode(
{
"words": ",".join(words),
}
),
)

if response.status_code != httpx.codes.ok:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

setup(
name="assemblyai",
version="0.5.0",
version="0.5.1",
description="AssemblyAI Python SDK",
author="AssemblyAI",
author_email="[email protected]",
Expand Down
8 changes: 6 additions & 2 deletions tests/unit/test_transcript.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Any, Dict, List
from urllib.parse import urlencode

import httpx
import pytest
Expand Down Expand Up @@ -114,9 +115,12 @@ def test_word_search_succeeds(httpx_mock: HTTPXMock):
factories.WordSearchMatchResponseFactory
)()

search_words = {
"words": ",".join(["test", "me"]),
}
# mock the specific endpoints
url = httpx.URL(
f"{aai.settings.base_url}/transcript/{transcript.id}/word-search?words=test",
f"{aai.settings.base_url}/transcript/{transcript.id}/word-search?{urlencode(search_words)}",
)

httpx_mock.add_response(
Expand All @@ -127,7 +131,7 @@ def test_word_search_succeeds(httpx_mock: HTTPXMock):
)

# mimic the SDK call
matches = transcript.word_search(words=["test"])
matches = transcript.word_search(words=["test", "me"])

# check integrity of the response

Expand Down