-
Notifications
You must be signed in to change notification settings - Fork 2k
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
refactor: Migrate RemoteWhisperTranscriber
to OpenAI SDK.
#6149
refactor: Migrate RemoteWhisperTranscriber
to OpenAI SDK.
#6149
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking quite good! I left a few suggestions, overall I believe it's soon ready for merge 🚀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thank you for your contribution 🤗
@awinml looks ok to me. Before I approve, aside from unit tests, have you played with the component, e.g. in a small demo? |
@ZanSara and @vblagoje , Thank you for your feedback! I did some digging on how the OpenAI SDK handles the file send to the These were some of the findings:
For reference, please have a look at: https://github.com/openai/openai-python/blob/main/openai/api_resources/audio.py#L61 I reworked the implementation to create a I created a simple demo highlighting these findings and showcasing an example using this component. |
@awinml thanks for these elaborate explanations. They are excellent! I'm wondering, can't we try to resolve file_path from metadata, but if it is not there, we just put a random name to satisfy the requirement of that value not being None? |
@ZanSara perhaps we should store |
@vblagoje We can do that. As far as I checked, the API does extract the file format from the name. We could just set it to something like I added an example to the notebook above, testing the API with a random name, which has a different file format as compared to the input file. It worked perfectly fine. |
for stream in streams: | ||
try: | ||
file = io.BytesIO(stream.data) | ||
file.name = stream.metadata["file_path"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@awinml yes, let's do a check here if stream.metadata["file_path"] is present. If it is, use it. If not, just use a random name, e.g. audio_input
, perhaps an extension is not even needed. Please check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried the API without using an extension, it does not allow that. I updated the example notebook with a test.
I think, we can use audio_input.wav
as the name if stream.metadata["file_path"]
is not present. Should we also log a warning if we do this?
Something like this:
for stream in streams:
file = io.BytesIO(stream.data)
try:
file.name = stream.metadata["file_path"]
except KeyError as e:
file.name = "audio_input.wav"
warning_msg = """Did not find 'file_path', setting 'file_name' to 'audio_input.wav'."""
logger.warning(warning_msg, e)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, I will push the changes without the warning then.
@awinml yes, let's do that small change and we can later decide to add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's 🚢 Thanks for this awesome contribution @awinml
Hi @awinml, thank you for your contribution to Haystack! Now that you resolved an issue labeled with 'hacktoberfest', you have a chance to receive an exclusive swag package from Haystack. 🎁 Fill in this form, and let us know if you have any questions! https://forms.gle/226vqWoN6NRAaqJ69 |
Related Issues
api_key
from serialization ofAzureOCRDocumentConverter
,SerperDevWebSearch
,RemoteWhisperTranscriber
2.0 #6116Proposed Changes:
Migrate
RemoteWhisperTranscriber
to use the OpenAI SDK.How did you test it?
Added Unit and Integration Tests.
Notes for the reviewer
response_format
parameter.response_format
parameter. We can add support for the other options in a future PR if required.Checklist
fix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
.