Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ all = { level = "warn", priority = -1 }
assigning_clones = "allow"
enum_glob_use = "allow"
format_push_string = "allow"
inefficient_to_string = "allow"
missing_errors_doc = "allow" # Temporary
option_option = "allow"
pedantic = { level = "warn", priority = -1 }
Expand Down
1 change: 1 addition & 0 deletions crates/jp_cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ comrak = { workspace = true }
crossterm = { workspace = true }
duct = { workspace = true }
futures = { workspace = true }
indexmap = { workspace = true }
inquire = { workspace = true, features = ["crossterm"] }
minijinja = { workspace = true }
path-clean = { workspace = true }
Expand Down
14 changes: 10 additions & 4 deletions crates/jp_cli/src/cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,14 @@ impl IntoPartialAppConfig for Commands {
&self,
workspace: Option<&Workspace>,
partial: PartialAppConfig,
merged_config: Option<&PartialAppConfig>,
) -> Result<PartialAppConfig, Box<dyn std::error::Error + Send + Sync>> {
match self {
Commands::Query(args) => args.apply_cli_config(workspace, partial),
Commands::Attachment(args) => args.apply_cli_config(workspace, partial),
Commands::AttachmentAdd(args) => args.apply_cli_config(workspace, partial),
Commands::Query(args) => args.apply_cli_config(workspace, partial, merged_config),
Commands::Attachment(args) => args.apply_cli_config(workspace, partial, merged_config),
Commands::AttachmentAdd(args) => {
args.apply_cli_config(workspace, partial, merged_config)
}
_ => Ok(partial),
}
}
Expand All @@ -81,9 +84,12 @@ impl IntoPartialAppConfig for Commands {
&self,
workspace: Option<&Workspace>,
partial: PartialAppConfig,
merged_config: Option<&PartialAppConfig>,
) -> Result<PartialAppConfig, Box<dyn std::error::Error + Send + Sync>> {
match self {
Commands::Query(args) => args.apply_conversation_config(workspace, partial),
Commands::Query(args) => {
args.apply_conversation_config(workspace, partial, merged_config)
}
_ => Ok(partial),
}
}
Expand Down
5 changes: 3 additions & 2 deletions crates/jp_cli/src/cmd/attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,11 @@ impl IntoPartialAppConfig for Attachment {
&self,
workspace: Option<&Workspace>,
partial: PartialAppConfig,
merged_config: Option<&PartialAppConfig>,
) -> std::result::Result<PartialAppConfig, Box<dyn std::error::Error + Send + Sync>> {
match &self.command {
Commands::Add(args) => args.apply_cli_config(workspace, partial),
Commands::Remove(args) => args.apply_cli_config(workspace, partial),
Commands::Add(args) => args.apply_cli_config(workspace, partial, merged_config),
Commands::Remove(args) => args.apply_cli_config(workspace, partial, merged_config),
Commands::List(_) => Ok(partial),
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/jp_cli/src/cmd/attachment/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ impl IntoPartialAppConfig for Add {
&self,
_: Option<&Workspace>,
mut partial: PartialAppConfig,
_: Option<&PartialAppConfig>,
) -> std::result::Result<PartialAppConfig, Box<dyn std::error::Error + Send + Sync>> {
for uri in &self.attachments {
validate_attachment(uri)?;
Expand Down
1 change: 1 addition & 0 deletions crates/jp_cli/src/cmd/attachment/rm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ impl IntoPartialAppConfig for Rm {
&self,
_: Option<&Workspace>,
mut partial: PartialAppConfig,
_: Option<&PartialAppConfig>,
) -> std::result::Result<PartialAppConfig, Box<dyn std::error::Error + Send + Sync>> {
partial
.conversation
Expand Down
10 changes: 4 additions & 6 deletions crates/jp_cli/src/cmd/config/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use jp_config::{
};

use super::TargetWithConversation;
use crate::{ctx::Ctx, Error, Output};
use crate::{ctx::Ctx, Output};

#[derive(Debug, clap::Args)]
pub(crate) struct Set {
Expand Down Expand Up @@ -45,11 +45,9 @@ impl Set {
None => ctx.workspace.active_conversation_id(),
};

ctx.workspace
.get_conversation_mut(&id)
.ok_or(Error::NotFound("Conversation", id.to_string()))?
.config_mut()
.assign(assignment)?;
let mut config = ctx.workspace.get_messages(&id).config();
config.assign(assignment)?;
ctx.workspace.set_conversation_config(&id, config)?;

return Ok(format!(
"Set configuration value for {} in conversation {id:?}",
Expand Down
6 changes: 3 additions & 3 deletions crates/jp_cli/src/cmd/conversation/edit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crossterm::style::Stylize as _;
use jp_config::AppConfig;
use jp_conversation::{ConversationId, MessagePair};
use jp_conversation::{message::Messages, ConversationId};
use jp_llm::{provider, structured};

use crate::{cmd::Success, ctx::Ctx, Output};
Expand Down Expand Up @@ -34,7 +34,7 @@ impl Edit {
pub(crate) async fn run(self, ctx: &mut Ctx) -> Output {
let active_id = ctx.workspace.active_conversation_id();
let id = self.id.unwrap_or(active_id);
let messages = ctx.workspace.get_messages(&id).to_vec();
let messages = ctx.workspace.get_messages(&id).to_messages();

if let Some(user) = self.local {
match ctx.workspace.get_conversation_mut(&id) {
Expand Down Expand Up @@ -70,7 +70,7 @@ fn missing_conversation(id: &ConversationId) -> Output {

async fn generate_titles(
config: &AppConfig,
messages: Vec<MessagePair>,
messages: Messages,
mut rejected: Vec<String>,
) -> Result<String, Box<dyn std::error::Error + Send + Sync>> {
let count = 3;
Expand Down
2 changes: 1 addition & 1 deletion crates/jp_cli/src/cmd/conversation/rm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ impl Rm {
};
let messages = ctx.workspace.get_messages(&id);
let local = conversation.user;
let mut details = DetailsFmt::new(id, conversation, messages)
let mut details = DetailsFmt::new(id, conversation, &messages)
.with_local_flag(local)
.with_active_conversation(active_id)
.with_hyperlinks(ctx.term.args.hyperlinks)
Expand Down
2 changes: 1 addition & 1 deletion crates/jp_cli/src/cmd/conversation/show.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl Show {
};
let messages = ctx.workspace.get_messages(&id);
let user = conversation.user;
let details = DetailsFmt::new(id, conversation, messages)
let details = DetailsFmt::new(id, conversation, &messages)
.with_local_flag(user)
.with_active_conversation(active_id)
.with_hyperlinks(ctx.term.args.hyperlinks)
Expand Down
1 change: 1 addition & 0 deletions crates/jp_cli/src/cmd/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ impl IntoPartialAppConfig for Init {
&self,
_workspace: Option<&Workspace>,
partial: PartialAppConfig,
_: Option<&PartialAppConfig>,
) -> std::result::Result<PartialAppConfig, Box<dyn std::error::Error + Send + Sync>> {
Ok(partial)
}
Expand Down
Loading