Documentation
¶
Overview ¶
Example ¶
client := NewClient("http://xe-flux.flycast")
if _, err := client.HealthCheck(); err != nil {
fmt.Println("Error health checking:", err)
panic(err)
}
// Example of using the Predict method
predictionReq := PredictionRequest{
Input: Input{
Prompt: "A beautiful sunrise over the mountains",
NumOutputs: 1,
GuidanceScale: 7.5,
MaxSequenceLength: 256,
NumInferenceSteps: 50,
PromptStrength: 0.8,
OutputFormat: "png",
OutputQuality: 90,
},
ID: "example-prediction-id",
CreatedAt: time.Now().Format(time.RFC3339),
OutputFilePrefix: "output",
Webhook: "http://example.com/webhook",
WebhookEventsFilter: []string{"start", "completed"},
}
predictionResp, err := client.Predict(predictionReq)
if err != nil {
fmt.Println("Error predicting:", err)
} else {
fmt.Println("PredictionResponse:", predictionResp)
}
// Example of using the PredictIdempotent method
predictionResp, err = client.PredictIdempotent("example-prediction-id", predictionReq)
if err != nil {
fmt.Println("Error predicting idempotent:", err)
} else {
fmt.Println("PredictIdempotentResponse:", predictionResp)
}
// Example of using the CancelPrediction method
resp, err := client.CancelPrediction("example-prediction-id")
if err != nil {
fmt.Println("Error cancelling prediction:", err)
} else {
body, _ := ioutil.ReadAll(resp.Body)
fmt.Println("CancelPrediction response:", string(body))
resp.Body.Close()
}
Index ¶
- type Client
- func (c *Client) CancelPrediction(predictionID string) (*http.Response, error)
- func (c *Client) HealthCheck() (*HealthCheckResponse, error)
- func (c *Client) Predict(predictionReq PredictionRequest) (*PredictionResponse, error)
- func (c *Client) PredictIdempotent(predictionID string, predictionReq PredictionRequest) (*PredictionResponse, error)
- type HTTPValidationError
- type HealthCheckResponse
- type Input
- type Output
- type PredictionRequest
- type PredictionResponse
- type ValidationError
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
func (*Client) CancelPrediction ¶
func (*Client) HealthCheck ¶
func (c *Client) HealthCheck() (*HealthCheckResponse, error)
HealthCheck checks the health of the service
func (*Client) Predict ¶
func (c *Client) Predict(predictionReq PredictionRequest) (*PredictionResponse, error)
func (*Client) PredictIdempotent ¶
func (c *Client) PredictIdempotent(predictionID string, predictionReq PredictionRequest) (*PredictionResponse, error)
type HTTPValidationError ¶
type HTTPValidationError struct {
Detail []ValidationError `json:"detail"`
}
type HealthCheckResponse ¶
type HealthCheckResponse struct {
Status string `json:"status"`
}
HealthCheckResponse represents the response structure for the health check endpoint.
type Input ¶
type Input struct {
Prompt string `json:"prompt"`
Image string `json:"image,omitempty"`
AspectRatio string `json:"aspect_ratio,omitempty"`
NumOutputs int `json:"num_outputs"`
GuidanceScale float64 `json:"guidance_scale"`
MaxSequenceLength int `json:"max_sequence_length"`
NumInferenceSteps int `json:"num_inference_steps"`
PromptStrength float64 `json:"prompt_strength"`
Seed *int `json:"seed,omitempty"`
OutputFormat string `json:"output_format"`
OutputQuality int `json:"output_quality"`
}
type PredictionRequest ¶
type PredictionRequest struct {
Input Input `json:"input"`
ID string `json:"id,omitempty"`
CreatedAt string `json:"created_at,omitempty"`
OutputFilePrefix string `json:"output_file_prefix,omitempty"`
Webhook string `json:"webhook,omitempty"`
WebhookEventsFilter []string `json:"webhook_events_filter,omitempty"`
}
type PredictionResponse ¶
type PredictionResponse struct {
Input Input `json:"input"`
Output Output `json:"output"`
ID string `json:"id"`
Version string `json:"version"`
CreatedAt string `json:"created_at"`
StartedAt string `json:"started_at"`
CompletedAt string `json:"completed_at"`
Logs string `json:"logs"`
Error string `json:"error"`
Status string `json:"status"`
Metrics map[string]interface{} `json:"metrics"`
}
type ValidationError ¶
Click to show internal directories.
Click to hide internal directories.