mirror of
https://github.com/openai/codex.git
synced 2026-05-03 10:56:37 +00:00
This brings us into better alignment with the JSON schema subset that is supported in <https://developers.openai.com/api/docs/guides/structured-outputs#supported-schemas>, and also allows us to render richer function signatures in code mode (e.g., anyOf{null, OtherObjectType})
50 lines
1.5 KiB
Rust
50 lines
1.5 KiB
Rust
use crate::JsonSchema;
|
|
use crate::ResponsesApiTool;
|
|
use crate::ToolSpec;
|
|
use std::collections::BTreeMap;
|
|
|
|
pub fn create_update_plan_tool() -> ToolSpec {
|
|
let plan_item_properties = BTreeMap::from([
|
|
("step".to_string(), JsonSchema::string(/*description*/ None)),
|
|
(
|
|
"status".to_string(),
|
|
JsonSchema::string(Some("One of: pending, in_progress, completed".to_string())),
|
|
),
|
|
]);
|
|
|
|
let properties = BTreeMap::from([
|
|
(
|
|
"explanation".to_string(),
|
|
JsonSchema::string(/*description*/ None),
|
|
),
|
|
(
|
|
"plan".to_string(),
|
|
JsonSchema::array(
|
|
JsonSchema::object(
|
|
plan_item_properties,
|
|
Some(vec!["step".to_string(), "status".to_string()]),
|
|
Some(false.into()),
|
|
),
|
|
Some("The list of steps".to_string()),
|
|
),
|
|
),
|
|
]);
|
|
|
|
ToolSpec::Function(ResponsesApiTool {
|
|
name: "update_plan".to_string(),
|
|
description: r#"Updates the task plan.
|
|
Provide an optional explanation and a list of plan items, each with a step and status.
|
|
At most one step can be in_progress at a time.
|
|
"#
|
|
.to_string(),
|
|
strict: false,
|
|
defer_loading: None,
|
|
parameters: JsonSchema::object(
|
|
properties,
|
|
Some(vec!["plan".to_string()]),
|
|
Some(false.into()),
|
|
),
|
|
output_schema: None,
|
|
})
|
|
}
|