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

[bug]Unawaited Coroutine Warning in openinference: AsyncAPIResponse.parse #1134

Open
SiyuanQi opened this issue Nov 23, 2024 · 3 comments
Open
Assignees
Labels
bug Something isn't working language: python Related to Python integration

Comments

@SiyuanQi
Copy link

SiyuanQi commented Nov 23, 2024

A RuntimeWarning is raised during the execution of the program, indicating that a coroutine was never awaited. Specifically, the error occurs in the file openinference/instrumentation/openai/_request.py at line 191. The warning message is:
RuntimeWarning: coroutine 'AsyncAPIResponse.parse' was never awaited.

.../lib/python3.12/site-packages/openinference/instrumentation/openai/_request.py:191: RuntimeWarning: coroutine 
'AsyncAPIResponse.parse' was never awaited
  response.parse()
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
.../lib/python3.12/site-packages/openinference/instrumentation/openai/_request.py:250: RuntimeWarning: coroutine 
'AsyncAPIResponse.parse' was never awaited
  _finish_tracing(
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Environment:

  • OS: macOS 14.6.1
  • Version: Python 3.12 (Anaconda environment)
  • openinference-instrumentation 0.1.18
  • openinference-instrumentation-groq 0.1.4
  • openinference-instrumentation-openai 0.1.17
  • openinference-semantic-conventions 0.1.12
@SiyuanQi SiyuanQi added bug Something isn't working triage Issues that require triage labels Nov 23, 2024
@github-project-automation github-project-automation bot moved this to 📘 Todo in phoenix Nov 23, 2024
@dosubot dosubot bot added the language: python Related to Python integration label Nov 23, 2024
@axiomofjoy
Copy link
Contributor

Thanks @SiyuanQi. Do you have a code snippet to reproduce the issue? Or can you let us know which interface you are using when you hit the issue?

@axiomofjoy axiomofjoy added needs information and removed triage Issues that require triage labels Nov 25, 2024
@SiyuanQi
Copy link
Author

SiyuanQi commented Nov 26, 2024

Sure! Below is a code snippet that reproduces the issue:

import os
import dotenv
import asyncio

from openai import AsyncClient

from phoenix.otel import register
from openinference.instrumentation.openai import OpenAIInstrumentor


dotenv.load_dotenv("../.env.local")
tracer_provider = register(
    project_name="openinference-test",
    endpoint=os.getenv("PHOENIX_COLLECTOR_ENDPOINT"),
)
OpenAIInstrumentor().instrument(tracer_provider=tracer_provider)


async def run_tts():
    client = AsyncClient(api_key=os.getenv("OPENAI_API_KEY"))
    async with client.audio.speech.with_streaming_response.create(
        input="Hello",
        model="tts-1",
        voice="alloy",
    ) as audio_stream:
        async for data in audio_stream.iter_bytes():
            pass


if __name__ == "__main__":
    asyncio.run(run_tts())

@axiomofjoy
Copy link
Contributor

Thanks @SiyuanQi, we'll take a look.

@RogerHYang RogerHYang moved this from 📘 Todo to 👨‍💻 In progress in phoenix Dec 4, 2024
@RogerHYang RogerHYang moved this from 👨‍💻 In progress to 📘 Todo in phoenix Dec 5, 2024
@RogerHYang RogerHYang moved this from 📘 Todo to 👨‍💻 In progress in phoenix Dec 12, 2024
@RogerHYang RogerHYang moved this from 👨‍💻 In progress to 📘 Todo in phoenix Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working language: python Related to Python integration
Projects
Status: 📘 Todo
Development

No branches or pull requests

3 participants