objectiveai_cli/command/
python.rs1use objectiveai_sdk::cli::command::python::{Request, Response};
11
12use crate::context::Context;
13use crate::error::Error;
14
15pub async fn execute(ctx: &Context, request: Request) -> Result<Response, Error> {
16 let ctx = ctx.with_no_objectiveai(request.no_objectiveai.unwrap_or(false));
18 let output: Option<serde_json::Value> = ctx
19 .python()
20 .await?
21 .exec_code(&ctx, &request.code, request.input)
22 .await?;
23 Ok(output.unwrap_or(serde_json::Value::Null))
24}
25
26pub mod request_schema {
27 use objectiveai_sdk::cli::command::python as sdk;
28 use objectiveai_sdk::cli::command::python::request_schema::{Request, Response};
29
30 use crate::context::Context;
31 use crate::error::Error;
32
33 pub async fn execute(_ctx: &Context, _request: Request) -> Result<Response, Error> {
34 Ok(objectiveai_sdk::cli::command::ResponseSchema(schemars::schema_for!(sdk::Request)))
35 }
36}
37
38pub mod response_schema {
39 use objectiveai_sdk::cli::command::python as sdk;
40 use objectiveai_sdk::cli::command::python::response_schema::{Request, Response};
41
42 use crate::context::Context;
43 use crate::error::Error;
44
45 pub async fn execute(_ctx: &Context, _request: Request) -> Result<Response, Error> {
46 Ok(objectiveai_sdk::cli::command::ResponseSchema(schemars::schema_for!(sdk::Response)))
47 }
48}