Skip to content

Commit 98602af

Browse files
authored
Topics cli (#113)
Allows you to view status, poke the machine, and update config
1 parent 3970185 commit 98602af

10 files changed

Lines changed: 5072 additions & 0 deletions

File tree

src/http.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,30 @@ impl ApiClient {
103103
response.json().await.context("failed to parse response")
104104
}
105105

106+
pub async fn patch<T: DeserializeOwned, B: Serialize>(
107+
&self,
108+
path: &str,
109+
body: &B,
110+
) -> Result<T> {
111+
let url = self.url(path);
112+
let response = self
113+
.http
114+
.patch(&url)
115+
.bearer_auth(&self.api_key)
116+
.json(body)
117+
.send()
118+
.await
119+
.context("request failed")?;
120+
121+
if !response.status().is_success() {
122+
let status = response.status();
123+
let body = response.text().await.unwrap_or_default();
124+
return Err(HttpError { status, body }.into());
125+
}
126+
127+
response.json().await.context("failed to parse response")
128+
}
129+
106130
pub async fn post_with_headers<T, B>(
107131
&self,
108132
path: &str,

src/main.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ mod status;
2626
mod switch;
2727
mod sync;
2828
mod tools;
29+
mod topics;
2930
mod traces;
3031
mod ui;
3132
mod util_cmd;
@@ -59,6 +60,7 @@ Core
5960
6061
Projects & resources
6162
projects Manage projects
63+
topics Inspect and control Topics automation
6264
prompts Manage prompts
6365
functions Manage functions (tools, scorers, and more)
6466
tools Manage tools
@@ -128,6 +130,8 @@ enum Commands {
128130
Eval(CLIArgs<eval::EvalArgs>),
129131
/// Manage projects
130132
Projects(CLIArgs<projects::ProjectsArgs>),
133+
/// Inspect and control Topics automation
134+
Topics(CLIArgs<topics::TopicsArgs>),
131135
/// Manage prompts
132136
Prompts(CLIArgs<prompts::PromptsArgs>),
133137
#[command(name = "self")]
@@ -165,6 +169,7 @@ impl Commands {
165169
#[cfg(unix)]
166170
Commands::Eval(cmd) => &cmd.base,
167171
Commands::Projects(cmd) => &cmd.base,
172+
Commands::Topics(cmd) => &cmd.base,
168173
Commands::Prompts(cmd) => &cmd.base,
169174
Commands::SelfCommand(cmd) => &cmd.base,
170175
Commands::Tools(cmd) => &cmd.base,
@@ -189,6 +194,7 @@ impl Commands {
189194
#[cfg(unix)]
190195
Commands::Eval(cmd) => &mut cmd.base,
191196
Commands::Projects(cmd) => &mut cmd.base,
197+
Commands::Topics(cmd) => &mut cmd.base,
192198
Commands::Prompts(cmd) => &mut cmd.base,
193199
Commands::SelfCommand(cmd) => &mut cmd.base,
194200
Commands::Tools(cmd) => &mut cmd.base,
@@ -245,6 +251,7 @@ async fn try_main() -> Result<()> {
245251
#[cfg(unix)]
246252
Commands::Eval(cmd) => eval::run(cmd.base, cmd.args).await?,
247253
Commands::Projects(cmd) => projects::run(cmd.base, cmd.args).await?,
254+
Commands::Topics(cmd) => topics::run(cmd.base, cmd.args).await?,
248255
Commands::Prompts(cmd) => prompts::run(cmd.base, cmd.args).await?,
249256
Commands::Tools(cmd) => tools::run(cmd.base, cmd.args).await?,
250257
Commands::Scorers(cmd) => scorers::run(cmd.base, cmd.args).await?,

0 commit comments

Comments
 (0)