Fix Python FastAPI middle tier demo for Azure backend#110
Conversation
@microsoft-github-policy-service agree |
|
Please merge 🙏 I am also have these troubles with the Python middle tier |
|
@kingychiu are you maintaining an updated version of the rtclient package? I'd be happy to contribute if so. |
|
@ElliotRoe, If you clone the code from this PR, it should work except the text input issue I mentioned here #111. Because I need both audio and text input, I switched to using OpenAI-python beta realtime api. Init client: Connection: The rest of the websocket logic is mostly similar to this |
Purpose
The original code force people to use Azure CLI to login, this PR add another option (using the API Key generated from Azure Portal)
The client.send_item expects the message to have an id attribute because it expects an Item type, so the current demo will raise an exception when user try to send a text message. Updating to UserMessageItem type has default id=None attribute.
Change the default voice to alloy, because coral voice also trigger a runtime exception.
The import order changes are from ruff linter & format, if you wish I can revert those.
Does this introduce a breaking change?
Pull Request Type
What kind of change does this Pull Request introduce?
How to Test
Other Information
I found another issue (not fixed by this PR): the
RTClient.generate_responseconflicts withRTClient.events, because both will take theresponse.createdevent. As a resultRTClient.generate_responsewill be blocked forever, becauseresponse.createdis removed byRTClient.eventsI am creating another issue for this: #111