Skip to content
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

Propagation of Exceptions from streaming synthesis (text-to-speech) #13391

Closed
1 task done
AKSHILMY opened this issue Dec 27, 2024 · 3 comments
Closed
1 task done

Propagation of Exceptions from streaming synthesis (text-to-speech) #13391

AKSHILMY opened this issue Dec 27, 2024 · 3 comments
Assignees
Labels
type: question Request for information or clarification. Not an issue.

Comments

@AKSHILMY
Copy link

Determine this is the right repository

  • I determined this is the correct repository in which to report this bug.

Summary of the issue

Context
I was trying to use raise an exception if certain condition is met inside the async iterator that I am providing as an argument to the streaming synthesize tts function.

The requirement is to identify that a condition is met in the text yielded by the iterator and stop the streaming synthesis and do some other defined function.

Expected Behavior:
I expected the error to be able to catch from outside, so that I could proceed.

Actual Behavior:
The streaming synthesis doesn't appear to be stopped. I am also unable to catch the exception that I raised.

API client name and version

google-cloud-texttospeech v2.21.1

Reproduction steps: code

async def text_stream(response):
    yield self.config_request
    async for chunk in response:
        chunk_message = chunk.choices[0].delta.content
        if "###" in chunk_message: raise
        else: yield chunk_message
        
streaming_responses = await self.client.streaming_synthesize(text_stream(response))

Reproduction steps: supporting files

No response

Reproduction steps: actual results

No response

Reproduction steps: expected results

No response

OS & version + platform

Ubuntu 22.04

Python environment

Python 3.11.10

Python dependencies

Package Version


aenum 3.1.15
aiohttp 3.8.4
aiosignal 1.3.1
alembic 1.13.1
altair 5.4.1
anyio 3.7.1
APScheduler 3.10.4
asttokens 2.4.1
async-timeout 4.0.3
attrs 24.2.0
babel 2.16.0
bcrypt 4.2.0
beautifulsoup4 4.12.2
blinker 1.6.2
botbuilder-core 4.14.4
botbuilder-schema 4.14.4
botframework-connector 4.14.4
botframework-streaming 4.14.4
boto3 1.26.159
botocore 1.29.165
cachetools 5.5.0
certifi 2024.8.30
cffi 1.17.1
charset-normalizer 3.3.2
click 8.1.7
clickhouse-connect 0.8.6
comm 0.2.2
cryptography 41.0.1
dataclasses-json 0.6.7
debugpy 1.8.6
decorator 5.1.1
Deprecated 1.2.14
distro 1.9.0
docstring_parser 0.16
executing 2.1.0
fastapi 0.106.0
fastjsonschema 2.20.0
frozenlist 1.4.1
gitdb 4.0.11
GitPython 3.1.43
google-api-core 2.20.0
google-api-python-client 2.90.0
google-auth 2.35.0
google-auth-httplib2 0.2.0
google-auth-oauthlib 1.0.0
google-cloud 0.34.0
google-cloud-aiplatform 1.72.0
google-cloud-bigquery 3.26.0
google-cloud-core 2.4.1
google-cloud-resource-manager 1.12.5
google-cloud-speech 2.27.0
google-cloud-storage 2.18.2
google-cloud-texttospeech 2.21.1
google-cloud-translate 3.18.0
google-crc32c 1.6.0
google-resumable-media 2.7.2
googleapis-common-protos 1.65.0
greenlet 3.1.1
grpc-google-iam-v1 0.13.1
grpcio 1.66.1
grpcio-status 1.62.3
grpcio-tools 1.62.3
gunicorn 23.0.0
h11 0.14.0
httpcore 1.0.5
httplib2 0.22.0
httptools 0.6.1
httpx 0.27.2
idna 3.10
importlib-metadata 6.11.0
importlib_resources 6.4.5
ipykernel 6.29.5
ipython 8.27.0
isodate 0.6.1
jedi 0.19.1
Jinja2 3.1.4
jiter 0.8.2
jmespath 1.0.1
jsonpatch 1.33
jsonpickle 1.4.2
jsonpointer 3.0.0
jsonschema 4.23.0
jsonschema-specifications 2023.12.1
jupyter_client 8.6.3
jupyter_core 5.7.2
langchain 0.2.17
langchain-community 0.2.19
langchain-core 0.2.43
langchain-text-splitters 0.2.4
langdetect 1.0.9
langid 1.1.6
langsmith 0.1.129
limits 3.13.0
lxml 5.3.0
lz4 4.3.3
mailjet-rest 1.3.4
Mako 1.3.5
markdown-it-py 3.0.0
MarkupSafe 2.1.5
marshmallow 3.22.0
matplotlib-inline 0.1.7
mdurl 0.1.2
msal 1.28.1
msrest 0.6.21
multidict 6.1.0
mypy-extensions 1.0.0
narwhals 1.8.4
nest-asyncio 1.6.0
numpy 1.26.4
oauthlib 3.2.2
onelogin 3.1.4
openai 1.35.15
orjson 3.10.7
packaging 23.2
pandas 2.2.3
parso 0.8.4
passlib 1.7.4
pexpect 4.9.0
Pillow 9.5.0
pip 24.0
platformdirs 4.3.6
prompt_toolkit 3.0.48
proto-plus 1.24.0
protobuf 4.25.5
psutil 6.0.0
ptyprocess 0.7.0
pure_eval 0.2.3
pyarrow 17.0.0
pyasn1 0.6.1
pyasn1_modules 0.4.1
PyAudio 0.2.14
pycparser 2.22
pydantic 1.10.9
pydeck 0.9.1
pydub 0.25.1
Pygments 2.18.0
PyJWT 2.7.0
Pympler 1.1
PyMySQL 1.0.3
pyparsing 3.1.4
pypdf 5.1.0
python-dateutil 2.9.0.post0
python-dotenv 1.0.1
python-logstash 0.4.8
python-multipart 0.0.6
python3-logstash 0.4.80
python3-saml 1.16.0
pytz 2023.3
pytz-deprecation-shim 0.1.0.post0
PyYAML 6.0.2
pyzmq 26.2.0
referencing 0.35.1
requests 2.31.0
requests-oauthlib 2.0.0
rich 13.8.1
rpds-py 0.20.0
rsa 4.9
s3transfer 0.6.2
setuptools 65.5.0
shapely 2.0.6
six 1.16.0
slack_sdk 3.33.1
slowapi 0.1.9
smmap 5.0.1
sniffio 1.3.1
soupsieve 2.6
SQLAlchemy 2.0.16
SQLAlchemy-Utils 0.41.1
stack-data 0.6.3
starlette 0.27.0
streamlit 1.23.1
streamlit-chat 0.1.1
tenacity 8.5.0
toml 0.10.2
tornado 6.4.1
tqdm 4.66.5
traitlets 5.14.3
typing_extensions 4.12.2
typing-inspect 0.9.0
tzdata 2024.2
tzlocal 4.3.1
unicodecsv 0.14.1
uritemplate 4.1.1
urllib3 1.26.20
uvicorn 0.22.0
uvloop 0.20.0
validators 0.34.0
watchdog 5.0.3
watchfiles 0.24.0
wcwidth 0.2.13
websocket-client 1.8.0
websockets 14.1
Werkzeug 2.3.6
wrapt 1.16.0
xmlsec 1.3.14
yarl 1.13.1
zipp 3.20.2
zstandard 0.23.0

