Skip to content

Commit

Permalink
feat(agents): Implement Serialize and Deserialize for chat messages
Browse files Browse the repository at this point in the history
Persist, retry later, evaluate it completions in a script, you name it.
  • Loading branch information
timonv committed Feb 28, 2025
1 parent 96744a7 commit a754846
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
4 changes: 3 additions & 1 deletion swiftide-core/src/chat_completion/chat_message.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use serde::{Deserialize, Serialize};

use super::tools::{ToolCall, ToolOutput};

#[derive(Clone, strum_macros::EnumIs, PartialEq, Debug)]
#[derive(Clone, strum_macros::EnumIs, PartialEq, Debug, Serialize, Deserialize)]
pub enum ChatMessage {
System(String),
User(String),
Expand Down
5 changes: 3 additions & 2 deletions swiftide-core/src/chat_completion/tools.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use derive_builder::Builder;
use serde::{Deserialize, Serialize};

/// Output of a `ToolCall` which will be added as a message for the agent to use.
#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[non_exhaustive]
pub enum ToolOutput {
/// Adds the result of the toolcall to messages
Expand Down Expand Up @@ -39,7 +40,7 @@ impl std::fmt::Display for ToolOutput {
}

/// A tool call that can be executed by the executor
#[derive(Clone, Debug, Builder, PartialEq)]
#[derive(Clone, Debug, Builder, PartialEq, Serialize, Deserialize)]
#[builder(setter(into, strip_option))]
pub struct ToolCall {
id: String,
Expand Down

0 comments on commit a754846

Please sign in to comment.