mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-10-08 03:10:26 +00:00
Validate completion reasoning effort
This commit is contained in:
parent
df3c834581
commit
673a7064fe
5 changed files with 52 additions and 3 deletions
|
|
@ -8498,7 +8498,7 @@ components:
|
|||
type: string
|
||||
description: Stop sequences.
|
||||
reasoning_effort:
|
||||
type: string
|
||||
$ref: "#/components/schemas/ReasoningEffort"
|
||||
description: Reasoning effort level.
|
||||
provider:
|
||||
type: string
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ async fn create_completion(
|
|||
} else {
|
||||
Some(req.stop_sequences)
|
||||
},
|
||||
reasoning_effort: req.reasoning_effort.as_deref().and_then(|s| s.parse().ok()),
|
||||
reasoning_effort: req.reasoning_effort,
|
||||
speed: None,
|
||||
metadata: None,
|
||||
provider_options: req.provider_options,
|
||||
|
|
|
|||
|
|
@ -15240,6 +15240,27 @@ async fn create_completion_missing_messages_returns_422() {
|
|||
assert_status!(response, StatusCode::UNPROCESSABLE_ENTITY).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn create_completion_invalid_reasoning_effort_returns_422() {
|
||||
let app = test_app_with();
|
||||
|
||||
let req = Request::builder()
|
||||
.method("POST")
|
||||
.uri(api("/completions"))
|
||||
.header("content-type", "application/json")
|
||||
.body(Body::from(
|
||||
serde_json::json!({
|
||||
"messages": [],
|
||||
"reasoning_effort": "bogus"
|
||||
})
|
||||
.to_string(),
|
||||
))
|
||||
.unwrap();
|
||||
|
||||
let response = app.oneshot(req).await.unwrap();
|
||||
assert_status!(response, StatusCode::UNPROCESSABLE_ENTITY).await;
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn create_completion_unknown_provider_returns_clear_error() {
|
||||
let app = test_app_with();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
use fabro_api::types::CreateCompletionRequest;
|
||||
use fabro_model::ReasoningEffort;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn create_completion_request_reuses_canonical_reasoning_effort() {
|
||||
let request: CreateCompletionRequest = serde_json::from_value(json!({
|
||||
"messages": [],
|
||||
"reasoning_effort": "high"
|
||||
}))
|
||||
.unwrap();
|
||||
|
||||
let reasoning_effort: Option<ReasoningEffort> = request.reasoning_effort;
|
||||
assert_eq!(reasoning_effort, Some(ReasoningEffort::High));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn create_completion_request_rejects_unknown_reasoning_effort() {
|
||||
let result = serde_json::from_value::<CreateCompletionRequest>(json!({
|
||||
"messages": [],
|
||||
"reasoning_effort": "bogus"
|
||||
}));
|
||||
|
||||
assert!(result.is_err());
|
||||
}
|
||||
|
|
@ -22,6 +22,9 @@ import type { CompletionToolChoice } from './completion-tool-choice';
|
|||
// May contain unused imports in some cases
|
||||
// @ts-ignore
|
||||
import type { CompletionToolDefinition } from './completion-tool-definition';
|
||||
// May contain unused imports in some cases
|
||||
// @ts-ignore
|
||||
import type { ReasoningEffort } from './reasoning-effort';
|
||||
|
||||
export interface CreateCompletionRequest {
|
||||
/**
|
||||
|
|
@ -56,7 +59,7 @@ export interface CreateCompletionRequest {
|
|||
/**
|
||||
* Reasoning effort level.
|
||||
*/
|
||||
'reasoning_effort'?: string;
|
||||
'reasoning_effort'?: ReasoningEffort;
|
||||
/**
|
||||
* Optional provider pin.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue