Skip to content

Conversation

@LifeJiggy
Copy link

Summary

This PR adds a comprehensive CLI tool for basic Gradient SDK operations, providing developers with an easy command-line interface for testing and automation.

Problem

Developers need a quick way to interact with Gradient SDK from the command line for testing, debugging, and automation purposes. The current SDK only provides programmatic access.

Solution

Add a full-featured CLI tool (bin/gradient-cli) with the following commands:

Core Commands

  • models - List available models (table/JSON formats, export support)
  • chat - Chat completion with streaming support
  • agents - List agents with export functionality
  • image - Generate images with export options
  • paginate - Demonstrate pagination across models

Features

  • Environment variable support for all API keys
  • JSON export functionality for responses
  • Streaming chat completion
  • Comprehensive error handling
  • Help system and usage documentation

Testing

  • Added comprehensive test suite (tests/test_cli_tool.py) covering:
  • CLI initialization and client setup
  • All command functionality with mocked responses
  • Error handling and edge cases

All tests pass successfully

Benefits

  • 0 Quick Testing: Rapid API testing without writing code
  • Automation: Perfect for scripts and CI/CD pipelines
  • Debugging: Easy inspection of API responses
  • Learning: Great for understanding SDK capabilities
  • Production Ready: Proper error handling and logging

This significantly improves the developer experience by providing immediate access to Gradient SDK functionality from the command line.

Examples

# List models
gradient-cli models --format json

# Chat completion
gradient-cli chat "Hello, how are you?" --stream

# List agents with export
gradient-cli agents --export agents.json

# Generate image
gradient-cli image "A beautiful sunset" --export response.json

# Demonstrate pagination
gradient-cli paginate --max-pages 3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant