feat: finish implementation of decisions -> system one

This commit is contained in:
2026-10-10 19:23:40 -04:00
parent e0e1f0781e
commit 154cbac120

View File

@@ -79,28 +79,88 @@ pub async fn create_decision(
openai::decisions::DecisionInputContent::Parts(decision_input_parts) => { openai::decisions::DecisionInputContent::Parts(decision_input_parts) => {
for decision_input_part in decision_input_parts { for decision_input_part in decision_input_parts {
match decision_input_part { match decision_input_part {
openai::decisions::DecisionInputPart::Image { image_url, detail } => images.push(image_url), openai::decisions::DecisionInputPart::Image {
openai::decisions::DecisionInputPart::Text { text } => texts.push(text), image_url,
detail,
} => images.push(image_url),
openai::decisions::DecisionInputPart::Text { text } => {
texts.push(text)
}
} }
} }
}, }
} }
}; }
let text = texts.join("\n\n"); let text = texts.join("\n\n");
let files = images.clone(); let files = images.clone();
(openai::system_one::State::Text(text), Some(images), Some(files)) (
openai::system_one::State::Text(text),
Some(images),
Some(files),
)
}
openai::decisions::DecisionInput::Text(text) => {
(openai::system_one::State::Text(text), None, None)
} }
openai::decisions::DecisionInput::Text(text) => (openai::system_one::State::Text(text), None, None),
}; };
let questions = questions.into_iter().map(|question| match question { let questions = questions
openai::decisions::DecisionQuestion::Predicate(predicate_question) => todo!(), .into_iter()
openai::decisions::DecisionQuestion::Choice(choice_question) => todo!(), .map(|question| match question {
openai::decisions::DecisionQuestion::Score(score_question) => todo!(), openai::decisions::DecisionQuestion::Predicate(
} ).collect(); openai::decisions::PredicateQuestion { name, instructions },
) => (
name.expect("TODO"),
openai::system_one::Question::Noul(openai::system_one::NoulQuestion {
instructions: openai::system_one::QuestionInstructions::Text(instructions),
criteria: None,
}),
),
openai::decisions::DecisionQuestion::Choice(openai::decisions::ChoiceQuestion {
name,
instructions,
choices,
}) => (
name.expect("TODO"),
openai::system_one::Question::Choice(openai::system_one::ChoiceQuestion {
instructions: openai::system_one::QuestionInstructions::Text(instructions),
criteria: choices
.into_iter()
.map(|openai::decisions::ChoiceOption { value, description }| {
(
match value {
openai::decisions::Choice::String(s) => s,
openai::decisions::Choice::Boolean(b) => b.to_string(),
},
description.map(|description| {
openai::system_one::QuestionInstructions::Text(description)
}),
)
})
.collect(),
}),
),
openai::decisions::DecisionQuestion::Score(openai::decisions::ScoreQuestion {
name,
instructions,
levels,
}) => (
name.expect("TODO"),
openai::system_one::Question::Score(openai::system_one::ScoreQuestion {
instructions: openai::system_one::QuestionInstructions::Text(instructions),
criteria: levels
.into_iter()
.map(|openai::decisions::ScoreLevel { label, description }| {
openai::system_one::QuestionInstructions::Text(label)
})
.collect(),
}),
),
})
.collect();
let request = openai::system_one::SystemOneRequest { let request = openai::system_one::SystemOneRequest {
model, model,