Skip to content

Commit ead3a24

Browse files
committed
fix(commands): Stop spinner after response and other fixes
- anthropic, openai, and vertex commands now stop the spinner after receiving the response - Added #[serde(rename = "claude-2")] attribute to Model::Claude2 - Citation fields are now optional
1 parent a51dd2d commit ead3a24

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

crates/c/src/commands/anthropic.rs

+5-3
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ pub struct Chunk {
2323
#[serde(rename_all = "kebab-case")]
2424
pub enum Model {
2525
#[default]
26+
#[serde(rename = "claude-2")]
2627
Claude2,
2728
ClaudeV1,
2829
ClaudeV1_100k,
@@ -335,6 +336,9 @@ pub async fn run(mut options: CommandOptions) -> Result<()> {
335336
} else {
336337
let response = complete(&session).await?;
337338

339+
// Stop the spinner.
340+
spinner.stop();
341+
338342
// Print the response output.
339343
print_output(&session.meta.format, &response)?;
340344

@@ -349,9 +353,6 @@ pub async fn run(mut options: CommandOptions) -> Result<()> {
349353
// Save the session to a file.
350354
session.save()?;
351355

352-
// Stop the spinner.
353-
spinner.stop();
354-
355356
Ok(())
356357
}
357358

@@ -362,6 +363,7 @@ pub fn complete_prompt(
362363
max_tokens_to_sample: u32,
363364
) -> Result<String> {
364365
let max = max_supported_tokens - max_tokens_to_sample;
366+
365367
messages.push(Message::new("".to_string(), Role::Assistant, false));
366368

367369
tracing::event!(

crates/c/src/commands/openai.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,9 @@ pub async fn run(mut options: CommandOptions) -> Result<()> {
509509
} else {
510510
let response = complete(&session).await?;
511511

512+
// Stop the spinner.
513+
spinner.stop();
514+
512515
// Print the response output.
513516
print_output(&session.meta.format, &response)?;
514517

@@ -523,9 +526,6 @@ pub async fn run(mut options: CommandOptions) -> Result<()> {
523526
// Save the session to a file.
524527
session.save()?;
525528

526-
// Stop the spinner.
527-
spinner.stop();
528-
529529
Ok(())
530530
}
531531

crates/c/src/commands/vertex.rs

+9-9
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ pub struct Candidate {
159159
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
160160
#[serde(rename_all = "camelCase")]
161161
pub struct Citation {
162-
start_index: u32,
163-
end_index: u32,
164-
url: String,
165-
title: String,
166-
license: String,
167-
publication_date: String,
162+
start_index: Option<u32>,
163+
end_index: Option<u32>,
164+
url: Option<String>,
165+
title: Option<String>,
166+
license: Option<String>,
167+
publication_date: Option<String>,
168168
}
169169

170170
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
@@ -401,6 +401,9 @@ pub async fn run(mut options: CommandOptions) -> Result<()> {
401401

402402
let response = complete(&session).await?;
403403

404+
// Stop the spinner.
405+
spinner.stop();
406+
404407
// Print the response output.
405408
print_output(&session.meta.format, &response)?;
406409

@@ -422,9 +425,6 @@ pub async fn run(mut options: CommandOptions) -> Result<()> {
422425
// Save the session to a file.
423426
session.save()?;
424427

425-
// Stop the spinner.
426-
spinner.stop();
427-
428428
Ok(())
429429
}
430430

0 commit comments

Comments
 (0)