async_llm/types/
stop.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
4#[serde(untagged)]
5pub enum Stop {
6    String(String),
7    StringArray(Vec<String>), // minItems: 1; maxItems: 4
8}
9
10impl Default for Stop {
11    fn default() -> Self {
12        Self::String("".into())
13    }
14}
15
16impl From<&str> for Stop {
17    fn from(value: &str) -> Self {
18        Self::String(value.into())
19    }
20}
21
22impl From<Vec<&str>> for Stop {
23    fn from(value: Vec<&str>) -> Self {
24        Self::StringArray(value.iter().map(|v| v.to_string()).collect())
25    }
26}