Function chat_flame_backend::api::routes::generate_text::generate_text_handler
source · pub async fn generate_text_handler(
app_state: State<AppState>,
__arg1: Json<GenerateRequest>
) -> impl IntoResponse
Expand description
Asynchronous handler for generating text.
This function handles POST requests to the /generate
endpoint. It takes a JSON payload
representing a GenerateRequest
and uses the configuration and parameters specified to
generate text. The generated text is returned in a GenerateResponse
if successful.
Parameters
config
: Application state holding the global configuration.Json(payload)
: JSON payload containing the input text and generation parameters.
Responses
200 OK
: Successful text generation withGenerateResponse
.422 Unprocessable Entity
: Input validation error withErrorResponse
.424 Failed Dependency
: Generation error withErrorResponse
.429 Too Many Requests
: Model is overloaded withErrorResponse
.500 Internal Server Error
: Incomplete generation withErrorResponse
.
Usage
This endpoint is suitable for generating text based on given prompts and parameters. It can be used in scenarios where batch text generation is required, such as content creation, language modeling, or any application needing on-demand text generation.