ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s

This commit is contained in:
2026-08-20 13:12:50 +00:00
commit b119135836
10275 changed files with 3284984 additions and 0 deletions
@@ -0,0 +1,226 @@
# Cursor Chat: ai-agent-book
## Metadata
- **Project**: ai-agent-book
- **Path**: `/Users/boj`
- **Date**: 2025-10-03 23:53:10
- **Session ID**: `033185f2-73c0-4e9e-a12a-172a80b42f7e`
## Conversation
### 👤 You
Traceback (most recent call last):
File "/root/sesame.py", line 163, in <module>
processed_ds = raw_ds.map(
preprocess_example,
remove_columns=raw_ds.column_names,
desc="Preprocessing dataset",
)
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/datasets/arrow_dataset.py", line 562, in wrapper
out: Union["Dataset", "DatasetDict"] = func(self, *args, **kwargs)
~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/datasets/arrow_dataset.py", line 3327, in map
for rank, done, content in Dataset._map_single(**unprocessed_kwargs):
~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/datasets/arrow_dataset.py", line 3659, in _map_single
for i, example in iter_outputs(shard_iterable):
~~~~~~~~~~~~^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/datasets/arrow_dataset.py", line 3633, in iter_outputs
yield i, apply_function(example, i, offset=offset)
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/datasets/arrow_dataset.py", line 3556, in apply_function
processed_inputs = function(*fn_args, *additional_args, **fn_kwargs)
File "/root/sesame.py", line 116, in preprocess_example
{"type": "audio", "path": example["audio"]["array"]},
~~~~~~~^^^^^^^^^
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/datasets/formatting/formatting.py", line 285, in __getitem__
value = self.format(key)
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/datasets/formatting/formatting.py", line 380, in format
return self.formatter.format_column(self.pa_table.select([key]))[0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/datasets/formatting/formatting.py", line 465, in format_column
column = self.python_features_decoder.decode_column(column, pa_table.column_names[0])
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/datasets/formatting/formatting.py", line 228, in decode_column
self.features.decode_column(column, column_name, token_per_repo_id=self.token_per_repo_id)
~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/datasets/features/features.py", line 2121, in decode_column
decode_nested_example(self[column_name], value, token_per_repo_id=token_per_repo_id)
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/datasets/features/features.py", line 1409, in decode_nested_example
return schema.decode_example(obj, token_per_repo_id=token_per_repo_id) if obj is not None else None
~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/datasets/features/audio.py", line 179, in decode_example
from ._torchcodec import AudioDecoder
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/datasets/features/_torchcodec.py", line 2, in <module>
from torchcodec.decoders import AudioDecoder as _AudioDecoder
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/torchcodec/__init__.py", line 10, in <module>
from . import decoders, samplers # noqa
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/torchcodec/decoders/__init__.py", line 7, in <module>
from .._core import AudioStreamMetadata, VideoStreamMetadata
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/torchcodec/_core/__init__.py", line 8, in <module>
from ._metadata import (
...<5 lines>...
)
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/torchcodec/_core/_metadata.py", line 16, in <module>
from torchcodec._core.ops import (
...<3 lines>...
)
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/torchcodec/_core/ops.py", line 84, in <module>
load_torchcodec_shared_libraries()
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/root/miniconda3/envs/sesame/lib/python3.13/site-packages/torchcodec/_core/ops.py", line 69, in load_torchcodec_shared_libraries
raise RuntimeError(
...<11 lines>...
)
RuntimeError: Could not load libtorchcodec. Likely causes:
1. FFmpeg is not properly installed in your environment. We support
versions 4, 5, 6 and 7.
2. The PyTorch version (2.8.0+cu128) is not compatible with
this version of TorchCodec. Refer to the version compatibility
table:
https://github.com/pytorch/torchcodec?tab=readme-ov-file#installing-torchcodec.
3. Another runtime dependency; see exceptions below.
The following exceptions were raised as we tried to load libtorchcodec:
[start of libtorchcodec loading traceback]
FFmpeg version 7: libavutil.so.59: cannot open shared object file: No such file or directory
FFmpeg version 6: /root/miniconda3/envs/sesame/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /usr/lib/x86_64-linux-gnu/libavfilter.so.9)
FFmpeg version 5: libavutil.so.57: cannot open shared object file: No such file or directory
FFmpeg version 4: libavutil.so.56: cannot open shared object file: No such file or directory
[end of libtorchcodec loading traceback].
(sesame) root@C.26412100:~$ ffmpeg --version
ffmpeg version 6.1.1-3ubuntu5 Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 13 (Ubuntu 13.2.0-23ubuntu3)
---
### 🤖 Cursor Assistant
This is a library compatibility issue between your conda environment and the system FFmpeg installation. The system FFmpeg 6 requires `GLIBCXX_3.4.32`, but your conda environment has an older version of `libstdc++`.
Here are the solutions, in order of preference:
## Solution 1: Install FFmpeg in the conda environment (Recommended)
This ensures all libraries are compatible within the same environment:
---
### 👤 You
The following NEW packages will be INSTALLED:
aom conda-forge/linux-64::aom-3.3.0-h27087fc_1
ffmpeg conda-forge/linux-64::ffmpeg-5.0.1-h964e5f1_2
freetype pkgs/main/linux-64::freetype-2.13.3-h4a9f257_0
gmp conda-forge/linux-64::gmp-6.2.1-h58526e2_0
gnutls conda-forge/linux-64::gnutls-3.6.13-h85f3911_1
icu pkgs/main/linux-64::icu-73.1-h6a678d5_0
lame conda-forge/linux-64::lame-3.100-h7f98852_1001
libdrm pkgs/main/linux-64::libdrm-2.4.124-h5eee18b_0
libpciaccess pkgs/main/linux-64::libpciaccess-0.18-h5eee18b_0
libpng pkgs/main/linux-64::libpng-1.6.39-h5eee18b_0
libva conda-forge/linux-64::libva-2.21.0-hd590300_0
libvpx conda-forge/linux-64::libvpx-1.11.0-h9c3ff4c_3
libxml2 pkgs/main/linux-64::libxml2-2.13.8-hfdd30dd_0
nettle conda-forge/linux-64::nettle-3.6-he412f7d_0
openh264 pkgs/main/linux-64::openh264-2.1.1-h4ff587b_0
svt-av1 conda-forge/linux-64::svt-av1-1.1.0-h27087fc_1
x264 conda-forge/linux-64::x264-1!161.3030-h7f98852_1
x265 conda-forge/linux-64::x265-3.5-h924138e_3
xorg-libxext pkgs/main/linux-64::xorg-libxext-1.3.6-h9b100fa_0
xorg-libxfixes pkgs/main/linux-64::xorg-libxfixes-6.0.1-h9b100fa_0
Downloading and Extracting Packages:
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(sesame) root@C.26412100:~$ ffmpeg --version
ffmpeg: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory
(sesame) root@C.26412100:~$ which ffmpeg
/root/miniconda3/envs/sesame/bin/ffmpeg
---
### 🤖 Cursor Assistant
The FFmpeg installation is missing the `libiconv` library dependency. Let's install it:
---
### 👤 You
)
RuntimeError: Could not load libtorchcodec. Likely causes:
1. FFmpeg is not properly installed in your environment. We support
versions 4, 5, 6 and 7.
2. The PyTorch version (2.8.0+cu128) is not compatible with
this version of TorchCodec. Refer to the version compatibility
table:
https://github.com/pytorch/torchcodec?tab=readme-ov-file#installing-torchcodec.
3. Another runtime dependency; see exceptions below.
The following exceptions were raised as we tried to load libtorchcodec:
[start of libtorchcodec loading traceback]
FFmpeg version 7: libavutil.so.59: cannot open shared object file: No such file or directory
FFmpeg version 6: /root/miniconda3/envs/sesame/bin/../lib/libstdc++.so.6: version `GLIBCXX_3.4.32' not found (required by /usr/lib/x86_64-linux-gnu/libavfilter.so.9)
FFmpeg version 5: /root/miniconda3/envs/sesame/lib/python3.13/site-packages/torchcodec/libtorchcodec_core5.so: undefined symbol: av_channel_layout_default, version LIBAVUTIL_57
FFmpeg version 4: libavutil.so.56: cannot open shared object file: No such file or directory
[end of libtorchcodec loading traceback].
---
### 🤖 Cursor Assistant
I see the issue now. The conda FFmpeg 5 has a symbol compatibility problem with torchcodec. You need to install a newer FFmpeg version (6 or 7) in your conda environment. Since you're on a remote Linux server, here are the commands you should run:
## Solution: Install FFmpeg 6 or 7 in conda
Try FFmpeg 6 first (should work with your torchcodec version):
```bash
conda install -c conda-forge "ffmpeg>=6.0" -y
```
If that doesn't resolve it, you may also need to update `libstdc++` to get the required GLIBCXX version:
```bash
conda install -c conda-forge libstdcxx-ng -y
```
## Alternative: Install libiconv and upgrade FFmpeg
Since FFmpeg is also missing libiconv, install both together:
```bash
conda install -c conda-forge libiconv "ffmpeg>=6.0" libstdcxx-ng -y
```
## If conda approach doesn't work: Downgrade to avoid torchcodec
The audio decoding issue comes from the `datasets` library trying to use `torchcodec`. You can work around this by:
1. **Downgrade datasets** to a version that doesn't require torchcodec:
```bash
pip install "datasets<3.0.0"
```
2. **Or disable audio decoding** in your code by modifying how you load the dataset. Looking at your script, change the dataset loading to avoid decoding audio automatically:
```python
raw_ds = load_dataset("...", split="...", streaming=False)
# Set decode=False for audio to avoid torchcodec
raw_ds = raw_ds.cast_column("audio", datasets.Audio(decode=False))
```
**Recommendation**: Try the first approach (install FFmpeg 6+ and libstdcxx-ng in conda) as it's the cleanest solution that addresses all the library compatibility issues at once.
---
*Exported from [Cursor View](https://github.com/saharmor/cursor-view)*