Issue #315: Display full completion in CLI
- [x] I understand that this repository is auto-generated and my pull request may not be merged
Description
This PR addresses issue #315. The idea is introducing a new --verbose flag to the CLI to display the entire completion response.
Implementation
- Added argument
--verboseto CLI - Added verbose arg to
CLIChatCompletionCreateArgs - Passed
verbose_outputflag to static method_create - If True, dump completion, write to console and return
if verbose_output:
sys.stdout.write(completion.model_dump_json(indent=2))
return
Caveats
Since verbose is not a chat.completions.create argument, we can't pass it to CompletionCreateParams. In my opinion it seems ok to have a flag for now, but I'm sure there's a cleaner way of doing it in the future if new args are introduced that aren't parameters for completions endpoint.
Notes
Do we want this for _stream_create?
Thanks in advance 😀 @RobertCraigie
@backus is this what you were looking for?
Any news on this one?
@gooroodev please review
Thank you, @admsev, for involving me!
1. Summary of Changes
The pull request introduces the following changes:
- Adds a new
--verbose(-v) option to the CLI for chat completions. - When the
--verboseoption is used, the entire completion response is displayed instead of just the content of the completion. - Updates the
CLIChatCompletionCreateArgsclass to include theverboseattribute. - Modifies the
_createmethod inCLIChatCompletionto handle the verbose output.
2. Issues, Bugs, or Typos
Issue 1: Unnecessary Whitespace
In the help string for the --temperature argument, there is an unnecessary newline.
Current Code:
help="""What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer.
Mutually exclusive with `top_p`.""",
Improved Code:
help="""What sampling temperature to use. Higher values means the model will take more risks. Try 0.9 for more creative applications, and 0 (argmax sampling) for ones with a well-defined answer. Mutually exclusive with `top_p`.""",
Issue 2: Import for sys Module
The code uses sys.stdout.write but does not import the sys module.
Improved Code:
import sys
Add this import statement at the beginning of the file.
3. General Review of Code Quality and Style
Code Quality
- The code is generally well-structured and follows good practices.
- The addition of the
--verboseoption is a useful feature that enhances the CLI's functionality. - The use of Pydantic's
BaseModelfor argument parsing is a good practice for type safety and validation.
Code Style
- The code adheres to PEP 8 standards.
- The variable names are descriptive and meaningful.
- The method names and argument names are clear and self-explanatory.
Suggestions for Improvement
- Consider adding unit tests to cover the new
--verbosefunctionality to ensure it works as expected. - Update the documentation to include information about the new
--verboseoption.
Overall, the changes are well-implemented and improve the functionality of the CLI tool. With the minor issues addressed, the pull request should be ready for merging.
Yours, Gooroo.dev. React or reply to this review with your feedback!