-
Notifications
You must be signed in to change notification settings - Fork 2.5k
[docs] Add Google-style docstrings for dspy/adapters/types/audio.py Audio class #9086 #9101
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
base: main
Are you sure you want to change the base?
Conversation
chenmoneygithub
left a comment
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.
Thanks for the PR! This looks pretty good, dropped some comments.
| """A type for representing audio data in DSPy. | ||
| The Audio class provides a standardized way to handle audio inputs for language models | ||
| that support audio processing. Audio data is stored as base64-encoded strings along |
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.
"stored" reads a bit strange, do you mean represented?
| data: Base64-encoded audio data. | ||
| audio_format: The audio format (e.g., "wav", "mp3", "flac"). | ||
| Example: |
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.
For multiple examples, use one-line format like "Example: Basic usage with a local file"
| audio-enabled language models. | ||
| Raises: | ||
| ValueError: If the audio data cannot be formatted. |
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.
You can remove this Raises part. Actually the code is strange, which raises exception when self.data is empty.
| """Format the audio data for consumption by language models. | ||
| Returns: | ||
| A list containing the audio block in the format expected by |
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.
This is vague, we can write the format explicitly.
| Args: | ||
| audio: The audio input. Supported types include: | ||
| - ``str``: Local file path, HTTP(S) URL, or data URI |
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.
nit: use single backtick
resolve #9086
Summary
This PR adds comprehensive Google-style docstrings to the Audio class in
dspy/adapters/types/audio.py, covering 6 public APIs.Changes
format()- Formats audio data for LM consumptionfrom_url()- Creates Audio from URLfrom_file()- Creates Audio from file pathfrom_array()- Creates Audio from numpy arrayencode_audio()- Encodes audio from various sourcesChecklist
Testing
@chenmoneygithub - Ready for review!