pub enum Action {
Read {
path: String,
lines: Lines,
},
List {
path: String,
depth: Option<i64>,
},
Search {
pattern: String,
path: String,
glob: Option<String>,
ignore_case: bool,
},
Edit {
path: String,
old_text: String,
new_text: String,
},
Run {
command: String,
},
}Expand description
One action the model asked for.
Variants§
Read
Read a text file, all of it or one range of lines.
Fields
List
List a folder; an empty path or . is the root.
Fields
Search
Find a piece of text in the files under a folder.
Fields
Edit
Replace one exact piece of text in a file, or create a new file.
Fields
Run
Run a shell command in the workspace root.
Implementations§
Source§impl Action
impl Action
Sourcepub fn definitions() -> Value
pub fn definitions() -> Value
The five tools in Anthropic tool-use form: the JSON array for the request’s tools field,
each with a name, a description and an input_schema. It is the model’s manual, so
every optional field carries a short example of a call that uses it.
Sourcepub fn from_call(name: &str, input: &Value) -> Result<Self, String>
pub fn from_call(name: &str, input: &Value) -> Result<Self, String>
Reads a tool call. An unknown tool or a bad input gives a sentence for the model.
§Errors
When name is not one of the five tools, or input is not an object with the fields the
tool needs: text as a string, a line or a depth as a whole number, a flag as true or
false. Whether a range fits the file it names is left to the action, which reads the file.
Sourcepub fn needs_approval(&self) -> bool
pub fn needs_approval(&self) -> bool
Whether the person must approve the action first: editing and running do, reading does not.
Sourcepub fn kind(&self) -> ActionKind
pub fn kind(&self) -> ActionKind
Which action this is.
Sourcepub fn subject(&self) -> &str
pub fn subject(&self) -> &str
What the action is about: the path for reading, listing and editing, the pattern for a search and the command for running. The new fields narrow an action; they are not what the action is about, so the person’s line stays the same.
Sourcepub fn summary(&self) -> String
pub fn summary(&self) -> String
One short untranslated line for the transcript, such as read src/main.rs or
run cargo test. An application that translates builds its own line from Self::kind
and Self::subject.
Trait Implementations§
impl Eq for Action
impl StructuralPartialEq for Action
Auto Trait Implementations§
impl Freeze for Action
impl RefUnwindSafe for Action
impl Send for Action
impl Sync for Action
impl Unpin for Action
impl UnsafeUnpin for Action
impl UnwindSafe for Action
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more