Skip to content

Commit

Permalink
fix(commands): Stop spinner after response and other fixes
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
cloudbridgeuy committed Aug 15, 2023
1 parent a51dd2d commit ead3a24
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
8 changes: 5 additions & 3 deletions crates/c/src/commands/anthropic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct Chunk {
#[serde(rename_all = "kebab-case")]
pub enum Model {
#[default]
#[serde(rename = "claude-2")]
Claude2,
ClaudeV1,
ClaudeV1_100k,
Expand Down Expand Up @@ -335,6 +336,9 @@ pub async fn run(mut options: CommandOptions) -> Result<()> {
} else {
let response = complete(&session).await?;

// Stop the spinner.
spinner.stop();

// Print the response output.
print_output(&session.meta.format, &response)?;

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

// Stop the spinner.
spinner.stop();

Ok(())
}

Expand All @@ -362,6 +363,7 @@ pub fn complete_prompt(
max_tokens_to_sample: u32,
) -> Result<String> {
let max = max_supported_tokens - max_tokens_to_sample;

messages.push(Message::new("".to_string(), Role::Assistant, false));

tracing::event!(
Expand Down
6 changes: 3 additions & 3 deletions crates/c/src/commands/openai.rs
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,9 @@ pub async fn run(mut options: CommandOptions) -> Result<()> {
} else {
let response = complete(&session).await?;

// Stop the spinner.
spinner.stop();

// Print the response output.
print_output(&session.meta.format, &response)?;

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

// Stop the spinner.
spinner.stop();

Ok(())
}

Expand Down
18 changes: 9 additions & 9 deletions crates/c/src/commands/vertex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,12 +159,12 @@ pub struct Candidate {
#[derive(Debug, Serialize, Deserialize, Default, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Citation {
start_index: u32,
end_index: u32,
url: String,
title: String,
license: String,
publication_date: String,
start_index: Option<u32>,
end_index: Option<u32>,
url: Option<String>,
title: Option<String>,
license: Option<String>,
publication_date: Option<String>,
}

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

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

// Stop the spinner.
spinner.stop();

// Print the response output.
print_output(&session.meta.format, &response)?;

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

// Stop the spinner.
spinner.stop();

Ok(())
}

Expand Down

0 comments on commit ead3a24

Please sign in to comment.