Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
407bb022d9 | ||
|
|
faf92cac09 | ||
|
|
a82e9a1d1f | ||
|
|
8f87f05a08 |
36
.pre-commit-config.yaml
Normal file
36
.pre-commit-config.yaml
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
repos:
|
||||||
|
# Fast built-in hooks (Rust-native, no dependencies)
|
||||||
|
- repo: builtin
|
||||||
|
hooks:
|
||||||
|
- id: trailing-whitespace
|
||||||
|
- id: end-of-file-fixer
|
||||||
|
- id: check-yaml
|
||||||
|
- id: check-merge-conflict
|
||||||
|
- id: check-added-large-files
|
||||||
|
args: ['--maxkb=1024']
|
||||||
|
|
||||||
|
# Local hooks that run project-specific tools
|
||||||
|
- repo: local
|
||||||
|
hooks:
|
||||||
|
- id: cargo-fmt-check
|
||||||
|
name: Cargo Format Check
|
||||||
|
entry: cargo fmt --all -- --check
|
||||||
|
language: system
|
||||||
|
files: '\.rs$'
|
||||||
|
pass_filenames: false
|
||||||
|
|
||||||
|
- id: cargo-clippy
|
||||||
|
name: Cargo Clippy
|
||||||
|
entry: cargo clippy -- -D warnings
|
||||||
|
language: system
|
||||||
|
files: '\.rs$'
|
||||||
|
pass_filenames: false
|
||||||
|
priority: 100
|
||||||
|
|
||||||
|
- id: test-unit
|
||||||
|
name: Unit Tests
|
||||||
|
entry: just test
|
||||||
|
language: system
|
||||||
|
files: '\.rs$'
|
||||||
|
pass_filenames: false
|
||||||
|
priority: 100
|
||||||
11
CHANGELOG.md
11
CHANGELOG.md
@@ -1,3 +1,14 @@
|
|||||||
|
# (2026-02-10) Version 1.14.1
|
||||||
|
|
||||||
|
- (**Security**) Dependency updates to fix security vulnerabilities ([time](https://crates.io/crates/time) stack exhaustion DoS, [bytes](https://crates.io/crates/bytes) integer overflow), via [mxlink](https://crates.io/crates/mxlink) 1.12.0
|
||||||
|
|
||||||
|
- (**Internal Improvement**) Switch from deprecated [serde_yaml](https://crates.io/crates/serde_yaml) to its maintained fork [serde_yaml_ng](https://crates.io/crates/serde_yaml_ng)
|
||||||
|
|
||||||
|
- (**Internal Improvement**) Add [prek](https://github.com/nicholasgasior/prek) pre-commit hooks via [mise](https://mise.jdx.dev/) for automated code quality checks (formatting, clippy, tests)
|
||||||
|
|
||||||
|
- (**Internal Improvement**) Fix clippy warnings and formatting issues
|
||||||
|
|
||||||
|
|
||||||
# (2026-02-04) Version 1.14.0
|
# (2026-02-04) Version 1.14.0
|
||||||
|
|
||||||
- (**Feature**) The `openai` provider now uses OpenAI's [Responses API](https://platform.openai.com/docs/api-reference/responses) (instead of the older Chat Completions API), adding support for [🛠️ built-in tools](./docs/features.md#️-built-in-tools-openai-only) (`web_search` and `code_interpreter`). These tools are **disabled by default** and can be enabled via the `text_generation.tools` configuration (see the [sample configuration](https://github.com/etkecc/baibot/blob/c70387b0c38d8d0f30bba2179a2a21a3710dbeaf/docs/sample-provider-configs/openai.yml#L12-L15)). To enable tools on an existing agent, you need to [update the agent](./docs/agents.md#updating-agents) to re-create it with the `text_generation.tools` section added and enable the tools you need. Thanks to [Layla Manley](https://github.com/yeslayla) for the contribution in [#62](https://github.com/etkecc/baibot/pull/62)!
|
- (**Feature**) The `openai` provider now uses OpenAI's [Responses API](https://platform.openai.com/docs/api-reference/responses) (instead of the older Chat Completions API), adding support for [🛠️ built-in tools](./docs/features.md#️-built-in-tools-openai-only) (`web_search` and `code_interpreter`). These tools are **disabled by default** and can be enabled via the `text_generation.tools` configuration (see the [sample configuration](https://github.com/etkecc/baibot/blob/c70387b0c38d8d0f30bba2179a2a21a3710dbeaf/docs/sample-provider-configs/openai.yml#L12-L15)). To enable tools on an existing agent, you need to [update the agent](./docs/agents.md#updating-agents) to re-create it with the `text_generation.tools` section added and enable the tools you need. Thanks to [Layla Manley](https://github.com/yeslayla) for the contribution in [#62](https://github.com/etkecc/baibot/pull/62)!
|
||||||
|
|||||||
296
Cargo.lock
generated
296
Cargo.lock
generated
@@ -38,7 +38,7 @@ checksum = "b169f7a6d4742236a0a00c541b845991d0ac43e546831af1249753ab4c3aa3a0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"cipher",
|
"cipher",
|
||||||
"cpufeatures",
|
"cpufeatures 0.2.17",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -95,9 +95,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anyhow"
|
name = "anyhow"
|
||||||
version = "1.0.100"
|
version = "1.0.101"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a23eb6b1614318a8071c9b2521f36b424b2c83db5eb3a0fead4a6c0809af6e61"
|
checksum = "5f0e0fee31ef5ed1ba1316088939cea399010ed7731dba877ed44aeb407a75ea"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anymap2"
|
name = "anymap2"
|
||||||
@@ -166,9 +166,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "async-compression"
|
name = "async-compression"
|
||||||
version = "0.4.37"
|
version = "0.4.39"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d10e4f991a553474232bc0a31799f6d24b034a84c0971d80d2e2f78b2e576e40"
|
checksum = "68650b7df54f0293fd061972a0fb05aaf4fc0879d3b3d21a638a182c5c543b9f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"compression-codecs",
|
"compression-codecs",
|
||||||
"compression-core",
|
"compression-core",
|
||||||
@@ -288,7 +288,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "baibot"
|
name = "baibot"
|
||||||
version = "1.14.0"
|
version = "1.14.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anthropic",
|
"anthropic",
|
||||||
"anyhow",
|
"anyhow",
|
||||||
@@ -304,7 +304,7 @@ dependencies = [
|
|||||||
"regex",
|
"regex",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_yaml",
|
"serde_yaml_ng",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
"tiktoken-rs",
|
"tiktoken-rs",
|
||||||
"tokio",
|
"tokio",
|
||||||
@@ -384,7 +384,7 @@ dependencies = [
|
|||||||
"cc",
|
"cc",
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"constant_time_eq",
|
"constant_time_eq",
|
||||||
"cpufeatures",
|
"cpufeatures 0.2.17",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -488,7 +488,18 @@ checksum = "c3613f74bd2eac03dad61bd53dbe620703d4371614fe0bc3b9f04dd36fe4e818"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"cipher",
|
"cipher",
|
||||||
"cpufeatures",
|
"cpufeatures 0.2.17",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "chacha20"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "6f8d983286843e49675a4b7a2d174efe136dc93a18d69130dd18198a6c167601"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"cpufeatures 0.3.0",
|
||||||
|
"rand_core 0.10.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -498,7 +509,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35"
|
checksum = "10cd79432192d1c0f4e1a0fef9527696cc039165d729fb41b3f4f4f354c2dc35"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"aead",
|
"aead",
|
||||||
"chacha20",
|
"chacha20 0.9.1",
|
||||||
"cipher",
|
"cipher",
|
||||||
"poly1305",
|
"poly1305",
|
||||||
"zeroize",
|
"zeroize",
|
||||||
@@ -625,6 +636,15 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cpufeatures"
|
||||||
|
version = "0.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "8b2a41393f66f16b0823bb79094d54ac5fbd34ab292ddafb9a0456ac9f87d201"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "crc32fast"
|
name = "crc32fast"
|
||||||
version = "1.5.0"
|
version = "1.5.0"
|
||||||
@@ -667,7 +687,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be"
|
checksum = "97fb8b7c4503de7d6ae7b42ab72a5a59857b4c937ec27a3d4539dba95b5ab2be"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"cpufeatures",
|
"cpufeatures 0.2.17",
|
||||||
"curve25519-dalek-derive",
|
"curve25519-dalek-derive",
|
||||||
"digest",
|
"digest",
|
||||||
"fiat-crypto",
|
"fiat-crypto",
|
||||||
@@ -1344,6 +1364,20 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "139ef39800118c7683f2fd3c98c1b23c09ae076556b435f8e9064ae108aaeeec"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"r-efi",
|
||||||
|
"rand_core 0.10.0",
|
||||||
|
"wasip2",
|
||||||
|
"wasip3",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gloo-timers"
|
name = "gloo-timers"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
@@ -1467,6 +1501,12 @@ dependencies = [
|
|||||||
"http 1.4.0",
|
"http 1.4.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "heck"
|
||||||
|
version = "0.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
@@ -1805,6 +1845,12 @@ dependencies = [
|
|||||||
"zerovec",
|
"zerovec",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "id-arena"
|
||||||
|
version = "2.3.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3d3067d79b975e8844ca9eb072e16b31c3c1c36928edf9c6789548c524d0d954"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ident_case"
|
name = "ident_case"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
@@ -2018,10 +2064,16 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "leb128fmt"
|
||||||
version = "0.2.180"
|
version = "0.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "bcc35a38544a891a5f7c865aca548a982ccb3b8650a5b06d0fd33a10283c56fc"
|
checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.181"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "459427e2af2b9c839b132acb702a1c654d95e10f8c326bfc2ad11310e458b1c5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libsqlite3-sys"
|
name = "libsqlite3-sys"
|
||||||
@@ -2451,9 +2503,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.7.6"
|
version = "2.8.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273"
|
checksum = "f8ca58f447f06ed17d5fc4043ce1b10dd205e060fb3ce5b979b8ed8e59ff3f79"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mime"
|
name = "mime"
|
||||||
@@ -2515,9 +2567,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mxlink"
|
name = "mxlink"
|
||||||
version = "1.11.0"
|
version = "1.12.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f5f917fdf8eed1fe7085255be92bdd045df070bb69886190808e8ce2d74f4c0a"
|
checksum = "e5bf83148b4188a9d62a265642c36360af262006413634222c2706bc52e38ccb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64 0.22.1",
|
"base64 0.22.1",
|
||||||
"chacha20poly1305",
|
"chacha20poly1305",
|
||||||
@@ -2525,7 +2577,7 @@ dependencies = [
|
|||||||
"matrix-sdk",
|
"matrix-sdk",
|
||||||
"mime",
|
"mime",
|
||||||
"quick_cache",
|
"quick_cache",
|
||||||
"rand 0.9.2",
|
"rand 0.10.0",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"thiserror 2.0.18",
|
"thiserror 2.0.18",
|
||||||
@@ -2805,7 +2857,7 @@ version = "0.8.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf"
|
checksum = "8159bd90725d2df49889a078b54f4f79e87f1f8a8444194cdca81d38f5393abf"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cpufeatures",
|
"cpufeatures 0.2.17",
|
||||||
"opaque-debug",
|
"opaque-debug",
|
||||||
"universal-hash",
|
"universal-hash",
|
||||||
]
|
]
|
||||||
@@ -2840,6 +2892,16 @@ version = "0.1.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
|
checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "prettyplease"
|
||||||
|
version = "0.2.37"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "479ca8adacdd7ce8f1fb39ce9ecccbfe93a3f1344b3d0d97f20bc0196208f62b"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"syn 2.0.114",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro-crate"
|
name = "proc-macro-crate"
|
||||||
version = "3.4.0"
|
version = "3.4.0"
|
||||||
@@ -3023,6 +3085,17 @@ dependencies = [
|
|||||||
"rand_core 0.9.5",
|
"rand_core 0.9.5",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bc266eb313df6c5c09c1c7b1fbe2510961e5bcd3add930c1e31f7ed9da0feff8"
|
||||||
|
dependencies = [
|
||||||
|
"chacha20 0.10.0",
|
||||||
|
"getrandom 0.4.1",
|
||||||
|
"rand_core 0.10.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand_chacha"
|
name = "rand_chacha"
|
||||||
version = "0.3.1"
|
version = "0.3.1"
|
||||||
@@ -3061,6 +3134,12 @@ dependencies = [
|
|||||||
"getrandom 0.3.4",
|
"getrandom 0.3.4",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.10.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0c8d0fd677905edcbeedbf2edb6494d676f0e98d54d5cf9bda0b061cb8fb8aba"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand_xoshiro"
|
name = "rand_xoshiro"
|
||||||
version = "0.7.0"
|
version = "0.7.0"
|
||||||
@@ -3072,15 +3151,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "readlock"
|
name = "readlock"
|
||||||
version = "0.1.10"
|
version = "0.1.11"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6961798ceb493ecff2e50d3d9a6a9108124ee8298f81484d0ff623b6c32469e9"
|
checksum = "6da6f291b23556edd9edaf655a0be2ad8ef8002ff5f1bca62b264f3f58b53f34"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "readlock-tokio"
|
name = "readlock-tokio"
|
||||||
version = "0.1.5"
|
version = "0.1.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5f78bdff9b59a104cb171ceecc310c25e60ca02d7a95895afff559edd711fa1b"
|
checksum = "fc7e264f9ec4f3d112e8e2f214e8e7cb5cf3b83278f3570b7e00bfe13d3bd8ff"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"tokio",
|
"tokio",
|
||||||
]
|
]
|
||||||
@@ -3611,9 +3690,9 @@ checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.22"
|
version = "1.0.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a50f4cf475b65d88e057964e0e9bb1f0aa9bbb2036dc65c64596b42932536984"
|
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "schannel"
|
name = "schannel"
|
||||||
@@ -3813,10 +3892,10 @@ dependencies = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_yaml"
|
name = "serde_yaml_ng"
|
||||||
version = "0.9.34+deprecated"
|
version = "0.10.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6a8b1a1a2ebf674015cc02edccce75287f1a0130d394307b36743c2f5d504b47"
|
checksum = "7b4db627b98b36d4203a7b458cf3573730f2bb591b28871d916dfa9efabfd41f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itoa",
|
"itoa",
|
||||||
@@ -3832,7 +3911,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
|
checksum = "e3bf829a2d51ab4a5ddf1352d8470c140cadc8301b2ae1789db023f01cedd6ba"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"cpufeatures",
|
"cpufeatures 0.2.17",
|
||||||
"digest",
|
"digest",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -3843,7 +3922,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
|
checksum = "a7507d819769d01a365ab707794a4084392c824f54a7a6a7862f8c3d0892b283"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if",
|
"cfg-if",
|
||||||
"cpufeatures",
|
"cpufeatures 0.2.17",
|
||||||
"digest",
|
"digest",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -4048,12 +4127,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tempfile"
|
name = "tempfile"
|
||||||
version = "3.24.0"
|
version = "3.25.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "655da9c7eb6305c55742045d5a8d2037996d61d8de95806335c7c86ce0f82e9c"
|
checksum = "0136791f7c95b1f6dd99f9cc786b91bb81c3800b639b3478e561ddb7be95e5f1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"fastrand",
|
"fastrand",
|
||||||
"getrandom 0.3.4",
|
"getrandom 0.4.1",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"rustix",
|
"rustix",
|
||||||
"windows-sys 0.61.2",
|
"windows-sys 0.61.2",
|
||||||
@@ -4136,9 +4215,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.3.46"
|
version = "0.3.47"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9da98b7d9b7dad93488a84b8248efc35352b0b2657397d4167e7ad67e5d535e5"
|
checksum = "743bd48c283afc0388f9b8827b976905fb217ad9e647fae3a379a9283c4def2c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"deranged",
|
"deranged",
|
||||||
"itoa",
|
"itoa",
|
||||||
@@ -4157,9 +4236,9 @@ checksum = "7694e1cfe791f8d31026952abf09c69ca6f6fa4e1a1229e18988f06a04a12dca"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time-macros"
|
name = "time-macros"
|
||||||
version = "0.2.26"
|
version = "0.2.27"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "78cc610bac2dcee56805c99642447d4c5dbde4d01f752ffea0199aee1f601dc4"
|
checksum = "2e70e4c5a0e0a8a4823ad65dfe1a6930e4f4d756dcd9dd7939022b5e8c501215"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-conv",
|
"num-conv",
|
||||||
"time-core",
|
"time-core",
|
||||||
@@ -4470,9 +4549,9 @@ checksum = "dbc4bc3a9f746d862c45cb89d705aa10f187bb96c76001afab07a0d35ce60142"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.22"
|
version = "1.0.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9312f7c4f6ff9069b165498234ce8be658059c6728633667c526e27dc2cf1df5"
|
checksum = "537dd038a89878be9b64dd4bd1b260315c1bb94f4d784956b81e27a088d9a09e"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-normalization"
|
name = "unicode-normalization"
|
||||||
@@ -4644,6 +4723,15 @@ dependencies = [
|
|||||||
"wit-bindgen",
|
"wit-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasip3"
|
||||||
|
version = "0.4.0+wasi-0.3.0-rc-2026-01-06"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5428f8bf88ea5ddc08faddef2ac4a67e390b88186c703ce6dbd955e1c145aca5"
|
||||||
|
dependencies = [
|
||||||
|
"wit-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-bindgen"
|
name = "wasm-bindgen"
|
||||||
version = "0.2.108"
|
version = "0.2.108"
|
||||||
@@ -4703,6 +4791,28 @@ dependencies = [
|
|||||||
"unicode-ident",
|
"unicode-ident",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-encoder"
|
||||||
|
version = "0.244.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "990065f2fe63003fe337b932cfb5e3b80e0b4d0f5ff650e6985b1048f62c8319"
|
||||||
|
dependencies = [
|
||||||
|
"leb128fmt",
|
||||||
|
"wasmparser",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasm-metadata"
|
||||||
|
version = "0.244.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "bb0e353e6a2fbdc176932bbaab493762eb1255a7900fe0fea1a2f96c296cc909"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"indexmap",
|
||||||
|
"wasm-encoder",
|
||||||
|
"wasmparser",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "wasm-streams"
|
name = "wasm-streams"
|
||||||
version = "0.4.2"
|
version = "0.4.2"
|
||||||
@@ -4734,6 +4844,18 @@ dependencies = [
|
|||||||
"web-sys",
|
"web-sys",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasmparser"
|
||||||
|
version = "0.244.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "47b807c72e1bac69382b3a6fb3dbe8ea4c0ed87ff5629b8685ae6b9a611028fe"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags 2.10.0",
|
||||||
|
"hashbrown 0.15.5",
|
||||||
|
"indexmap",
|
||||||
|
"semver",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "web-sys"
|
name = "web-sys"
|
||||||
version = "0.3.85"
|
version = "0.3.85"
|
||||||
@@ -5096,6 +5218,88 @@ name = "wit-bindgen"
|
|||||||
version = "0.51.0"
|
version = "0.51.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
|
checksum = "d7249219f66ced02969388cf2bb044a09756a083d0fab1e566056b04d9fbcaa5"
|
||||||
|
dependencies = [
|
||||||
|
"wit-bindgen-rust-macro",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wit-bindgen-core"
|
||||||
|
version = "0.51.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ea61de684c3ea68cb082b7a88508a8b27fcc8b797d738bfc99a82facf1d752dc"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"heck",
|
||||||
|
"wit-parser",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wit-bindgen-rust"
|
||||||
|
version = "0.51.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b7c566e0f4b284dd6561c786d9cb0142da491f46a9fbed79ea69cdad5db17f21"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"heck",
|
||||||
|
"indexmap",
|
||||||
|
"prettyplease",
|
||||||
|
"syn 2.0.114",
|
||||||
|
"wasm-metadata",
|
||||||
|
"wit-bindgen-core",
|
||||||
|
"wit-component",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wit-bindgen-rust-macro"
|
||||||
|
version = "0.51.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "0c0f9bfd77e6a48eccf51359e3ae77140a7f50b1e2ebfe62422d8afdaffab17a"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"prettyplease",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.114",
|
||||||
|
"wit-bindgen-core",
|
||||||
|
"wit-bindgen-rust",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wit-component"
|
||||||
|
version = "0.244.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9d66ea20e9553b30172b5e831994e35fbde2d165325bec84fc43dbf6f4eb9cb2"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"bitflags 2.10.0",
|
||||||
|
"indexmap",
|
||||||
|
"log",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
"serde_json",
|
||||||
|
"wasm-encoder",
|
||||||
|
"wasm-metadata",
|
||||||
|
"wasmparser",
|
||||||
|
"wit-parser",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wit-parser"
|
||||||
|
version = "0.244.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ecc8ac4bc1dc3381b7f59c34f00b67e18f910c2c0f50015669dde7def656a736"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"id-arena",
|
||||||
|
"indexmap",
|
||||||
|
"log",
|
||||||
|
"semver",
|
||||||
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
|
"serde_json",
|
||||||
|
"unicode-xid",
|
||||||
|
"wasmparser",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "writeable"
|
name = "writeable"
|
||||||
@@ -5146,18 +5350,18 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy"
|
name = "zerocopy"
|
||||||
version = "0.8.38"
|
version = "0.8.39"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "57cf3aa6855b23711ee9852dfc97dfaa51c45feaba5b645d0c777414d494a961"
|
checksum = "db6d35d663eadb6c932438e763b262fe1a70987f9ae936e60158176d710cae4a"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"zerocopy-derive",
|
"zerocopy-derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zerocopy-derive"
|
name = "zerocopy-derive"
|
||||||
version = "0.8.38"
|
version = "0.8.39"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a616990af1a287837c4fe6596ad77ef57948f787e46ce28e166facc0cc1cb75"
|
checksum = "4122cd3169e94605190e77839c9a40d40ed048d305bfdc146e7df40ab0f3e517"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -5240,6 +5444,6 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "zmij"
|
name = "zmij"
|
||||||
version = "1.0.19"
|
version = "1.0.20"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3ff05f8caa9038894637571ae6b9e29466c1f4f829d26c9b28f869a29cbe3445"
|
checksum = "4de98dfa5d5b7fef4ee834d0073d560c9ca7b6c46a71d058c48db7960f8cfaf7"
|
||||||
|
|||||||
10
Cargo.toml
10
Cargo.toml
@@ -7,7 +7,7 @@ license = "AGPL-3.0-or-later"
|
|||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
keywords = ["matrix", "chat", "bot", "AI", "LLM"]
|
keywords = ["matrix", "chat", "bot", "AI", "LLM"]
|
||||||
include = ["/etc/assets/baibot-torso-768.png", "/src", "/README.md", "/CHANGELOG.md", "/LICENSE"]
|
include = ["/etc/assets/baibot-torso-768.png", "/src", "/README.md", "/CHANGELOG.md", "/LICENSE"]
|
||||||
version = "1.14.0"
|
version = "1.14.1"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[lib]
|
[lib]
|
||||||
@@ -17,7 +17,7 @@ path = "src/lib.rs"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anthropic = { git = "https://github.com/etkecc/anthropic-rs.git", branch = "fix-content-block-image" }
|
anthropic = { git = "https://github.com/etkecc/anthropic-rs.git", branch = "fix-content-block-image" }
|
||||||
anyhow = "1.0.*"
|
anyhow = "1.0.*"
|
||||||
async-openai = { version = "0.32.3", features = ["audio", "chat-completion", "image", "responses"] }
|
async-openai = { version = "0.32.4", features = ["audio", "chat-completion", "image", "responses"] }
|
||||||
base64 = "0.22.*"
|
base64 = "0.22.*"
|
||||||
chrono = { version = "0.4.*", default-features = false, features = ["std", "now"] }
|
chrono = { version = "0.4.*", default-features = false, features = ["std", "now"] }
|
||||||
# We'd rather not depend on this, but we cannot use the ruma-events EventContent macro without it.
|
# We'd rather not depend on this, but we cannot use the ruma-events EventContent macro without it.
|
||||||
@@ -25,14 +25,14 @@ chrono = { version = "0.4.*", default-features = false, features = ["std", "now"
|
|||||||
matrix-sdk = { version = "0.16.0", default-features = false, features = ["native-tls"] }
|
matrix-sdk = { version = "0.16.0", default-features = false, features = ["native-tls"] }
|
||||||
mime_guess = "2.0.*"
|
mime_guess = "2.0.*"
|
||||||
mxidwc = "1.0.*"
|
mxidwc = "1.0.*"
|
||||||
mxlink = ">=1.11.0"
|
mxlink = ">=1.12.0"
|
||||||
etke_openai_api_rust = "0.1.*"
|
etke_openai_api_rust = "0.1.*"
|
||||||
quick_cache = "0.6.*"
|
quick_cache = "0.6.*"
|
||||||
regex = "1.12.*"
|
regex = "1.12.*"
|
||||||
serde = { version = "1.0.*", features = ["derive"], default-features = false }
|
serde = { version = "1.0.*", features = ["derive"], default-features = false }
|
||||||
serde_json = "1.0.*"
|
serde_json = "1.0.*"
|
||||||
serde_yaml = "0.9.*"
|
serde_yaml_ng = "0.10.*"
|
||||||
tempfile = "3.24.*"
|
tempfile = "3.25.*"
|
||||||
tiktoken-rs = { version = "0.9.*", default-features = false }
|
tiktoken-rs = { version = "0.9.*", default-features = false }
|
||||||
tokio = { version = "1.49.*", features = ["rt", "rt-multi-thread", "macros"] }
|
tokio = { version = "1.49.*", features = ["rt", "rt-multi-thread", "macros"] }
|
||||||
tracing = "0.1.*"
|
tracing = "0.1.*"
|
||||||
|
|||||||
42
justfile
42
justfile
@@ -2,6 +2,9 @@ project_name := "baibot"
|
|||||||
container_image_name := "localhost/baibot"
|
container_image_name := "localhost/baibot"
|
||||||
project_container_network := "baibot"
|
project_container_network := "baibot"
|
||||||
|
|
||||||
|
mise_data_dir := env("MISE_DATA_DIR", justfile_directory() / "var/mise")
|
||||||
|
mise_trusted_config_paths := justfile_directory() / "mise.toml"
|
||||||
|
|
||||||
# Show help by default
|
# Show help by default
|
||||||
default:
|
default:
|
||||||
@just --list --justfile {{ justfile() }}
|
@just --list --justfile {{ justfile() }}
|
||||||
@@ -159,6 +162,44 @@ synapse-register-regular-user username password: services-prepare
|
|||||||
clippy *extra_args:
|
clippy *extra_args:
|
||||||
cargo clippy {{ extra_args }}
|
cargo clippy {{ extra_args }}
|
||||||
|
|
||||||
|
# Checks that the code compiles without building
|
||||||
|
check:
|
||||||
|
cargo check
|
||||||
|
|
||||||
|
# Invokes mise with the project-local data directory
|
||||||
|
mise *args: _ensure_mise_data_directory
|
||||||
|
#!/bin/sh
|
||||||
|
export MISE_DATA_DIR="{{ mise_data_dir }}"
|
||||||
|
export MISE_TRUSTED_CONFIG_PATHS="{{ mise_trusted_config_paths }}"
|
||||||
|
mise {{ args }}
|
||||||
|
|
||||||
|
# Runs prek (pre-commit hooks manager) with the given arguments
|
||||||
|
prek *args: _ensure_mise_tools_installed
|
||||||
|
@just --justfile {{ justfile() }} mise exec -- prek {{ args }}
|
||||||
|
|
||||||
|
# Runs pre-commit hooks on staged files
|
||||||
|
prek-run-on-staged *args: _ensure_mise_tools_installed
|
||||||
|
@just --justfile {{ justfile() }} mise exec -- prek run {{ args }}
|
||||||
|
|
||||||
|
# Runs pre-commit hooks on all files
|
||||||
|
prek-run-on-all *args: _ensure_mise_tools_installed
|
||||||
|
@just --justfile {{ justfile() }} mise exec -- prek run --all-files {{ args }}
|
||||||
|
|
||||||
|
# Installs the git pre-commit hook (runs prek automatically before each commit)
|
||||||
|
prek-install-git-pre-commit-hook: _ensure_mise_tools_installed
|
||||||
|
@just --justfile {{ justfile() }} mise exec -- prek install
|
||||||
|
|
||||||
|
# Internal - ensures var/mise directory exists
|
||||||
|
_ensure_mise_data_directory:
|
||||||
|
#!/bin/sh
|
||||||
|
if [ ! -d "{{ mise_data_dir }}" ]; then
|
||||||
|
mkdir -p "{{ mise_data_dir }}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Internal - ensures mise tools are installed
|
||||||
|
_ensure_mise_tools_installed: _ensure_mise_data_directory
|
||||||
|
@just --justfile {{ justfile() }} mise install --quiet
|
||||||
|
|
||||||
_prepare-var-services-env:
|
_prepare-var-services-env:
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
cd {{ justfile_directory() }};
|
cd {{ justfile_directory() }};
|
||||||
@@ -248,4 +289,3 @@ _prepare-var-app-container-data:
|
|||||||
if [ ! -f var/app/container/data ]; then
|
if [ ! -f var/app/container/data ]; then
|
||||||
mkdir -p var/app/container/data
|
mkdir -p var/app/container/data
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
6
mise.toml
Normal file
6
mise.toml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
[tools]
|
||||||
|
prek = "0.3.2"
|
||||||
|
|
||||||
|
[settings]
|
||||||
|
# Disable automatic trust prompts - we trust this config
|
||||||
|
yes = true
|
||||||
@@ -33,11 +33,11 @@ pub struct AgentDefinition {
|
|||||||
)]
|
)]
|
||||||
pub provider: AgentProvider,
|
pub provider: AgentProvider,
|
||||||
|
|
||||||
pub config: serde_yaml::Value,
|
pub config: serde_yaml_ng::Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AgentDefinition {
|
impl AgentDefinition {
|
||||||
pub fn new(id: String, provider: AgentProvider, config: serde_yaml::Value) -> Self {
|
pub fn new(id: String, provider: AgentProvider, config: serde_yaml_ng::Value) -> Self {
|
||||||
Self {
|
Self {
|
||||||
id,
|
id,
|
||||||
provider,
|
provider,
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ pub enum Error {
|
|||||||
// Contains the error from the constructor function
|
// Contains the error from the constructor function
|
||||||
ConstructionFailed(anyhow::Error),
|
ConstructionFailed(anyhow::Error),
|
||||||
// Contains the error from the YAML deserialization function
|
// Contains the error from the YAML deserialization function
|
||||||
Yaml(serde_yaml::Error),
|
Yaml(serde_yaml_ng::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, Error>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
@@ -69,7 +69,7 @@ pub(super) fn create(
|
|||||||
pub fn create_from_provider_and_yaml_value_config(
|
pub fn create_from_provider_and_yaml_value_config(
|
||||||
provider: &AgentProvider,
|
provider: &AgentProvider,
|
||||||
identifier: &PublicIdentifier,
|
identifier: &PublicIdentifier,
|
||||||
config: serde_yaml::Value,
|
config: serde_yaml_ng::Value,
|
||||||
) -> Result<AgentInstance> {
|
) -> Result<AgentInstance> {
|
||||||
let definition = AgentDefinition::new(identifier.prefixless(), provider.to_owned(), config);
|
let definition = AgentDefinition::new(identifier.prefixless(), provider.to_owned(), config);
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ pub fn create_from_provider_and_yaml_value_config(
|
|||||||
fn create_controller_from_provider_and_json_value_config(
|
fn create_controller_from_provider_and_json_value_config(
|
||||||
agent_id: &str,
|
agent_id: &str,
|
||||||
provider: &AgentProvider,
|
provider: &AgentProvider,
|
||||||
config: serde_yaml::Value,
|
config: serde_yaml_ng::Value,
|
||||||
) -> Result<ControllerType> {
|
) -> Result<ControllerType> {
|
||||||
match provider {
|
match provider {
|
||||||
AgentProvider::Anthropic => {
|
AgentProvider::Anthropic => {
|
||||||
@@ -112,43 +112,43 @@ fn create_controller_from_provider_and_json_value_config(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn default_config_for_provider(provider: &AgentProvider) -> serde_yaml::Value {
|
pub fn default_config_for_provider(provider: &AgentProvider) -> serde_yaml_ng::Value {
|
||||||
match provider {
|
match provider {
|
||||||
AgentProvider::Anthropic => {
|
AgentProvider::Anthropic => {
|
||||||
let config = super::provider::anthropic::default_config();
|
let config = super::provider::anthropic::default_config();
|
||||||
serde_yaml::to_value(config).expect("Failed to serialize config")
|
serde_yaml_ng::to_value(config).expect("Failed to serialize config")
|
||||||
}
|
}
|
||||||
AgentProvider::Groq => {
|
AgentProvider::Groq => {
|
||||||
let config = super::provider::groq::default_config();
|
let config = super::provider::groq::default_config();
|
||||||
serde_yaml::to_value(config).expect("Failed to serialize config")
|
serde_yaml_ng::to_value(config).expect("Failed to serialize config")
|
||||||
}
|
}
|
||||||
AgentProvider::LocalAI => {
|
AgentProvider::LocalAI => {
|
||||||
let config = super::provider::localai::default_config();
|
let config = super::provider::localai::default_config();
|
||||||
serde_yaml::to_value(config).expect("Failed to serialize config")
|
serde_yaml_ng::to_value(config).expect("Failed to serialize config")
|
||||||
}
|
}
|
||||||
AgentProvider::Mistral => {
|
AgentProvider::Mistral => {
|
||||||
let config = super::provider::mistral::default_config();
|
let config = super::provider::mistral::default_config();
|
||||||
serde_yaml::to_value(config).expect("Failed to serialize config")
|
serde_yaml_ng::to_value(config).expect("Failed to serialize config")
|
||||||
}
|
}
|
||||||
AgentProvider::Ollama => {
|
AgentProvider::Ollama => {
|
||||||
let config = super::provider::ollama::default_config();
|
let config = super::provider::ollama::default_config();
|
||||||
serde_yaml::to_value(config).expect("Failed to serialize config")
|
serde_yaml_ng::to_value(config).expect("Failed to serialize config")
|
||||||
}
|
}
|
||||||
AgentProvider::OpenAI => {
|
AgentProvider::OpenAI => {
|
||||||
let config = super::provider::openai::default_config();
|
let config = super::provider::openai::default_config();
|
||||||
serde_yaml::to_value(config).expect("Failed to serialize config")
|
serde_yaml_ng::to_value(config).expect("Failed to serialize config")
|
||||||
}
|
}
|
||||||
AgentProvider::OpenAICompat => {
|
AgentProvider::OpenAICompat => {
|
||||||
let config = super::provider::openai_compat::default_config();
|
let config = super::provider::openai_compat::default_config();
|
||||||
serde_yaml::to_value(config).expect("Failed to serialize config")
|
serde_yaml_ng::to_value(config).expect("Failed to serialize config")
|
||||||
}
|
}
|
||||||
AgentProvider::OpenRouter => {
|
AgentProvider::OpenRouter => {
|
||||||
let config = super::provider::openrouter::default_config();
|
let config = super::provider::openrouter::default_config();
|
||||||
serde_yaml::to_value(config).expect("Failed to serialize config")
|
serde_yaml_ng::to_value(config).expect("Failed to serialize config")
|
||||||
}
|
}
|
||||||
AgentProvider::TogetherAI => {
|
AgentProvider::TogetherAI => {
|
||||||
let config = super::provider::togetherai::default_config();
|
let config = super::provider::togetherai::default_config();
|
||||||
serde_yaml::to_value(config).expect("Failed to serialize config")
|
serde_yaml_ng::to_value(config).expect("Failed to serialize config")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,10 +146,10 @@ impl ControllerTrait for Controller {
|
|||||||
.temperature_override
|
.temperature_override
|
||||||
.unwrap_or(text_generation_config.temperature);
|
.unwrap_or(text_generation_config.temperature);
|
||||||
|
|
||||||
if let Some(prompt_message) = prompt_message {
|
if let Some(prompt_message) = prompt_message
|
||||||
if let LLMMessageContent::Text(text) = &prompt_message.content {
|
&& let LLMMessageContent::Text(text) = &prompt_message.content
|
||||||
request.system = text.clone();
|
{
|
||||||
}
|
request.system = text.clone();
|
||||||
}
|
}
|
||||||
|
|
||||||
request.model = text_generation_config.model_id.clone();
|
request.model = text_generation_config.model_id.clone();
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ use super::controller::ControllerType;
|
|||||||
|
|
||||||
pub fn create_controller_from_yaml_value_config(
|
pub fn create_controller_from_yaml_value_config(
|
||||||
agent_id: &str,
|
agent_id: &str,
|
||||||
config: serde_yaml::Value,
|
config: serde_yaml_ng::Value,
|
||||||
) -> AgentInstantiationResult<ControllerType> {
|
) -> AgentInstantiationResult<ControllerType> {
|
||||||
let config = match &config {
|
let config = match &config {
|
||||||
serde_yaml::Value::Mapping(_) => {
|
serde_yaml_ng::Value::Mapping(_) => {
|
||||||
let config: Config =
|
let config: Config =
|
||||||
serde_yaml::from_value(config).map_err(AgentInstantiationError::Yaml)?;
|
serde_yaml_ng::from_value(config).map_err(AgentInstantiationError::Yaml)?;
|
||||||
|
|
||||||
config
|
config
|
||||||
.validate()
|
.validate()
|
||||||
|
|||||||
@@ -5,14 +5,14 @@ use async_openai::{
|
|||||||
config::OpenAIConfig,
|
config::OpenAIConfig,
|
||||||
types::{
|
types::{
|
||||||
audio::{AudioInput, CreateSpeechRequestArgs, CreateTranscriptionRequestArgs},
|
audio::{AudioInput, CreateSpeechRequestArgs, CreateTranscriptionRequestArgs},
|
||||||
|
images::{
|
||||||
|
CreateImageEditRequestArgs, CreateImageRequestArgs, Image, ImageInput, ImageModel,
|
||||||
|
ImageResponseFormat,
|
||||||
|
},
|
||||||
responses::{
|
responses::{
|
||||||
CodeInterpreterContainerAuto, CodeInterpreterTool, CodeInterpreterToolContainer,
|
CodeInterpreterContainerAuto, CodeInterpreterTool, CodeInterpreterToolContainer,
|
||||||
CreateResponseArgs, OutputItem, OutputMessageContent, Tool, WebSearchTool,
|
CreateResponseArgs, OutputItem, OutputMessageContent, Tool, WebSearchTool,
|
||||||
},
|
},
|
||||||
images::{
|
|
||||||
CreateImageEditRequestArgs, CreateImageRequestArgs,
|
|
||||||
Image, ImageInput, ImageModel, ImageResponseFormat,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -32,8 +32,8 @@ use crate::{
|
|||||||
agent::{
|
agent::{
|
||||||
AgentPurpose,
|
AgentPurpose,
|
||||||
provider::entity::{
|
provider::entity::{
|
||||||
ImageEditResult, ImageGenerationResult, ImageSource, PingResult,
|
ImageEditResult, ImageGenerationResult, ImageSource, PingResult, TextToSpeechParams,
|
||||||
TextToSpeechParams, TextToSpeechResult,
|
TextToSpeechResult,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
strings,
|
strings,
|
||||||
@@ -129,7 +129,8 @@ impl ControllerTrait for Controller {
|
|||||||
conversation_messages.insert(0, prompt_message);
|
conversation_messages.insert(0, prompt_message);
|
||||||
}
|
}
|
||||||
|
|
||||||
let input = super::utils::convert_llm_messages_to_openai_response_input(conversation_messages);
|
let input =
|
||||||
|
super::utils::convert_llm_messages_to_openai_response_input(conversation_messages);
|
||||||
|
|
||||||
let messages_count = match &input {
|
let messages_count = match &input {
|
||||||
async_openai::types::responses::InputParam::Items(items) => items.len(),
|
async_openai::types::responses::InputParam::Items(items) => items.len(),
|
||||||
@@ -182,10 +183,7 @@ impl ControllerTrait for Controller {
|
|||||||
|
|
||||||
let response = self.client.responses().create(request).await?;
|
let response = self.client.responses().create(request).await?;
|
||||||
|
|
||||||
tracing::trace!(
|
tracing::trace!(?response, "Got response from the OpenAI response API");
|
||||||
?response,
|
|
||||||
"Got response from the OpenAI response API"
|
|
||||||
);
|
|
||||||
|
|
||||||
for item in response.output {
|
for item in response.output {
|
||||||
if let OutputItem::Message(message) = item {
|
if let OutputItem::Message(message) = item {
|
||||||
@@ -271,9 +269,7 @@ impl ControllerTrait for Controller {
|
|||||||
ImageModel::GptImage1 => ImageModel::GptImage1Mini,
|
ImageModel::GptImage1 => ImageModel::GptImage1Mini,
|
||||||
ImageModel::GptImage1dot5 => ImageModel::GptImage1Mini,
|
ImageModel::GptImage1dot5 => ImageModel::GptImage1Mini,
|
||||||
ImageModel::GptImage1Mini => ImageModel::GptImage1Mini,
|
ImageModel::GptImage1Mini => ImageModel::GptImage1Mini,
|
||||||
ImageModel::Other(_) => {
|
ImageModel::Other(_) => ImageModel::DallE2,
|
||||||
ImageModel::DallE2
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
original_model
|
original_model
|
||||||
@@ -408,9 +404,15 @@ impl ControllerTrait for Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let dalle2_size = match image_generation_config.size {
|
let dalle2_size = match image_generation_config.size {
|
||||||
Some(async_openai::types::images::ImageSize::S256x256) => Some(async_openai::types::images::ImageSize::S256x256),
|
Some(async_openai::types::images::ImageSize::S256x256) => {
|
||||||
Some(async_openai::types::images::ImageSize::S512x512) => Some(async_openai::types::images::ImageSize::S512x512),
|
Some(async_openai::types::images::ImageSize::S256x256)
|
||||||
Some(async_openai::types::images::ImageSize::S1024x1024) => Some(async_openai::types::images::ImageSize::S1024x1024),
|
}
|
||||||
|
Some(async_openai::types::images::ImageSize::S512x512) => {
|
||||||
|
Some(async_openai::types::images::ImageSize::S512x512)
|
||||||
|
}
|
||||||
|
Some(async_openai::types::images::ImageSize::S1024x1024) => {
|
||||||
|
Some(async_openai::types::images::ImageSize::S1024x1024)
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -419,12 +421,8 @@ impl ControllerTrait for Controller {
|
|||||||
.map_err(|err| anyhow::anyhow!(err))?;
|
.map_err(|err| anyhow::anyhow!(err))?;
|
||||||
|
|
||||||
let response_format = match model.clone() {
|
let response_format = match model.clone() {
|
||||||
ImageModel::DallE2 => {
|
ImageModel::DallE2 => Some(ImageResponseFormat::B64Json),
|
||||||
Some(ImageResponseFormat::B64Json)
|
ImageModel::DallE3 => Some(ImageResponseFormat::B64Json),
|
||||||
}
|
|
||||||
ImageModel::DallE3 => {
|
|
||||||
Some(ImageResponseFormat::B64Json)
|
|
||||||
}
|
|
||||||
// gpt-image-1 only outputs base64 and we don't need to specify the response format.
|
// gpt-image-1 only outputs base64 and we don't need to specify the response format.
|
||||||
// In fact, specifying the response format results in an error.
|
// In fact, specifying the response format results in an error.
|
||||||
ImageModel::GptImage1 => None,
|
ImageModel::GptImage1 => None,
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ pub const OPENAI_IMAGE_MODEL_GPT_IMAGE_1_DOT_5: &str = "gpt-image-1.5";
|
|||||||
|
|
||||||
pub fn create_controller_from_yaml_value_config(
|
pub fn create_controller_from_yaml_value_config(
|
||||||
agent_id: &str,
|
agent_id: &str,
|
||||||
config: serde_yaml::Value,
|
config: serde_yaml_ng::Value,
|
||||||
) -> AgentInstantiationResult<ControllerType> {
|
) -> AgentInstantiationResult<ControllerType> {
|
||||||
let config = match &config {
|
let config = match &config {
|
||||||
serde_yaml::Value::Mapping(_) => {
|
serde_yaml_ng::Value::Mapping(_) => {
|
||||||
let config: Config =
|
let config: Config =
|
||||||
serde_yaml::from_value(config).map_err(AgentInstantiationError::Yaml)?;
|
serde_yaml_ng::from_value(config).map_err(AgentInstantiationError::Yaml)?;
|
||||||
|
|
||||||
config
|
config
|
||||||
.validate()
|
.validate()
|
||||||
|
|||||||
@@ -162,13 +162,14 @@ impl TryInto<OpenAITextToSpeechConfig> for TextToSpeechConfig {
|
|||||||
type Error = String;
|
type Error = String;
|
||||||
|
|
||||||
fn try_into(self) -> Result<OpenAITextToSpeechConfig, Self::Error> {
|
fn try_into(self) -> Result<OpenAITextToSpeechConfig, Self::Error> {
|
||||||
let model_id = convert_string_to_enum::<async_openai::types::audio::SpeechModel>(&self.model_id)?;
|
let model_id =
|
||||||
|
convert_string_to_enum::<async_openai::types::audio::SpeechModel>(&self.model_id)?;
|
||||||
|
|
||||||
let voice = convert_string_to_enum::<async_openai::types::audio::Voice>(&self.voice)?;
|
let voice = convert_string_to_enum::<async_openai::types::audio::Voice>(&self.voice)?;
|
||||||
|
|
||||||
let response_format = convert_string_to_enum::<async_openai::types::audio::SpeechResponseFormat>(
|
let response_format = convert_string_to_enum::<
|
||||||
&self.response_format,
|
async_openai::types::audio::SpeechResponseFormat,
|
||||||
)?;
|
>(&self.response_format)?;
|
||||||
|
|
||||||
Ok(OpenAITextToSpeechConfig {
|
Ok(OpenAITextToSpeechConfig {
|
||||||
model_id,
|
model_id,
|
||||||
@@ -225,25 +226,25 @@ impl TryInto<OpenAIImageGenerationConfig> for ImageGenerationConfig {
|
|||||||
|
|
||||||
fn try_into(self) -> Result<OpenAIImageGenerationConfig, Self::Error> {
|
fn try_into(self) -> Result<OpenAIImageGenerationConfig, Self::Error> {
|
||||||
let size = if let Some(size) = &self.size {
|
let size = if let Some(size) = &self.size {
|
||||||
Some(convert_string_to_enum::<async_openai::types::images::ImageSize>(
|
Some(convert_string_to_enum::<
|
||||||
size,
|
async_openai::types::images::ImageSize,
|
||||||
)?)
|
>(size)?)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let style = if let Some(style) = &self.style {
|
let style = if let Some(style) = &self.style {
|
||||||
Some(convert_string_to_enum::<async_openai::types::images::ImageStyle>(
|
Some(convert_string_to_enum::<
|
||||||
style,
|
async_openai::types::images::ImageStyle,
|
||||||
)?)
|
>(style)?)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let quality = if let Some(quality) = &self.quality {
|
let quality = if let Some(quality) = &self.quality {
|
||||||
Some(convert_string_to_enum::<async_openai::types::images::ImageQuality>(
|
Some(convert_string_to_enum::<
|
||||||
quality,
|
async_openai::types::images::ImageQuality,
|
||||||
)?)
|
>(quality)?)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -26,12 +26,12 @@ use super::controller::ControllerType;
|
|||||||
|
|
||||||
pub fn create_controller_from_yaml_value_config(
|
pub fn create_controller_from_yaml_value_config(
|
||||||
agent_id: &str,
|
agent_id: &str,
|
||||||
config: serde_yaml::Value,
|
config: serde_yaml_ng::Value,
|
||||||
) -> AgentInstantiationResult<ControllerType> {
|
) -> AgentInstantiationResult<ControllerType> {
|
||||||
let config = match &config {
|
let config = match &config {
|
||||||
serde_yaml::Value::Mapping(_) => {
|
serde_yaml_ng::Value::Mapping(_) => {
|
||||||
let config: Config =
|
let config: Config =
|
||||||
serde_yaml::from_value(config).map_err(AgentInstantiationError::Yaml)?;
|
serde_yaml_ng::from_value(config).map_err(AgentInstantiationError::Yaml)?;
|
||||||
|
|
||||||
config
|
config
|
||||||
.validate()
|
.validate()
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ use std::{future::Future, pin::Pin};
|
|||||||
|
|
||||||
use mxlink::matrix_sdk::Room;
|
use mxlink::matrix_sdk::Room;
|
||||||
use mxlink::matrix_sdk::media::{MediaFormat, MediaRequestParameters};
|
use mxlink::matrix_sdk::media::{MediaFormat, MediaRequestParameters};
|
||||||
|
use mxlink::matrix_sdk::ruma::api::client::profile::{AvatarUrl, DisplayName};
|
||||||
use mxlink::matrix_sdk::ruma::{
|
use mxlink::matrix_sdk::ruma::{
|
||||||
MilliSecondsSinceUnixEpoch, OwnedUserId, events::room::MediaSource,
|
MilliSecondsSinceUnixEpoch, OwnedUserId, events::room::MediaSource,
|
||||||
};
|
};
|
||||||
use mxlink::matrix_sdk::ruma::api::client::profile::{AvatarUrl, DisplayName};
|
|
||||||
|
|
||||||
use mxlink::{
|
use mxlink::{
|
||||||
InitConfig, LoginConfig, LoginCredentials, LoginEncryption, MatrixLink, PersistenceConfig,
|
InitConfig, LoginConfig, LoginCredentials, LoginEncryption, MatrixLink, PersistenceConfig,
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ pub fn load() -> anyhow::Result<Config> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let config_str = std::fs::read_to_string(config_file_path)?;
|
let config_str = std::fs::read_to_string(config_file_path)?;
|
||||||
let mut config: Config = serde_yaml::from_str(&config_str)?;
|
let mut config: Config = serde_yaml_ng::from_str(&config_str)?;
|
||||||
|
|
||||||
// Allow environment variables to override some configuration keys
|
// Allow environment variables to override some configuration keys
|
||||||
for (key, value) in env::vars() {
|
for (key, value) in env::vars() {
|
||||||
|
|||||||
@@ -28,18 +28,18 @@ pub async fn handle_set(
|
|||||||
message_context: &MessageContext,
|
message_context: &MessageContext,
|
||||||
patterns: &Option<Vec<String>>,
|
patterns: &Option<Vec<String>>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
if let Some(patterns) = patterns {
|
if let Some(patterns) = patterns
|
||||||
if let Err(err) = mxidwc::parse_patterns_vector(patterns) {
|
&& let Err(err) = mxidwc::parse_patterns_vector(patterns)
|
||||||
bot.messaging()
|
{
|
||||||
.send_error_markdown_no_fail(
|
bot.messaging()
|
||||||
message_context.room(),
|
.send_error_markdown_no_fail(
|
||||||
&strings::access::failed_to_parse_patterns(&err.to_string()),
|
message_context.room(),
|
||||||
MessageResponseType::Reply(message_context.thread_info().root_event_id.clone()),
|
&strings::access::failed_to_parse_patterns(&err.to_string()),
|
||||||
)
|
MessageResponseType::Reply(message_context.thread_info().root_event_id.clone()),
|
||||||
.await;
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut global_config_manager_guard = bot.global_config_manager().lock().await;
|
let mut global_config_manager_guard = bot.global_config_manager().lock().await;
|
||||||
|
|||||||
@@ -24,18 +24,18 @@ pub async fn handle_set(
|
|||||||
message_context: &MessageContext,
|
message_context: &MessageContext,
|
||||||
patterns: &Option<Vec<String>>,
|
patterns: &Option<Vec<String>>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
if let Some(patterns) = patterns {
|
if let Some(patterns) = patterns
|
||||||
if let Err(err) = mxidwc::parse_patterns_vector(patterns) {
|
&& let Err(err) = mxidwc::parse_patterns_vector(patterns)
|
||||||
bot.messaging()
|
{
|
||||||
.send_error_markdown_no_fail(
|
bot.messaging()
|
||||||
message_context.room(),
|
.send_error_markdown_no_fail(
|
||||||
&strings::access::failed_to_parse_patterns(&err.to_string()),
|
message_context.room(),
|
||||||
MessageResponseType::Reply(message_context.thread_info().root_event_id.clone()),
|
&strings::access::failed_to_parse_patterns(&err.to_string()),
|
||||||
)
|
MessageResponseType::Reply(message_context.thread_info().root_event_id.clone()),
|
||||||
.await;
|
)
|
||||||
|
.await;
|
||||||
|
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut global_config_manager_guard = bot.global_config_manager().lock().await;
|
let mut global_config_manager_guard = bot.global_config_manager().lock().await;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use crate::{Bot, entity::MessageContext};
|
|||||||
|
|
||||||
struct ParsedAgentConfig {
|
struct ParsedAgentConfig {
|
||||||
agent: AgentInstance,
|
agent: AgentInstance,
|
||||||
config: serde_yaml::Value,
|
config: serde_yaml_ng::Value,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn handle_room_local(
|
pub async fn handle_room_local(
|
||||||
@@ -250,7 +250,7 @@ async fn send_guide(
|
|||||||
provider: &AgentProvider,
|
provider: &AgentProvider,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let sample_config = crate::agent::default_config_for_provider(provider);
|
let sample_config = crate::agent::default_config_for_provider(provider);
|
||||||
let sample_config_pretty_yaml = serde_yaml::to_string(&sample_config)?;
|
let sample_config_pretty_yaml = serde_yaml_ng::to_string(&sample_config)?;
|
||||||
|
|
||||||
bot.messaging()
|
bot.messaging()
|
||||||
.send_text_markdown_no_fail(
|
.send_text_markdown_no_fail(
|
||||||
@@ -263,7 +263,7 @@ async fn send_guide(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_from_message_to_yaml_value(text: &str) -> Result<serde_yaml::Value, String> {
|
fn parse_from_message_to_yaml_value(text: &str) -> Result<serde_yaml_ng::Value, String> {
|
||||||
let mut text = text.trim();
|
let mut text = text.trim();
|
||||||
|
|
||||||
if text.starts_with("```") {
|
if text.starts_with("```") {
|
||||||
@@ -274,10 +274,10 @@ fn parse_from_message_to_yaml_value(text: &str) -> Result<serde_yaml::Value, Str
|
|||||||
text = text.trim_end_matches("```");
|
text = text.trim_end_matches("```");
|
||||||
}
|
}
|
||||||
|
|
||||||
let config: serde_yaml::Value = serde_yaml::from_str(text).map_err(|e| e.to_string())?;
|
let config: serde_yaml_ng::Value = serde_yaml_ng::from_str(text).map_err(|e| e.to_string())?;
|
||||||
|
|
||||||
match config {
|
match config {
|
||||||
serde_yaml::Value::Mapping(_) => {}
|
serde_yaml_ng::Value::Mapping(_) => {}
|
||||||
_ => {
|
_ => {
|
||||||
return Err("Not a valid YAML hashmap".to_owned());
|
return Err("Not a valid YAML hashmap".to_owned());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,12 @@
|
|||||||
fn agent_config_parsing_works() {
|
fn agent_config_parsing_works() {
|
||||||
struct TestCase {
|
struct TestCase {
|
||||||
input: String,
|
input: String,
|
||||||
expected: Option<serde_yaml::Value>,
|
expected: Option<serde_yaml_ng::Value>,
|
||||||
}
|
}
|
||||||
|
|
||||||
let provider = crate::agent::AgentProvider::OpenAI;
|
let provider = crate::agent::AgentProvider::OpenAI;
|
||||||
let sample_config = crate::agent::default_config_for_provider(&provider);
|
let sample_config = crate::agent::default_config_for_provider(&provider);
|
||||||
let sample_config_pretty_yaml = serde_yaml::to_string(&sample_config).unwrap();
|
let sample_config_pretty_yaml = serde_yaml_ng::to_string(&sample_config).unwrap();
|
||||||
|
|
||||||
let test_cases = vec![
|
let test_cases = vec![
|
||||||
// Invalid input
|
// Invalid input
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ pub async fn handle(
|
|||||||
PublicIdentifier::Static(_) => {}
|
PublicIdentifier::Static(_) => {}
|
||||||
};
|
};
|
||||||
|
|
||||||
let config_yaml_pretty = serde_yaml::to_string(&agent.definition().config)?;
|
let config_yaml_pretty = serde_yaml_ng::to_string(&agent.definition().config)?;
|
||||||
|
|
||||||
bot.messaging()
|
bot.messaging()
|
||||||
.send_text_markdown_no_fail(
|
.send_text_markdown_no_fail(
|
||||||
|
|||||||
@@ -39,18 +39,18 @@ async fn dispatch_config_related_handler(
|
|||||||
message_context: &MessageContext,
|
message_context: &MessageContext,
|
||||||
bot: &Bot,
|
bot: &Bot,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
if let SettingsStorageSource::Global = config_type {
|
if let SettingsStorageSource::Global = config_type
|
||||||
if !message_context.sender_can_manage_global_config() {
|
&& !message_context.sender_can_manage_global_config()
|
||||||
bot.messaging()
|
{
|
||||||
.send_error_markdown_no_fail(
|
bot.messaging()
|
||||||
message_context.room(),
|
.send_error_markdown_no_fail(
|
||||||
strings::global_config::no_permissions_to_administrate(),
|
message_context.room(),
|
||||||
MessageResponseType::Reply(message_context.thread_info().root_event_id.clone()),
|
strings::global_config::no_permissions_to_administrate(),
|
||||||
)
|
MessageResponseType::Reply(message_context.thread_info().root_event_id.clone()),
|
||||||
.await;
|
)
|
||||||
return Ok(());
|
.await;
|
||||||
}
|
return Ok(());
|
||||||
};
|
}
|
||||||
|
|
||||||
let room_settings = match config_type {
|
let room_settings = match config_type {
|
||||||
SettingsStorageSource::Room => &message_context.room_config().settings,
|
SettingsStorageSource::Room => &message_context.room_config().settings,
|
||||||
|
|||||||
@@ -154,35 +154,35 @@ pub async fn process_matrix_messages(
|
|||||||
|
|
||||||
let mut message = message.clone();
|
let mut message = message.clone();
|
||||||
|
|
||||||
if i == 0 && !params.first_message_prefixes_to_strip.is_empty() {
|
if i == 0
|
||||||
if let MatrixMessageContent::Text(message_text) = &message.content {
|
&& !params.first_message_prefixes_to_strip.is_empty()
|
||||||
let mut message_text = message_text.clone();
|
&& let MatrixMessageContent::Text(message_text) = &message.content
|
||||||
|
{
|
||||||
|
let mut message_text = message_text.clone();
|
||||||
|
|
||||||
for prefix in ¶ms.first_message_prefixes_to_strip {
|
for prefix in ¶ms.first_message_prefixes_to_strip {
|
||||||
if let Some(message_text_stripped) = message_text.strip_prefix(prefix) {
|
if let Some(message_text_stripped) = message_text.strip_prefix(prefix) {
|
||||||
message_text = message_text_stripped.to_owned();
|
message_text = message_text_stripped.to_owned();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message.content = MatrixMessageContent::Text(message_text.trim().to_owned());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message.content = MatrixMessageContent::Text(message_text.trim().to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
// We only strip `bot_user_prefixes_to_strip`-defined prefixes from messages that mention the bot user.
|
// We only strip `bot_user_prefixes_to_strip`-defined prefixes from messages that mention the bot user.
|
||||||
if !params.bot_user_prefixes_to_strip.is_empty()
|
if !params.bot_user_prefixes_to_strip.is_empty()
|
||||||
&& message.mentioned_users.contains(¶ms.bot_user_id)
|
&& message.mentioned_users.contains(¶ms.bot_user_id)
|
||||||
|
&& let MatrixMessageContent::Text(message_text) = &message.content
|
||||||
{
|
{
|
||||||
if let MatrixMessageContent::Text(message_text) = &message.content {
|
let mut message_text = message_text.clone();
|
||||||
let mut message_text = message_text.clone();
|
|
||||||
|
|
||||||
for prefix in ¶ms.bot_user_prefixes_to_strip {
|
for prefix in ¶ms.bot_user_prefixes_to_strip {
|
||||||
if let Some(message_text_stripped) = message_text.strip_prefix(prefix) {
|
if let Some(message_text_stripped) = message_text.strip_prefix(prefix) {
|
||||||
message_text = message_text_stripped.to_owned();
|
message_text = message_text_stripped.to_owned();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message.content = MatrixMessageContent::Text(message_text.trim().to_owned());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message.content = MatrixMessageContent::Text(message_text.trim().to_owned());
|
||||||
}
|
}
|
||||||
|
|
||||||
messages_filtered.push(message);
|
messages_filtered.push(message);
|
||||||
|
|||||||
@@ -88,9 +88,10 @@ impl ConfigHomeserver {
|
|||||||
/// - `Default`: Use the built-in default avatar (null, empty string, or missing in config)
|
/// - `Default`: Use the built-in default avatar (null, empty string, or missing in config)
|
||||||
/// - `Keep`: Don't touch the avatar, keep whatever is already set ("keep" in config)
|
/// - `Keep`: Don't touch the avatar, keep whatever is already set ("keep" in config)
|
||||||
/// - `Custom(String)`: Use a custom avatar from the specified file path
|
/// - `Custom(String)`: Use a custom avatar from the specified file path
|
||||||
#[derive(Debug, Clone, PartialEq, Serialize)]
|
#[derive(Debug, Clone, Default, PartialEq, Serialize)]
|
||||||
pub enum Avatar {
|
pub enum Avatar {
|
||||||
/// Use the built-in default avatar
|
/// Use the built-in default avatar
|
||||||
|
#[default]
|
||||||
Default,
|
Default,
|
||||||
/// Keep the current avatar, don't change it
|
/// Keep the current avatar, don't change it
|
||||||
Keep,
|
Keep,
|
||||||
@@ -98,12 +99,6 @@ pub enum Avatar {
|
|||||||
Custom(String),
|
Custom(String),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Avatar {
|
|
||||||
fn default() -> Self {
|
|
||||||
Avatar::Default
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'de> Deserialize<'de> for Avatar {
|
impl<'de> Deserialize<'de> for Avatar {
|
||||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||||
where
|
where
|
||||||
@@ -181,13 +176,13 @@ pub struct ConfigUserEncryption {
|
|||||||
|
|
||||||
impl ConfigUserEncryption {
|
impl ConfigUserEncryption {
|
||||||
pub fn validate(&self) -> anyhow::Result<()> {
|
pub fn validate(&self) -> anyhow::Result<()> {
|
||||||
if let Some(passphrase) = &self.recovery_passphrase {
|
if let Some(passphrase) = &self.recovery_passphrase
|
||||||
if passphrase.is_empty() {
|
&& passphrase.is_empty()
|
||||||
return Err(anyhow::anyhow!(
|
{
|
||||||
"The user.encryption.recovery_passphrase ({}) configuration must either be null or set to a non-empty passphrase",
|
return Err(anyhow::anyhow!(
|
||||||
super::env::BAIBOT_USER_ENCRYPTION_RECOVERY_PASSPHRASE
|
"The user.encryption.recovery_passphrase ({}) configuration must either be null or set to a non-empty passphrase",
|
||||||
));
|
super::env::BAIBOT_USER_ENCRYPTION_RECOVERY_PASSPHRASE
|
||||||
}
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|||||||
Reference in New Issue
Block a user