agcodex_chatgpt/
get_task.rs1use agcodex_core::config::Config;
2use serde::Deserialize;
3
4use crate::chatgpt_client::chatgpt_get_request;
5
6#[derive(Debug, Deserialize)]
7pub struct GetTaskResponse {
8 pub current_diff_task_turn: Option<AssistantTurn>,
9}
10
11#[derive(Debug, Deserialize)]
13pub struct AssistantTurn {
14 pub output_items: Vec<OutputItem>,
15}
16
17#[derive(Debug, Deserialize)]
18#[serde(tag = "type")]
19pub enum OutputItem {
20 #[serde(rename = "pr")]
21 Pr(PrOutputItem),
22
23 #[serde(other)]
24 Other,
25}
26
27#[derive(Debug, Deserialize)]
28pub struct PrOutputItem {
29 pub output_diff: OutputDiff,
30}
31
32#[derive(Debug, Deserialize)]
33pub struct OutputDiff {
34 pub diff: String,
35}
36
37pub(crate) async fn get_task(config: &Config, task_id: String) -> anyhow::Result<GetTaskResponse> {
38 let path = format!("/wham/tasks/{task_id}");
39 chatgpt_get_request(config, path).await
40}