Skip to main content

tycode_core/file/
config.rs

1use crate::settings::config::FileModificationApi;
2use schemars::JsonSchema;
3use serde::{Deserialize, Serialize};
4
5fn is_default_file_modification_api(api: &FileModificationApi) -> bool {
6    api == &FileModificationApi::Default
7}
8
9fn default_auto_context_bytes() -> usize {
10    80_000
11}
12
13/// Settings for tools that interact with the file system.
14#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
15pub struct File {
16    /// Controls which tool is used for editing files. Different models work best with
17    /// different tools (or leave default for what we think works best).
18    #[serde(default, skip_serializing_if = "is_default_file_modification_api")]
19    pub file_modification_api: FileModificationApi,
20
21    /// Maximum amount of bytes the file listing can be. Beyond that a directory listing
22    /// is not shown to the model and a warning is shown on every message - this generally
23    /// means that build artifacts are included in the directory listing and a gitignore
24    /// needs to be configured.
25    #[serde(default = "default_auto_context_bytes")]
26    pub auto_context_bytes: usize,
27}
28
29impl File {
30    pub const NAMESPACE: &str = "file";
31}
32
33impl Default for File {
34    fn default() -> Self {
35        Self {
36            file_modification_api: FileModificationApi::Default,
37            auto_context_bytes: default_auto_context_bytes(),
38        }
39    }
40}