providers-kit 0.0.2

Portable enum-dispatch Kit over multiple model provider APIs.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
use serde_json::Value;

use crate::KitError;
use crate::generation::ResponseFormat;

pub(crate) fn response_format_to_ollama(
    format: Option<&ResponseFormat>,
) -> Result<Option<Value>, KitError> {
    match format {
        None | Some(ResponseFormat::Text) => Ok(None),
        Some(ResponseFormat::JsonObject) => Ok(Some(Value::String("json".to_owned()))),
        Some(ResponseFormat::JsonSchema(schema)) => Ok(Some(schema.schema().clone())),
    }
}