Additional context

No response

@AKSHILMY AKSHILMY added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Dec 27, 2024
@parthea parthea added needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue. and removed triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 2, 2025
@parthea
Copy link
Contributor

parthea commented Jan 2, 2025

Hi @AKSHILMY,

Please could you provide the full sample code to help reproduce the issue?

For example, it's not clear what response is from your code snippet.

async def text_stream(response):
    yield self.config_request
    async for chunk in response:
        chunk_message = chunk.choices[0].delta.content
        if "###" in chunk_message: raise
        else: yield chunk_message
        

@AKSHILMY
Copy link
Author

AKSHILMY commented Jan 3, 2025

# Here _response is an async iterable obtained from the openai chat completions api (stream param set to true). 

async def test():
    async def text_stream():
        yield self.config_request
        async for chunk in _response:
            chunk_message = chunk.choices[0].delta.content
            if "###" in chunk_message: raise
            else: yield chunk_message
    
    streaming_responses = await self.client.streaming_synthesize(text_stream())
            async for response in streaming_responses:
                print(response)
                
                
try:
   await test()
except Exception as e:
       print(e)




Here when I print the exception I want the exception raised in text_stream iterator to be captured, so that I could retry the process

@AKSHILMY AKSHILMY changed the title Propagation of Exceptions from streaming synthesis (test-to-speech) Propagation of Exceptions from streaming synthesis (text-to-speech) Jan 6, 2025
@parthea parthea removed the needs more info This issue needs more information from the customer to proceed. label Jan 21, 2025
@parthea parthea self-assigned this Jan 21, 2025
@parthea parthea added the status: investigating The issue is under investigation, which is determined to be non-trivial. label Jan 21, 2025
@parthea
Copy link
Contributor

parthea commented Jan 21, 2025

As indicated in #13391 (comment), _response is an async iterable obtained from the openai chat completions api, and this is where you're not seeing the raised exception. Please file an issue in the openai chat completions api issue tracker instead.

@parthea parthea closed this as completed Jan 21, 2025
@parthea parthea removed the status: investigating The issue is under investigation, which is determined to be non-trivial. label Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

2 participants