Warning: Permanently added '2620:52:6:1161:dead:beef:cafe:c170' (ED25519) to the list of known hosts. You can reproduce this build on your computer by running: sudo dnf install copr-rpmbuild /usr/bin/copr-rpmbuild --verbose --drop-resultdir --task-url https://copr.fedorainfracloud.org/backend/get-build-task/11330284-fedora-45-x86_64 --chroot fedora-45-x86_64 Version: 1.11 PID: 5762 Logging PID: 5764 Task: {'allow_user_ssh': False, 'appstream': False, 'background': True, 'build_id': 11330284, 'buildroot_pkgs': [], 'chroot': 'fedora-45-x86_64', 'enable_net': False, 'fedora_review': False, 'git_hash': '46cd648a235a7499e8dc6cb9e0a552d71ec49fd3', 'git_repo': 'https://copr-dist-git.fedorainfracloud.org/git/thrnciar/python-setuptools/python-llm', 'isolation': 'default', 'memory_reqs': 2048, 'package_name': 'python-llm', 'package_version': '0.37.2-1', 'project_dirname': 'python-setuptools', 'project_name': 'python-setuptools', 'project_owner': 'thrnciar', 'repo_priority': None, 'repos': [{'baseurl': 'https://download.copr.fedorainfracloud.org/results/thrnciar/python-setuptools/fedora-45-x86_64/', 'id': 'copr_base', 'name': 'Copr repository', 'priority': None, 'repo_gpgcheck': False}], 'sandbox': 'thrnciar/python-setuptools--https://src.fedoraproject.org/user/terjeros', 'source_json': {}, 'source_type': None, 'ssh_public_keys': None, 'storage': 1, 'submitter': 'https://src.fedoraproject.org/user/terjeros', 'tags': [], 'task_id': '11330284-fedora-45-x86_64', 'timeout': 18000, 'uses_devel_repo': False, 'with_opts': [], 'without_opts': []} Running: git clone https://copr-dist-git.fedorainfracloud.org/git/thrnciar/python-setuptools/python-llm /var/lib/copr-rpmbuild/workspace/workdir-3lwbw5ag/python-llm --depth 500 --no-single-branch --recursive cmd: ['git', 'clone', 'https://copr-dist-git.fedorainfracloud.org/git/thrnciar/python-setuptools/python-llm', '/var/lib/copr-rpmbuild/workspace/workdir-3lwbw5ag/python-llm', '--depth', '500', '--no-single-branch', '--recursive'] cwd: . rc: 0 stdout: stderr: Cloning into '/var/lib/copr-rpmbuild/workspace/workdir-3lwbw5ag/python-llm'... Running: git checkout 46cd648a235a7499e8dc6cb9e0a552d71ec49fd3 -- cmd: ['git', 'checkout', '46cd648a235a7499e8dc6cb9e0a552d71ec49fd3', '--'] cwd: /var/lib/copr-rpmbuild/workspace/workdir-3lwbw5ag/python-llm rc: 0 stdout: stderr: Note: switching to '46cd648a235a7499e8dc6cb9e0a552d71ec49fd3'. You are in 'detached HEAD' state. You can look around, make experimental changes and commit them, and you can discard any commits you make in this state without impacting any branches by switching back to a branch. If you want to create a new branch to retain commits you create, you may do so (now or later) by using -c with the switch command. Example: git switch -c Or undo this operation with: git switch - Turn off this advice by setting config variable advice.detachedHead to false HEAD is now at 46cd648 automatic import of python-llm Running: dist-git-client sources cmd: ['dist-git-client', 'sources'] cwd: /var/lib/copr-rpmbuild/workspace/workdir-3lwbw5ag/python-llm rc: 0 stdout: stderr: INFO: Reading stdout from command: git rev-parse --abbrev-ref HEAD INFO: Reading stdout from command: git rev-parse HEAD INFO: Reading sources specification file: sources INFO: Downloading llm-0.37.2.tar.gz INFO: Reading stdout from command: curl --help all INFO: Calling: curl -H Pragma: -H 'Accept-Encoding: identity' -o llm-0.37.2.tar.gz --location --connect-timeout 60 --retry 3 --retry-delay 10 --remote-time --show-error --fail --retry-all-errors https://copr-dist-git.fedorainfracloud.org/repo/pkgs/thrnciar/python-setuptools/python-llm/llm-0.37.2.tar.gz/md5/c0e418e8002adc37b5abc8b0e546721b/llm-0.37.2.tar.gz % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 461.1k 100 461.1k 0 0 1.66M 0 0 INFO: Reading stdout from command: md5sum llm-0.37.2.tar.gz tail: /var/lib/copr-rpmbuild/main.log: file truncated Running (timeout=18000): unbuffer mock --spec /var/lib/copr-rpmbuild/workspace/workdir-3lwbw5ag/python-llm/python-llm.spec --sources /var/lib/copr-rpmbuild/workspace/workdir-3lwbw5ag/python-llm --resultdir /var/lib/copr-rpmbuild/results --uniqueext 1794743501.743658 -r /var/lib/copr-rpmbuild/results/configs/child.cfg INFO: mock.py version 6.9 starting (python version = 3.14.5, NVR = mock-6.9-1.fc44), args: /usr/libexec/mock/mock --spec /var/lib/copr-rpmbuild/workspace/workdir-3lwbw5ag/python-llm/python-llm.spec --sources /var/lib/copr-rpmbuild/workspace/workdir-3lwbw5ag/python-llm --resultdir /var/lib/copr-rpmbuild/results --uniqueext 1794743501.743658 -r /var/lib/copr-rpmbuild/results/configs/child.cfg Start(bootstrap): init plugins INFO: tmpfs initialized INFO: selinux enabled INFO: chroot_scan: initialized INFO: compress_logs: initialized Finish(bootstrap): init plugins Start: init plugins INFO: tmpfs initialized INFO: selinux enabled INFO: chroot_scan: initialized INFO: compress_logs: initialized Finish: init plugins INFO: Signal handler active Start: run INFO: Start(/var/lib/copr-rpmbuild/workspace/workdir-3lwbw5ag/python-llm/python-llm.spec) Config(fedora-45-x86_64) Start: clean chroot Finish: clean chroot Mock Version: 6.9 INFO: Mock Version: 6.9 Start(bootstrap): chroot init INFO: mounting tmpfs at /var/lib/mock/fedora-45-x86_64-bootstrap-1794743501.743658/root. INFO: calling preinit hooks INFO: enabled root cache INFO: enabled package manager cache Start(bootstrap): cleaning package manager metadata Finish(bootstrap): cleaning package manager metadata INFO: Guessed host environment type: unknown INFO: Using container image: registry.fedoraproject.org/fedora:45 INFO: Pulling image: registry.fedoraproject.org/fedora:45 INFO: Tagging container image as mock-bootstrap-5b90d33d-29c7-4107-94b9-ab15ac901782 INFO: Checking that 9b0258576599be0e9bb4da8021a9dae70a46e8cf92fc9b67bc6d1a97577fc871 image matches host's architecture INFO: Copy content of container 9b0258576599be0e9bb4da8021a9dae70a46e8cf92fc9b67bc6d1a97577fc871 to /var/lib/mock/fedora-45-x86_64-bootstrap-1794743501.743658/root INFO: mounting 9b0258576599be0e9bb4da8021a9dae70a46e8cf92fc9b67bc6d1a97577fc871 with podman image mount INFO: image 9b0258576599be0e9bb4da8021a9dae70a46e8cf92fc9b67bc6d1a97577fc871 as /var/lib/containers/storage/overlay/97156f1d0ecaf474bed0f7642388972900fbcb9ef7bff7ad9c6b3362d93912c3/merged INFO: umounting image 9b0258576599be0e9bb4da8021a9dae70a46e8cf92fc9b67bc6d1a97577fc871 (/var/lib/containers/storage/overlay/97156f1d0ecaf474bed0f7642388972900fbcb9ef7bff7ad9c6b3362d93912c3/merged) with podman image umount INFO: Removing image mock-bootstrap-5b90d33d-29c7-4107-94b9-ab15ac901782 INFO: Package manager dnf5 detected and used (fallback) INFO: Not updating bootstrap chroot, bootstrap_image_ready=True Start(bootstrap): creating root cache Finish(bootstrap): creating root cache Finish(bootstrap): chroot init Start: chroot init INFO: mounting tmpfs at /var/lib/mock/fedora-45-x86_64-1794743501.743658/root. INFO: calling preinit hooks INFO: enabled root cache INFO: enabled package manager cache Start: cleaning package manager metadata Finish: cleaning package manager metadata INFO: enabled HW Info plugin INFO: Package manager dnf5 detected and used (direct choice) INFO: Buildroot is handled by package management downloaded with a bootstrap image: rpm-6.1.0-1.fc45.x86_64 rpm-sequoia-1.10.3-1.fc45.x86_64 dnf5-5.4.8.0-2.fc45.x86_64 dnf5-plugins-5.4.8.0-2.fc45.x86_64 Start: installing minimal buildroot with dnf5 Updating and loading repositories: updates 100% | 5.8 MiB/s | 5.2 MiB | 00m01s fedora 100% | 26.8 MiB/s | 36.9 MiB | 00m01s Copr repository 100% | 3.5 MiB/s | 27.5 MiB | 00m08s Repositories loaded. Package Arch Version Repository Size Installing group/module packages: bash x86_64 0:5.3.15-2.fc45 fedora 8.5 MiB bzip2 x86_64 0:1.0.8-24.fc45 fedora 95.0 KiB coreutils x86_64 0:9.11-6.fc45 fedora 5.9 MiB cpio x86_64 0:2.15-10.fc45 fedora 1.1 MiB diffutils x86_64 0:3.12-6.fc45 fedora 1.6 MiB fedora-release-common noarch 0:45-14 updates 4.2 KiB findutils x86_64 1:4.11.0-2.fc45 fedora 1.9 MiB gawk x86_64 0:5.4.1-1.fc45 fedora 2.2 MiB glibc-minimal-langpack x86_64 0:2.44-2.fc45 updates 0.0 B grep x86_64 0:3.12-4.fc45 fedora 1.0 MiB gzip x86_64 0:1.14-4.fc45 fedora 401.6 KiB info x86_64 0:7.3-3.fc45 fedora 372.4 KiB patch x86_64 0:2.8-6.fc45 fedora 226.6 KiB redhat-rpm-config noarch 0:345-5.fc45 updates 184.2 KiB rpm-build x86_64 0:6.1.0-1.fc45 fedora 312.2 KiB sed x86_64 0:4.10-2.fc45 fedora 866.5 KiB shadow-utils x86_64 2:4.20.0-2.fc45 fedora 3.9 MiB tar x86_64 2:1.35-10.fc45 fedora 3.0 MiB unzip x86_64 0:6.0-71.fc45 fedora 441.8 KiB util-linux x86_64 0:2.42.4-1.fc45 fedora 3.7 MiB which x86_64 0:2.25-2.fc45 fedora 83.6 KiB xz x86_64 1:5.8.3-2.fc45 fedora 1.4 MiB Installing dependencies: R-srpm-macros noarch 0:1.3.7-3.fc45 fedora 3.5 KiB add-determinism x86_64 0:0.7.3-3.fc45 fedora 2.2 MiB alternatives x86_64 0:1.33-6.fc45 fedora 62.1 KiB ansible-srpm-macros noarch 0:1-22.fc45 fedora 35.7 KiB audit-libs x86_64 0:4.2.1-2.fc45 fedora 390.5 KiB binutils x86_64 0:2.47-1.fc45 fedora 28.4 MiB build-reproducibility-srpm-macros noarch 0:0.7.3-3.fc45 fedora 1.2 KiB bzip2-libs x86_64 0:1.0.8-24.fc45 fedora 80.5 KiB ca-certificates noarch 0:2026.2.92_v9.0.319-2.fc45 fedora 2.7 MiB cmake-srpm-macros noarch 0:4.3.0-7.fc45 updates 524.0 B coreutils-common x86_64 0:9.11-6.fc45 fedora 10.9 MiB crypto-policies noarch 0:20260713-2.gitc42da77.fc45 fedora 134.3 KiB curl x86_64 0:8.23.0-1.fc45 copr_base 486.1 KiB cyrus-sasl-lib x86_64 0:2.1.28-37.fc45 fedora 2.3 MiB debugedit x86_64 0:5.4-1.fc45 updates 228.8 KiB dwz x86_64 0:0.17-3.fc45 fedora 291.1 KiB ed x86_64 0:1.22.6-1.fc45 fedora 150.9 KiB efi-srpm-macros noarch 0:6-9.fc45 fedora 40.3 KiB elfutils x86_64 0:0.197-1.fc45 updates 3.1 MiB elfutils-debuginfod-client x86_64 0:0.197-1.fc45 updates 79.9 KiB elfutils-libelf x86_64 0:0.197-1.fc45 updates 1.6 MiB elfutils-libs x86_64 0:0.197-1.fc45 updates 719.5 KiB erlang-srpm-macros noarch 0:0.4.2-1.fc45 updates 2.0 KiB fedora-gpg-keys noarch 0:45-1 fedora 130.3 KiB fedora-release noarch 0:45-14 updates 0.0 B fedora-release-identity-basic noarch 0:45-14 updates 629.0 B fedora-repos noarch 0:45-1 fedora 4.9 KiB file x86_64 0:5.48-3.fc45 copr_base 101.9 KiB file-libs x86_64 0:5.48-3.fc45 copr_base 12.3 MiB filesystem x86_64 0:3.18-59.fc45 fedora 112.0 B filesystem-srpm-macros noarch 0:3.18-59.fc45 fedora 38.2 KiB fips-provider x86_64 0:1.5.3-2.fc45 updates 4.8 MiB fonts-srpm-macros noarch 1:5.0.0-4.fc45 fedora 55.8 KiB forge-srpm-macros noarch 0:0.4.0-5.fc45 fedora 38.9 KiB fpc-srpm-macros noarch 0:1.3-17.fc45 fedora 144.0 B gap-srpm-macros noarch 0:2-3.fc45 fedora 2.1 KiB gdb-minimal x86_64 0:18.1-1.fc45 updates 14.4 MiB gdbm-libs x86_64 1:1.23-12.fc45 fedora 133.7 KiB ghc-srpm-macros noarch 0:1.10-2.fc45 fedora 792.0 B glibc x86_64 0:2.44-2.fc45 updates 7.1 MiB glibc-common x86_64 0:2.44-2.fc45 updates 1.0 MiB glibc-gconv-extra x86_64 0:2.44-2.fc45 updates 7.7 MiB gmp x86_64 1:6.3.0-6.fc45 fedora 815.2 KiB gnat-srpm-macros noarch 0:7-3.fc45 fedora 1.0 KiB gnome-srpm-macros noarch 0:1.0-2.fc45 fedora 3.5 KiB gnulib-l10n noarch 0:20241231-4.fc45 fedora 655.0 KiB gnupg2 x86_64 0:2.4.9-18.fc45 fedora 6.5 MiB gnupg2-dirmngr x86_64 0:2.4.9-18.fc45 fedora 630.1 KiB gnupg2-gpg-agent x86_64 0:2.4.9-18.fc45 fedora 678.8 KiB gnupg2-gpgconf x86_64 0:2.4.9-18.fc45 fedora 253.8 KiB gnupg2-keyboxd x86_64 0:2.4.9-18.fc45 fedora 201.3 KiB gnupg2-verify x86_64 0:2.4.9-18.fc45 fedora 356.3 KiB gnutls x86_64 0:3.8.13-3.fc45 fedora 3.8 MiB go-srpm-macros noarch 0:3.8.0-3.fc45 fedora 61.9 KiB gpgverify noarch 0:2.2-5.fc45 fedora 8.7 KiB ima-evm-utils-libs x86_64 0:1.6.2-12.fc45 fedora 56.6 KiB jansson x86_64 0:2.14-5.fc45 fedora 89.0 KiB java-srpm-macros noarch 0:1-9.fc45 fedora 870.0 B json-c x86_64 0:0.18-9.fc45 fedora 82.7 KiB kernel-srpm-macros noarch 0:1.0-30.fc45 fedora 1.9 KiB keyutils-libs x86_64 0:1.6.3-8.fc45 fedora 54.2 KiB krb5-libs x86_64 0:1.22.2-11.fc45 updates 2.4 MiB libacl x86_64 0:2.4.0-2.fc45 fedora 43.9 KiB libarchive x86_64 0:3.8.9-2.fc45 fedora 1.0 MiB libassuan x86_64 0:2.5.7-6.fc45 fedora 163.9 KiB libattr x86_64 0:2.6.0-2.fc45 fedora 24.3 KiB libblkid x86_64 0:2.42.4-1.fc45 fedora 282.3 KiB libbrotli x86_64 0:1.2.1-1.fc45 copr_base 865.0 KiB libcap x86_64 0:2.78-2.fc45 fedora 208.2 KiB libcap-ng x86_64 0:0.9.6-1.fc45 fedora 68.8 KiB libcbor x86_64 0:0.14.0-3.fc45 fedora 83.5 KiB libcom_err x86_64 0:1.47.4-2.fc45 fedora 63.0 KiB libcurl x86_64 0:8.23.0-1.fc45 copr_base 1.1 MiB libeconf x86_64 0:0.7.9-4.fc45 fedora 64.8 KiB libevent x86_64 0:2.1.13-1.fc45 fedora 980.7 KiB libfdisk x86_64 0:2.42.4-1.fc45 fedora 392.3 KiB libffi x86_64 0:3.5.2-3.fc45 fedora 83.7 KiB libfido2 x86_64 0:1.17.0-6.fc45 updates 256.5 KiB libfsverity x86_64 0:1.7-4.fc45 fedora 24.4 KiB libgcc x86_64 0:16.2.1-3.fc45 updates 270.7 KiB libgcrypt x86_64 0:1.12.2-2.fc45 fedora 1.7 MiB libgomp x86_64 0:16.2.1-3.fc45 updates 577.5 KiB libgpg-error x86_64 0:1.61-2.fc45 fedora 953.9 KiB libidn2 x86_64 0:2.3.8-4.fc45 fedora 556.4 KiB libksba x86_64 0:1.8.0-3.fc45 fedora 431.1 KiB liblastlog2 x86_64 0:2.42.4-1.fc45 fedora 37.6 KiB libmount x86_64 0:2.42.4-1.fc45 fedora 408.9 KiB libnghttp2 x86_64 0:1.69.0-6.fc45 fedora 166.1 KiB libnghttp3 x86_64 0:1.19.0-1.fc45 updates 163.4 KiB libpfm x86_64 0:4.14.1-2.fc45 copr_base 2.4 MiB libpkgconf x86_64 0:2.5.1-2.fc45 fedora 90.1 KiB libpsl x86_64 0:0.23.1-1.fc45 fedora 80.4 KiB libselinux x86_64 0:3.11-5.fc45 copr_base 205.2 KiB libselinux-utils x86_64 0:3.11-5.fc45 copr_base 306.0 KiB libsemanage x86_64 0:3.11-4.fc45 copr_base 320.6 KiB libsepol x86_64 0:3.11-2.fc45 fedora 866.1 KiB libsmartcols x86_64 0:2.42.4-1.fc45 fedora 188.5 KiB libssh x86_64 0:0.12.2-1.fc45 fedora 725.7 KiB libssh-config noarch 0:0.12.2-1.fc45 fedora 277.0 B libstdc++ x86_64 0:16.2.1-3.fc45 updates 3.1 MiB libtasn1 x86_64 0:4.21.0-2.fc45 fedora 176.6 KiB libtool-ltdl x86_64 0:2.5.4-11.fc45 fedora 70.0 KiB libunistring x86_64 0:1.1-12.fc45 fedora 1.7 MiB libusb1 x86_64 0:1.0.30-2.fc45 fedora 180.1 KiB libuuid x86_64 0:2.42.4-1.fc45 fedora 37.2 KiB libverto x86_64 0:0.3.2-13.fc45 fedora 25.3 KiB libxcrypt x86_64 0:4.5.2-4.fc45 fedora 293.2 KiB libxml2 x86_64 0:2.15.4-1.fc45 fedora 1.7 MiB libzstd x86_64 0:1.5.7-6.fc45 fedora 956.1 KiB linkdupes x86_64 0:0.7.3-3.fc45 fedora 782.1 KiB lua-libs x86_64 0:5.5.1-2.fc45 fedora 298.0 KiB lua-srpm-macros noarch 0:1-18.fc45 fedora 1.3 KiB lz4-libs x86_64 0:1.10.0-5.fc45 fedora 165.3 KiB meson-srpm-macros noarch 0:1.12.1-2.fc45 copr_base 1.7 KiB mpfr x86_64 0:4.2.2-4.fc45 fedora 849.2 KiB ncurses-base noarch 0:6.6-3.fc45 fedora 329.7 KiB ncurses-libs x86_64 0:6.6-3.fc45 fedora 969.1 KiB nettle x86_64 0:4.0-5.fc45 fedora 801.9 KiB ngtcp2 x86_64 0:1.22.1-3.fc45 fedora 334.3 KiB ngtcp2-crypto-ossl x86_64 0:1.22.1-3.fc45 fedora 51.6 KiB npth x86_64 0:1.8-5.fc45 fedora 49.5 KiB ocaml-srpm-macros noarch 0:11-4.fc45 fedora 1.9 KiB openblas-srpm-macros noarch 0:2-22.fc45 fedora 112.0 B openldap x86_64 0:2.6.16-1.fc45 updates 683.9 KiB openssl-libs x86_64 1:4.0.3-1.fc45 fedora 6.7 MiB p11-kit x86_64 0:0.26.5-1.fc45 fedora 2.6 MiB p11-kit-trust x86_64 0:0.26.5-1.fc45 fedora 478.4 KiB package-notes-srpm-macros noarch 0:0.20-2.fc45 fedora 1.6 KiB pam-libs x86_64 0:1.7.2-4.fc45 fedora 134.5 KiB pcre2 x86_64 0:10.49-1.fc45 updates 726.6 KiB pcre2-syntax noarch 0:10.49-1.fc45 updates 292.5 KiB perl-srpm-macros noarch 0:1-65.fc45 fedora 861.0 B pkgconf x86_64 0:2.5.1-2.fc45 fedora 92.7 KiB pkgconf-m4 noarch 0:2.5.1-2.fc45 fedora 14.3 KiB pkgconf-pkg-config x86_64 0:2.5.1-2.fc45 fedora 989.0 B policycoreutils x86_64 0:3.11-2.fc45 copr_base 892.9 KiB popt x86_64 0:1.19-11.fc45 fedora 136.7 KiB publicsuffix-list-dafsa noarch 0:20260624-2.fc45 fedora 71.3 KiB pyproject-srpm-macros noarch 0:1.24.0-1.fc45 copr_base 3.4 KiB python-srpm-macros noarch 0:3.15-2.fc45 fedora 51.6 KiB qt5-srpm-macros noarch 0:5.15.18-3.fc45 fedora 500.0 B qt6-srpm-macros noarch 0:6.11.2-1.fc45 fedora 472.0 B readline x86_64 0:8.3-6.fc45 fedora 515.5 KiB redhat-systemd-presets noarch 0:102-3.fc45 fedora 1.0 KiB redhat-systemd-presets-common noarch 0:102-3.fc45 fedora 16.9 KiB rpm x86_64 0:6.1.0-1.fc45 fedora 3.1 MiB rpm-build-libs x86_64 0:6.1.0-1.fc45 fedora 288.3 KiB rpm-libs x86_64 0:6.1.0-1.fc45 fedora 1.1 MiB rpm-plugin-selinux x86_64 0:6.1.0-1.fc45 fedora 11.9 KiB rpm-sequoia x86_64 0:1.10.3-1.fc45 fedora 2.4 MiB rpm-sign-libs x86_64 0:6.1.0-1.fc45 fedora 39.6 KiB rust-srpm-macros noarch 0:28.5-2.fc45 fedora 5.5 KiB selinux-policy noarch 0:45.24-1.fc45 updates 32.1 KiB selinux-policy-targeted noarch 0:45.24-1.fc45 updates 18.9 MiB setup noarch 0:2.15.1-2.fc45 fedora 725.6 KiB sqlite-libs x86_64 0:3.53.4-1.fc45 fedora 1.6 MiB systemd-libs x86_64 0:262.2-2.fc45 copr_base 2.8 MiB systemd-standalone-sysusers x86_64 0:262.2-2.fc45 copr_base 981.2 KiB tpm2-tss x86_64 0:4.2.1-1.fc45 updates 1.7 MiB tree-sitter-srpm-macros noarch 0:0.4.6-2.fc45 fedora 8.6 KiB util-linux-core x86_64 0:2.42.4-1.fc45 fedora 1.5 MiB xxhash-libs x86_64 0:0.8.4-2.fc45 updates 94.0 KiB xz-libs x86_64 1:5.8.3-2.fc45 fedora 221.7 KiB zig-srpm-macros noarch 0:1-9.fc45 fedora 1.3 KiB zip x86_64 0:3.0-46.fc45 fedora 694.1 KiB zlib-ng-compat x86_64 0:2.3.3-6.fc45 fedora 165.6 KiB zstd x86_64 0:1.5.7-6.fc45 fedora 502.6 KiB Installing groups: Buildsystem building group Transaction Summary: Installing: 189 packages Total size of inbound packages is 72 MiB. Need to download 72 MiB. After this operation, 234 MiB extra will be used (install 234 MiB, remove 0 B). [ 1/189] bzip2-0:1.0.8-24.fc45.x86_64 100% | 10.2 MiB/s | 52.3 KiB | 00m00s [ 2/189] cpio-0:2.15-10.fc45.x86_64 100% | 57.1 MiB/s | 292.5 KiB | 00m00s [ 3/189] coreutils-0:9.11-6.fc45.x86_6 100% | 119.9 MiB/s | 1.2 MiB | 00m00s [ 4/189] diffutils-0:3.12-6.fc45.x86_6 100% | 96.8 MiB/s | 396.6 KiB | 00m00s [ 5/189] findutils-1:4.11.0-2.fc45.x86 100% | 111.5 MiB/s | 570.7 KiB | 00m00s [ 6/189] bash-0:5.3.15-2.fc45.x86_64 100% | 118.2 MiB/s | 1.9 MiB | 00m00s [ 7/189] grep-0:3.12-4.fc45.x86_64 100% | 49.0 MiB/s | 301.0 KiB | 00m00s [ 8/189] gzip-0:1.14-4.fc45.x86_64 100% | 58.5 MiB/s | 179.6 KiB | 00m00s [ 9/189] info-0:7.3-3.fc45.x86_64 100% | 93.4 MiB/s | 191.2 KiB | 00m00s [ 10/189] patch-0:2.8-6.fc45.x86_64 100% | 55.9 MiB/s | 114.4 KiB | 00m00s [ 11/189] rpm-build-0:6.1.0-1.fc45.x86_ 100% | 77.2 MiB/s | 158.1 KiB | 00m00s [ 12/189] sed-0:4.10-2.fc45.x86_64 100% | 63.0 MiB/s | 322.8 KiB | 00m00s [ 13/189] unzip-0:6.0-71.fc45.x86_64 100% | 65.0 MiB/s | 199.6 KiB | 00m00s [ 14/189] tar-2:1.35-10.fc45.x86_64 100% | 94.4 MiB/s | 870.2 KiB | 00m00s [ 15/189] which-0:2.25-2.fc45.x86_64 100% | 41.2 MiB/s | 42.2 KiB | 00m00s [ 16/189] shadow-utils-2:4.20.0-2.fc45. 100% | 109.0 MiB/s | 1.4 MiB | 00m00s [ 17/189] fedora-release-common-0:45-14 100% | 8.6 MiB/s | 17.7 KiB | 00m00s [ 18/189] xz-1:5.8.3-2.fc45.x86_64 100% | 127.2 MiB/s | 651.2 KiB | 00m00s [ 19/189] glibc-minimal-langpack-0:2.44 100% | 40.4 MiB/s | 124.1 KiB | 00m00s [ 20/189] redhat-rpm-config-0:345-5.fc4 100% | 25.4 MiB/s | 78.1 KiB | 00m00s [ 21/189] gawk-0:5.4.1-1.fc45.x86_64 100% | 90.6 MiB/s | 1.2 MiB | 00m00s [ 22/189] util-linux-0:2.42.4-1.fc45.x8 100% | 105.4 MiB/s | 1.3 MiB | 00m00s [ 23/189] ncurses-libs-0:6.6-3.fc45.x86 100% | 83.9 MiB/s | 343.7 KiB | 00m00s [ 24/189] bzip2-libs-0:1.0.8-24.fc45.x8 100% | 21.2 MiB/s | 43.5 KiB | 00m00s [ 25/189] filesystem-0:3.18-59.fc45.x86 100% | 121.1 MiB/s | 1.8 MiB | 00m00s [ 26/189] gmp-1:6.3.0-6.fc45.x86_64 100% | 78.6 MiB/s | 321.8 KiB | 00m00s [ 27/189] libacl-0:2.4.0-2.fc45.x86_64 100% | 8.9 MiB/s | 27.5 KiB | 00m00s [ 28/189] libattr-0:2.6.0-2.fc45.x86_64 100% | 8.8 MiB/s | 18.1 KiB | 00m00s [ 29/189] libcap-0:2.78-2.fc45.x86_64 100% | 43.3 MiB/s | 88.6 KiB | 00m00s [ 30/189] coreutils-common-0:9.11-6.fc4 100% | 180.5 MiB/s | 2.2 MiB | 00m00s [ 31/189] ed-0:1.22.6-1.fc45.x86_64 100% | 16.7 MiB/s | 85.6 KiB | 00m00s [ 32/189] libarchive-0:3.8.9-2.fc45.x86 100% | 87.1 MiB/s | 446.0 KiB | 00m00s [ 33/189] popt-0:1.19-11.fc45.x86_64 100% | 16.2 MiB/s | 66.6 KiB | 00m00s [ 34/189] readline-0:8.3-6.fc45.x86_64 100% | 55.9 MiB/s | 228.8 KiB | 00m00s [ 35/189] rpm-0:6.1.0-1.fc45.x86_64 100% | 111.4 MiB/s | 570.4 KiB | 00m00s [ 36/189] openssl-libs-1:4.0.3-1.fc45.x 100% | 117.1 MiB/s | 2.3 MiB | 00m00s [ 37/189] rpm-build-libs-0:6.1.0-1.fc45 100% | 26.3 MiB/s | 134.8 KiB | 00m00s [ 38/189] rpm-libs-0:6.1.0-1.fc45.x86_6 100% | 116.4 MiB/s | 476.6 KiB | 00m00s [ 39/189] zstd-0:1.5.7-6.fc45.x86_64 100% | 93.6 MiB/s | 191.7 KiB | 00m00s [ 40/189] audit-libs-0:4.2.1-2.fc45.x86 100% | 46.6 MiB/s | 143.3 KiB | 00m00s [ 41/189] libeconf-0:0.7.9-4.fc45.x86_6 100% | 17.5 MiB/s | 35.9 KiB | 00m00s [ 42/189] libxcrypt-0:4.5.2-4.fc45.x86_ 100% | 63.9 MiB/s | 130.9 KiB | 00m00s [ 43/189] pam-libs-0:1.7.2-4.fc45.x86_6 100% | 28.5 MiB/s | 58.4 KiB | 00m00s [ 44/189] setup-0:2.15.1-2.fc45.noarch 100% | 77.0 MiB/s | 157.6 KiB | 00m00s [ 45/189] xz-libs-1:5.8.3-2.fc45.x86_64 100% | 56.7 MiB/s | 116.1 KiB | 00m00s [ 46/189] fedora-repos-0:45-1.noarch 100% | 9.2 MiB/s | 9.5 KiB | 00m00s [ 47/189] redhat-systemd-presets-0:102- 100% | 8.3 MiB/s | 8.5 KiB | 00m00s [ 48/189] mpfr-0:4.2.2-4.fc45.x86_64 100% | 116.4 MiB/s | 357.4 KiB | 00m00s [ 49/189] R-srpm-macros-0:1.3.7-3.fc45. 100% | 5.4 MiB/s | 11.1 KiB | 00m00s [ 50/189] glibc-common-0:2.44-2.fc45.x8 100% | 101.7 MiB/s | 416.5 KiB | 00m00s [ 51/189] ansible-srpm-macros-0:1-22.fc 100% | 9.7 MiB/s | 19.8 KiB | 00m00s [ 52/189] build-reproducibility-srpm-ma 100% | 5.3 MiB/s | 10.8 KiB | 00m00s [ 53/189] dwz-0:0.17-3.fc45.x86_64 100% | 68.0 MiB/s | 139.2 KiB | 00m00s [ 54/189] efi-srpm-macros-0:6-9.fc45.no 100% | 10.5 MiB/s | 21.4 KiB | 00m00s [ 55/189] filesystem-srpm-macros-0:3.18 100% | 12.9 MiB/s | 26.4 KiB | 00m00s [ 56/189] fonts-srpm-macros-1:5.0.0-4.f 100% | 26.5 MiB/s | 27.2 KiB | 00m00s [ 57/189] forge-srpm-macros-0:0.4.0-5.f 100% | 19.3 MiB/s | 19.7 KiB | 00m00s [ 58/189] fpc-srpm-macros-0:1.3-17.fc45 100% | 7.6 MiB/s | 7.8 KiB | 00m00s [ 59/189] gap-srpm-macros-0:2-3.fc45.no 100% | 9.1 MiB/s | 9.3 KiB | 00m00s [ 60/189] ghc-srpm-macros-0:1.10-2.fc45 100% | 8.3 MiB/s | 8.5 KiB | 00m00s [ 61/189] gnat-srpm-macros-0:7-3.fc45.n 100% | 8.4 MiB/s | 8.6 KiB | 00m00s [ 62/189] gnome-srpm-macros-0:1.0-2.fc4 100% | 4.3 MiB/s | 8.8 KiB | 00m00s [ 63/189] go-srpm-macros-0:3.8.0-3.fc45 100% | 13.6 MiB/s | 27.8 KiB | 00m00s [ 64/189] java-srpm-macros-0:1-9.fc45.n 100% | 4.0 MiB/s | 8.3 KiB | 00m00s [ 65/189] kernel-srpm-macros-0:1.0-30.f 100% | 8.1 MiB/s | 8.3 KiB | 00m00s [ 66/189] lua-srpm-macros-0:1-18.fc45.n 100% | 8.5 MiB/s | 8.7 KiB | 00m00s [ 67/189] ocaml-srpm-macros-0:11-4.fc45 100% | 4.4 MiB/s | 9.0 KiB | 00m00s [ 68/189] openblas-srpm-macros-0:2-22.f 100% | 7.3 MiB/s | 7.5 KiB | 00m00s [ 69/189] package-notes-srpm-macros-0:0 100% | 5.1 MiB/s | 10.5 KiB | 00m00s [ 70/189] perl-srpm-macros-0:1-65.fc45. 100% | 4.1 MiB/s | 8.4 KiB | 00m00s [ 71/189] python-srpm-macros-0:3.15-2.f 100% | 11.6 MiB/s | 23.9 KiB | 00m00s [ 72/189] qt5-srpm-macros-0:5.15.18-3.f 100% | 7.9 MiB/s | 8.1 KiB | 00m00s [ 73/189] qt6-srpm-macros-0:6.11.2-1.fc 100% | 4.4 MiB/s | 9.1 KiB | 00m00s [ 74/189] tree-sitter-srpm-macros-0:0.4 100% | 6.8 MiB/s | 14.0 KiB | 00m00s [ 75/189] rust-srpm-macros-0:28.5-2.fc4 100% | 2.8 MiB/s | 11.4 KiB | 00m00s [ 76/189] zig-srpm-macros-0:1-9.fc45.no 100% | 2.9 MiB/s | 8.8 KiB | 00m00s [ 77/189] libcap-ng-0:0.9.6-1.fc45.x86_ 100% | 17.0 MiB/s | 34.8 KiB | 00m00s [ 78/189] zip-0:3.0-46.fc45.x86_64 100% | 43.1 MiB/s | 264.6 KiB | 00m00s [ 79/189] libblkid-0:2.42.4-1.fc45.x86_ 100% | 26.2 MiB/s | 134.0 KiB | 00m00s [ 80/189] libfdisk-0:2.42.4-1.fc45.x86_ 100% | 82.8 MiB/s | 169.6 KiB | 00m00s [ 81/189] libmount-0:2.42.4-1.fc45.x86_ 100% | 58.4 MiB/s | 179.5 KiB | 00m00s [ 82/189] liblastlog2-0:2.42.4-1.fc45.x 100% | 6.1 MiB/s | 24.8 KiB | 00m00s [ 83/189] libsmartcols-0:2.42.4-1.fc45. 100% | 43.3 MiB/s | 88.6 KiB | 00m00s [ 84/189] libuuid-0:2.42.4-1.fc45.x86_6 100% | 13.5 MiB/s | 27.7 KiB | 00m00s [ 85/189] zlib-ng-compat-0:2.3.3-6.fc45 100% | 17.7 MiB/s | 90.4 KiB | 00m00s [ 86/189] util-linux-core-0:2.42.4-1.fc 100% | 94.9 MiB/s | 583.0 KiB | 00m00s [ 87/189] ncurses-base-0:6.6-3.fc45.noa 100% | 17.2 MiB/s | 88.1 KiB | 00m00s [ 88/189] gnulib-l10n-0:20241231-4.fc45 100% | 49.0 MiB/s | 150.4 KiB | 00m00s [ 89/189] crypto-policies-0:20260713-2. 100% | 31.7 MiB/s | 97.5 KiB | 00m00s [ 90/189] ca-certificates-0:2026.2.92_v 100% | 158.2 MiB/s | 972.1 KiB | 00m00s [ 91/189] libxml2-0:2.15.4-1.fc45.x86_6 100% | 132.2 MiB/s | 676.8 KiB | 00m00s [ 92/189] libzstd-0:1.5.7-6.fc45.x86_64 100% | 88.8 MiB/s | 363.9 KiB | 00m00s [ 93/189] lz4-libs-0:1.10.0-5.fc45.x86_ 100% | 39.3 MiB/s | 80.4 KiB | 00m00s [ 94/189] lua-libs-0:5.5.1-2.fc45.x86_6 100% | 70.4 MiB/s | 144.3 KiB | 00m00s [ 95/189] rpm-sign-libs-0:6.1.0-1.fc45. 100% | 13.2 MiB/s | 26.9 KiB | 00m00s [ 96/189] fedora-gpg-keys-0:45-1.noarch 100% | 46.8 MiB/s | 143.9 KiB | 00m00s [ 97/189] redhat-systemd-presets-common 100% | 6.5 MiB/s | 13.2 KiB | 00m00s [ 98/189] rpm-sequoia-0:1.10.3-1.fc45.x 100% | 101.7 MiB/s | 937.1 KiB | 00m00s [ 99/189] sqlite-libs-0:3.53.4-1.fc45.x 100% | 88.1 MiB/s | 812.1 KiB | 00m00s [100/189] linkdupes-0:0.7.3-3.fc45.x86_ 100% | 110.4 MiB/s | 339.2 KiB | 00m00s [101/189] add-determinism-0:0.7.3-3.fc4 100% | 103.2 MiB/s | 845.7 KiB | 00m00s [102/189] ima-evm-utils-libs-0:1.6.2-12 100% | 7.4 MiB/s | 30.2 KiB | 00m00s [103/189] gnupg2-0:2.4.9-18.fc45.x86_64 100% | 183.5 MiB/s | 1.7 MiB | 00m00s [104/189] libfsverity-0:1.7-4.fc45.x86_ 100% | 6.2 MiB/s | 19.0 KiB | 00m00s [105/189] gpgverify-0:2.2-5.fc45.noarch 100% | 2.2 MiB/s | 11.3 KiB | 00m00s [106/189] glibc-0:2.44-2.fc45.x86_64 100% | 205.1 MiB/s | 2.5 MiB | 00m00s [107/189] gnupg2-dirmngr-0:2.4.9-18.fc4 100% | 25.0 MiB/s | 281.6 KiB | 00m00s [108/189] gnupg2-gpg-agent-0:2.4.9-18.f 100% | 45.8 MiB/s | 281.3 KiB | 00m00s [109/189] gnupg2-gpgconf-0:2.4.9-18.fc4 100% | 56.9 MiB/s | 116.5 KiB | 00m00s [110/189] gnupg2-keyboxd-0:2.4.9-18.fc4 100% | 47.2 MiB/s | 96.6 KiB | 00m00s [111/189] gnupg2-verify-0:2.4.9-18.fc45 100% | 57.3 MiB/s | 176.1 KiB | 00m00s [112/189] libassuan-0:2.5.7-6.fc45.x86_ 100% | 33.5 MiB/s | 68.5 KiB | 00m00s [113/189] npth-0:1.8-5.fc45.x86_64 100% | 12.4 MiB/s | 25.5 KiB | 00m00s [114/189] libgcrypt-0:1.12.2-2.fc45.x86 100% | 122.9 MiB/s | 629.0 KiB | 00m00s [115/189] libgpg-error-0:1.61-2.fc45.x8 100% | 41.2 MiB/s | 252.9 KiB | 00m00s [116/189] libksba-0:1.8.0-3.fc45.x86_64 100% | 42.0 MiB/s | 172.2 KiB | 00m00s [117/189] glibc-gconv-extra-0:2.44-2.fc 100% | 141.6 MiB/s | 1.7 MiB | 00m00s [118/189] gnutls-0:3.8.13-3.fc45.x86_64 100% | 129.3 MiB/s | 1.4 MiB | 00m00s [119/189] libidn2-0:2.3.8-4.fc45.x86_64 100% | 34.2 MiB/s | 175.2 KiB | 00m00s [120/189] libtasn1-0:4.21.0-2.fc45.x86_ 100% | 14.8 MiB/s | 75.9 KiB | 00m00s [121/189] libunistring-0:1.1-12.fc45.x8 100% | 133.2 MiB/s | 545.8 KiB | 00m00s [122/189] nettle-0:4.0-5.fc45.x86_64 100% | 83.9 MiB/s | 429.7 KiB | 00m00s [123/189] libffi-0:3.5.2-3.fc45.x86_64 100% | 40.9 MiB/s | 41.9 KiB | 00m00s [124/189] p11-kit-0:0.26.5-1.fc45.x86_6 100% | 136.7 MiB/s | 560.0 KiB | 00m00s [125/189] libgcc-0:16.2.1-3.fc45.x86_64 100% | 68.1 MiB/s | 139.6 KiB | 00m00s [126/189] libstdc++-0:16.2.1-3.fc45.x86 100% | 167.3 MiB/s | 1.0 MiB | 00m00s [127/189] libsepol-0:3.11-2.fc45.x86_64 100% | 71.3 MiB/s | 365.2 KiB | 00m00s [128/189] libsemanage-0:3.11-4.fc45.x86 100% | 288.4 KiB/s | 130.4 KiB | 00m00s [129/189] elfutils-libelf-0:0.197-1.fc4 100% | 64.9 MiB/s | 265.9 KiB | 00m00s [130/189] elfutils-libs-0:0.197-1.fc45. 100% | 93.0 MiB/s | 285.6 KiB | 00m00s [131/189] elfutils-0:0.197-1.fc45.x86_6 100% | 152.7 MiB/s | 625.4 KiB | 00m00s [132/189] libselinux-0:3.11-5.fc45.x86_ 100% | 219.1 KiB/s | 104.1 KiB | 00m00s [133/189] elfutils-debuginfod-client-0: 100% | 23.1 MiB/s | 47.4 KiB | 00m00s [134/189] json-c-0:0.18-9.fc45.x86_64 100% | 22.8 MiB/s | 46.7 KiB | 00m00s [135/189] libgomp-0:16.2.1-3.fc45.x86_6 100% | 130.5 MiB/s | 400.8 KiB | 00m00s [136/189] debugedit-0:5.4-1.fc45.x86_64 100% | 85.9 MiB/s | 87.9 KiB | 00m00s [137/189] binutils-0:2.47-1.fc45.x86_64 100% | 223.0 MiB/s | 6.2 MiB | 00m00s [138/189] alternatives-0:1.33-6.fc45.x8 100% | 38.5 MiB/s | 39.4 KiB | 00m00s [139/189] jansson-0:2.14-5.fc45.x86_64 100% | 45.8 MiB/s | 46.9 KiB | 00m00s [140/189] systemd-libs-0:262.2-2.fc45.x 100% | 1.7 MiB/s | 964.8 KiB | 00m01s [141/189] pkgconf-pkg-config-0:2.5.1-2. 100% | 4.6 MiB/s | 9.5 KiB | 00m00s [142/189] pkgconf-0:2.5.1-2.fc45.x86_64 100% | 47.8 MiB/s | 49.0 KiB | 00m00s [143/189] pkgconf-m4-0:2.5.1-2.fc45.noa 100% | 13.5 MiB/s | 13.8 KiB | 00m00s [144/189] libpkgconf-0:2.5.1-2.fc45.x86 100% | 41.6 MiB/s | 42.6 KiB | 00m00s [145/189] file-0:5.48-3.fc45.x86_64 100% | 161.6 KiB/s | 50.6 KiB | 00m00s [146/189] fips-provider-0:1.5.3-2.fc45. 100% | 202.2 MiB/s | 1.6 MiB | 00m00s [147/189] tpm2-tss-0:4.2.1-1.fc45.x86_6 100% | 149.3 MiB/s | 458.6 KiB | 00m00s [148/189] libusb1-0:1.0.30-2.fc45.x86_6 100% | 40.9 MiB/s | 83.8 KiB | 00m00s [149/189] pcre2-0:10.49-1.fc45.x86_64 100% | 136.7 MiB/s | 280.0 KiB | 00m00s [150/189] pcre2-syntax-0:10.49-1.fc45.n 100% | 82.1 MiB/s | 168.2 KiB | 00m00s [151/189] p11-kit-trust-0:0.26.5-1.fc45 100% | 71.4 MiB/s | 146.3 KiB | 00m00s [152/189] openldap-0:2.6.16-1.fc45.x86_ 100% | 89.0 MiB/s | 273.4 KiB | 00m00s [153/189] cyrus-sasl-lib-0:2.1.28-37.fc 100% | 199.7 MiB/s | 817.8 KiB | 00m00s [154/189] libevent-0:2.1.13-1.fc45.x86_ 100% | 141.3 MiB/s | 289.3 KiB | 00m00s [155/189] libtool-ltdl-0:2.5.4-11.fc45. 100% | 35.9 MiB/s | 36.7 KiB | 00m00s [156/189] gdbm-libs-1:1.23-12.fc45.x86_ 100% | 28.4 MiB/s | 58.2 KiB | 00m00s [157/189] cmake-srpm-macros-0:4.3.0-7.f 100% | 10.1 MiB/s | 10.3 KiB | 00m00s [158/189] erlang-srpm-macros-0:0.4.2-1. 100% | 9.8 MiB/s | 10.0 KiB | 00m00s [159/189] curl-0:8.23.0-1.fc45.x86_64 100% | 742.7 KiB/s | 245.1 KiB | 00m00s [160/189] file-libs-0:5.48-3.fc45.x86_6 100% | 2.1 MiB/s | 885.0 KiB | 00m00s [161/189] libpfm-0:4.14.1-2.fc45.x86_64 100% | 916.9 KiB/s | 277.8 KiB | 00m00s [162/189] fedora-release-0:45-14.noarch 100% | 5.7 MiB/s | 11.8 KiB | 00m00s [163/189] meson-srpm-macros-0:1.12.1-2. 100% | 32.8 KiB/s | 11.8 KiB | 00m00s [164/189] gdb-minimal-0:18.1-1.fc45.x86 100% | 240.2 MiB/s | 4.8 MiB | 00m00s [165/189] pyproject-srpm-macros-0:1.24. 100% | 41.6 KiB/s | 15.3 KiB | 00m00s [166/189] selinux-policy-0:45.24-1.fc45 100% | 21.7 MiB/s | 44.4 KiB | 00m00s [167/189] rpm-plugin-selinux-0:6.1.0-1. 100% | 8.7 MiB/s | 17.8 KiB | 00m00s [168/189] selinux-policy-targeted-0:45. 100% | 200.8 MiB/s | 6.8 MiB | 00m00s [169/189] xxhash-libs-0:0.8.4-2.fc45.x8 100% | 20.1 MiB/s | 41.3 KiB | 00m00s [170/189] fedora-release-identity-basic 100% | 6.1 MiB/s | 12.5 KiB | 00m00s [171/189] systemd-standalone-sysusers-0 100% | 1.2 MiB/s | 435.3 KiB | 00m00s [172/189] libnghttp2-0:1.69.0-6.fc45.x8 100% | 37.7 MiB/s | 77.2 KiB | 00m00s [173/189] libpsl-0:0.23.1-1.fc45.x86_64 100% | 33.0 MiB/s | 67.6 KiB | 00m00s [174/189] libssh-0:0.12.2-1.fc45.x86_64 100% | 96.3 MiB/s | 295.9 KiB | 00m00s [175/189] ngtcp2-0:1.22.1-3.fc45.x86_64 100% | 77.0 MiB/s | 157.7 KiB | 00m00s [176/189] ngtcp2-crypto-ossl-0:1.22.1-3 100% | 27.2 MiB/s | 27.8 KiB | 00m00s [177/189] publicsuffix-list-dafsa-0:202 100% | 59.6 MiB/s | 61.1 KiB | 00m00s [178/189] libssh-config-0:0.12.2-1.fc45 100% | 8.7 MiB/s | 8.9 KiB | 00m00s [179/189] policycoreutils-0:3.11-2.fc45 100% | 631.6 KiB/s | 236.9 KiB | 00m00s [180/189] krb5-libs-0:1.22.2-11.fc45.x8 100% | 130.8 MiB/s | 803.7 KiB | 00m00s [181/189] keyutils-libs-0:1.6.3-8.fc45. 100% | 15.4 MiB/s | 31.5 KiB | 00m00s [182/189] libcom_err-0:1.47.4-2.fc45.x8 100% | 26.0 MiB/s | 26.6 KiB | 00m00s [183/189] libverto-0:0.3.2-13.fc45.x86_ 100% | 20.5 MiB/s | 21.0 KiB | 00m00s [184/189] libnghttp3-0:1.19.0-1.fc45.x8 100% | 36.8 MiB/s | 75.3 KiB | 00m00s [185/189] libcurl-0:8.23.0-1.fc45.x86_6 100% | 1.3 MiB/s | 497.3 KiB | 00m00s [186/189] libfido2-0:1.17.0-6.fc45.x86_ 100% | 34.8 MiB/s | 107.0 KiB | 00m00s [187/189] libcbor-0:0.14.0-3.fc45.x86_6 100% | 35.9 MiB/s | 36.8 KiB | 00m00s [188/189] libselinux-utils-0:3.11-5.fc4 100% | 307.7 KiB/s | 114.2 KiB | 00m00s [189/189] libbrotli-0:1.2.1-1.fc45.x86_ 100% | 901.7 KiB/s | 347.1 KiB | 00m00s -------------------------------------------------------------------------------- [189/189] Total 100% | 29.8 MiB/s | 72.4 MiB | 00m02s Running transaction Importing OpenPGP key 0xF577861E: UserID : "Fedora (45) " Fingerprint: 4F50A6114CD5C6976A7F1179655A4B02F577861E From : file:///usr/share/distribution-gpg-keys/fedora/RPM-GPG-KEY-fedora-45-primary The key was successfully imported. [ 1/191] Verify package files 100% | 623.0 B/s | 189.0 B | 00m00s >>> Running %pretrans scriptlet: filesystem-0:3.18-59.fc45.x86_64 >>> Finished %pretrans scriptlet: filesystem-0:3.18-59.fc45.x86_64 >>> [RPM] /var/lib/mock/fedora-45-x86_64-1794743501.743658/root/var/cache/dnf/copr_base-c274f0beff99c177/packages/systemd-libs-262.2-2.fc45.x86_64.rpm: Header OpenPGP V4 RSA/SHA256 signature, key ID 5cb33c8fabc04a02: NOKEY >>> [RPM] failed to open /var/lib/mock/fedora-45-x86_64-1794743501.743658/root/etc/group for id/name lookup: No such file or directory [ 2/191] Prepare transaction 100% | 2.4 KiB/s | 189.0 B | 00m00s [ 3/191] Installing libgcc-0:16.2.1-3. 100% | 265.9 MiB/s | 272.3 KiB | 00m00s [ 4/191] Installing redhat-systemd-pre 100% | 0.0 B/s | 1.5 KiB | 00m00s [ 5/191] Installing redhat-systemd-pre 100% | 0.0 B/s | 18.1 KiB | 00m00s [ 6/191] Installing libssh-config-0:0. 100% | 0.0 B/s | 816.0 B | 00m00s [ 7/191] Installing publicsuffix-list- 100% | 0.0 B/s | 72.0 KiB | 00m00s [ 8/191] Installing fedora-release-ide 100% | 867.2 KiB/s | 888.0 B | 00m00s [ 9/191] Installing fedora-gpg-keys-0: 100% | 29.6 MiB/s | 181.7 KiB | 00m00s [ 10/191] Installing fedora-repos-0:45- 100% | 0.0 B/s | 5.9 KiB | 00m00s [ 11/191] Installing fedora-release-com 100% | 7.2 MiB/s | 7.4 KiB | 00m00s [ 12/191] Installing fedora-release-0:4 100% | 9.3 KiB/s | 124.0 B | 00m00s >>> Running sysusers scriptlet: setup-0:2.15.1-2.fc45.noarch >>> Finished sysusers scriptlet: setup-0:2.15.1-2.fc45.noarch >>> Scriptlet output: >>> Creating group 'adm' with GID 4. >>> Creating group 'audio' with GID 63. >>> Creating group 'cdrom' with GID 11. >>> Creating group 'clock' with GID 103. >>> Creating group 'dialout' with GID 18. >>> Creating group 'disk' with GID 6. >>> Creating group 'floppy' with GID 19. >>> Creating group 'ftp' with GID 50. >>> Creating group 'games' with GID 20. >>> Creating group 'input' with GID 104. >>> Creating group 'kmem' with GID 9. >>> Creating group 'kvm' with GID 36. >>> Creating group 'lock' with GID 54. >>> Creating group 'lp' with GID 7. >>> Creating group 'mail' with GID 12. >>> Creating group 'man' with GID 15. >>> Creating group 'mem' with GID 8. >>> Creating group 'nobody' with GID 65534. >>> Creating group 'render' with GID 105. >>> Creating group 'root' with GID 0. >>> Creating group 'sgx' with GID 106. >>> Creating group 'sys' with GID 3. >>> Creating group 'tape' with GID 33. >>> Creating group 'tty' with GID 5. >>> Creating group 'users' with GID 100. >>> Creating group 'utmp' with GID 22. >>> Creating group 'video' with GID 39. >>> Creating group 'wheel' with GID 10. >>> Creating user 'adm' (adm) with UID 3 and GID 4. >>> Creating group 'bin' with GID 1. >>> Creating user 'bin' (bin) with UID 1 and GID 1. >>> Creating group 'daemon' with GID 2. >>> Creating user 'daemon' (daemon) with UID 2 and GID 2. >>> Creating user 'ftp' (FTP User) with UID 14 and GID 50. >>> Creating user 'games' (games) with UID 12 and GID 100. >>> Creating user 'halt' (halt) with UID 7 and GID 0. >>> Creating user 'lp' (lp) with UID 4 and GID 7. >>> Creating user 'mail' (mail) with UID 8 and GID 12. >>> Creating user 'nobody' (Kernel Overflow User) with UID 65534 and GID 65534. >>> Creating user 'operator' (operator) with UID 11 and GID 0. >>> Creating user 'root' (Super User) with UID 0 and GID 0. >>> Creating user 'shutdown' (shutdown) with UID 6 and GID 0. >>> Creating user 'sync' (sync) with UID 5 and GID 0. >>> [ 13/191] Installing setup-0:2.15.1-2.f 100% | 34.0 MiB/s | 731.3 KiB | 00m00s >>> [RPM] /etc/hosts created as /etc/hosts.rpmnew [ 14/191] Installing filesystem-0:3.18- 100% | 1.9 MiB/s | 253.6 KiB | 00m00s [ 15/191] Installing meson-srpm-macros- 100% | 0.0 B/s | 1.9 KiB | 00m00s [ 16/191] Installing pcre2-syntax-0:10. 100% | 288.1 MiB/s | 295.0 KiB | 00m00s [ 17/191] Installing pkgconf-m4-0:2.5.1 100% | 0.0 B/s | 14.7 KiB | 00m00s [ 18/191] Installing gnulib-l10n-0:2024 100% | 161.6 MiB/s | 661.9 KiB | 00m00s [ 19/191] Installing coreutils-common-0 100% | 313.1 MiB/s | 11.0 MiB | 00m00s [ 20/191] Installing ncurses-base-0:6.6 100% | 69.4 MiB/s | 355.3 KiB | 00m00s [ 21/191] Installing bash-0:5.3.15-2.fc 100% | 211.8 MiB/s | 8.5 MiB | 00m00s [ 22/191] Installing glibc-common-0:2.4 100% | 44.8 MiB/s | 1.0 MiB | 00m00s [ 23/191] Installing glibc-gconv-extra- 100% | 222.4 MiB/s | 7.8 MiB | 00m00s [ 24/191] Installing glibc-0:2.44-2.fc4 100% | 155.5 MiB/s | 7.2 MiB | 00m00s [ 25/191] Installing ncurses-libs-0:6.6 100% | 190.4 MiB/s | 974.9 KiB | 00m00s [ 26/191] Installing glibc-minimal-lang 100% | 0.0 B/s | 124.0 B | 00m00s [ 27/191] Installing zlib-ng-compat-0:2 100% | 162.5 MiB/s | 166.4 KiB | 00m00s [ 28/191] Installing bzip2-libs-0:1.0.8 100% | 79.7 MiB/s | 81.6 KiB | 00m00s [ 29/191] Installing libgpg-error-0:1.6 100% | 44.6 MiB/s | 959.7 KiB | 00m00s [ 30/191] Installing libstdc++-0:16.2.1 100% | 309.0 MiB/s | 3.1 MiB | 00m00s [ 31/191] Installing readline-0:8.3-6.f 100% | 252.8 MiB/s | 517.7 KiB | 00m00s [ 32/191] Installing libzstd-0:1.5.7-6. 100% | 233.7 MiB/s | 957.4 KiB | 00m00s [ 33/191] Installing elfutils-libelf-0: 100% | 327.2 MiB/s | 1.6 MiB | 00m00s [ 34/191] Installing libassuan-0:2.5.7- 100% | 161.8 MiB/s | 165.7 KiB | 00m00s [ 35/191] Installing libgcrypt-0:1.12.2 100% | 332.5 MiB/s | 1.7 MiB | 00m00s [ 36/191] Installing gmp-1:6.3.0-6.fc45 100% | 266.1 MiB/s | 817.4 KiB | 00m00s [ 37/191] Installing libacl-0:2.4.0-2.f 100% | 0.0 B/s | 44.7 KiB | 00m00s [ 38/191] Installing libuuid-0:2.42.4-1 100% | 37.3 MiB/s | 38.2 KiB | 00m00s [ 39/191] Installing systemd-libs-0:262 100% | 307.8 MiB/s | 2.8 MiB | 00m00s [ 40/191] Installing popt-0:1.19-11.fc4 100% | 70.0 MiB/s | 143.3 KiB | 00m00s [ 41/191] Installing xz-libs-1:5.8.3-2. 100% | 217.6 MiB/s | 222.8 KiB | 00m00s [ 42/191] Installing sqlite-libs-0:3.53 100% | 269.8 MiB/s | 1.6 MiB | 00m00s [ 43/191] Installing npth-0:1.8-5.fc45. 100% | 49.4 MiB/s | 50.6 KiB | 00m00s [ 44/191] Installing elfutils-libs-0:0. 100% | 234.8 MiB/s | 721.4 KiB | 00m00s [ 45/191] Installing libblkid-0:2.42.4- 100% | 276.6 MiB/s | 283.3 KiB | 00m00s [ 46/191] Installing libsepol-0:3.11-2. 100% | 282.3 MiB/s | 867.1 KiB | 00m00s [ 47/191] Installing gnupg2-gpgconf-0:2 100% | 13.9 MiB/s | 255.9 KiB | 00m00s [ 48/191] Installing libxcrypt-0:4.5.2- 100% | 144.5 MiB/s | 295.9 KiB | 00m00s [ 49/191] Installing libtasn1-0:4.21.0- 100% | 174.3 MiB/s | 178.5 KiB | 00m00s [ 50/191] Installing libunistring-0:1.1 100% | 289.1 MiB/s | 1.7 MiB | 00m00s [ 51/191] Installing libidn2-0:2.3.8-4. 100% | 137.3 MiB/s | 562.6 KiB | 00m00s [ 52/191] Installing json-c-0:0.18-9.fc 100% | 82.0 MiB/s | 83.9 KiB | 00m00s [ 53/191] Installing pcre2-0:10.49-1.fc 100% | 355.5 MiB/s | 728.0 KiB | 00m00s [ 54/191] Installing libselinux-0:3.11- 100% | 201.6 MiB/s | 206.5 KiB | 00m00s [ 55/191] Installing grep-0:3.12-4.fc45 100% | 45.6 MiB/s | 1.0 MiB | 00m00s [ 56/191] Installing sed-0:4.10-2.fc45. 100% | 38.8 MiB/s | 874.9 KiB | 00m00s [ 57/191] Installing findutils-1:4.11.0 100% | 54.4 MiB/s | 2.0 MiB | 00m00s [ 58/191] Installing crypto-policies-0: 100% | 26.0 MiB/s | 159.5 KiB | 00m00s [ 59/191] Installing xz-1:5.8.3-2.fc45. 100% | 54.0 MiB/s | 1.4 MiB | 00m00s [ 60/191] Installing libmount-0:2.42.4- 100% | 200.1 MiB/s | 409.9 KiB | 00m00s [ 61/191] Installing gnupg2-verify-0:2. 100% | 19.4 MiB/s | 357.7 KiB | 00m00s [ 62/191] Installing mpfr-0:4.2.2-4.fc4 100% | 207.7 MiB/s | 850.9 KiB | 00m00s [ 63/191] Installing gawk-0:5.4.1-1.fc4 100% | 89.1 MiB/s | 2.2 MiB | 00m00s [ 64/191] Installing dwz-0:0.17-3.fc45. 100% | 15.9 MiB/s | 292.5 KiB | 00m00s [ 65/191] Installing libksba-0:1.8.0-3. 100% | 211.8 MiB/s | 433.7 KiB | 00m00s [ 66/191] Installing unzip-0:6.0-71.fc4 100% | 24.2 MiB/s | 445.3 KiB | 00m00s [ 67/191] Installing file-libs-0:5.48-3 100% | 587.8 MiB/s | 12.3 MiB | 00m00s [ 68/191] Installing file-0:5.48-3.fc45 100% | 5.9 MiB/s | 103.4 KiB | 00m00s [ 69/191] Installing diffutils-0:3.12-6 100% | 68.0 MiB/s | 1.6 MiB | 00m00s [ 70/191] Installing libattr-0:2.6.0-2. 100% | 24.7 MiB/s | 25.2 KiB | 00m00s [ 71/191] Installing libeconf-0:0.7.9-4 100% | 64.9 MiB/s | 66.4 KiB | 00m00s [ 72/191] Installing libcap-ng-0:0.9.6- 100% | 69.0 MiB/s | 70.6 KiB | 00m00s [ 73/191] Installing audit-libs-0:4.2.1 100% | 191.9 MiB/s | 393.1 KiB | 00m00s [ 74/191] Installing pam-libs-0:1.7.2-4 100% | 133.7 MiB/s | 136.9 KiB | 00m00s [ 75/191] Installing libcap-0:2.78-2.fc 100% | 11.0 MiB/s | 213.3 KiB | 00m00s [ 76/191] Installing libsemanage-0:3.11 100% | 157.4 MiB/s | 322.4 KiB | 00m00s [ 77/191] Installing libsmartcols-0:2.4 100% | 185.0 MiB/s | 189.5 KiB | 00m00s [ 78/191] Installing lua-libs-0:5.5.1-2 100% | 146.2 MiB/s | 299.5 KiB | 00m00s [ 79/191] Installing libffi-0:3.5.2-3.f 100% | 83.1 MiB/s | 85.1 KiB | 00m00s [ 80/191] Installing p11-kit-0:0.26.5-1 100% | 94.1 MiB/s | 2.6 MiB | 00m00s [ 81/191] Installing alternatives-0:1.3 100% | 3.7 MiB/s | 63.6 KiB | 00m00s [ 82/191] Installing p11-kit-trust-0:0. 100% | 14.7 MiB/s | 480.1 KiB | 00m00s [ 83/191] Installing ngtcp2-0:1.22.1-3. 100% | 164.0 MiB/s | 335.8 KiB | 00m00s [ 84/191] Installing util-linux-core-0: 100% | 58.2 MiB/s | 1.5 MiB | 00m00s [ 85/191] Installing liblastlog2-0:2.42 100% | 3.0 MiB/s | 39.7 KiB | 00m00s [ 86/191] Installing zip-0:3.0-46.fc45. 100% | 32.5 MiB/s | 698.0 KiB | 00m00s [ 87/191] Installing gnupg2-keyboxd-0:2 100% | 14.1 MiB/s | 202.5 KiB | 00m00s [ 88/191] Installing tar-2:1.35-10.fc45 100% | 102.7 MiB/s | 3.0 MiB | 00m00s [ 89/191] Installing linkdupes-0:0.7.3- 100% | 40.3 MiB/s | 783.5 KiB | 00m00s [ 90/191] Installing libselinux-utils-0 100% | 16.5 MiB/s | 320.3 KiB | 00m00s [ 91/191] Installing libpsl-0:0.23.1-1. 100% | 79.6 MiB/s | 81.5 KiB | 00m00s [ 92/191] Installing libfdisk-0:2.42.4- 100% | 192.0 MiB/s | 393.2 KiB | 00m00s [ 93/191] Installing fips-provider-0:1. 100% | 344.9 MiB/s | 4.8 MiB | 00m00s [ 94/191] Installing openssl-libs-1:4.0 100% | 335.0 MiB/s | 6.7 MiB | 00m00s [ 95/191] Installing coreutils-0:9.11-6 100% | 120.9 MiB/s | 5.9 MiB | 00m00s [ 96/191] Installing ca-certificates-0: 100% | 1.6 MiB/s | 2.5 MiB | 00m02s [ 97/191] Installing gzip-0:1.14-4.fc45 100% | 18.9 MiB/s | 407.2 KiB | 00m00s [ 98/191] Installing util-linux-0:2.42. 100% | 72.2 MiB/s | 3.8 MiB | 00m00s [ 99/191] Installing policycoreutils-0: 100% | 23.1 MiB/s | 921.4 KiB | 00m00s [100/191] Installing selinux-policy-0:4 100% | 863.4 KiB/s | 34.5 KiB | 00m00s [101/191] Installing selinux-policy-tar 100% | 141.2 MiB/s | 15.1 MiB | 00m00s [102/191] Installing rpm-sequoia-0:1.10 100% | 270.6 MiB/s | 2.4 MiB | 00m00s [103/191] Installing libfsverity-0:1.7- 100% | 24.8 MiB/s | 25.4 KiB | 00m00s [104/191] Installing libevent-0:2.1.13- 100% | 320.5 MiB/s | 984.5 KiB | 00m00s [105/191] Installing ngtcp2-crypto-ossl 100% | 0.0 B/s | 52.5 KiB | 00m00s [106/191] Installing libusb1-0:1.0.30-2 100% | 8.9 MiB/s | 181.8 KiB | 00m00s >>> Running sysusers scriptlet: tpm2-tss-0:4.2.1-1.fc45.x86_64 >>> Finished sysusers scriptlet: tpm2-tss-0:4.2.1-1.fc45.x86_64 >>> Scriptlet output: >>> Creating group 'tss' with GID 59. >>> Creating user 'tss' (Account used for TPM access) with UID 59 and GID 59. >>> [107/191] Installing tpm2-tss-0:4.2.1-1 100% | 239.0 MiB/s | 1.7 MiB | 00m00s [108/191] Installing ima-evm-utils-libs 100% | 56.5 MiB/s | 57.9 KiB | 00m00s [109/191] Installing gnupg2-gpg-agent-0 100% | 20.2 MiB/s | 682.8 KiB | 00m00s [110/191] Installing nettle-0:4.0-5.fc4 100% | 196.5 MiB/s | 805.0 KiB | 00m00s [111/191] Installing gnutls-0:3.8.13-3. 100% | 295.2 MiB/s | 3.8 MiB | 00m00s [112/191] Installing zstd-0:1.5.7-6.fc4 100% | 24.7 MiB/s | 506.1 KiB | 00m00s [113/191] Installing libxml2-0:2.15.4-1 100% | 71.9 MiB/s | 1.7 MiB | 00m00s [114/191] Installing bzip2-0:1.0.8-24.f 100% | 5.4 MiB/s | 99.5 KiB | 00m00s [115/191] Installing add-determinism-0: 100% | 90.0 MiB/s | 2.2 MiB | 00m00s [116/191] Installing build-reproducibil 100% | 0.0 B/s | 1.5 KiB | 00m00s [117/191] Installing cpio-0:2.15-10.fc4 100% | 52.5 MiB/s | 1.1 MiB | 00m00s [118/191] Installing ed-0:1.22.6-1.fc45 100% | 8.3 MiB/s | 153.2 KiB | 00m00s [119/191] Installing patch-0:2.8-6.fc45 100% | 12.4 MiB/s | 228.1 KiB | 00m00s [120/191] Installing lz4-libs-0:1.10.0- 100% | 162.5 MiB/s | 166.4 KiB | 00m00s [121/191] Installing libarchive-0:3.8.9 100% | 245.5 MiB/s | 1.0 MiB | 00m00s [122/191] Installing libgomp-0:16.2.1-3 100% | 282.7 MiB/s | 578.9 KiB | 00m00s [123/191] Installing jansson-0:2.14-5.f 100% | 88.2 MiB/s | 90.3 KiB | 00m00s [124/191] Installing libpkgconf-0:2.5.1 100% | 89.1 MiB/s | 91.3 KiB | 00m00s [125/191] Installing pkgconf-0:2.5.1-2. 100% | 5.5 MiB/s | 95.2 KiB | 00m00s [126/191] Installing pkgconf-pkg-config 100% | 104.3 KiB/s | 1.8 KiB | 00m00s [127/191] Installing libtool-ltdl-0:2.5 100% | 69.5 MiB/s | 71.1 KiB | 00m00s [128/191] Installing gdbm-libs-1:1.23-1 100% | 132.2 MiB/s | 135.4 KiB | 00m00s [129/191] Installing cyrus-sasl-lib-0:2 100% | 97.4 MiB/s | 2.3 MiB | 00m00s [130/191] Installing openldap-0:2.6.16- 100% | 167.9 MiB/s | 687.7 KiB | 00m00s [131/191] Installing gnupg2-dirmngr-0:2 100% | 21.3 MiB/s | 632.8 KiB | 00m00s [132/191] Installing gnupg2-0:2.4.9-18. 100% | 166.7 MiB/s | 6.5 MiB | 00m00s [133/191] Installing gpgverify-0:2.2-5. 100% | 0.0 B/s | 9.4 KiB | 00m00s [134/191] Installing libpfm-0:4.14.1-2. 100% | 474.4 MiB/s | 2.4 MiB | 00m00s [135/191] Installing systemd-standalone 100% | 47.9 MiB/s | 981.8 KiB | 00m00s [136/191] Installing rpm-libs-0:6.1.0-1 100% | 274.8 MiB/s | 1.1 MiB | 00m00s [137/191] Installing rpm-sign-libs-0:6. 100% | 39.5 MiB/s | 40.5 KiB | 00m00s [138/191] Installing rpm-build-libs-0:6 100% | 141.2 MiB/s | 289.1 KiB | 00m00s [139/191] Installing xxhash-libs-0:0.8. 100% | 93.1 MiB/s | 95.4 KiB | 00m00s [140/191] Installing libnghttp2-0:1.69. 100% | 163.3 MiB/s | 167.3 KiB | 00m00s [141/191] Installing keyutils-libs-0:1. 100% | 54.3 MiB/s | 55.6 KiB | 00m00s [142/191] Installing libcom_err-0:1.47. 100% | 62.6 MiB/s | 64.1 KiB | 00m00s [143/191] Installing libverto-0:0.3.2-1 100% | 26.4 MiB/s | 27.1 KiB | 00m00s [144/191] Installing krb5-libs-0:1.22.2 100% | 265.2 MiB/s | 2.4 MiB | 00m00s [145/191] Installing libnghttp3-0:1.19. 100% | 161.0 MiB/s | 164.8 KiB | 00m00s [146/191] Installing libbrotli-0:1.2.1- 100% | 282.3 MiB/s | 867.3 KiB | 00m00s [147/191] Installing libcbor-0:0.14.0-3 100% | 82.9 MiB/s | 84.9 KiB | 00m00s [148/191] Installing libfido2-0:1.17.0- 100% | 252.0 MiB/s | 258.1 KiB | 00m00s [149/191] Installing libssh-0:0.12.2-1. 100% | 236.9 MiB/s | 727.8 KiB | 00m00s [150/191] Installing libcurl-0:8.23.0-1 100% | 271.4 MiB/s | 1.1 MiB | 00m00s [151/191] Installing elfutils-debuginfo 100% | 4.5 MiB/s | 82.2 KiB | 00m00s [152/191] Installing elfutils-0:0.197-1 100% | 113.7 MiB/s | 3.1 MiB | 00m00s [153/191] Installing binutils-0:2.47-1. 100% | 270.4 MiB/s | 28.4 MiB | 00m00s [154/191] Installing gdb-minimal-0:18.1 100% | 236.7 MiB/s | 14.4 MiB | 00m00s [155/191] Installing debugedit-0:5.4-1. 100% | 12.6 MiB/s | 232.1 KiB | 00m00s [156/191] Installing curl-0:8.23.0-1.fc 100% | 14.5 MiB/s | 488.7 KiB | 00m00s [157/191] Installing rpm-0:6.1.0-1.fc45 100% | 53.3 MiB/s | 2.5 MiB | 00m00s [158/191] Installing efi-srpm-macros-0: 100% | 40.3 MiB/s | 41.3 KiB | 00m00s [159/191] Installing java-srpm-macros-0 100% | 0.0 B/s | 1.1 KiB | 00m00s [160/191] Installing lua-srpm-macros-0: 100% | 317.1 KiB/s | 1.9 KiB | 00m00s [161/191] Installing tree-sitter-srpm-m 100% | 9.4 MiB/s | 9.6 KiB | 00m00s [162/191] Installing zig-srpm-macros-0: 100% | 0.0 B/s | 1.9 KiB | 00m00s [163/191] Installing cmake-srpm-macros- 100% | 0.0 B/s | 804.0 B | 00m00s [164/191] Installing filesystem-srpm-ma 100% | 0.0 B/s | 38.9 KiB | 00m00s [165/191] Installing rust-srpm-macros-0 100% | 0.0 B/s | 6.4 KiB | 00m00s [166/191] Installing qt6-srpm-macros-0: 100% | 0.0 B/s | 748.0 B | 00m00s [167/191] Installing qt5-srpm-macros-0: 100% | 0.0 B/s | 776.0 B | 00m00s [168/191] Installing perl-srpm-macros-0 100% | 0.0 B/s | 1.1 KiB | 00m00s [169/191] Installing package-notes-srpm 100% | 0.0 B/s | 2.1 KiB | 00m00s [170/191] Installing openblas-srpm-macr 100% | 0.0 B/s | 392.0 B | 00m00s [171/191] Installing ocaml-srpm-macros- 100% | 0.0 B/s | 2.1 KiB | 00m00s [172/191] Installing kernel-srpm-macros 100% | 0.0 B/s | 2.3 KiB | 00m00s [173/191] Installing gnome-srpm-macros- 100% | 0.0 B/s | 4.1 KiB | 00m00s [174/191] Installing gnat-srpm-macros-0 100% | 0.0 B/s | 1.3 KiB | 00m00s [175/191] Installing ghc-srpm-macros-0: 100% | 0.0 B/s | 1.0 KiB | 00m00s [176/191] Installing gap-srpm-macros-0: 100% | 0.0 B/s | 2.7 KiB | 00m00s [177/191] Installing fpc-srpm-macros-0: 100% | 0.0 B/s | 420.0 B | 00m00s [178/191] Installing ansible-srpm-macro 100% | 35.4 MiB/s | 36.2 KiB | 00m00s [179/191] Installing redhat-rpm-config- 100% | 93.0 MiB/s | 190.4 KiB | 00m00s [180/191] Installing forge-srpm-macros- 100% | 39.3 MiB/s | 40.3 KiB | 00m00s [181/191] Installing rpm-build-0:6.1.0- 100% | 15.0 MiB/s | 322.1 KiB | 00m00s [182/191] Installing erlang-srpm-macros 100% | 0.0 B/s | 2.6 KiB | 00m00s [183/191] Installing pyproject-srpm-mac 100% | 0.0 B/s | 4.0 KiB | 00m00s [184/191] Installing fonts-srpm-macros- 100% | 55.7 MiB/s | 57.0 KiB | 00m00s [185/191] Installing go-srpm-macros-0:3 100% | 61.6 MiB/s | 63.0 KiB | 00m00s [186/191] Installing R-srpm-macros-0:1. 100% | 0.0 B/s | 4.4 KiB | 00m00s [187/191] Installing python-srpm-macros 100% | 51.7 MiB/s | 52.9 KiB | 00m00s [188/191] Installing rpm-plugin-selinux 100% | 0.0 B/s | 12.9 KiB | 00m00s [189/191] Installing which-0:2.25-2.fc4 100% | 4.4 MiB/s | 85.8 KiB | 00m00s [190/191] Installing shadow-utils-2:4.2 100% | 98.6 MiB/s | 3.9 MiB | 00m00s [191/191] Installing info-0:7.3-3.fc45. 100% | 44.8 KiB/s | 372.8 KiB | 00m08s Warning: skipped OpenPGP checks for 14 packages from repository: copr_base Complete! Finish: installing minimal buildroot with dnf5 Start: creating root cache Finish: creating root cache Finish: chroot init INFO: Installed packages: INFO: R-srpm-macros-1.3.7-3.fc45.noarch add-determinism-0.7.3-3.fc45.x86_64 alternatives-1.33-6.fc45.x86_64 ansible-srpm-macros-1-22.fc45.noarch audit-libs-4.2.1-2.fc45.x86_64 bash-5.3.15-2.fc45.x86_64 binutils-2.47-1.fc45.x86_64 build-reproducibility-srpm-macros-0.7.3-3.fc45.noarch bzip2-1.0.8-24.fc45.x86_64 bzip2-libs-1.0.8-24.fc45.x86_64 ca-certificates-2026.2.92_v9.0.319-2.fc45.noarch cmake-srpm-macros-4.3.0-7.fc45.noarch coreutils-9.11-6.fc45.x86_64 coreutils-common-9.11-6.fc45.x86_64 cpio-2.15-10.fc45.x86_64 crypto-policies-20260713-2.gitc42da77.fc45.noarch curl-8.23.0-1.fc45.x86_64 cyrus-sasl-lib-2.1.28-37.fc45.x86_64 debugedit-5.4-1.fc45.x86_64 diffutils-3.12-6.fc45.x86_64 dwz-0.17-3.fc45.x86_64 ed-1.22.6-1.fc45.x86_64 efi-srpm-macros-6-9.fc45.noarch elfutils-0.197-1.fc45.x86_64 elfutils-debuginfod-client-0.197-1.fc45.x86_64 elfutils-libelf-0.197-1.fc45.x86_64 elfutils-libs-0.197-1.fc45.x86_64 erlang-srpm-macros-0.4.2-1.fc45.noarch fedora-gpg-keys-45-1.noarch fedora-release-45-14.noarch fedora-release-common-45-14.noarch fedora-release-identity-basic-45-14.noarch fedora-repos-45-1.noarch file-5.48-3.fc45.x86_64 file-libs-5.48-3.fc45.x86_64 filesystem-3.18-59.fc45.x86_64 filesystem-srpm-macros-3.18-59.fc45.noarch findutils-4.11.0-2.fc45.x86_64 fips-provider-1.5.3-2.fc45.x86_64 fonts-srpm-macros-5.0.0-4.fc45.noarch forge-srpm-macros-0.4.0-5.fc45.noarch fpc-srpm-macros-1.3-17.fc45.noarch gap-srpm-macros-2-3.fc45.noarch gawk-5.4.1-1.fc45.x86_64 gdb-minimal-18.1-1.fc45.x86_64 gdbm-libs-1.23-12.fc45.x86_64 ghc-srpm-macros-1.10-2.fc45.noarch glibc-2.44-2.fc45.x86_64 glibc-common-2.44-2.fc45.x86_64 glibc-gconv-extra-2.44-2.fc45.x86_64 glibc-minimal-langpack-2.44-2.fc45.x86_64 gmp-6.3.0-6.fc45.x86_64 gnat-srpm-macros-7-3.fc45.noarch gnome-srpm-macros-1.0-2.fc45.noarch gnulib-l10n-20241231-4.fc45.noarch gnupg2-2.4.9-18.fc45.x86_64 gnupg2-dirmngr-2.4.9-18.fc45.x86_64 gnupg2-gpg-agent-2.4.9-18.fc45.x86_64 gnupg2-gpgconf-2.4.9-18.fc45.x86_64 gnupg2-keyboxd-2.4.9-18.fc45.x86_64 gnupg2-verify-2.4.9-18.fc45.x86_64 gnutls-3.8.13-3.fc45.x86_64 go-srpm-macros-3.8.0-3.fc45.noarch gpg-pubkey-4f50a6114cd5c6976a7f1179655a4b02f577861e-6888bc98 gpgverify-2.2-5.fc45.noarch grep-3.12-4.fc45.x86_64 gzip-1.14-4.fc45.x86_64 ima-evm-utils-libs-1.6.2-12.fc45.x86_64 info-7.3-3.fc45.x86_64 jansson-2.14-5.fc45.x86_64 java-srpm-macros-1-9.fc45.noarch json-c-0.18-9.fc45.x86_64 kernel-srpm-macros-1.0-30.fc45.noarch keyutils-libs-1.6.3-8.fc45.x86_64 krb5-libs-1.22.2-11.fc45.x86_64 libacl-2.4.0-2.fc45.x86_64 libarchive-3.8.9-2.fc45.x86_64 libassuan-2.5.7-6.fc45.x86_64 libattr-2.6.0-2.fc45.x86_64 libblkid-2.42.4-1.fc45.x86_64 libbrotli-1.2.1-1.fc45.x86_64 libcap-2.78-2.fc45.x86_64 libcap-ng-0.9.6-1.fc45.x86_64 libcbor-0.14.0-3.fc45.x86_64 libcom_err-1.47.4-2.fc45.x86_64 libcurl-8.23.0-1.fc45.x86_64 libeconf-0.7.9-4.fc45.x86_64 libevent-2.1.13-1.fc45.x86_64 libfdisk-2.42.4-1.fc45.x86_64 libffi-3.5.2-3.fc45.x86_64 libfido2-1.17.0-6.fc45.x86_64 libfsverity-1.7-4.fc45.x86_64 libgcc-16.2.1-3.fc45.x86_64 libgcrypt-1.12.2-2.fc45.x86_64 libgomp-16.2.1-3.fc45.x86_64 libgpg-error-1.61-2.fc45.x86_64 libidn2-2.3.8-4.fc45.x86_64 libksba-1.8.0-3.fc45.x86_64 liblastlog2-2.42.4-1.fc45.x86_64 libmount-2.42.4-1.fc45.x86_64 libnghttp2-1.69.0-6.fc45.x86_64 libnghttp3-1.19.0-1.fc45.x86_64 libpfm-4.14.1-2.fc45.x86_64 libpkgconf-2.5.1-2.fc45.x86_64 libpsl-0.23.1-1.fc45.x86_64 libselinux-3.11-5.fc45.x86_64 libselinux-utils-3.11-5.fc45.x86_64 libsemanage-3.11-4.fc45.x86_64 libsepol-3.11-2.fc45.x86_64 libsmartcols-2.42.4-1.fc45.x86_64 libssh-0.12.2-1.fc45.x86_64 libssh-config-0.12.2-1.fc45.noarch libstdc++-16.2.1-3.fc45.x86_64 libtasn1-4.21.0-2.fc45.x86_64 libtool-ltdl-2.5.4-11.fc45.x86_64 libunistring-1.1-12.fc45.x86_64 libusb1-1.0.30-2.fc45.x86_64 libuuid-2.42.4-1.fc45.x86_64 libverto-0.3.2-13.fc45.x86_64 libxcrypt-4.5.2-4.fc45.x86_64 libxml2-2.15.4-1.fc45.x86_64 libzstd-1.5.7-6.fc45.x86_64 linkdupes-0.7.3-3.fc45.x86_64 lua-libs-5.5.1-2.fc45.x86_64 lua-srpm-macros-1-18.fc45.noarch lz4-libs-1.10.0-5.fc45.x86_64 meson-srpm-macros-1.12.1-2.fc45.noarch mpfr-4.2.2-4.fc45.x86_64 ncurses-base-6.6-3.fc45.noarch ncurses-libs-6.6-3.fc45.x86_64 nettle-4.0-5.fc45.x86_64 ngtcp2-1.22.1-3.fc45.x86_64 ngtcp2-crypto-ossl-1.22.1-3.fc45.x86_64 npth-1.8-5.fc45.x86_64 ocaml-srpm-macros-11-4.fc45.noarch openblas-srpm-macros-2-22.fc45.noarch openldap-2.6.16-1.fc45.x86_64 openssl-libs-4.0.3-1.fc45.x86_64 p11-kit-0.26.5-1.fc45.x86_64 p11-kit-trust-0.26.5-1.fc45.x86_64 package-notes-srpm-macros-0.20-2.fc45.noarch pam-libs-1.7.2-4.fc45.x86_64 patch-2.8-6.fc45.x86_64 pcre2-10.49-1.fc45.x86_64 pcre2-syntax-10.49-1.fc45.noarch perl-srpm-macros-1-65.fc45.noarch pkgconf-2.5.1-2.fc45.x86_64 pkgconf-m4-2.5.1-2.fc45.noarch pkgconf-pkg-config-2.5.1-2.fc45.x86_64 policycoreutils-3.11-2.fc45.x86_64 popt-1.19-11.fc45.x86_64 publicsuffix-list-dafsa-20260624-2.fc45.noarch pyproject-srpm-macros-1.24.0-1.fc45.noarch python-srpm-macros-3.15-2.fc45.noarch qt5-srpm-macros-5.15.18-3.fc45.noarch qt6-srpm-macros-6.11.2-1.fc45.noarch readline-8.3-6.fc45.x86_64 redhat-rpm-config-345-5.fc45.noarch redhat-systemd-presets-102-3.fc45.noarch redhat-systemd-presets-common-102-3.fc45.noarch rpm-6.1.0-1.fc45.x86_64 rpm-build-6.1.0-1.fc45.x86_64 rpm-build-libs-6.1.0-1.fc45.x86_64 rpm-libs-6.1.0-1.fc45.x86_64 rpm-plugin-selinux-6.1.0-1.fc45.x86_64 rpm-sequoia-1.10.3-1.fc45.x86_64 rpm-sign-libs-6.1.0-1.fc45.x86_64 rust-srpm-macros-28.5-2.fc45.noarch sed-4.10-2.fc45.x86_64 selinux-policy-45.24-1.fc45.noarch selinux-policy-targeted-45.24-1.fc45.noarch setup-2.15.1-2.fc45.noarch shadow-utils-4.20.0-2.fc45.x86_64 sqlite-libs-3.53.4-1.fc45.x86_64 systemd-libs-262.2-2.fc45.x86_64 systemd-standalone-sysusers-262.2-2.fc45.x86_64 tar-1.35-10.fc45.x86_64 tpm2-tss-4.2.1-1.fc45.x86_64 tree-sitter-srpm-macros-0.4.6-2.fc45.noarch unzip-6.0-71.fc45.x86_64 util-linux-2.42.4-1.fc45.x86_64 util-linux-core-2.42.4-1.fc45.x86_64 which-2.25-2.fc45.x86_64 xxhash-libs-0.8.4-2.fc45.x86_64 xz-5.8.3-2.fc45.x86_64 xz-libs-5.8.3-2.fc45.x86_64 zig-srpm-macros-1-9.fc45.noarch zip-3.0-46.fc45.x86_64 zlib-ng-compat-2.3.3-6.fc45.x86_64 zstd-1.5.7-6.fc45.x86_64 Start: buildsrpm Start: rpmbuild -bs Building target platforms: x86_64 Building for target x86_64 setting SOURCE_DATE_EPOCH=1794700800 Wrote: /builddir/build/SRPMS/python-llm-0.37.2-1.fc45.src.rpm Finish: rpmbuild -bs INFO: chroot_scan: 1 files copied to /var/lib/copr-rpmbuild/results/chroot_scan INFO: /var/lib/mock/fedora-45-x86_64-1794743501.743658/root/var/log/dnf5.log INFO: chroot_scan: creating tarball /var/lib/copr-rpmbuild/results/chroot_scan.tar.gz /bin/tar: Removing leading `/' from member names Finish: buildsrpm INFO: Done(/var/lib/copr-rpmbuild/workspace/workdir-3lwbw5ag/python-llm/python-llm.spec) Config(child) 0 minutes 42 seconds INFO: Results and/or logs in: /var/lib/copr-rpmbuild/results INFO: Cleaning up build root ('cleanup_on_success=True') Start: clean chroot INFO: unmounting tmpfs. Finish: clean chroot INFO: Start(/var/lib/copr-rpmbuild/results/python-llm-0.37.2-1.fc45.src.rpm) Config(fedora-45-x86_64) Start(bootstrap): chroot init INFO: mounting tmpfs at /var/lib/mock/fedora-45-x86_64-bootstrap-1794743501.743658/root. INFO: reusing tmpfs at /var/lib/mock/fedora-45-x86_64-bootstrap-1794743501.743658/root. INFO: calling preinit hooks INFO: enabled root cache INFO: enabled package manager cache Start(bootstrap): cleaning package manager metadata Finish(bootstrap): cleaning package manager metadata Finish(bootstrap): chroot init Start: chroot init INFO: mounting tmpfs at /var/lib/mock/fedora-45-x86_64-1794743501.743658/root. INFO: calling preinit hooks INFO: enabled root cache Start: unpacking root cache Finish: unpacking root cache INFO: enabled package manager cache Start: cleaning package manager metadata Finish: cleaning package manager metadata INFO: enabled HW Info plugin INFO: Buildroot is handled by package management downloaded with a bootstrap image: rpm-6.1.0-1.fc45.x86_64 rpm-sequoia-1.10.3-1.fc45.x86_64 dnf5-5.4.8.0-2.fc45.x86_64 dnf5-plugins-5.4.8.0-2.fc45.x86_64 Finish: chroot init Start: build phase for python-llm-0.37.2-1.fc45.src.rpm Start: build setup for python-llm-0.37.2-1.fc45.src.rpm Building target platforms: x86_64 Building for target x86_64 setting SOURCE_DATE_EPOCH=1794700800 Wrote: /builddir/build/SRPMS/python-llm-0.37.2-1.fc45.src.rpm Updating and loading repositories: updates 100% | 64.6 KiB/s | 30.6 KiB | 00m00s fedora 100% | 93.9 KiB/s | 44.7 KiB | 00m00s Copr repository 100% | 4.9 KiB/s | 1.6 KiB | 00m00s Repositories loaded. Package Arch Version Repository Size Installing: make x86_64 1:4.4.1-13.fc45 fedora 1.8 MiB python3-devel x86_64 0:3.15.2-6.fc45 copr_base 2.5 MiB python3-furo noarch 0:2025.12.19-7.fc45 copr_base 369.2 KiB python3-httpx2-pytest noarch 0:2.0.0-1.fc45 updates 162.6 KiB python3-llm-echo noarch 0:0.4-4.fc45 copr_base 27.9 KiB python3-myst-parser noarch 0:5.1.0-3.fc45 fedora 880.8 KiB python3-numpy x86_64 1:2.5.4-1.fc45 updates 43.1 MiB python3-pytest noarch 0:9.1.1-1.fc45 fedora 24.3 MiB python3-pytest-asyncio noarch 0:1.4.0-4.fc45 fedora 171.5 KiB python3-pytest-httpx noarch 0:0.36.0-3.fc45 fedora 185.6 KiB python3-pytest-recording noarch 0:0.13.4-7.fc45 fedora 93.3 KiB python3-sphinx-copybutton noarch 0:0.5.2-14.fc45 fedora 35.3 KiB python3-sphinx-markdown-builder noarch 0:0.6.11-1.fc45 fedora 199.5 KiB Installing dependencies: expat x86_64 0:2.9.0-1.fc45 updates 349.6 KiB flexiblas x86_64 0:3.5.0-3.fc45 fedora 38.0 KiB flexiblas-netlib x86_64 0:3.5.0-3.fc45 fedora 16.3 MiB flexiblas-openblas-openmp x86_64 0:3.5.0-3.fc45 fedora 39.1 KiB less x86_64 0:710-2.fc45 updates 488.7 KiB libgfortran x86_64 0:16.2.1-3.fc45 updates 3.4 MiB libquadmath x86_64 0:16.2.1-3.fc45 updates 321.9 KiB libxml2_2.13 x86_64 0:2.13.9-4.fc45 fedora 1.7 MiB libxslt x86_64 0:1.1.43-10.fc45 fedora 471.8 KiB libyaml x86_64 0:0.2.5-19.fc45 fedora 138.5 KiB mpdecimal x86_64 0:4.0.1-4.fc45 fedora 221.2 KiB openblas x86_64 0:0.3.34-1.fc45 fedora 138.1 KiB openblas-openmp x86_64 0:0.3.34-1.fc45 fedora 44.8 MiB pyproject-rpm-macros noarch 0:1.24.0-1.fc45 copr_base 168.8 KiB python-pip-wheel noarch 0:26.3-1.fc45 copr_base 1.4 MiB python-rpm-macros noarch 0:3.15-2.fc45 fedora 28.0 KiB python3 x86_64 0:3.15.2-6.fc45 copr_base 28.7 KiB python3-accessible-pygments noarch 0:0.0.5-13.fc45 fedora 1.5 MiB python3-annotated-types noarch 0:0.8.0-1.fc45 fedora 83.8 KiB python3-anyio noarch 0:4.15.1-2.fc45 updates 1.7 MiB python3-babel noarch 0:2.18.0-4.fc45 fedora 30.3 MiB python3-beautifulsoup4 noarch 0:4.15.0-3.fc45 copr_base 1.1 MiB python3-certifi noarch 0:2026.01.04-3.fc45 fedora 7.5 KiB python3-charset-normalizer noarch 0:3.5.2-2.fc45 copr_base 477.6 KiB python3-click noarch 1:8.4.2-1.fc45 fedora 1.3 MiB python3-click-default-group noarch 0:1.2.2-29.fc45 fedora 17.1 KiB python3-condense-json noarch 0:1.1-2.fc45 fedora 75.6 KiB python3-dateutil noarch 1:2.9.0.post0-15.fc45 fedora 879.9 KiB python3-distro noarch 0:1.9.0-13.fc45 fedora 214.1 KiB python3-docutils noarch 0:0.23-2.fc45 fedora 5.6 MiB python3-h11 noarch 0:0.16.0-8.fc45 fedora 285.6 KiB python3-httpcore noarch 0:1.0.9-9.fc45 fedora 880.9 KiB python3-httpcore2 noarch 0:2.16.0-1.fc45 updates 954.1 KiB python3-httpx noarch 0:0.28.1-14.fc45 fedora 1.0 MiB python3-httpx2 noarch 0:2.16.0-1.fc45 updates 1.4 MiB python3-idna noarch 0:3.18-2.fc45 fedora 523.7 KiB python3-imagesize noarch 0:2.0.0-3.fc45 fedora 82.8 KiB python3-iniconfig noarch 0:2.3.0-5.fc45 fedora 49.6 KiB python3-jinja2 noarch 0:3.1.6-10.fc45 fedora 3.3 MiB python3-jiter x86_64 0:0.19.0-1.fc45 updates 624.3 KiB python3-libs x86_64 0:3.15.2-6.fc45 copr_base 48.2 MiB python3-llm noarch 0:0.34-1.fc45 copr_base 1.6 MiB python3-lxml x86_64 0:6.1.2-1.fc45 copr_base 5.8 MiB python3-markdown-it-py noarch 0:4.2.0-2.fc45 fedora 577.0 KiB python3-markupsafe x86_64 0:3.0.4-1.fc45 copr_base 62.9 KiB python3-mdit-py-plugins noarch 0:0.6.1-2.fc45 fedora 379.5 KiB python3-mdurl noarch 0:0.1.2-16.fc45 fedora 44.3 KiB python3-numpy-f2py x86_64 1:2.5.4-1.fc45 updates 2.1 MiB python3-openai noarch 0:2.24.0-3.fc45 fedora 7.9 MiB python3-packaging noarch 0:26.2-4.fc45 fedora 1.0 MiB python3-pip noarch 0:26.3-1.fc45 copr_base 13.4 MiB python3-pluggy noarch 0:1.7.0-1.fc45 copr_base 246.1 KiB python3-puremagic noarch 0:2.2.0-3.fc45 fedora 469.1 KiB python3-pydantic noarch 0:2.13.5-1.fc45 fedora 5.3 MiB python3-pydantic-core x86_64 0:2.46.5-7.fc45 updates 5.3 MiB python3-pygments noarch 0:2.20.0-5.fc45 fedora 11.3 MiB python3-python-ulid noarch 0:4.1.0-4.fc45 copr_base 116.8 KiB python3-pyyaml x86_64 0:6.0.3-6.fc45 fedora 794.2 KiB python3-requests noarch 0:2.34.2-2.fc45 fedora 679.2 KiB python3-roman-numerals noarch 0:4.1.0-3.fc45 fedora 41.2 KiB python3-rpm-generators noarch 0:14-35.fc45 fedora 81.9 KiB python3-rpm-macros noarch 0:3.15-2.fc45 fedora 6.5 KiB python3-setuptools noarch 0:83.0.0-2.fc45 fedora 7.3 MiB python3-six noarch 0:1.17.0-10.fc45 fedora 118.2 KiB python3-sniffio noarch 0:1.3.1-11.fc45 fedora 35.5 KiB python3-snowballstemmer noarch 0:3.1.1-2.fc45 fedora 1.8 MiB python3-soupsieve noarch 0:2.8.3-4.fc45 fedora 327.6 KiB python3-sphinx noarch 1:9.1.0-9.fc45 copr_base 14.0 MiB python3-sphinx-basic-ng noarch 0:1.0.0-0.21.beta2.fc45 copr_base 33.3 KiB python3-sphinx-theme-alabaster noarch 0:0.7.16-14.fc45 fedora 42.0 KiB python3-sqlite-fts4 noarch 0:1.0.3-4.fc45 fedora 42.6 KiB python3-sqlite-utils noarch 0:4.2.1-1.fc45 fedora 1.3 MiB python3-tabulate noarch 0:0.10.0-8.fc45 fedora 389.6 KiB python3-tqdm noarch 0:4.70.0-1.fc45 copr_base 595.3 KiB python3-truststore noarch 0:0.10.4-3.fc45 fedora 124.8 KiB python3-typing-extensions noarch 0:4.16.0-4.fc45 fedora 554.7 KiB python3-typing-inspection noarch 0:0.4.5-2.fc45 updates 95.8 KiB python3-urllib3 noarch 0:2.8.0-3.fc45 copr_base 1.2 MiB python3-vcrpy noarch 0:8.3.0-2.fc45 fedora 345.8 KiB python3-wrapt x86_64 0:2.5.2-2.fc45 copr_base 497.8 KiB tzdata noarch 0:2026f-1.fc45 updates 1.3 MiB Transaction Summary: Installing: 94 packages Total size of inbound packages is 71 MiB. Need to download 71 MiB. After this operation, 331 MiB extra will be used (install 331 MiB, remove 0 B). [ 1/94] make-1:4.4.1-13.fc45.x86_64 100% | 63.8 MiB/s | 588.3 KiB | 00m00s [ 2/94] python3-httpx2-pytest-0:2.0.0-1 100% | 6.2 MiB/s | 50.6 KiB | 00m00s [ 3/94] python3-myst-parser-0:5.1.0-3.f 100% | 22.8 MiB/s | 233.6 KiB | 00m00s [ 4/94] python3-pytest-recording-0:0.13 100% | 6.0 MiB/s | 43.0 KiB | 00m00s [ 5/94] python3-pytest-0:9.1.1-1.fc45.n 100% | 78.2 MiB/s | 2.5 MiB | 00m00s [ 6/94] python3-pytest-asyncio-0:1.4.0- 100% | 6.5 MiB/s | 46.7 KiB | 00m00s [ 7/94] python3-pytest-httpx-0:0.36.0-3 100% | 8.2 MiB/s | 50.1 KiB | 00m00s [ 8/94] python3-sphinx-copybutton-0:0.5 100% | 2.5 MiB/s | 23.0 KiB | 00m00s [ 9/94] python3-sphinx-markdown-builder 100% | 9.4 MiB/s | 57.5 KiB | 00m00s [10/94] python3-llm-echo-0:0.4-4.fc45.n 100% | 43.7 KiB/s | 18.8 KiB | 00m00s [11/94] python3-furo-0:2025.12.19-7.fc4 100% | 192.0 KiB/s | 101.9 KiB | 00m01s [12/94] python3-docutils-0:0.23-2.fc45. 100% | 45.4 MiB/s | 1.2 MiB | 00m00s [13/94] python3-jinja2-0:3.1.6-10.fc45. 100% | 39.2 MiB/s | 642.7 KiB | 00m00s [14/94] python3-markdown-it-py-0:4.2.0- 100% | 23.1 MiB/s | 213.0 KiB | 00m00s [15/94] python3-numpy-1:2.5.4-1.fc45.x8 100% | 85.6 MiB/s | 8.5 MiB | 00m00s [16/94] python3-mdit-py-plugins-0:0.6.1 100% | 16.1 MiB/s | 148.8 KiB | 00m00s [17/94] python3-vcrpy-0:8.3.0-2.fc45.no 100% | 16.1 MiB/s | 131.5 KiB | 00m00s [18/94] python3-pyyaml-0:6.0.3-6.fc45.x 100% | 25.9 MiB/s | 238.9 KiB | 00m00s [19/94] python3-devel-0:3.15.2-6.fc45.x 100% | 653.5 KiB/s | 441.8 KiB | 00m01s [20/94] python3-accessible-pygments-0:0 100% | 63.8 MiB/s | 1.3 MiB | 00m00s [21/94] python3-pygments-0:2.20.0-5.fc4 100% | 95.0 MiB/s | 2.7 MiB | 00m00s [22/94] python3-iniconfig-0:2.3.0-5.fc4 100% | 3.6 MiB/s | 25.8 KiB | 00m00s [23/94] python3-packaging-0:26.2-4.fc45 100% | 25.8 MiB/s | 238.0 KiB | 00m00s [24/94] python3-httpx-0:0.28.1-14.fc45. 100% | 26.1 MiB/s | 213.5 KiB | 00m00s [25/94] python3-tabulate-0:0.10.0-8.fc4 100% | 9.6 MiB/s | 79.0 KiB | 00m00s [26/94] python3-numpy-f2py-1:2.5.4-1.fc 100% | 42.0 MiB/s | 515.9 KiB | 00m00s [27/94] flexiblas-netlib-0:3.5.0-3.fc45 100% | 83.2 MiB/s | 4.5 MiB | 00m00s [28/94] python3-mdurl-0:0.1.2-16.fc45.n 100% | 4.4 MiB/s | 31.3 KiB | 00m00s [29/94] libyaml-0:0.2.5-19.fc45.x86_64 100% | 6.8 MiB/s | 62.4 KiB | 00m00s [30/94] expat-0:2.9.0-1.fc45.x86_64 100% | 14.8 MiB/s | 136.2 KiB | 00m00s [31/94] mpdecimal-0:4.0.1-4.fc45.x86_64 100% | 12.0 MiB/s | 98.5 KiB | 00m00s [32/94] python3-certifi-0:2026.01.04-3. 100% | 2.5 MiB/s | 15.1 KiB | 00m00s [33/94] python3-httpcore-0:1.0.9-9.fc45 100% | 22.2 MiB/s | 159.2 KiB | 00m00s [34/94] python3-idna-0:3.18-2.fc45.noar 100% | 17.0 MiB/s | 104.5 KiB | 00m00s [35/94] flexiblas-0:3.5.0-3.fc45.x86_64 100% | 2.8 MiB/s | 22.7 KiB | 00m00s [36/94] flexiblas-openblas-openmp-0:3.5 100% | 2.3 MiB/s | 16.6 KiB | 00m00s [37/94] python3-h11-0:0.16.0-8.fc45.noa 100% | 15.8 MiB/s | 81.1 KiB | 00m00s [38/94] openblas-openmp-0:0.3.34-1.fc45 100% | 88.5 MiB/s | 5.5 MiB | 00m00s [39/94] python3-0:3.15.2-6.fc45.x86_64 100% | 75.0 KiB/s | 27.9 KiB | 00m00s [40/94] python3-click-1:8.4.2-1.fc45.no 100% | 31.6 MiB/s | 291.5 KiB | 00m00s [41/94] python3-click-default-group-0:1 100% | 2.2 MiB/s | 16.0 KiB | 00m00s [42/94] python3-condense-json-0:1.1-2.f 100% | 2.9 MiB/s | 29.8 KiB | 00m00s [43/94] python3-openai-0:2.24.0-3.fc45. 100% | 58.6 MiB/s | 1.9 MiB | 00m00s [44/94] python3-puremagic-0:2.2.0-3.fc4 100% | 18.5 MiB/s | 132.4 KiB | 00m00s [45/94] python3-pydantic-0:2.13.5-1.fc4 100% | 45.9 MiB/s | 1.0 MiB | 00m00s [46/94] python3-sqlite-utils-0:4.2.1-1. 100% | 22.7 MiB/s | 255.6 KiB | 00m00s [47/94] python3-typing-extensions-0:4.1 100% | 18.6 MiB/s | 114.2 KiB | 00m00s [48/94] python3-distro-0:1.9.0-13.fc45. 100% | 7.7 MiB/s | 47.3 KiB | 00m00s [49/94] python3-sniffio-0:1.3.1-11.fc45 100% | 3.8 MiB/s | 27.4 KiB | 00m00s [50/94] python3-annotated-types-0:0.8.0 100% | 5.0 MiB/s | 30.6 KiB | 00m00s [51/94] python3-dateutil-1:2.9.0.post0- 100% | 48.1 MiB/s | 344.8 KiB | 00m00s [52/94] python3-sqlite-fts4-0:1.0.3-4.f 100% | 3.5 MiB/s | 21.6 KiB | 00m00s [53/94] python3-six-0:1.17.0-10.fc45.no 100% | 8.2 MiB/s | 41.8 KiB | 00m00s [54/94] python3-httpx2-0:2.16.0-1.fc45. 100% | 27.3 MiB/s | 279.7 KiB | 00m00s [55/94] python3-httpcore2-0:2.16.0-1.fc 100% | 16.6 MiB/s | 169.5 KiB | 00m00s [56/94] python3-truststore-0:0.10.4-3.f 100% | 10.3 MiB/s | 52.8 KiB | 00m00s [57/94] python3-python-ulid-0:4.1.0-4.f 100% | 100.4 KiB/s | 45.3 KiB | 00m00s [58/94] python3-llm-0:0.34-1.fc45.noarc 100% | 678.0 KiB/s | 475.9 KiB | 00m01s [59/94] python3-pluggy-0:1.7.0-1.fc45.n 100% | 196.9 KiB/s | 67.2 KiB | 00m00s [60/94] tzdata-0:2026f-1.fc45.noarch 100% | 41.0 MiB/s | 713.8 KiB | 00m00s [61/94] python3-libs-0:3.15.2-6.fc45.x8 100% | 6.6 MiB/s | 10.9 MiB | 00m02s [62/94] python3-pip-0:26.3-1.fc45.noarc 100% | 3.4 MiB/s | 2.7 MiB | 00m01s [63/94] python3-soupsieve-0:2.8.3-4.fc4 100% | 14.6 MiB/s | 104.3 KiB | 00m00s [64/94] python-pip-wheel-0:26.3-1.fc45. 100% | 3.0 MiB/s | 1.3 MiB | 00m00s [65/94] python3-babel-0:2.18.0-4.fc45.n 100% | 75.4 MiB/s | 6.9 MiB | 00m00s [66/94] python3-imagesize-0:2.0.0-3.fc4 100% | 4.4 MiB/s | 35.9 KiB | 00m00s [67/94] python3-requests-0:2.34.2-2.fc4 100% | 23.0 MiB/s | 188.0 KiB | 00m00s [68/94] python3-beautifulsoup4-0:4.15.0 100% | 749.4 KiB/s | 243.5 KiB | 00m00s [69/94] python3-roman-numerals-0:4.1.0- 100% | 2.8 MiB/s | 20.1 KiB | 00m00s [70/94] python3-snowballstemmer-0:3.1.1 100% | 30.6 MiB/s | 282.1 KiB | 00m00s [71/94] python3-sphinx-theme-alabaster- 100% | 3.4 MiB/s | 24.2 KiB | 00m00s [72/94] python3-sphinx-1:9.1.0-9.fc45.n 100% | 7.5 MiB/s | 3.0 MiB | 00m00s [73/94] libxml2_2.13-0:2.13.9-4.fc45.x8 100% | 36.7 MiB/s | 676.5 KiB | 00m00s [74/94] libxslt-0:1.1.43-10.fc45.x86_64 100% | 26.7 MiB/s | 191.6 KiB | 00m00s [75/94] python3-sphinx-basic-ng-0:1.0.0 100% | 89.3 KiB/s | 26.0 KiB | 00m00s [76/94] python3-lxml-0:6.1.2-1.fc45.x86 100% | 3.4 MiB/s | 1.7 MiB | 00m00s [77/94] python3-wrapt-0:2.5.2-2.fc45.x8 100% | 400.7 KiB/s | 138.2 KiB | 00m00s [78/94] python3-pydantic-core-0:2.46.5- 100% | 48.1 MiB/s | 1.7 MiB | 00m00s [79/94] python3-urllib3-0:2.8.0-3.fc45. 100% | 883.6 KiB/s | 293.4 KiB | 00m00s [80/94] python3-typing-inspection-0:0.4 100% | 3.8 MiB/s | 34.6 KiB | 00m00s [81/94] python3-anyio-0:4.15.1-2.fc45.n 100% | 35.8 MiB/s | 366.2 KiB | 00m00s [82/94] python3-jiter-0:0.19.0-1.fc45.x 100% | 23.3 MiB/s | 263.0 KiB | 00m00s [83/94] python3-charset-normalizer-0:3. 100% | 434.6 KiB/s | 133.4 KiB | 00m00s [84/94] less-0:710-2.fc45.x86_64 100% | 20.6 MiB/s | 231.7 KiB | 00m00s [85/94] libgfortran-0:16.2.1-3.fc45.x86 100% | 56.8 MiB/s | 989.3 KiB | 00m00s [86/94] openblas-0:0.3.34-1.fc45.x86_64 100% | 6.7 MiB/s | 48.2 KiB | 00m00s [87/94] libquadmath-0:16.2.1-3.fc45.x86 100% | 18.7 MiB/s | 210.9 KiB | 00m00s [88/94] python3-setuptools-0:83.0.0-2.f 100% | 70.6 MiB/s | 1.7 MiB | 00m00s [89/94] python-rpm-macros-0:3.15-2.fc45 100% | 2.8 MiB/s | 19.8 KiB | 00m00s [90/94] python3-rpm-generators-0:14-35. 100% | 5.6 MiB/s | 28.7 KiB | 00m00s [91/94] python3-rpm-macros-0:3.15-2.fc4 100% | 2.0 MiB/s | 12.2 KiB | 00m00s [92/94] python3-markupsafe-0:3.0.4-1.fc 100% | 118.1 KiB/s | 32.2 KiB | 00m00s [93/94] python3-tqdm-0:4.70.0-1.fc45.no 100% | 441.1 KiB/s | 163.6 KiB | 00m00s [94/94] pyproject-rpm-macros-0:1.24.0-1 100% | 208.4 KiB/s | 57.9 KiB | 00m00s -------------------------------------------------------------------------------- [94/94] Total 100% | 18.1 MiB/s | 71.4 MiB | 00m04s Running transaction [ 1/96] Verify package files 100% | 334.0 B/s | 94.0 B | 00m00s [ 2/96] Prepare transaction 100% | 686.0 B/s | 94.0 B | 00m00s [ 3/96] Installing python-rpm-macros-0: 100% | 28.2 MiB/s | 28.9 KiB | 00m00s [ 4/96] Installing python3-rpm-macros-0 100% | 0.0 B/s | 6.8 KiB | 00m00s [ 5/96] Installing libgfortran-0:16.2.1 100% | 261.4 MiB/s | 3.4 MiB | 00m00s [ 6/96] Installing tzdata-0:2026f-1.fc4 100% | 34.6 MiB/s | 1.5 MiB | 00m00s [ 7/96] Installing pyproject-rpm-macros 100% | 167.2 MiB/s | 171.3 KiB | 00m00s [ 8/96] Installing libquadmath-0:16.2.1 100% | 315.5 MiB/s | 323.1 KiB | 00m00s [ 9/96] Installing openblas-0:0.3.34-1. 100% | 136.6 MiB/s | 139.9 KiB | 00m00s [10/96] Installing openblas-openmp-0:0. 100% | 532.9 MiB/s | 44.8 MiB | 00m00s [11/96] Installing flexiblas-netlib-0:3 100% | 263.2 MiB/s | 16.3 MiB | 00m00s [12/96] Installing flexiblas-0:3.5.0-3. 100% | 0.0 B/s | 39.2 KiB | 00m00s [13/96] Installing flexiblas-openblas-o 100% | 39.0 MiB/s | 40.0 KiB | 00m00s [14/96] Installing less-0:710-2.fc45.x8 100% | 25.3 MiB/s | 492.0 KiB | 00m00s [15/96] Installing libxslt-0:1.1.43-10. 100% | 23.2 MiB/s | 474.9 KiB | 00m00s [16/96] Installing libxml2_2.13-0:2.13. 100% | 276.5 MiB/s | 1.7 MiB | 00m00s [17/96] Installing python-pip-wheel-0:2 100% | 698.1 MiB/s | 1.4 MiB | 00m00s [18/96] Installing mpdecimal-0:4.0.1-4. 100% | 217.5 MiB/s | 222.7 KiB | 00m00s [19/96] Installing expat-0:2.9.0-1.fc45 100% | 14.9 MiB/s | 351.7 KiB | 00m00s [20/96] Installing python3-libs-0:3.15. 100% | 279.7 MiB/s | 48.7 MiB | 00m00s [21/96] Installing python3-0:3.15.2-6.f 100% | 1.7 MiB/s | 30.4 KiB | 00m00s [22/96] Installing python3-typing-exten 100% | 271.9 MiB/s | 557.0 KiB | 00m00s [23/96] Installing python3-idna-0:3.18- 100% | 23.6 MiB/s | 531.6 KiB | 00m00s [24/96] Installing python3-pygments-0:2 100% | 169.6 MiB/s | 11.5 MiB | 00m00s [25/96] Installing python3-anyio-0:4.15 100% | 196.8 MiB/s | 1.8 MiB | 00m00s [26/96] Installing python3-docutils-0:0 100% | 132.4 MiB/s | 5.7 MiB | 00m00s [27/96] Installing python3-packaging-0: 100% | 202.3 MiB/s | 1.0 MiB | 00m00s [28/96] Installing python3-click-1:8.4. 100% | 266.2 MiB/s | 1.3 MiB | 00m00s [29/96] Installing python3-pluggy-0:1.7 100% | 124.6 MiB/s | 255.2 KiB | 00m00s [30/96] Installing python3-click-defaul 100% | 19.2 MiB/s | 19.7 KiB | 00m00s [31/96] Installing python3-tabulate-0:0 100% | 20.2 MiB/s | 392.7 KiB | 00m00s [32/96] Installing python3-certifi-0:20 100% | 11.0 MiB/s | 11.3 KiB | 00m00s [33/96] Installing python3-h11-0:0.16.0 100% | 143.3 MiB/s | 293.6 KiB | 00m00s [34/96] Installing python3-truststore-0 100% | 31.7 MiB/s | 129.9 KiB | 00m00s [35/96] Installing python3-pip-0:26.3-1 100% | 152.2 MiB/s | 13.7 MiB | 00m00s [36/96] Installing python3-httpcore2-0: 100% | 190.4 MiB/s | 974.9 KiB | 00m00s [37/96] Installing python3-httpx2-0:2.1 100% | 228.6 MiB/s | 1.4 MiB | 00m00s [38/96] Installing python3-httpcore-0:1 100% | 176.1 MiB/s | 901.4 KiB | 00m00s [39/96] Installing python3-httpx-0:0.28 100% | 201.3 MiB/s | 1.0 MiB | 00m00s [40/96] Installing python3-rpm-generato 100% | 81.1 MiB/s | 83.1 KiB | 00m00s [41/96] Installing python3-accessible-p 100% | 122.6 MiB/s | 1.6 MiB | 00m00s [42/96] Installing python3-urllib3-0:2. 100% | 200.3 MiB/s | 1.2 MiB | 00m00s [43/96] Installing python3-pydantic-cor 100% | 331.2 MiB/s | 5.3 MiB | 00m00s [44/96] Installing python3-typing-inspe 100% | 19.5 MiB/s | 99.9 KiB | 00m00s [45/96] Installing python3-numpy-1:2.5. 100% | 274.7 MiB/s | 43.4 MiB | 00m00s [46/96] Installing python3-numpy-f2py-1 100% | 68.6 MiB/s | 2.2 MiB | 00m00s [47/96] Installing python3-iniconfig-0: 100% | 17.6 MiB/s | 54.0 KiB | 00m00s [48/96] Installing python3-pytest-0:9.1 100% | 287.5 MiB/s | 24.4 MiB | 00m00s [49/96] Installing python3-mdurl-0:0.1. 100% | 24.3 MiB/s | 49.7 KiB | 00m00s [50/96] Installing python3-markdown-it- 100% | 23.3 MiB/s | 621.1 KiB | 00m00s [51/96] Installing python3-mdit-py-plug 100% | 57.7 MiB/s | 413.9 KiB | 00m00s [52/96] Installing python3-condense-jso 100% | 76.5 MiB/s | 78.3 KiB | 00m00s [53/96] Installing python3-puremagic-0: 100% | 21.4 MiB/s | 482.4 KiB | 00m00s [54/96] Installing python3-distro-0:1.9 100% | 11.2 MiB/s | 218.7 KiB | 00m00s [55/96] Installing python3-sniffio-0:1. 100% | 20.1 MiB/s | 41.1 KiB | 00m00s [56/96] Installing python3-annotated-ty 100% | 42.5 MiB/s | 86.9 KiB | 00m00s [57/96] Installing python3-pydantic-0:2 100% | 253.2 MiB/s | 5.3 MiB | 00m00s [58/96] Installing python3-sqlite-fts4- 100% | 44.1 MiB/s | 45.2 KiB | 00m00s [59/96] Installing python3-six-0:1.17.0 100% | 117.6 MiB/s | 120.5 KiB | 00m00s [60/96] Installing python3-dateutil-1:2 100% | 218.1 MiB/s | 893.4 KiB | 00m00s [61/96] Installing python3-sqlite-utils 100% | 63.5 MiB/s | 1.3 MiB | 00m00s [62/96] Installing python3-python-ulid- 100% | 6.3 MiB/s | 121.8 KiB | 00m00s [63/96] Installing python3-soupsieve-0: 100% | 65.2 MiB/s | 333.7 KiB | 00m00s [64/96] Installing python3-babel-0:2.18 100% | 270.2 MiB/s | 30.5 MiB | 00m00s [65/96] Installing python3-imagesize-0: 100% | 83.9 MiB/s | 85.9 KiB | 00m00s [66/96] Installing python3-roman-numera 100% | 43.1 MiB/s | 44.1 KiB | 00m00s [67/96] Installing python3-snowballstem 100% | 258.3 MiB/s | 1.8 MiB | 00m00s [68/96] Installing python3-sphinx-theme 100% | 22.8 MiB/s | 46.6 KiB | 00m00s [69/96] Installing python3-lxml-0:6.1.2 100% | 279.3 MiB/s | 5.9 MiB | 00m00s [70/96] Installing python3-beautifulsou 100% | 216.8 MiB/s | 1.1 MiB | 00m00s [71/96] Installing python3-wrapt-0:2.5. 100% | 165.5 MiB/s | 508.3 KiB | 00m00s [72/96] Installing python3-charset-norm 100% | 22.7 MiB/s | 487.7 KiB | 00m00s [73/96] Installing python3-requests-0:2 100% | 169.0 MiB/s | 692.0 KiB | 00m00s [74/96] Installing python3-jiter-0:0.19 100% | 204.4 MiB/s | 627.8 KiB | 00m00s [75/96] Installing python3-tqdm-0:4.70. 100% | 20.1 MiB/s | 618.1 KiB | 00m00s [76/96] Installing python3-openai-0:2.2 100% | 78.5 MiB/s | 8.6 MiB | 00m00s [77/96] Installing python3-markupsafe-0 100% | 32.8 MiB/s | 67.1 KiB | 00m00s [78/96] Installing python3-jinja2-0:3.1 100% | 254.1 MiB/s | 3.3 MiB | 00m00s [79/96] Installing python3-sphinx-1:9.1 100% | 160.4 MiB/s | 14.3 MiB | 00m00s [80/96] Installing python3-sphinx-basic 100% | 8.8 MiB/s | 45.1 KiB | 00m00s [81/96] Installing python3-setuptools-0 100% | 173.3 MiB/s | 7.5 MiB | 00m00s [82/96] Installing libyaml-0:0.2.5-19.f 100% | 136.6 MiB/s | 139.9 KiB | 00m00s [83/96] Installing python3-pyyaml-0:6.0 100% | 157.8 MiB/s | 808.2 KiB | 00m00s [84/96] Installing python3-vcrpy-0:8.3. 100% | 89.0 MiB/s | 364.7 KiB | 00m00s [85/96] Installing python3-llm-0:0.34-1 100% | 66.4 MiB/s | 1.6 MiB | 00m00s [86/96] Installing python3-llm-echo-0:0 100% | 29.2 MiB/s | 29.9 KiB | 00m00s [87/96] Installing python3-pytest-recor 100% | 49.0 MiB/s | 100.4 KiB | 00m00s [88/96] Installing python3-myst-parser- 100% | 38.3 MiB/s | 902.5 KiB | 00m00s [89/96] Installing python3-furo-0:2025. 100% | 76.2 MiB/s | 390.1 KiB | 00m00s [90/96] Installing python3-sphinx-copyb 100% | 38.3 MiB/s | 39.2 KiB | 00m00s [91/96] Installing python3-sphinx-markd 100% | 100.4 MiB/s | 205.7 KiB | 00m00s [92/96] Installing python3-httpx2-pytes 100% | 82.4 MiB/s | 168.7 KiB | 00m00s [93/96] Installing python3-pytest-async 100% | 85.4 MiB/s | 175.0 KiB | 00m00s [94/96] Installing python3-pytest-httpx 100% | 93.7 MiB/s | 191.9 KiB | 00m00s [95/96] Installing python3-devel-0:3.15 100% | 79.6 MiB/s | 2.5 MiB | 00m00s [96/96] Installing make-1:4.4.1-13.fc45 100% | 15.2 MiB/s | 1.8 MiB | 00m00s Warning: skipped OpenPGP checks for 20 packages from repository: copr_base Complete! Building target platforms: x86_64 Building for target x86_64 setting SOURCE_DATE_EPOCH=1794700800 Wrote: /builddir/build/SRPMS/python-llm-0.37.2-1.fc45.src.rpm Updating and loading repositories: updates 100% | 64.9 KiB/s | 30.6 KiB | 00m00s fedora 100% | 94.3 KiB/s | 44.7 KiB | 00m00s Copr repository 100% | 4.4 KiB/s | 1.6 KiB | 00m00s Repositories loaded. Package "make-1:4.4.1-13.fc45.x86_64" is already installed. Package "python3-devel-3.15.2-6.fc45.x86_64" is already installed. Package "python3-furo-2025.12.19-7.fc45.noarch" is already installed. Package "python3-httpx2-pytest-2.0.0-1.fc45.noarch" is already installed. Package "python3-myst-parser-5.1.0-3.fc45.noarch" is already installed. Package "python3-pytest-9.1.1-1.fc45.noarch" is already installed. Package "python3-pytest-asyncio-1.4.0-4.fc45.noarch" is already installed. Package "python3-pytest-httpx-0.36.0-3.fc45.noarch" is already installed. Package "python3-pytest-recording-0.13.4-7.fc45.noarch" is already installed. Package "python3-sphinx-copybutton-0.5.2-14.fc45.noarch" is already installed. Package "python3-sphinx-markdown-builder-0.6.11-1.fc45.noarch" is already installed. Package "python3-llm-echo-0.4-4.fc45.noarch" is already installed. Package "python3-numpy-1:2.5.4-1.fc45.x86_64" is already installed. Nothing to do. Finish: build setup for python-llm-0.37.2-1.fc45.src.rpm Start: rpmbuild python-llm-0.37.2-1.fc45.src.rpm Building target platforms: x86_64 Building for target x86_64 setting SOURCE_DATE_EPOCH=1794700800 Executing(mkbuilddir): /bin/sh -e /var/tmp/rpm-tmp.RJbIJW Creating(rpmbuild.env): /builddir/build/BUILD/python-llm-0.37.2-build/rpmbuild.env RPM_SOURCE_DIR="/builddir/build/SOURCES" RPM_BUILD_DIR="/builddir/build/BUILD/python-llm-0.37.2-build" RPM_OPT_FLAGS="-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wno-complain-wrong-lang -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer" RPM_LD_FLAGS="-Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes " RPM_ARCH="x86_64" RPM_OS="linux" RPM_BUILD_NCPUS="2" RPM_SPECPARTS_DIR="/builddir/build/BUILD/python-llm-0.37.2-build/SPECPARTS" export RPM_SOURCE_DIR RPM_BUILD_DIR RPM_OPT_FLAGS RPM_ARCH RPM_OS RPM_BUILD_NCPUS RPM_SPECPARTS_DIR RPM_LD_FLAGS RPM_DOC_DIR="/usr/share/doc" export RPM_DOC_DIR RPM_PACKAGE_NAME="python-llm" RPM_PACKAGE_VERSION="0.37.2" RPM_PACKAGE_RELEASE="1.fc45" export RPM_PACKAGE_NAME RPM_PACKAGE_VERSION RPM_PACKAGE_RELEASE LANG=C.UTF-8 export LANG unset CDPATH DISPLAY ||: unset DEBUGINFOD_URLS ||: unset RPM_CONFIG_DIR ||: RPM_BUILD_ROOT="/builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT" export RPM_BUILD_ROOT PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/lib64/pkgconfig:/usr/share/pkgconfig" export PKG_CONFIG_PATH CONFIG_SITE=${CONFIG_SITE:-NONE} export CONFIG_SITE Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.stHqhx + umask 022 + cd /builddir/build/BUILD/python-llm-0.37.2-build + cd /builddir/build/BUILD/python-llm-0.37.2-build + rm -rf llm-0.37.2 + /usr/bin/rpmuncompress -x /builddir/build/SOURCES/llm-0.37.2.tar.gz + STATUS=0 + '[' 0 -ne 0 ']' + cd llm-0.37.2 + /usr/bin/chmod -Rf a+rX,u+w,g-w,o-w . + /usr/bin/rpmuncompress /builddir/build/SOURCES/0001-Relax-reqs.patch + /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f + /usr/bin/rpmuncompress /builddir/build/SOURCES/0002-Skip-tests-failing-with-sqlite-3.51.patch + /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f + /usr/bin/rpmuncompress /builddir/build/SOURCES/0001-Keep-legacy-tool-result-attachments-as-JSON-on-newer.patch + /usr/bin/patch -p1 -s --fuzz=0 --no-backup-if-mismatch -f + RPM_EC=0 ++ jobs -p + exit 0 Executing(%generate_buildrequires): /bin/sh -e /var/tmp/rpm-tmp.JzFOhX + umask 022 + cd /builddir/build/BUILD/python-llm-0.37.2-build + cd llm-0.37.2 + echo pyproject-rpm-macros + echo python3-devel + echo 'python3dist(packaging)' + echo 'python3dist(pip) >= 19' + '[' -f pyproject.toml ']' + echo '(python3dist(tomli) if python3-devel < 3.11)' + rm -rfv '*.dist-info/' + '[' -f /usr/bin/python3 ']' + mkdir -p /builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir + echo -n + CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' + CXXFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' + FFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules ' + FCFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules ' + VALAFLAGS=-g + RUSTFLAGS='-Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Cforce-frame-pointers=yes --cap-lints=warn' + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' + LT_SYS_LIBRARY_PATH=/usr/lib64: + CC=gcc + CXX=g++ + TMPDIR=/builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir + RPM_TOXENV=py315 + FEDORA=45 + HOSTNAME=rpmbuild + /usr/bin/python3 -Bs /usr/lib/rpm/redhat/pyproject_buildrequires.py --generate-extras --python3_pkgversion 3 --wheeldir /builddir/build/BUILD/python-llm-0.37.2-build/pyproject-wheeldir --output /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-buildrequires --dep-overrides-file /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-dep-overrides Handling setuptools from build-system.requires Requirement satisfied: setuptools (installed: setuptools 83.0.0) running egg_info creating llm.egg-info writing llm.egg-info/PKG-INFO writing dependency_links to llm.egg-info/dependency_links.txt writing entry points to llm.egg-info/entry_points.txt writing requirements to llm.egg-info/requires.txt writing top-level names to llm.egg-info/top_level.txt writing manifest file 'llm.egg-info/SOURCES.txt' reading manifest file 'llm.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' adding license file 'LICENSE' writing manifest file 'llm.egg-info/SOURCES.txt' running dist_info writing llm.egg-info/PKG-INFO writing dependency_links to llm.egg-info/dependency_links.txt writing entry points to llm.egg-info/entry_points.txt writing requirements to llm.egg-info/requires.txt writing top-level names to llm.egg-info/top_level.txt reading manifest file 'llm.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' adding license file 'LICENSE' writing manifest file 'llm.egg-info/SOURCES.txt' creating '/builddir/build/BUILD/python-llm-0.37.2-build/llm-0.37.2/llm-0.37.2.dist-info' Handling click from hook generated metadata: Requires-Dist (llm) Requirement satisfied: click (installed: click 8.4.2) Handling httpx2 from hook generated metadata: Requires-Dist (llm) Requirement satisfied: httpx2 (installed: httpx2 2.16.0) Handling condense-json>=1.1 from hook generated metadata: Requires-Dist (llm) Requirement satisfied: condense-json>=1.1 (installed: condense-json 1.1) Handling openai>=2.21.0 from hook generated metadata: Requires-Dist (llm) Requirement satisfied: openai>=2.21.0 (installed: openai 2.24.0) Handling click-default-group>=1.2.2 from hook generated metadata: Requires-Dist (llm) Requirement satisfied: click-default-group>=1.2.2 (installed: click-default-group 1.2.2) Handling sqlite-utils>=4.0 from hook generated metadata: Requires-Dist (llm) Requirement satisfied: sqlite-utils>=4.0 (installed: sqlite-utils 4.2.1) Handling pydantic>=2.0.0 from hook generated metadata: Requires-Dist (llm) Requirement satisfied: pydantic>=2.0.0 (installed: pydantic 2.13.5) Handling typing-extensions from hook generated metadata: Requires-Dist (llm) Requirement satisfied: typing-extensions (installed: typing-extensions 4.16.0) Handling PyYAML from hook generated metadata: Requires-Dist (llm) Requirement satisfied: PyYAML (installed: PyYAML 6.0.3) Handling pluggy from hook generated metadata: Requires-Dist (llm) Requirement satisfied: pluggy (installed: pluggy 1.7.0) Handling python-ulid from hook generated metadata: Requires-Dist (llm) Requirement satisfied: python-ulid (installed: python-ulid 4.1.0) Handling setuptools from hook generated metadata: Requires-Dist (llm) Requirement satisfied: setuptools (installed: setuptools 83.0.0) Handling pip from hook generated metadata: Requires-Dist (llm) Requirement satisfied: pip (installed: pip 26.3) Handling pyreadline3; sys_platform == "win32" from hook generated metadata: Requires-Dist (llm) Ignoring alien requirement: pyreadline3; sys_platform == "win32" Handling puremagic from hook generated metadata: Requires-Dist (llm) Requirement satisfied: puremagic (installed: puremagic 2.2.0) + cat /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-buildrequires + rm -rfv llm-0.37.2.dist-info/ removed 'llm-0.37.2.dist-info/licenses/LICENSE' removed directory 'llm-0.37.2.dist-info/licenses' removed 'llm-0.37.2.dist-info/METADATA' removed 'llm-0.37.2.dist-info/entry_points.txt' removed 'llm-0.37.2.dist-info/top_level.txt' removed directory 'llm-0.37.2.dist-info/' + RPM_EC=0 ++ jobs -p + exit 0 Wrote: /builddir/build/SRPMS/python-llm-0.37.2-1.fc45.buildreqs.nosrc.rpm INFO: Going to install missing dynamic buildrequires Updating and loading repositories: updates 100% | 68.4 KiB/s | 30.6 KiB | 00m00s fedora 100% | 100.6 KiB/s | 44.7 KiB | 00m00s Copr repository 100% | 5.1 KiB/s | 1.6 KiB | 00m00s Repositories loaded. Package "make-1:4.4.1-13.fc45.x86_64" is already installed. Package "pyproject-rpm-macros-1.24.0-1.fc45.noarch" is already installed. Package "python3-devel-3.15.2-6.fc45.x86_64" is already installed. Package "python3-furo-2025.12.19-7.fc45.noarch" is already installed. Package "python3-httpx2-pytest-2.0.0-1.fc45.noarch" is already installed. Package "python3-myst-parser-5.1.0-3.fc45.noarch" is already installed. Package "python3-pytest-9.1.1-1.fc45.noarch" is already installed. Package "python3-pytest-asyncio-1.4.0-4.fc45.noarch" is already installed. Package "python3-pytest-httpx-0.36.0-3.fc45.noarch" is already installed. Package "python3-pytest-recording-0.13.4-7.fc45.noarch" is already installed. Package "python3-sphinx-copybutton-0.5.2-14.fc45.noarch" is already installed. Package "python3-sphinx-markdown-builder-0.6.11-1.fc45.noarch" is already installed. Package "python3-click-1:8.4.2-1.fc45.noarch" is already installed. Package "python3-click-default-group-1.2.2-29.fc45.noarch" is already installed. Package "python3-condense-json-1.1-2.fc45.noarch" is already installed. Package "python3-httpx2-2.16.0-1.fc45.noarch" is already installed. Package "python3-llm-echo-0.4-4.fc45.noarch" is already installed. Package "python3-numpy-1:2.5.4-1.fc45.x86_64" is already installed. Package "python3-openai-2.24.0-3.fc45.noarch" is already installed. Package "python3-packaging-26.2-4.fc45.noarch" is already installed. Package "python3-pip-26.3-1.fc45.noarch" is already installed. Package "python3-pip-26.3-1.fc45.noarch" is already installed. Package "python3-pluggy-1.7.0-1.fc45.noarch" is already installed. Package "python3-puremagic-2.2.0-3.fc45.noarch" is already installed. Package "python3-pydantic-2.13.5-1.fc45.noarch" is already installed. Package "python3-python-ulid-4.1.0-4.fc45.noarch" is already installed. Package "python3-pyyaml-6.0.3-6.fc45.x86_64" is already installed. Package "python3-setuptools-83.0.0-2.fc45.noarch" is already installed. Package "python3-sqlite-utils-4.2.1-1.fc45.noarch" is already installed. Package "python3-typing-extensions-4.16.0-4.fc45.noarch" is already installed. Nothing to do. Building target platforms: x86_64 Building for target x86_64 setting SOURCE_DATE_EPOCH=1794700800 Executing(%generate_buildrequires): /bin/sh -e /var/tmp/rpm-tmp.95UtBg + umask 022 + cd /builddir/build/BUILD/python-llm-0.37.2-build + cd llm-0.37.2 + echo pyproject-rpm-macros + echo python3-devel + echo 'python3dist(packaging)' + echo 'python3dist(pip) >= 19' + '[' -f pyproject.toml ']' + echo '(python3dist(tomli) if python3-devel < 3.11)' + rm -rfv '*.dist-info/' + '[' -f /usr/bin/python3 ']' + mkdir -p /builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir + echo -n + CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' + CXXFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' + FFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules ' + FCFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules ' + VALAFLAGS=-g + RUSTFLAGS='-Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Cforce-frame-pointers=yes --cap-lints=warn' + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 ' + LT_SYS_LIBRARY_PATH=/usr/lib64: + CC=gcc + CXX=g++ + TMPDIR=/builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir + RPM_TOXENV=py315 + FEDORA=45 + HOSTNAME=rpmbuild + /usr/bin/python3 -Bs /usr/lib/rpm/redhat/pyproject_buildrequires.py --generate-extras --python3_pkgversion 3 --wheeldir /builddir/build/BUILD/python-llm-0.37.2-build/pyproject-wheeldir --output /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-buildrequires --dep-overrides-file /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-dep-overrides Handling setuptools from build-system.requires Requirement satisfied: setuptools (installed: setuptools 83.0.0) running egg_info writing llm.egg-info/PKG-INFO writing dependency_links to llm.egg-info/dependency_links.txt writing entry points to llm.egg-info/entry_points.txt writing requirements to llm.egg-info/requires.txt writing top-level names to llm.egg-info/top_level.txt reading manifest file 'llm.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' adding license file 'LICENSE' writing manifest file 'llm.egg-info/SOURCES.txt' running dist_info writing llm.egg-info/PKG-INFO writing dependency_links to llm.egg-info/dependency_links.txt writing entry points to llm.egg-info/entry_points.txt writing requirements to llm.egg-info/requires.txt writing top-level names to llm.egg-info/top_level.txt reading manifest file 'llm.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' adding license file 'LICENSE' writing manifest file 'llm.egg-info/SOURCES.txt' creating '/builddir/build/BUILD/python-llm-0.37.2-build/llm-0.37.2/llm-0.37.2.dist-info' Handling click from hook generated metadata: Requires-Dist (llm) Requirement satisfied: click (installed: click 8.4.2) Handling httpx2 from hook generated metadata: Requires-Dist (llm) Requirement satisfied: httpx2 (installed: httpx2 2.16.0) Handling condense-json>=1.1 from hook generated metadata: Requires-Dist (llm) Requirement satisfied: condense-json>=1.1 (installed: condense-json 1.1) Handling openai>=2.21.0 from hook generated metadata: Requires-Dist (llm) Requirement satisfied: openai>=2.21.0 (installed: openai 2.24.0) Handling click-default-group>=1.2.2 from hook generated metadata: Requires-Dist (llm) Requirement satisfied: click-default-group>=1.2.2 (installed: click-default-group 1.2.2) Handling sqlite-utils>=4.0 from hook generated metadata: Requires-Dist (llm) Requirement satisfied: sqlite-utils>=4.0 (installed: sqlite-utils 4.2.1) Handling pydantic>=2.0.0 from hook generated metadata: Requires-Dist (llm) Requirement satisfied: pydantic>=2.0.0 (installed: pydantic 2.13.5) Handling typing-extensions from hook generated metadata: Requires-Dist (llm) Requirement satisfied: typing-extensions (installed: typing-extensions 4.16.0) Handling PyYAML from hook generated metadata: Requires-Dist (llm) Requirement satisfied: PyYAML (installed: PyYAML 6.0.3) Handling pluggy from hook generated metadata: Requires-Dist (llm) Requirement satisfied: pluggy (installed: pluggy 1.7.0) Handling python-ulid from hook generated metadata: Requires-Dist (llm) Requirement satisfied: python-ulid (installed: python-ulid 4.1.0) Handling setuptools from hook generated metadata: Requires-Dist (llm) Requirement satisfied: setuptools (installed: setuptools 83.0.0) Handling pip from hook generated metadata: Requires-Dist (llm) Requirement satisfied: pip (installed: pip 26.3) Handling pyreadline3; sys_platform == "win32" from hook generated metadata: Requires-Dist (llm) Ignoring alien requirement: pyreadline3; sys_platform == "win32" Handling puremagic from hook generated metadata: Requires-Dist (llm) Requirement satisfied: puremagic (installed: puremagic 2.2.0) + cat /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-buildrequires + rm -rfv llm-0.37.2.dist-info/ removed 'llm-0.37.2.dist-info/licenses/LICENSE' removed directory 'llm-0.37.2.dist-info/licenses' removed 'llm-0.37.2.dist-info/METADATA' removed 'llm-0.37.2.dist-info/top_level.txt' removed 'llm-0.37.2.dist-info/entry_points.txt' removed directory 'llm-0.37.2.dist-info/' + RPM_EC=0 ++ jobs -p + exit 0 Executing(%build): /bin/sh -e /var/tmp/rpm-tmp.8MrvRY + umask 022 + cd /builddir/build/BUILD/python-llm-0.37.2-build + CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' + export CFLAGS + CXXFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' + export CXXFLAGS + FFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules ' + export FFLAGS + FCFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules ' + export FCFLAGS + VALAFLAGS=-g + export VALAFLAGS + RUSTFLAGS='-Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Cforce-frame-pointers=yes -Clink-arg=-specs=/usr/lib/rpm/redhat/redhat-package-notes --cap-lints=warn' + export RUSTFLAGS + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes ' + export LDFLAGS + LT_SYS_LIBRARY_PATH=/usr/lib64: + export LT_SYS_LIBRARY_PATH + CC=gcc + export CC + CXX=g++ + export CXX + cd llm-0.37.2 + mkdir -p /builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir + CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' + CXXFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' + FFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules ' + FCFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules ' + VALAFLAGS=-g + RUSTFLAGS='-Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Cforce-frame-pointers=yes -Clink-arg=-specs=/usr/lib/rpm/redhat/redhat-package-notes --cap-lints=warn' + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes ' + LT_SYS_LIBRARY_PATH=/usr/lib64: + CC=gcc + CXX=g++ + TMPDIR=/builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir + /usr/bin/python3 -Bs /usr/lib/rpm/redhat/pyproject_wheel.py /builddir/build/BUILD/python-llm-0.37.2-build/pyproject-wheeldir Processing ./. Preparing metadata (pyproject.toml): started Running command Preparing metadata (pyproject.toml) running dist_info creating /builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir/pip-modern-metadata-u4ubg901/llm.egg-info writing /builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir/pip-modern-metadata-u4ubg901/llm.egg-info/PKG-INFO writing dependency_links to /builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir/pip-modern-metadata-u4ubg901/llm.egg-info/dependency_links.txt writing entry points to /builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir/pip-modern-metadata-u4ubg901/llm.egg-info/entry_points.txt writing requirements to /builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir/pip-modern-metadata-u4ubg901/llm.egg-info/requires.txt writing top-level names to /builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir/pip-modern-metadata-u4ubg901/llm.egg-info/top_level.txt writing manifest file '/builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir/pip-modern-metadata-u4ubg901/llm.egg-info/SOURCES.txt' reading manifest file '/builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir/pip-modern-metadata-u4ubg901/llm.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' adding license file 'LICENSE' writing manifest file '/builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir/pip-modern-metadata-u4ubg901/llm.egg-info/SOURCES.txt' creating '/builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir/pip-modern-metadata-u4ubg901/llm-0.37.2.dist-info' Preparing metadata (pyproject.toml): finished with status 'done' Building wheels for collected packages: llm Building wheel for llm (pyproject.toml): started Running command Building wheel for llm (pyproject.toml) running bdist_wheel running build running build_py creating build/lib/llm copying llm/logs.py -> build/lib/llm copying llm/utils.py -> build/lib/llm copying llm/tools.py -> build/lib/llm copying llm/templates.py -> build/lib/llm copying llm/serialization.py -> build/lib/llm copying llm/plugins.py -> build/lib/llm copying llm/parts.py -> build/lib/llm copying llm/models.py -> build/lib/llm copying llm/migrations.py -> build/lib/llm copying llm/hookspecs.py -> build/lib/llm copying llm/errors.py -> build/lib/llm copying llm/embeddings_migrations.py -> build/lib/llm copying llm/embeddings.py -> build/lib/llm copying llm/cli.py -> build/lib/llm copying llm/__main__.py -> build/lib/llm copying llm/__init__.py -> build/lib/llm creating build/lib/llm/default_plugins copying llm/default_plugins/openai_models.py -> build/lib/llm/default_plugins copying llm/default_plugins/default_tools.py -> build/lib/llm/default_plugins copying llm/default_plugins/__init__.py -> build/lib/llm/default_plugins running egg_info writing llm.egg-info/PKG-INFO writing dependency_links to llm.egg-info/dependency_links.txt writing entry points to llm.egg-info/entry_points.txt writing requirements to llm.egg-info/requires.txt writing top-level names to llm.egg-info/top_level.txt reading manifest file 'llm.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' adding license file 'LICENSE' writing manifest file 'llm.egg-info/SOURCES.txt' copying llm/py.typed -> build/lib/llm installing to build/bdist.linux-x86_64/wheel running install running install_lib creating build/bdist.linux-x86_64/wheel creating build/bdist.linux-x86_64/wheel/llm copying build/lib/llm/py.typed -> build/bdist.linux-x86_64/wheel/./llm creating build/bdist.linux-x86_64/wheel/llm/default_plugins copying build/lib/llm/default_plugins/__init__.py -> build/bdist.linux-x86_64/wheel/./llm/default_plugins copying build/lib/llm/default_plugins/default_tools.py -> build/bdist.linux-x86_64/wheel/./llm/default_plugins copying build/lib/llm/default_plugins/openai_models.py -> build/bdist.linux-x86_64/wheel/./llm/default_plugins copying build/lib/llm/__init__.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/__main__.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/cli.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/embeddings.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/embeddings_migrations.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/errors.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/hookspecs.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/migrations.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/models.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/parts.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/plugins.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/serialization.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/templates.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/tools.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/utils.py -> build/bdist.linux-x86_64/wheel/./llm copying build/lib/llm/logs.py -> build/bdist.linux-x86_64/wheel/./llm running install_egg_info Copying llm.egg-info to build/bdist.linux-x86_64/wheel/./llm-0.37.2-py3.15.egg-info running install_scripts creating build/bdist.linux-x86_64/wheel/llm-0.37.2.dist-info/WHEEL creating '/builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir/pip-ephem-wheel-cache-m4lrzq_c/wheels/0a/96/32/07f57861913af1583dcbf1069a3f99fa0fe0be39296403c88f/tmpn21qk0jq/.tmp-er6jergy/llm-0.37.2-py3-none-any.whl' and adding 'build/bdist.linux-x86_64/wheel' to it adding 'llm/__init__.py' adding 'llm/__main__.py' adding 'llm/cli.py' adding 'llm/embeddings.py' adding 'llm/embeddings_migrations.py' adding 'llm/errors.py' adding 'llm/hookspecs.py' adding 'llm/logs.py' adding 'llm/migrations.py' adding 'llm/models.py' adding 'llm/parts.py' adding 'llm/plugins.py' adding 'llm/py.typed' adding 'llm/serialization.py' adding 'llm/templates.py' adding 'llm/tools.py' adding 'llm/utils.py' adding 'llm/default_plugins/__init__.py' adding 'llm/default_plugins/default_tools.py' adding 'llm/default_plugins/openai_models.py' adding 'llm-0.37.2.dist-info/licenses/LICENSE' adding 'llm-0.37.2.dist-info/METADATA' adding 'llm-0.37.2.dist-info/WHEEL' adding 'llm-0.37.2.dist-info/entry_points.txt' adding 'llm-0.37.2.dist-info/top_level.txt' adding 'llm-0.37.2.dist-info/RECORD' removing build/bdist.linux-x86_64/wheel Building wheel for llm (pyproject.toml): finished with status 'done' Created wheel for llm: filename=llm-0.37.2-py3-none-any.whl size=151429 sha256=f9d5fb42b0f70413c229880dfe44268fe5b7460b6be6e7bb7e4f8c44ec0b60f7 Stored in directory: /builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir/pip-ephem-wheel-cache-m4lrzq_c/wheels/0a/96/32/07f57861913af1583dcbf1069a3f99fa0fe0be39296403c88f Successfully built llm + pushd docs ~/build/BUILD/python-llm-0.37.2-build/llm-0.37.2/docs ~/build/BUILD/python-llm-0.37.2-build/llm-0.37.2 + make man html Running Sphinx v9.1.0 /bin/sh: line 1: git: command not found loading translations [en]... done making output directory... done Converting `source_suffix = '.rst'` to `source_suffix = {'.rst': 'restructuredtext'}`. myst v5.1.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions={'colon_fence'}, disable_syntax=[], all_links_external=False, links_external_new_tab=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_sort=True, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, strikethrough_single_tilde=False, colon_fence_exact_match=False, suppress_warnings=[], highlight_code_blocks=True) building [mo]: targets for 0 po files that are out of date writing output... building [man]: all manpages updating environment: [new config] 28 added, 0 changed, 0 removed reading sources... [ 4%] aliases reading sources... [ 7%] changelog reading sources... [ 11%] contributing reading sources... [ 14%] embeddings/cli reading sources... [ 18%] embeddings/index reading sources... [ 21%] embeddings/python-api reading sources... [ 25%] embeddings/storage reading sources... [ 29%] embeddings/writing-plugins reading sources... [ 32%] fragments reading sources... [ 36%] help reading sources... [ 39%] index reading sources... [ 43%] logging reading sources... [ 46%] openai-models reading sources... [ 50%] other-models reading sources... [ 54%] plugins/advanced-model-plugins reading sources... [ 57%] plugins/directory reading sources... [ 61%] plugins/index reading sources... [ 64%] plugins/installing-plugins reading sources... [ 68%] plugins/plugin-hooks reading sources... [ 71%] plugins/plugin-utilities reading sources... [ 75%] plugins/tutorial-model-plugin reading sources... [ 79%] python-api reading sources... [ 82%] related-tools reading sources... [ 86%] schemas reading sources... [ 89%] setup reading sources... [ 93%] templates reading sources... [ 96%] tools reading sources... [100%] usage looking for now-outdated files... none found pickling environment... done checking consistency... done preparing documents... done copying assets... copying assets: done writing... llm.1 { setup usage openai-models other-models tools schemas templates fragments aliases embeddings/index embeddings/cli embeddings/python-api embeddings/writing-plugins embeddings/storage plugins/index plugins/installing-plugins plugins/directory plugins/plugin-hooks plugins/tutorial-model-plugin plugins/advanced-model-plugins plugins/plugin-utilities python-api logging related-tools help contributing changelog } done build succeeded. The manual pages are in _build/man. Running Sphinx v9.1.0 /bin/sh: line 1: git: command not found loading translations [en]... done making output directory... done Converting `source_suffix = '.rst'` to `source_suffix = {'.rst': 'restructuredtext'}`. loading pickled environment... The configuration has changed (1 option: 'html_static_path') done myst v5.1.0: MdParserConfig(commonmark_only=False, gfm_only=False, enable_extensions={'colon_fence'}, disable_syntax=[], all_links_external=False, links_external_new_tab=False, url_schemes=('http', 'https', 'mailto', 'ftp'), ref_domains=None, fence_as_directive=set(), number_code_blocks=[], title_to_header=False, heading_anchors=0, heading_slug_func=None, html_meta={}, footnote_sort=True, footnote_transition=True, words_per_minute=200, substitutions={}, linkify_fuzzy_links=True, dmath_allow_labels=True, dmath_allow_space=True, dmath_allow_digits=True, dmath_double_inline=False, update_mathjax=True, mathjax_classes='tex2jax_process|mathjax_process|math|output_area', enable_checkboxes=False, strikethrough_single_tilde=False, colon_fence_exact_match=False, suppress_warnings=[], highlight_code_blocks=True) building [mo]: targets for 0 po files that are out of date writing output... building [html]: targets for 28 source files that are out of date updating environment: 0 added, 0 changed, 0 removed reading sources... looking for now-outdated files... none found preparing documents... done copying assets... copying static files... Writing evaluated template result to /builddir/build/BUILD/python-llm-0.37.2-build/llm-0.37.2/docs/_build/html/_static/language_data.js Writing evaluated template result to /builddir/build/BUILD/python-llm-0.37.2-build/llm-0.37.2/docs/_build/html/_static/documentation_options.js Writing evaluated template result to /builddir/build/BUILD/python-llm-0.37.2-build/llm-0.37.2/docs/_build/html/_static/basic.css Writing evaluated template result to /builddir/build/BUILD/python-llm-0.37.2-build/llm-0.37.2/docs/_build/html/_static/copybutton.js copying static files: done copying extra files... copying extra files: done copying assets: done writing output... [ 4%] aliases writing output... [ 7%] changelog writing output... [ 11%] contributing writing output... [ 14%] embeddings/cli writing output... [ 18%] embeddings/index writing output... [ 21%] embeddings/python-api writing output... [ 25%] embeddings/storage writing output... [ 29%] embeddings/writing-plugins writing output... [ 32%] fragments writing output... [ 36%] help writing output... [ 39%] index writing output... [ 43%] logging writing output... [ 46%] openai-models writing output... [ 50%] other-models writing output... [ 54%] plugins/advanced-model-plugins writing output... [ 57%] plugins/directory writing output... [ 61%] plugins/index writing output... [ 64%] plugins/installing-plugins writing output... [ 68%] plugins/plugin-hooks writing output... [ 71%] plugins/plugin-utilities writing output... [ 75%] plugins/tutorial-model-plugin writing output... [ 79%] python-api writing output... [ 82%] related-tools writing output... [ 86%] schemas writing output... [ 89%] setup writing output... [ 93%] templates writing output... [ 96%] tools writing output... [100%] usage generating indices... genindex done writing additional pages... search done dumping search index in English (code: en)... done dumping object inventory... done build succeeded. The HTML pages are in _build/html. + rm -rf docs/_build/html/.buildinfo + find docs/_build/html -size 0 -delete + RPM_EC=0 ++ jobs -p + exit 0 Executing(%install): /bin/sh -e /var/tmp/rpm-tmp.axr3N7 + umask 022 + cd /builddir/build/BUILD/python-llm-0.37.2-build + '[' /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT '!=' / ']' + rm -rf /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT ++ dirname /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT + mkdir -p /builddir/build/BUILD/python-llm-0.37.2-build + mkdir /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT + CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' + export CFLAGS + CXXFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' + export CXXFLAGS + FFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules ' + export FFLAGS + FCFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules ' + export FCFLAGS + VALAFLAGS=-g + export VALAFLAGS + RUSTFLAGS='-Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Cforce-frame-pointers=yes -Clink-arg=-specs=/usr/lib/rpm/redhat/redhat-package-notes --cap-lints=warn' + export RUSTFLAGS + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes ' + export LDFLAGS + LT_SYS_LIBRARY_PATH=/usr/lib64: + export LT_SYS_LIBRARY_PATH + CC=gcc + export CC + CXX=g++ + export CXX + cd llm-0.37.2 ++ xargs basename --multiple ++ ls /builddir/build/BUILD/python-llm-0.37.2-build/pyproject-wheeldir/llm-0.37.2-py3-none-any.whl ++ sed -E 's/([^-]+)-([^-]+)-.+\.whl/\1==\2/' + specifier=llm==0.37.2 + '[' -z llm==0.37.2 ']' + PIP_CONFIG_FILE=/dev/null + TMPDIR=/builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir + /usr/bin/python3 -m pip install --root /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT --prefix /usr --no-deps --disable-pip-version-check --progress-bar off --verbose --ignore-installed --no-warn-script-location --no-index --no-cache-dir --find-links /builddir/build/BUILD/python-llm-0.37.2-build/pyproject-wheeldir llm==0.37.2 Using pip 26.3 from /usr/lib/python3.15/site-packages/pip (python 3.15) Looking in links: /builddir/build/BUILD/python-llm-0.37.2-build/pyproject-wheeldir Processing /builddir/build/BUILD/python-llm-0.37.2-build/pyproject-wheeldir/llm-0.37.2-py3-none-any.whl Installing collected packages: llm Creating /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/bin changing mode of /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/bin/llm to 755 Successfully installed llm-0.37.2 + '[' -d /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/bin ']' + '[' -z sP ']' + shebang_flags=-kasP + /usr/bin/python3 -B /usr/lib/rpm/redhat/pathfix.py -pni /usr/bin/python3 -kasP /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/bin/llm /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/bin/llm: updating + rm -rfv /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/bin/__pycache__ + rm -f /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-ghost-distinfo + site_dirs=() + '[' -d /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages ']' + site_dirs+=("/usr/lib/python3.15/site-packages") + '[' /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib64/python3.15/site-packages '!=' /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages ']' + '[' -d /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib64/python3.15/site-packages ']' + for site_dir in ${site_dirs[@]} + for distinfo in /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT$site_dir/*.dist-info + echo '%ghost %dir /usr/lib/python3.15/site-packages/llm-0.37.2.dist-info' +++ basename /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm-0.37.2.dist-info ++ PYTHONPATH=/usr/lib/rpm/redhat ++ /usr/bin/python3 -sBc 'import sys; from pyproject_save_files import canonical_name_from_distinfo; print(canonical_name_from_distinfo(sys.argv[1]))' llm-0.37.2.dist-info + _normalized=llm + echo '%ghost %dir /usr/lib/python3.15/site-packages/llm-0.37.2.dist-info' + sed -i s/pip/rpm/ /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm-0.37.2.dist-info/INSTALLER + PYTHONPATH=/usr/lib/rpm/redhat + /usr/bin/python3 -B /usr/lib/rpm/redhat/pyproject_preprocess_record.py --buildroot /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT --record /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm-0.37.2.dist-info/RECORD --output /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-record + rm -fv /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm-0.37.2.dist-info/RECORD removed '/builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm-0.37.2.dist-info/RECORD' + rm -fv /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm-0.37.2.dist-info/REQUESTED removed '/builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm-0.37.2.dist-info/REQUESTED' + '[' -f /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-dep-overrides ']' ++ cut -f1 '-d ' ++ wc -l /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-ghost-distinfo + lines=1 + '[' 1 -ne 1 ']' + RPM_FILES_ESCAPE=4.19 + /usr/bin/python3 /usr/lib/rpm/redhat/pyproject_save_files.py --output-files /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-files --output-modules /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-modules --buildroot /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT --sitelib /usr/lib/python3.15/site-packages --sitearch /usr/lib64/python3.15/site-packages --python-version 3.15 --pyproject-record /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-record --prefix /usr llm + install -D -m0644 docs/_build/man/llm.1 /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/share/man/man1/llm.1 + /usr/lib/rpm/check-buildroot + /usr/lib/rpm/redhat/brp-ldconfig + COMPRESS='gzip -9 -n' + COMPRESS_EXT=.gz + /usr/lib/rpm/brp-compress + /usr/lib/rpm/brp-strip /usr/bin/strip + /usr/lib/rpm/brp-strip-comment-note /usr/bin/strip /usr/bin/objdump + /usr/lib/rpm/redhat/brp-strip-lto /usr/bin/strip + /usr/lib/rpm/check-rpaths + /usr/lib/rpm/redhat/brp-mangle-shebangs + /usr/lib/rpm/brp-remove-la-files + /usr/lib/rpm/redhat/brp-python-rpm-in-distinfo + env /usr/lib/rpm/redhat/brp-python-bytecompile '' 1 0 -j2 Bytecompiling .py files below /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15 using python3.15 + /usr/lib/rpm/redhat/brp-python-hardlink + /usr/bin/add-det --brp -j2 /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/plugins.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/parts.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/models.cpython-315.opt-1.pyc: replacing with normalized version /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/models.cpython-315.pyc: replacing with normalized version /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/tools.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/utils.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/templates.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/serialization.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/migrations.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/logs.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/hookspecs.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/errors.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/embeddings_migrations.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/embeddings.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/__main__.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/cli.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/__pycache__/__init__.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/__pycache__/__init__.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/__pycache__/default_tools.cpython-315.opt-1.pyc: rewriting with normalized contents /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/__pycache__/openai_models.cpython-315.opt-1.pyc: rewriting with normalized contents Scanned 15 directories and 66 files, processed 21 inodes, 20 modified (2 replaced + 18 rewritten), 0 unsupported format, 0 errors + /usr/bin/linkdupes --brp /builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr Scanned 14 directories and 66 files, considered 66 files, read 2 files, linked 1 files, 0 errors sum of sizes of linked files: 0 bytes Executing(%check): /bin/sh -e /var/tmp/rpm-tmp.mGIfUr + umask 022 + cd /builddir/build/BUILD/python-llm-0.37.2-build + CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' + export CFLAGS + CXXFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' + export CXXFLAGS + FFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules ' + export FFLAGS + FCFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -I/usr/lib64/gfortran/modules ' + export FCFLAGS + VALAFLAGS=-g + export VALAFLAGS + RUSTFLAGS='-Copt-level=3 -Cdebuginfo=2 -Ccodegen-units=1 -Cstrip=none -Cforce-frame-pointers=yes -Clink-arg=-specs=/usr/lib/rpm/redhat/redhat-package-notes --cap-lints=warn' + export RUSTFLAGS + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes ' + export LDFLAGS + LT_SYS_LIBRARY_PATH=/usr/lib64: + export LT_SYS_LIBRARY_PATH + CC=gcc + export CC + CXX=g++ + export CXX + cd llm-0.37.2 + '[' '!' -f /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-modules ']' + PATH=/builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin + PYTHONPATH=/builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib64/python3.15/site-packages:/builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages + _PYTHONSITE=/builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib64/python3.15/site-packages:/builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages + PYTHONDONTWRITEBYTECODE=1 + /usr/bin/python3 -sP /usr/lib/rpm/redhat/import_all_modules.py -f /builddir/build/BUILD/python-llm-0.37.2-build/python-llm-0.37.2-1.fc45.x86_64-pyproject-modules Check import: llm Check import: llm.cli Check import: llm.default_plugins Check import: llm.default_plugins.default_tools Check import: llm.default_plugins.openai_models Check import: llm.embeddings Check import: llm.embeddings_migrations Check import: llm.errors Check import: llm.hookspecs Check import: llm.logs Check import: llm.migrations Check import: llm.models Check import: llm.parts Check import: llm.plugins Check import: llm.serialization Check import: llm.templates Check import: llm.tools Check import: llm.utils + export ISOLATED_CI_ENV=1 + ISOLATED_CI_ENV=1 + CFLAGS='-O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -mtls-dialect=gnu2 -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer ' + LDFLAGS='-Wl,-z,relro -Wl,--as-needed -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-hardened-ld-errors -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes ' + PATH=/builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin + PYTHONPATH=/builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib64/python3.15/site-packages:/builddir/build/BUILD/python-llm-0.37.2-build/BUILDROOT/usr/lib/python3.15/site-packages + PYTHONDONTWRITEBYTECODE=1 + PYTEST_ADDOPTS=' --ignore=/builddir/build/BUILD/python-llm-0.37.2-build/.pyproject-builddir' + PYTEST_XDIST_AUTO_NUM_WORKERS=2 + /usr/bin/pytest ============================= test session starts ============================== platform linux -- Python 3.15.2, pytest-9.1.1, pluggy-1.7.0 SQLite: 3.53.4 sqlite-utils: 4.2.1 rootdir: /builddir/build/BUILD/python-llm-0.37.2-build/llm-0.37.2 configfile: pytest.ini plugins: httpx-0.36.0, asyncio-1.4.0, httpx2-pytest-2.0.0, recording-0.13.4, anyio-4.15.1 asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=function, asyncio_default_test_loop_scope=function collected 1491 items tests/test_aliases.py ................. [ 1%] tests/test_async.py .... [ 1%] tests/test_async_parity.py ................... [ 2%] tests/test_attachments.py .................. [ 3%] tests/test_chain_callbacks.py ...... [ 4%] tests/test_chat.py ...................... [ 5%] tests/test_chat_templates.py ... [ 5%] tests/test_cli_openai_models.py ....................................FEFE [ 8%] .FEFEFE......FEFEFE.FEFEFEFEFEFEFEFEFEFE [ 10%] tests/test_cli_options.py ...... [ 10%] tests/test_cli_streaming.py ........ [ 11%] tests/test_connection_cleanup.py .............. [ 12%] tests/test_embed.py ................................. [ 14%] tests/test_embed_cli.py ................................................ [ 17%] ................................................................... [ 21%] tests/test_encode_decode.py .. [ 22%] tests/test_fragments_cli.py ...FE [ 22%] tests/test_incremental_logging.py ...................................... [ 24%] .. [ 25%] tests/test_keys.py ......FE [ 25%] tests/test_llm.py .FEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEF [ 27%] EFEFEFEFE.FEFEFE..................................FEFE........ [ 30%] tests/test_llm_logs.py ................................................. [ 34%] .....................sss.sss........................... [ 37%] tests/test_logs_store.py ............................................... [ 40%] ........................................................................ [ 45%] ............................................................... [ 50%] tests/test_migrate.py ...... [ 50%] tests/test_openai_endpoint.py FEFEFEFEFEFE.FEFEFEFEFEFEFEFEFEFE.FEFEFEFE [ 51%] FEFEFE [ 52%] tests/test_openai_endpoint_add.py ................................... [ 54%] tests/test_openai_key_leaks.py FFFFFF...FFFFFF...FFFFFF...FFFFFF...FFFFF [ 57%] F...FFFFFF...FFFFFF..........FFF [ 59%] tests/test_openai_messages.py .............FEFEFEFEFEFEFEFEFEFEFE [ 60%] tests/test_openai_responses.py ..................FE.FEFE..FEFE.FEFEFEFEF [ 63%] EFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFEFE..FE..................FEFEF [ 66%] E......FEFEFEFEFE. [ 67%] tests/test_options_parameter.py FEFEFEFE......... [ 67%] tests/test_parts.py .................................................... [ 71%] ........................................................................ [ 76%] .................................. [ 78%] tests/test_pause_resume.py ............... [ 79%] tests/test_plugins.py ........... [ 80%] tests/test_schema_turn_usage.py ..... [ 80%] tests/test_serialization.py ............................................ [ 83%] ....... [ 83%] tests/test_supports_conversation.py ................................ [ 86%] tests/test_templates.py ..........................FEFEFEFE.FEFEFEFEFEFE. [ 88%] ...FE.... [ 89%] tests/test_tools.py .................................................... [ 92%] ....... [ 93%] tests/test_tools_streaming.py .... [ 93%] tests/test_utils.py .................................................... [ 96%] .............................................. [100%] ==================================== ERRORS ==================================== _ ERROR at teardown of test_gpt5_verbosity_option_is_sent_to_openai_chat_completions _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4ca9c9860> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_gpt5_verbosity_option_is_sent_to_openai_responses_by_default _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8cb91d0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_code_interpreter_cli_tool_is_resolved_from_model __ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9c70ec0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_code_interpreter_cli_tool_is_reused_on_continue ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c850a2e0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _____ ERROR at teardown of test_web_search_cli_tool_is_resolved_from_model _____ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9bb4b40> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_openai_image_detail_option_is_sent_on_image_attachments _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9bd4e50> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ___ ERROR at teardown of test_openai_image_detail_original_is_sent_for_gpt54 ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d43310> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_openai_image_detail_original_is_sent_for_gpt54_responses_by_default _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9bd77e0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _______ ERROR at teardown of test_gpt4o_mini_sync_and_async[None-False] ________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d8dd30> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ________ ERROR at teardown of test_gpt4o_mini_sync_and_async[None-True] ________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d8e740> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ________ ERROR at teardown of test_gpt4o_mini_sync_and_async[-u-False] _________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9226190> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _________ ERROR at teardown of test_gpt4o_mini_sync_and_async[-u-True] _________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9b3f9a0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ______ ERROR at teardown of test_gpt4o_mini_sync_and_async[--usage-False] ______ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d5fb60> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ______ ERROR at teardown of test_gpt4o_mini_sync_and_async[--usage-True] _______ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d96660> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_chat_completion_without_usage_sync_and_async[missing-False] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d7ee40> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_chat_completion_without_usage_sync_and_async[missing-True] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d5b4d0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_chat_completion_without_usage_sync_and_async[null-False] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c91acc20> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_chat_completion_without_usage_sync_and_async[null-True] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d7c1a0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ______________ ERROR at teardown of test_fragment_url_user_agent _______________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9275fd0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __________________ ERROR at teardown of test_uses_correct_key __________________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c92740c0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _______ ERROR at teardown of test_llm_prompt_creates_log_database[False] _______ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9a557f0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _______ ERROR at teardown of test_llm_prompt_creates_log_database[True] ________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9a71f60> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ___ ERROR at teardown of test_llm_default_prompt[True-logs_args0-False-True] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c99d1b00> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_llm_default_prompt[True-logs_args0-False-False] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c99c1320> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_llm_default_prompt[True-logs_args0-False-split] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9a031c0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ___ ERROR at teardown of test_llm_default_prompt[False-logs_args1-True-True] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c99d02f0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_llm_default_prompt[False-logs_args1-True-False] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c85531c0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_llm_default_prompt[False-logs_args1-True-split] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8552d60> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_llm_default_prompt[False-logs_args2-False-True] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9a59710> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_llm_default_prompt[False-logs_args2-False-False] __ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9a97d90> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_llm_default_prompt[False-logs_args2-False-split] __ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9a17b60> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ___ ERROR at teardown of test_llm_default_prompt[False-logs_args3-True-True] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9a3b850> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_llm_default_prompt[False-logs_args3-True-False] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9a3d6a0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_llm_default_prompt[False-logs_args3-True-split] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9275e80> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ___ ERROR at teardown of test_llm_default_prompt[True-logs_args4-False-True] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9a5ac80> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_llm_default_prompt[True-logs_args4-False-False] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c68cc6e0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_llm_default_prompt[True-logs_args4-False-split] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8f24d00> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ___ ERROR at teardown of test_llm_default_prompt[True-logs_args5-True-True] ____ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8ebe0b0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ___ ERROR at teardown of test_llm_default_prompt[True-logs_args5-True-False] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8f335b0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ___ ERROR at teardown of test_llm_default_prompt[True-logs_args5-True-split] ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8ebea50> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _____________ ERROR at teardown of test_llm_prompt_continue[False] _____________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8edeb30> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _____________ ERROR at teardown of test_llm_prompt_continue[True] ______________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8f42430> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __________ ERROR at teardown of test_extract_fenced_code[args0-True] ___________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8ef7e00> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __________ ERROR at teardown of test_extract_fenced_code[args1-True] ___________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8f76270> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __________ ERROR at teardown of test_extract_fenced_code[args2-True] ___________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8edd550> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __________ ERROR at teardown of test_extract_fenced_code[args3-True] ___________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8f75fd0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __________ ERROR at teardown of test_extract_fenced_code[args4-False] __________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8ef2c80> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ______________ ERROR at teardown of test_extract_fenced_code_crlf ______________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8f9ef90> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _________________ ERROR at teardown of test_openai_chat_stream _________________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8f8f310> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _________________ ERROR at teardown of test_openai_completion __________________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8f8cf30> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ____ ERROR at teardown of test_openai_completion_continue_includes_history _____ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c7ded2b0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _________ ERROR at teardown of test_openai_completion_logprobs_stream __________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c7e859b0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ________ ERROR at teardown of test_openai_completion_logprobs_nostream _________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c7ddbe00> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ____________ ERROR at teardown of test_openai_localai_configuration ____________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c7e50b40> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on http://localai.localhost/chat/completions E - Match POST request on http://localai.localhost/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ______ ERROR at teardown of test_llm_prompt_continue_with_database[False] ______ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8ef6b30> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ______ ERROR at teardown of test_llm_prompt_continue_with_database[True] _______ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c7e50b40> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_endpoint_chat_completions_does_not_log_or_leak_default_key _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c7e95cc0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://example.test/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ________ ERROR at teardown of test_endpoint_chat_completions_attachment ________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8c1b850> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://attachments.example.test/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _________________ ERROR at teardown of test_endpoint_template __________________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c83734d0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://templates.example.test/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_endpoint_template_schema_object_used_when_no_cli_schema _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c884bb60> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://templates2.example.test/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __________________ ERROR at teardown of test_endpoint_schema ___________________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c7e95a20> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://schema.example.test/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_endpoint_schema_by_id_from_existing_logs_database __ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c7db2b30> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://schema-id.example.test/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ___ ERROR at teardown of test_endpoint_static_template_runs_once_on_terminal ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c7de2270> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://terminal-template.example.test/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ____________ ERROR at teardown of test_endpoint_tools_and_functions ____________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c82e0670> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://tools.example.test/v1/chat/completions E - Match POST request on https://tools.example.test/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ____________ ERROR at teardown of test_endpoint_streams_by_default _____________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8378c20> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://stream.example.test/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _____________ ERROR at teardown of test_endpoint_uses_explicit_key _____________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c83648a0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://example.test/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ___ ERROR at teardown of test_endpoint_lists_models_without_model_or_logging ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c82fda20> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match GET request on https://models.example.test/v1/models E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_endpoint_models_surfaces_error_from_successful_response _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8861010> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match GET request on https://models-error.example.test/models E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _______________ ERROR at teardown of test_endpoint_responses_api _______________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c87dc830> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://responses.example.test/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_endpoint_responses_reasoning_summary_option[auto] __ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c884cec0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://responses-summary.example.test/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_endpoint_responses_reasoning_summary_option[concise] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8364bb0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://responses-summary.example.test/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_endpoint_responses_reasoning_summary_option[detailed] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c884a3c0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://responses-summary.example.test/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _________ ERROR at teardown of test_endpoint_responses_api_attachment __________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8868e50> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://responses-attachments.example.test/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ________ ERROR at teardown of test_endpoint_responses_api_schema_multi _________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c87c4910> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://responses-schema.example.test/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ____________ ERROR at teardown of test_endpoint_responses_api_tools ____________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c87fc7c0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://responses-tools.example.test/v1/responses E - Match POST request on https://responses-tools.example.test/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ____ ERROR at teardown of test_endpoint_responses_api_raw_server_side_tool _____ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c87fee40> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://raw-tools.example.test/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ______ ERROR at teardown of test_endpoint_reads_one_off_prompt_from_stdin ______ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9473310> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://stdin.example.test/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ______ ERROR at teardown of test_endpoint_without_prompt_waits_for_stdin _______ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c87d2a50> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://terminal-stdin.example.test/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ____ ERROR at teardown of test_endpoint_interactive_chat_preserves_history _____ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c87fe270> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://chat.example.test/v1/chat/completions E - Match POST request on https://chat.example.test/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of TestBuildMessagesConversationHistory.test_no_double_emission_from_conversation_prompt_flow _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c869ba10> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of TestStreamingExecuteYieldsStreamEvents.test_text_stream_yields_text_events _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c85c8590> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of TestStreamingExecuteYieldsStreamEvents.test_text_stream_plain_iteration_still_returns_strings _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c85f0050> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of TestStreamingExecuteYieldsStreamEvents.test_text_stream_messages_assembled _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8e9a5f0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of TestStreamingExecuteYieldsStreamEvents.test_tool_call_stream_yields_name_and_args_events _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8695e10> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of TestStreamingExecuteYieldsStreamEvents.test_tool_call_registered_via_add_tool_call _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c869a200> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of TestStreamingExecuteYieldsStreamEvents.test_text_then_tool_call_part_index_advances _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8dae900> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of TestAsyncStreamingExecuteYieldsStreamEvents.test_text_stream_yields_text_events _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c86048a0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of TestReasoningTokenCount.test_redacted_reasoning_part_emitted_when_count_present _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c865dcc0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of TestReasoningTokenCount.test_no_reasoning_part_when_zero_or_absent _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c85d79a0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of TestNonStreamingExecuteYieldsStreamEvents.test_non_streaming_text_yields_single_event _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c903d1d0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_responses_web_search_request_and_result_capture ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c903f2a0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_responses_mixes_function_and_code_interpreter_tools _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c90843d0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_responses_raw_server_tool_passthrough_on_custom_endpoint _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9085be0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://example.test/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ______ ERROR at teardown of test_async_responses_code_interpreter_request ______ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c85f04b0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _________ ERROR at teardown of test_async_responses_web_search_request _________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8607ee0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ____ ERROR at teardown of test_chat_completions_opt_out_dispatches_to_chat _____ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8ff6120> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[None-False-gpt-5.5] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8fbaf20> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[None-False-gpt-6-sol] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c90259b0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[None-False-gpt-6-luna] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c90944b0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[None-False-gpt-6.1-terra] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c6ac42f0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[None-True-gpt-5.5] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c6ac7310> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[None-True-gpt-6-sol] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c6afeac0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[None-True-gpt-6-luna] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c6ab7d20> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[None-True-gpt-6.1-terra] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c6b36a50> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[none-False-gpt-5.5] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c6b61a90> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[none-False-gpt-6-sol] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8dae900> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[none-False-gpt-6-luna] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c6ac6510> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[none-False-gpt-6.1-terra] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8fc91d0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[none-True-gpt-5.5] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8fca350> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[none-True-gpt-6-sol] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c6aa64a0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[none-True-gpt-6-luna] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c6b2f5b0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[none-True-gpt-6.1-terra] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c826e0b0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[max-False-gpt-5.5] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c82772a0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[max-False-gpt-6-sol] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8241710> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[max-False-gpt-6-luna] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c81d2d60> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[max-False-gpt-6.1-terra] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c82401a0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[max-True-gpt-5.5] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8281b00> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[max-True-gpt-6-sol] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8272200> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[max-True-gpt-6-luna] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c6b608a0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_default_routes_to_responses_endpoint[max-True-gpt-6.1-terra] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c826f5b0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_hide_reasoning_omits_reasoning_summary_from_responses_request _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c824b4d0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_non_reasoning_responses_model_omits_encrypted_reasoning_include _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c96a0f30> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_responses_reply_sends_prior_assistant_text_as_string _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c81fdc50> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ______ ERROR at teardown of test_service_tier_sent_to_responses_endpoint _______ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c965e660> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ___ ERROR at teardown of test_service_tier_sent_to_chat_completions_fallback ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c96a3f50> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ______ ERROR at teardown of test_responses_streams_reasoning_summary_text ______ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9662430> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_responses_reasoning_metadata_refreshed_from_final_payload _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c69d3620> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ______ ERROR at teardown of test_code_interpreter_multi_message_response _______ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8b4c0c0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError ___ ERROR at teardown of test_code_interpreter_streaming_output_and_request ____ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8b4f850> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_web_search_streaming_refreshes_from_final_payload __ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c96638c0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_async_web_search_streaming_refreshes_from_final_payload _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8271ef0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _______ ERROR at teardown of test_direct_prompt_default_options[kwargs0] _______ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c6a4a820> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _______ ERROR at teardown of test_direct_prompt_default_options[kwargs1] _______ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8b96cf0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _______ ERROR at teardown of test_direct_prompt_default_options[kwargs2] _______ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8b26270> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __________ ERROR at teardown of test_direct_prompt_preserves_options ___________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8b024a0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/responses E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_execute_prompt_with_a_template['Summarize this: $input'-Input text-extra_args0-gpt-4o-mini-Summarize this: Input text-None-None] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c6717380> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'\nmodel: gpt-4o-Input text-extra_args1-gpt-4o-Summarize this: Input text-None-None] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8a83070> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'-Input text-extra_args2-gpt-4o-Summarize this: Input text-None-None] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8a0e120> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_execute_prompt_with_a_template[boo-Input text-extra_args3-gpt-4o-mini-expected_input3-None-None] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c67155c0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_execute_prompt_with_a_template[prompt: 'Say $hello'-Input text-extra_args5-gpt-4o-mini-Say Blah\nInput text-None-None] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c89a8fa0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_execute_prompt_with_a_template[prompt: 'Say pelican'--extra_args6-gpt-4o-mini-Say pelican-None-None] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c89a87c0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_execute_prompt_with_a_template[system: 'Summarize this'-Input text-extra_args7-gpt-4o-mini-expected_input7-None-None] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8a11780> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5-Input text-extra_args8-gpt-4o-mini-Summarize this: Input text-None-expected_options8] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8a9f7e0> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _ ERROR at teardown of test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5-Input text-extra_args9-gpt-4o-mini-Summarize this: Input text-None-expected_options9] _ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c89fa120> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError __ ERROR at teardown of test_execute_prompt_with_multiple_templates_in_order ___ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c89eb230> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError _________ ERROR at teardown of test_template_respects_cli_extract_flag _________ monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c89e8910> request = > @pytest.fixture def httpx2_mock( monkeypatch: MonkeyPatch, request: FixtureRequest, ) -> Generator[HTTPXMock, None, None]: options = _httpx2_mock_options(request) mock = HTTPXMock(options) # Mock synchronous requests real_handle_request = httpx2.HTTPTransport.handle_request def mocked_handle_request( transport: httpx2.HTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return mock._handle_request(transport, request) return real_handle_request(transport, request) monkeypatch.setattr( httpx2.HTTPTransport, "handle_request", mocked_handle_request, ) # Mock asynchronous requests real_handle_async_request = httpx2.AsyncHTTPTransport.handle_async_request async def mocked_handle_async_request( transport: httpx2.AsyncHTTPTransport, request: httpx2.Request ) -> httpx2.Response: if options.should_mock(request): return await mock._handle_async_request(transport, request) return await real_handle_async_request(transport, request) monkeypatch.setattr( httpx2.AsyncHTTPTransport, "handle_async_request", mocked_handle_async_request, ) yield mock try: > mock._assert_options() /usr/lib/python3.15/site-packages/pytest_httpx2/__init__.py:70: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = def _assert_options(self) -> None: callbacks_not_executed = [ matcher for matcher, _ in self._callbacks if matcher.should_have_matched() ] matchers_description = "\n".join( [f"- {matcher}" for matcher in callbacks_not_executed] ) > assert not callbacks_not_executed, ( ^^^^^^^^^^^^^^^^^^^^^^^^^^ "The following responses are mocked but not requested:\n" f"{matchers_description}\n" "\n" "If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested" ) E AssertionError: The following responses are mocked but not requested: E - Match POST request on https://api.openai.com/v1/chat/completions E E If this is on purpose, refer to https://github.com/angryfoxx/httpx2-pytest/blob/master/README.md#allow-to-register-more-responses-than-what-will-be-requested /usr/lib/python3.15/site-packages/pytest_httpx2/_httpx_mock.py:344: AssertionError =================================== FAILURES =================================== ________ test_gpt5_verbosity_option_is_sent_to_openai_chat_completions _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo... 'content': 'Say hi'}], 'model': 'gpt-5', 'stream': False, 'verbosity': }, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_gpt5_verbosity_option_is_sent_to_openai_chat_completions(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", json={ "model": "gpt-5", "usage": {}, "choices": [{"message": {"content": "Verbose enough"}}], }, headers={"Content-Type": "application/json"}, ) runner = CliRunner() > result = runner.invoke( cli, [ "-m", "gpt-5", "-o", "chat_completions", "1", "-o", "verbosity", "high", "--no-stream", "--key", "x", "Say hi", ], catch_exceptions=False, ) tests/test_cli_openai_models.py:138: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2777: in execute yield from chat.execute(prompt, stream, response, conversation, key) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo... 'content': 'Say hi'}], 'model': 'gpt-5', 'stream': False, 'verbosity': }, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ______ test_gpt5_verbosity_option_is_sent_to_openai_responses_by_default _______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...mary': 'auto'}, 'store': False, 'stream': False, 'text': {'verbosity': }}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_gpt5_verbosity_option_is_sent_to_openai_responses_by_default(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": "gpt-5", "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "Verbose enough", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) runner = CliRunner() > result = runner.invoke( cli, [ "-m", "gpt-5", "-o", "verbosity", "high", "--no-stream", "--key", "x", "Say hi", ], catch_exceptions=False, ) tests/test_cli_openai_models.py:196: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...mary': 'auto'}, 'store': False, 'stream': False, 'text': {'verbosity': }}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____________ test_code_interpreter_cli_tool_is_resolved_from_model _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_... False, 'tools': [{'type': 'code_interpreter', 'container': {'type': 'auto', 'memory_limit': '4g'}}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_code_interpreter_cli_tool_is_resolved_from_model(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_code_interpreter_cli", "object": "response", "created_at": 1, "model": "gpt-5.6-luna", "output": [ { "type": "message", "id": "msg_code_interpreter_cli", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "Calculated", "annotations": [], } ], } ], "usage": {"input_tokens": 1, "output_tokens": 1, "total_tokens": 2}, "status": "completed", }, headers={"Content-Type": "application/json"}, ) > result = CliRunner().invoke( cli, [ "-m", "gpt-5.6-luna", "-T", 'CodeInterpreter(memory_limit="4g")', "--no-stream", "--no-log", "--key", "x", "Run this calculation", ], catch_exceptions=False, ) tests/test_cli_openai_models.py:257: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:3106: in text return "".join(self) ^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:3069: in __iter__ for chunk in response_item: ^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_... False, 'tools': [{'type': 'code_interpreter', 'container': {'type': 'auto', 'memory_limit': '4g'}}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_code_interpreter_cli_tool_is_reused_on_continue _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_... False, 'tools': [{'type': 'code_interpreter', 'container': {'type': 'auto', 'memory_limit': '4g'}}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9c9fd70> httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_code_interpreter_cli_tool1/llm.datasette.io') def test_code_interpreter_cli_tool_is_reused_on_continue( db_factory, httpx2_mock, user_path ): def response_payload(response_id, text): return { "id": response_id, "object": "response", "created_at": 1, "model": "gpt-5.6-luna", "output": [ { "type": "message", "id": f"msg_{response_id}", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": text, "annotations": [], } ], } ], "usage": {"input_tokens": 1, "output_tokens": 1, "total_tokens": 2}, "status": "completed", } first_payload = response_payload("resp_code_interpreter_first", "Calculated") first_payload["output"] = [ { "type": "message", "id": "msg_before_code", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "Running Python", "annotations": [], } ], }, { "type": "code_interpreter_call", "id": "ci_continue", "status": "completed", "container_id": "cntr_continue", "code": "print(6 * 7)", "outputs": [{"type": "logs", "logs": "42\n"}], }, { "type": "message", "id": "msg_after_code", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "Calculated", "annotations": [], } ], }, ] for payload in ( first_payload, response_payload("resp_code_interpreter_second", "Continued"), ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json=payload, headers={"Content-Type": "application/json"}, ) runner = CliRunner() > first = runner.invoke( cli, [ "-m", "gpt-5.6-luna", "-T", 'CodeInterpreter(memory_limit="4g")', "--no-stream", "--key", "x", "Run this calculation", ], catch_exceptions=False, ) tests/test_cli_openai_models.py:362: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:3106: in text return "".join(self) ^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:3069: in __iter__ for chunk in response_item: ^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_... False, 'tools': [{'type': 'code_interpreter', 'container': {'type': 'auto', 'memory_limit': '4g'}}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______________ test_web_search_cli_tool_is_resolved_from_model ________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...'type': 'web_search', 'filters': {'allowed_domains': ['openai.com']}, 'search_context_size': 'low'}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_web_search_cli_tool_is_resolved_from_model(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_web_search_cli", "object": "response", "created_at": 1, "model": "gpt-5.6-luna", "output": [ { "type": "message", "id": "msg_web_search_cli", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "Search complete", "annotations": [], } ], } ], "usage": {"input_tokens": 1, "output_tokens": 1, "total_tokens": 2}, "status": "completed", }, headers={"Content-Type": "application/json"}, ) > result = CliRunner().invoke( cli, [ "-m", "gpt-5.6-luna", "-T", 'WebSearch(allowed_domains=["openai.com"], search_context_size="low", include_sources=true)', "--no-stream", "--no-log", "--key", "x", "Search for OpenAI news", ], catch_exceptions=False, ) tests/test_cli_openai_models.py:437: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:3106: in text return "".join(self) ^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:3069: in __iter__ for chunk in response_item: ^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...'type': 'web_search', 'filters': {'allowed_domains': ['openai.com']}, 'search_context_size': 'low'}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________ test_openai_image_detail_option_is_sent_on_image_attachments _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...: {'url': 'https://example.com/image.jpg', 'detail': 'high'}}]}], 'model': 'gpt-4o', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_openai_image_detail_option_is_sent_on_image_attachments(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", json={ "model": "gpt-4o", "usage": {}, "choices": [{"message": {"content": "Looks detailed"}}], }, headers={"Content-Type": "application/json"}, ) runner = CliRunner() > result = runner.invoke( cli, [ "-m", "gpt-4o", "-o", "image_detail", "high", "--at", "https://example.com/image.jpg", "image/jpeg", "--no-stream", "--key", "x", "Describe this", ], catch_exceptions=False, ) tests/test_cli_openai_models.py:550: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...: {'url': 'https://example.com/image.jpg', 'detail': 'high'}}]}], 'model': 'gpt-4o', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_openai_image_detail_original_is_sent_for_gpt54 ______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...rl': 'https://example.com/image.jpg', 'detail': 'original'}}]}], 'model': 'gpt-5.4', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_openai_image_detail_original_is_sent_for_gpt54(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", json={ "model": "gpt-5.4", "usage": {}, "choices": [{"message": {"content": "Original detail"}}], }, headers={"Content-Type": "application/json"}, ) runner = CliRunner() > result = runner.invoke( cli, [ "-m", "gpt-5.4", "-o", "chat_completions", "1", "-o", "image_detail", "original", "--at", "https://example.com/image.jpg", "image/jpeg", "--no-stream", "--key", "x", "Describe this", ], catch_exceptions=False, ) tests/test_cli_openai_models.py:593: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2777: in execute yield from chat.execute(prompt, stream, response, conversation, key) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...rl': 'https://example.com/image.jpg', 'detail': 'original'}}]}], 'model': 'gpt-5.4', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ___ test_openai_image_detail_original_is_sent_for_gpt54_responses_by_default ___ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...original'}]}], 'model': 'gpt-5.4', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_openai_image_detail_original_is_sent_for_gpt54_responses_by_default( httpx2_mock, ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": "gpt-5.4", "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "Original detail", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) runner = CliRunner() > result = runner.invoke( cli, [ "-m", "gpt-5.4", "-o", "image_detail", "original", "--at", "https://example.com/image.jpg", "image/jpeg", "--no-stream", "--key", "x", "Describe this", ], catch_exceptions=False, ) tests/test_cli_openai_models.py:656: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...original'}]}], 'model': 'gpt-5.4', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError __________________ test_gpt4o_mini_sync_and_async[None-False] __________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4ca3f6090> monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d8dd30> tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_gpt4o_mini_sync_and_async0') httpx2_mock = async_ = False, usage = None @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("usage", (None, "-u", "--usage")) def test_gpt4o_mini_sync_and_async( db_factory, monkeypatch, tmpdir, httpx2_mock, async_, usage ): user_path = tmpdir / "user_dir" log_db = user_path / "logs.db" monkeypatch.setenv("LLM_USER_PATH", str(user_path)) assert not log_db.exists() httpx2_mock.add_response( method="POST", # chat completion request url="https://api.openai.com/v1/chat/completions", json={ "id": "chatcmpl-AQT9a30kxEaM1bqxRPepQsPlCyGJh", "object": "chat.completion", "created": 1730871958, "model": "gpt-4o-mini", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Ho ho ho", "refusal": None, }, "finish_reason": "stop", } ], "usage": { "prompt_tokens": 1000, "completion_tokens": 2000, "total_tokens": 12, }, "system_fingerprint": "fp_49254d0e9b", }, headers={"Content-Type": "application/json"}, ) runner = CliRunner() args = ["-m", "gpt-4o-mini", "--key", "x", "--no-stream"] if usage: args.append(usage) if async_: args.append("--async") > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_cli_openai_models.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError __________________ test_gpt4o_mini_sync_and_async[None-True] ___________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4ca3f4e00> monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d8e740> tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_gpt4o_mini_sync_and_async1') httpx2_mock = async_ = True, usage = None @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("usage", (None, "-u", "--usage")) def test_gpt4o_mini_sync_and_async( db_factory, monkeypatch, tmpdir, httpx2_mock, async_, usage ): user_path = tmpdir / "user_dir" log_db = user_path / "logs.db" monkeypatch.setenv("LLM_USER_PATH", str(user_path)) assert not log_db.exists() httpx2_mock.add_response( method="POST", # chat completion request url="https://api.openai.com/v1/chat/completions", json={ "id": "chatcmpl-AQT9a30kxEaM1bqxRPepQsPlCyGJh", "object": "chat.completion", "created": 1730871958, "model": "gpt-4o-mini", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Ho ho ho", "refusal": None, }, "finish_reason": "stop", } ], "usage": { "prompt_tokens": 1000, "completion_tokens": 2000, "total_tokens": 12, }, "system_fingerprint": "fp_49254d0e9b", }, headers={"Content-Type": "application/json"}, ) runner = CliRunner() args = ["-m", "gpt-4o-mini", "--key", "x", "--no-stream"] if usage: args.append(usage) if async_: args.append("--async") > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_cli_openai_models.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1153: in prompt asyncio.run(inner()) /usr/lib64/python3.15/asyncio/runners.py:205: in run return runner.run(main) ^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/runners.py:128: in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/base_events.py:724: in run_until_complete return future.result() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1145: in inner text = await response.text() ^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ___________________ test_gpt4o_mini_sync_and_async[-u-False] ___________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9c766c0> monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9226190> tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_gpt4o_mini_sync_and_async2') httpx2_mock = async_ = False, usage = '-u' @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("usage", (None, "-u", "--usage")) def test_gpt4o_mini_sync_and_async( db_factory, monkeypatch, tmpdir, httpx2_mock, async_, usage ): user_path = tmpdir / "user_dir" log_db = user_path / "logs.db" monkeypatch.setenv("LLM_USER_PATH", str(user_path)) assert not log_db.exists() httpx2_mock.add_response( method="POST", # chat completion request url="https://api.openai.com/v1/chat/completions", json={ "id": "chatcmpl-AQT9a30kxEaM1bqxRPepQsPlCyGJh", "object": "chat.completion", "created": 1730871958, "model": "gpt-4o-mini", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Ho ho ho", "refusal": None, }, "finish_reason": "stop", } ], "usage": { "prompt_tokens": 1000, "completion_tokens": 2000, "total_tokens": 12, }, "system_fingerprint": "fp_49254d0e9b", }, headers={"Content-Type": "application/json"}, ) runner = CliRunner() args = ["-m", "gpt-4o-mini", "--key", "x", "--no-stream"] if usage: args.append(usage) if async_: args.append("--async") > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_cli_openai_models.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ___________________ test_gpt4o_mini_sync_and_async[-u-True] ____________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9c768d0> monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9b3f9a0> tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_gpt4o_mini_sync_and_async3') httpx2_mock = async_ = True, usage = '-u' @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("usage", (None, "-u", "--usage")) def test_gpt4o_mini_sync_and_async( db_factory, monkeypatch, tmpdir, httpx2_mock, async_, usage ): user_path = tmpdir / "user_dir" log_db = user_path / "logs.db" monkeypatch.setenv("LLM_USER_PATH", str(user_path)) assert not log_db.exists() httpx2_mock.add_response( method="POST", # chat completion request url="https://api.openai.com/v1/chat/completions", json={ "id": "chatcmpl-AQT9a30kxEaM1bqxRPepQsPlCyGJh", "object": "chat.completion", "created": 1730871958, "model": "gpt-4o-mini", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Ho ho ho", "refusal": None, }, "finish_reason": "stop", } ], "usage": { "prompt_tokens": 1000, "completion_tokens": 2000, "total_tokens": 12, }, "system_fingerprint": "fp_49254d0e9b", }, headers={"Content-Type": "application/json"}, ) runner = CliRunner() args = ["-m", "gpt-4o-mini", "--key", "x", "--no-stream"] if usage: args.append(usage) if async_: args.append("--async") > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_cli_openai_models.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1153: in prompt asyncio.run(inner()) /usr/lib64/python3.15/asyncio/runners.py:205: in run return runner.run(main) ^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/runners.py:128: in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/base_events.py:724: in run_until_complete return future.result() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1145: in inner text = await response.text() ^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ________________ test_gpt4o_mini_sync_and_async[--usage-False] _________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9c76980> monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d5fb60> tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_gpt4o_mini_sync_and_async4') httpx2_mock = async_ = False, usage = '--usage' @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("usage", (None, "-u", "--usage")) def test_gpt4o_mini_sync_and_async( db_factory, monkeypatch, tmpdir, httpx2_mock, async_, usage ): user_path = tmpdir / "user_dir" log_db = user_path / "logs.db" monkeypatch.setenv("LLM_USER_PATH", str(user_path)) assert not log_db.exists() httpx2_mock.add_response( method="POST", # chat completion request url="https://api.openai.com/v1/chat/completions", json={ "id": "chatcmpl-AQT9a30kxEaM1bqxRPepQsPlCyGJh", "object": "chat.completion", "created": 1730871958, "model": "gpt-4o-mini", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Ho ho ho", "refusal": None, }, "finish_reason": "stop", } ], "usage": { "prompt_tokens": 1000, "completion_tokens": 2000, "total_tokens": 12, }, "system_fingerprint": "fp_49254d0e9b", }, headers={"Content-Type": "application/json"}, ) runner = CliRunner() args = ["-m", "gpt-4o-mini", "--key", "x", "--no-stream"] if usage: args.append(usage) if async_: args.append("--async") > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_cli_openai_models.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________________ test_gpt4o_mini_sync_and_async[--usage-True] _________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9c76ae0> monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d96660> tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_gpt4o_mini_sync_and_async5') httpx2_mock = async_ = True, usage = '--usage' @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("usage", (None, "-u", "--usage")) def test_gpt4o_mini_sync_and_async( db_factory, monkeypatch, tmpdir, httpx2_mock, async_, usage ): user_path = tmpdir / "user_dir" log_db = user_path / "logs.db" monkeypatch.setenv("LLM_USER_PATH", str(user_path)) assert not log_db.exists() httpx2_mock.add_response( method="POST", # chat completion request url="https://api.openai.com/v1/chat/completions", json={ "id": "chatcmpl-AQT9a30kxEaM1bqxRPepQsPlCyGJh", "object": "chat.completion", "created": 1730871958, "model": "gpt-4o-mini", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Ho ho ho", "refusal": None, }, "finish_reason": "stop", } ], "usage": { "prompt_tokens": 1000, "completion_tokens": 2000, "total_tokens": 12, }, "system_fingerprint": "fp_49254d0e9b", }, headers={"Content-Type": "application/json"}, ) runner = CliRunner() args = ["-m", "gpt-4o-mini", "--key", "x", "--no-stream"] if usage: args.append(usage) if async_: args.append("--async") > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_cli_openai_models.py:739: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1153: in prompt asyncio.run(inner()) /usr/lib64/python3.15/asyncio/runners.py:205: in run return runner.run(main) ^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/runners.py:128: in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/base_events.py:724: in run_until_complete return future.result() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1145: in inner text = await response.text() ^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _______ test_chat_completion_without_usage_sync_and_async[missing-False] _______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9d22770> monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d7ee40> tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_chat_completion_without_u0') httpx2_mock = async_ = False, usage_field = 'missing' @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("usage_field", ("missing", "null")) def test_chat_completion_without_usage_sync_and_async( db_factory, monkeypatch, tmpdir, httpx2_mock, async_, usage_field ): # OpenAI-compatible servers can omit "usage" from non-streaming responses user_path = tmpdir / "user_dir" log_db = user_path / "logs.db" monkeypatch.setenv("LLM_USER_PATH", str(user_path)) body = { "id": "chatcmpl-no-usage", "object": "chat.completion", "created": 1730871958, "model": "gpt-4o-mini", "choices": [ { "index": 0, "message": {"role": "assistant", "content": "Ho ho ho"}, "finish_reason": "stop", } ], } if usage_field == "null": body["usage"] = None httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", json=body, headers={"Content-Type": "application/json"}, ) runner = CliRunner() args = ["-m", "gpt-4o-mini", "--key", "x", "--no-stream"] if async_: args.append("--async") > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_cli_openai_models.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______ test_chat_completion_without_usage_sync_and_async[missing-True] ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9d20460> monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d5b4d0> tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_chat_completion_without_u1') httpx2_mock = async_ = True, usage_field = 'missing' @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("usage_field", ("missing", "null")) def test_chat_completion_without_usage_sync_and_async( db_factory, monkeypatch, tmpdir, httpx2_mock, async_, usage_field ): # OpenAI-compatible servers can omit "usage" from non-streaming responses user_path = tmpdir / "user_dir" log_db = user_path / "logs.db" monkeypatch.setenv("LLM_USER_PATH", str(user_path)) body = { "id": "chatcmpl-no-usage", "object": "chat.completion", "created": 1730871958, "model": "gpt-4o-mini", "choices": [ { "index": 0, "message": {"role": "assistant", "content": "Ho ho ho"}, "finish_reason": "stop", } ], } if usage_field == "null": body["usage"] = None httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", json=body, headers={"Content-Type": "application/json"}, ) runner = CliRunner() args = ["-m", "gpt-4o-mini", "--key", "x", "--no-stream"] if async_: args.append("--async") > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_cli_openai_models.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1153: in prompt asyncio.run(inner()) /usr/lib64/python3.15/asyncio/runners.py:205: in run return runner.run(main) ^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/runners.py:128: in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/base_events.py:724: in run_until_complete return future.result() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1145: in inner text = await response.text() ^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ________ test_chat_completion_without_usage_sync_and_async[null-False] _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9c74880> monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c91acc20> tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_chat_completion_without_u2') httpx2_mock = async_ = False, usage_field = 'null' @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("usage_field", ("missing", "null")) def test_chat_completion_without_usage_sync_and_async( db_factory, monkeypatch, tmpdir, httpx2_mock, async_, usage_field ): # OpenAI-compatible servers can omit "usage" from non-streaming responses user_path = tmpdir / "user_dir" log_db = user_path / "logs.db" monkeypatch.setenv("LLM_USER_PATH", str(user_path)) body = { "id": "chatcmpl-no-usage", "object": "chat.completion", "created": 1730871958, "model": "gpt-4o-mini", "choices": [ { "index": 0, "message": {"role": "assistant", "content": "Ho ho ho"}, "finish_reason": "stop", } ], } if usage_field == "null": body["usage"] = None httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", json=body, headers={"Content-Type": "application/json"}, ) runner = CliRunner() args = ["-m", "gpt-4o-mini", "--key", "x", "--no-stream"] if async_: args.append("--async") > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_cli_openai_models.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________ test_chat_completion_without_usage_sync_and_async[null-True] _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9c775e0> monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9d7c1a0> tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_chat_completion_without_u3') httpx2_mock = async_ = True, usage_field = 'null' @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("usage_field", ("missing", "null")) def test_chat_completion_without_usage_sync_and_async( db_factory, monkeypatch, tmpdir, httpx2_mock, async_, usage_field ): # OpenAI-compatible servers can omit "usage" from non-streaming responses user_path = tmpdir / "user_dir" log_db = user_path / "logs.db" monkeypatch.setenv("LLM_USER_PATH", str(user_path)) body = { "id": "chatcmpl-no-usage", "object": "chat.completion", "created": 1730871958, "model": "gpt-4o-mini", "choices": [ { "index": 0, "message": {"role": "assistant", "content": "Ho ho ho"}, "finish_reason": "stop", } ], } if usage_field == "null": body["usage"] = None httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", json=body, headers={"Content-Type": "application/json"}, ) runner = CliRunner() args = ["-m", "gpt-4o-mini", "--key", "x", "--no-stream"] if async_: args.append("--async") > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_cli_openai_models.py:788: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1153: in prompt asyncio.run(inner()) /usr/lib64/python3.15/asyncio/runners.py:205: in run return runner.run(main) ^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/runners.py:128: in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/base_events.py:724: in run_until_complete return future.result() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1145: in inner text = await response.text() ^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...vent_and_data=None, content=None, json_data={'messages': [], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _________________________ test_fragment_url_user_agent _________________________ mocked_openai_chat = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_fragment_url_user_agent0/llm.datasette.io') @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) def test_fragment_url_user_agent(mocked_openai_chat, user_path): mocked_openai_chat.add_response( url="https://example.com/fragment.txt", text="Hello from URL", ) runner = CliRunner() result = runner.invoke( cli, [ "prompt", "-m", "gpt-4o-mini", "-f", "https://example.com/fragment.txt", ], ) > assert result.exit_code == 0 E AssertionError: assert 1 == 0 E + where 1 = .exit_code tests/test_fragments_cli.py:165: AssertionError ____________________________ test_uses_correct_key _____________________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...on_data={'messages': [{'role': 'user', 'content': 'hello'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: mocked_openai_chat = monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c92740c0> tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_uses_correct_key0') @pytest.mark.httpx2_mock( assert_all_requests_were_expected=False, can_send_already_matched_responses=True ) def test_uses_correct_key(mocked_openai_chat, monkeypatch, tmpdir): user_dir = tmpdir / "user-dir" pathlib.Path(user_dir).mkdir() keys_path = user_dir / "keys.json" KEYS = { "openai": "from-keys-file", "other": "other-key", } keys_path.write_text(json.dumps(KEYS), "utf-8") monkeypatch.setenv("LLM_USER_PATH", str(user_dir)) monkeypatch.setenv("OPENAI_API_KEY", "from-env") def assert_key(key): request = mocked_openai_chat.get_requests()[-1] assert request.headers["Authorization"] == f"Bearer {key}" runner = CliRunner() # Called without --key uses stored key > result = runner.invoke( cli, ["hello", "--no-stream", "-m", "gpt-4o-mini"], catch_exceptions=False, ) tests/test_keys.py:91: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...on_data={'messages': [{'role': 'user', 'content': 'hello'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________________ test_llm_prompt_creates_log_database[False] __________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84f75e0> mocked_openai_responses = tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_prompt_creates_log_da0') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9a557f0> custom_database_path = False @pytest.mark.parametrize("custom_database_path", (False, True)) def test_llm_prompt_creates_log_database( db_factory, mocked_openai_responses, tmpdir, monkeypatch, custom_database_path ): user_path = tmpdir / "user" custom_db_path = tmpdir / "custom_log.db" monkeypatch.setenv("LLM_USER_PATH", str(user_path)) runner = CliRunner() args = ["three names \nfor a pet pelican", "--no-stream", "--key", "x"] if custom_database_path: args.extend(["--database", str(custom_db_path)]) > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:38: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError __________________ test_llm_prompt_creates_log_database[True] __________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84f7ab0> mocked_openai_responses = tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_prompt_creates_log_da1') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9a71f60> custom_database_path = True @pytest.mark.parametrize("custom_database_path", (False, True)) def test_llm_prompt_creates_log_database( db_factory, mocked_openai_responses, tmpdir, monkeypatch, custom_database_path ): user_path = tmpdir / "user" custom_db_path = tmpdir / "custom_log.db" monkeypatch.setenv("LLM_USER_PATH", str(user_path)) runner = CliRunner() args = ["three names \nfor a pet pelican", "--no-stream", "--key", "x"] if custom_database_path: args.extend(["--database", str(custom_db_path)]) > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:38: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[True-logs_args0-False-True] ______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84f5170> mocked_openai_responses = use_stdin = True user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_True_l0/llm.datasette.io') logs_off = True, logs_args = [], should_log = False @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[True-logs_args0-False-False] _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84f41a0> mocked_openai_responses = use_stdin = False user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_True_l1/llm.datasette.io') logs_off = True, logs_args = [], should_log = False @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[True-logs_args0-False-split] _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9c74510> mocked_openai_responses = use_stdin = 'split' user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_True_l2/llm.datasette.io') logs_off = True, logs_args = [], should_log = False @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[False-logs_args1-True-True] ______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c854c510> mocked_openai_responses = use_stdin = True user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_False_0/llm.datasette.io') logs_off = False, logs_args = [], should_log = True @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[False-logs_args1-True-False] _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9c77480> mocked_openai_responses = use_stdin = False user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_False_1/llm.datasette.io') logs_off = False, logs_args = [], should_log = True @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[False-logs_args1-True-split] _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9c74670> mocked_openai_responses = use_stdin = 'split' user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_False_2/llm.datasette.io') logs_off = False, logs_args = [], should_log = True @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[False-logs_args2-False-True] _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9d23270> mocked_openai_responses = use_stdin = True user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_False_3/llm.datasette.io') logs_off = False, logs_args = ['--no-log'], should_log = False @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____________ test_llm_default_prompt[False-logs_args2-False-False] _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84f64b0> mocked_openai_responses = use_stdin = False user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_False_4/llm.datasette.io') logs_off = False, logs_args = ['--no-log'], should_log = False @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____________ test_llm_default_prompt[False-logs_args2-False-split] _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84f6350> mocked_openai_responses = use_stdin = 'split' user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_False_5/llm.datasette.io') logs_off = False, logs_args = ['--no-log'], should_log = False @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[False-logs_args3-True-True] ______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84f4b40> mocked_openai_responses = use_stdin = True user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_False_6/llm.datasette.io') logs_off = False, logs_args = ['--log'], should_log = True @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[False-logs_args3-True-False] _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84f5430> mocked_openai_responses = use_stdin = False user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_False_7/llm.datasette.io') logs_off = False, logs_args = ['--log'], should_log = True @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[False-logs_args3-True-split] _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84f6980> mocked_openai_responses = use_stdin = 'split' user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_False_8/llm.datasette.io') logs_off = False, logs_args = ['--log'], should_log = True @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[True-logs_args4-False-True] ______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84f59b0> mocked_openai_responses = use_stdin = True user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_True_l3/llm.datasette.io') logs_off = True, logs_args = ['-n'], should_log = False @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[True-logs_args4-False-False] _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84f5a60> mocked_openai_responses = use_stdin = False user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_True_l4/llm.datasette.io') logs_off = True, logs_args = ['-n'], should_log = False @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[True-logs_args4-False-split] _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84f54e0> mocked_openai_responses = use_stdin = 'split' user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_True_l5/llm.datasette.io') logs_off = True, logs_args = ['-n'], should_log = False @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ______________ test_llm_default_prompt[True-logs_args5-True-True] ______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9c76da0> mocked_openai_responses = use_stdin = True user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_True_l6/llm.datasette.io') logs_off = True, logs_args = ['--log'], should_log = True @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[True-logs_args5-True-False] ______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c9c750c0> mocked_openai_responses = use_stdin = False user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_True_l7/llm.datasette.io') logs_off = True, logs_args = ['--log'], should_log = True @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_llm_default_prompt[True-logs_args5-True-split] ______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84f5220> mocked_openai_responses = use_stdin = 'split' user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_default_prompt_True_l8/llm.datasette.io') logs_off = True, logs_args = ['--log'], should_log = True @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("use_stdin", (True, False, "split")) @pytest.mark.parametrize( "logs_off,logs_args,should_log", ( (True, [], False), (False, [], True), (False, ["--no-log"], False), (False, ["--log"], True), (True, ["-n"], False), # Short for --no-log (True, ["--log"], True), ), ) def test_llm_default_prompt( db_factory, mocked_openai_responses, use_stdin, user_path, logs_off, logs_args, should_log, ): # Reset the log_path database log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") logs_off_path = user_path / "logs-off" if logs_off: # Turn off logging assert not logs_off_path.exists() CliRunner().invoke(cli, ["logs", "off"]) assert logs_off_path.exists() else: # Turn on logging CliRunner().invoke(cli, ["logs", "on"]) assert not logs_off_path.exists() # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" input = None args = ["--no-stream"] if use_stdin == "split": input = "three names" args.append("\nfor a pet pelican") elif use_stdin: input = prompt else: args.append(prompt) args += logs_args > result = runner.invoke(cli, args, input=input, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:104: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______________________ test_llm_prompt_continue[False] ________________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84e16f0> httpx2_mock = mock_openai_responses = .add_response at 0x7fb4c84e1b10> user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_prompt_continue_False0/llm.datasette.io') async_ = False @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("async_", (False, True)) def test_llm_prompt_continue( db_factory, httpx2_mock, mock_openai_responses, user_path, async_ ): mock_openai_responses( text="Bob, Alice, Eve", response_id="resp_first", message_id="msg_first", ) mock_openai_responses( text="Terry", response_id="resp_second", message_id="msg_second", ) log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") # First prompt runner = CliRunner() args = ["three names \nfor a pet pelican", "--no-stream"] + ( ["--async"] if async_ else [] ) > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:177: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ________________________ test_llm_prompt_continue[True] ________________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84e05c0> httpx2_mock = mock_openai_responses = .add_response at 0x7fb4c84e3110> user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_prompt_continue_True_0/llm.datasette.io') async_ = True @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("async_", (False, True)) def test_llm_prompt_continue( db_factory, httpx2_mock, mock_openai_responses, user_path, async_ ): mock_openai_responses( text="Bob, Alice, Eve", response_id="resp_first", message_id="msg_first", ) mock_openai_responses( text="Terry", response_id="resp_second", message_id="msg_second", ) log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") # First prompt runner = CliRunner() args = ["three names \nfor a pet pelican", "--no-stream"] + ( ["--async"] if async_ else [] ) > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:177: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1153: in prompt asyncio.run(inner()) /usr/lib64/python3.15/asyncio/runners.py:205: in run return runner.run(main) ^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/runners.py:128: in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/base_events.py:724: in run_until_complete return future.result() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1145: in inner text = await response.text() ^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _____________________ test_extract_fenced_code[args0-True] _____________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ta={'messages': [{'role': 'user', 'content': 'Write code'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: mocked_openai_chat_returning_fenced_code = args = ['-x'], expect_just_code = True @pytest.mark.parametrize( "args,expect_just_code", ( (["-x"], True), (["--extract"], True), (["-x", "--async"], True), (["--extract", "--async"], True), # Use --no-stream here to ensure it passes test same as -x/--extract cases (["--no-stream"], False), ), ) def test_extract_fenced_code( mocked_openai_chat_returning_fenced_code, args, expect_just_code ): runner = CliRunner() > result = runner.invoke( cli, ["-m", "gpt-4o-mini", "--key", "x", "Write code"] + args, catch_exceptions=False, ) tests/test_llm.py:210: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ta={'messages': [{'role': 'user', 'content': 'Write code'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________________ test_extract_fenced_code[args1-True] _____________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ta={'messages': [{'role': 'user', 'content': 'Write code'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: mocked_openai_chat_returning_fenced_code = args = ['--extract'], expect_just_code = True @pytest.mark.parametrize( "args,expect_just_code", ( (["-x"], True), (["--extract"], True), (["-x", "--async"], True), (["--extract", "--async"], True), # Use --no-stream here to ensure it passes test same as -x/--extract cases (["--no-stream"], False), ), ) def test_extract_fenced_code( mocked_openai_chat_returning_fenced_code, args, expect_just_code ): runner = CliRunner() > result = runner.invoke( cli, ["-m", "gpt-4o-mini", "--key", "x", "Write code"] + args, catch_exceptions=False, ) tests/test_llm.py:210: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ta={'messages': [{'role': 'user', 'content': 'Write code'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________________ test_extract_fenced_code[args2-True] _____________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ta={'messages': [{'role': 'user', 'content': 'Write code'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: mocked_openai_chat_returning_fenced_code = args = ['-x', '--async'], expect_just_code = True @pytest.mark.parametrize( "args,expect_just_code", ( (["-x"], True), (["--extract"], True), (["-x", "--async"], True), (["--extract", "--async"], True), # Use --no-stream here to ensure it passes test same as -x/--extract cases (["--no-stream"], False), ), ) def test_extract_fenced_code( mocked_openai_chat_returning_fenced_code, args, expect_just_code ): runner = CliRunner() > result = runner.invoke( cli, ["-m", "gpt-4o-mini", "--key", "x", "Write code"] + args, catch_exceptions=False, ) tests/test_llm.py:210: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1153: in prompt asyncio.run(inner()) /usr/lib64/python3.15/asyncio/runners.py:205: in run return runner.run(main) ^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/runners.py:128: in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/base_events.py:724: in run_until_complete return future.result() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1145: in inner text = await response.text() ^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ta={'messages': [{'role': 'user', 'content': 'Write code'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _____________________ test_extract_fenced_code[args3-True] _____________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ta={'messages': [{'role': 'user', 'content': 'Write code'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: mocked_openai_chat_returning_fenced_code = args = ['--extract', '--async'], expect_just_code = True @pytest.mark.parametrize( "args,expect_just_code", ( (["-x"], True), (["--extract"], True), (["-x", "--async"], True), (["--extract", "--async"], True), # Use --no-stream here to ensure it passes test same as -x/--extract cases (["--no-stream"], False), ), ) def test_extract_fenced_code( mocked_openai_chat_returning_fenced_code, args, expect_just_code ): runner = CliRunner() > result = runner.invoke( cli, ["-m", "gpt-4o-mini", "--key", "x", "Write code"] + args, catch_exceptions=False, ) tests/test_llm.py:210: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1153: in prompt asyncio.run(inner()) /usr/lib64/python3.15/asyncio/runners.py:205: in run return runner.run(main) ^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/runners.py:128: in run return self._loop.run_until_complete(task) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/asyncio/base_events.py:724: in run_until_complete return future.result() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1145: in inner text = await response.text() ^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ta={'messages': [{'role': 'user', 'content': 'Write code'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ____________________ test_extract_fenced_code[args4-False] _____________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ta={'messages': [{'role': 'user', 'content': 'Write code'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: mocked_openai_chat_returning_fenced_code = args = ['--no-stream'], expect_just_code = False @pytest.mark.parametrize( "args,expect_just_code", ( (["-x"], True), (["--extract"], True), (["-x", "--async"], True), (["--extract", "--async"], True), # Use --no-stream here to ensure it passes test same as -x/--extract cases (["--no-stream"], False), ), ) def test_extract_fenced_code( mocked_openai_chat_returning_fenced_code, args, expect_just_code ): runner = CliRunner() > result = runner.invoke( cli, ["-m", "gpt-4o-mini", "--key", "x", "Write code"] + args, catch_exceptions=False, ) tests/test_llm.py:210: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ta={'messages': [{'role': 'user', 'content': 'Write code'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ________________________ test_extract_fenced_code_crlf _________________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ta={'messages': [{'role': 'user', 'content': 'Write code'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_extract_fenced_code_crlf(httpx2_mock): """The CLI extracts fenced code when the model response uses CRLF.""" httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", json={ "model": "gpt-4o-mini", "usage": {}, "choices": [ { "message": { "content": 'Code:\r\n\r\n```python\r\nprint("ok")\r\n```\r\nDone.' } } ], }, headers={"Content-Type": "application/json"}, ) runner = CliRunner() > result = runner.invoke( cli, ["-m", "gpt-4o-mini", "--key", "x", "Write code", "--extract"], catch_exceptions=False, ) tests/test_llm.py:241: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ta={'messages': [{'role': 'user', 'content': 'Write code'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ___________________________ test_openai_chat_stream ____________________________ mocked_openai_chat_stream = None user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_openai_chat_stream0/llm.datasette.io') def test_openai_chat_stream(mocked_openai_chat_stream, user_path): runner = CliRunner() result = runner.invoke(cli, ["-m", "gpt-4o-mini", "--key", "x", "Say hi"]) > assert result.exit_code == 0 E AssertionError: assert 1 == 0 E + where 1 = .exit_code tests/test_llm.py:255: AssertionError ____________________________ test_openai_completion ____________________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...content=None, json_data={'model': 'completion-demo', 'prompt': 'Say this is a test', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84e1bc0> mocked_openai_completion = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_openai_completion0/llm.datasette.io') @pytest.mark.usefixtures("completion_model") def test_openai_completion(db_factory, mocked_openai_completion, user_path): log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") runner = CliRunner() > result = runner.invoke( cli, [ "-m", "completion-demo", "Say this is a test", "--no-stream", "--key", "x", ], catch_exceptions=False, ) tests/test_llm.py:267: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3264: in execute completion = client.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/completions.py:550: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...content=None, json_data={'model': 'completion-demo', 'prompt': 'Say this is a test', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______________ test_openai_completion_continue_includes_history _______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...content=None, json_data={'model': 'completion-demo', 'prompt': 'Say this is a test', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: mocked_openai_completion = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_openai_completion_continu0/llm.datasette.io') @pytest.mark.usefixtures("completion_model") def test_openai_completion_continue_includes_history( mocked_openai_completion, user_path ): # A continued conversation reloaded from storage must send the # prior exchanges, not just the newest prompt - prompt.messages # carries them; conversation.responses does not. runner = CliRunner() base = ["-m", "completion-demo", "--no-stream", "--key", "x"] > result = runner.invoke(cli, base + ["Say this is a test"], catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:318: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3264: in execute completion = client.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/completions.py:550: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...content=None, json_data={'model': 'completion-demo', 'prompt': 'Say this is a test', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____________________ test_openai_completion_logprobs_stream ____________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...-demo', 'prompt': 'Say hi', 'logprobs': 2, 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84e3740> mocked_openai_completion_logprobs_stream = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_openai_completion_logprob0/llm.datasette.io') @pytest.mark.usefixtures("completion_model") def test_openai_completion_logprobs_stream( db_factory, mocked_openai_completion_logprobs_stream, user_path ): log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") runner = CliRunner() args = [ "-m", "completion-demo", "Say hi", "-o", "logprobs", "2", "--key", "x", ] > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:370: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1156: in prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3245: in execute completion = client.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/completions.py:550: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...-demo', 'prompt': 'Say hi', 'logprobs': 2, 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ___________________ test_openai_completion_logprobs_nostream ___________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...tent=None, json_data={'model': 'completion-demo', 'prompt': 'Say hi', 'logprobs': 2, 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c84e2da0> mocked_openai_completion_logprobs = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_openai_completion_logprob1/llm.datasette.io') @pytest.mark.usefixtures("completion_model") def test_openai_completion_logprobs_nostream( db_factory, mocked_openai_completion_logprobs, user_path ): log_path = user_path / "logs.db" log_db = db_factory(str(log_path)) if "turns" in log_db.table_names(): with log_db.conn: log_db.execute("delete from turns") runner = CliRunner() args = [ "-m", "completion-demo", "Say hi", "-o", "logprobs", "2", "--key", "x", "--no-stream", ] > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:401: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3264: in execute completion = client.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/completions.py:550: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...tent=None, json_data={'model': 'completion-demo', 'prompt': 'Say hi', 'logprobs': 2, 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ______________________ test_openai_localai_configuration _______________________ db_factory = .create at 0x7fb4c84f5a60> mocked_localai = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_openai_localai_configurat0/llm.datasette.io') def test_openai_localai_configuration(db_factory, mocked_localai, user_path): log_path = user_path / "logs.db" db_factory(str(log_path)) # Write the configuration file config_path = user_path / "extra-openai-models.yaml" config_path.write_text(EXTRA_MODELS_YAML, "utf-8") # Run the prompt runner = CliRunner() prompt = "three names \nfor a pet pelican" result = runner.invoke(cli, ["--no-stream", "--model", "orca", prompt]) > assert result.exit_code == 0 E AssertionError: assert 1 == 0 E + where 1 = .exit_code tests/test_llm.py:433: AssertionError ________________ test_llm_prompt_continue_with_database[False] _________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c7dd49e0> tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_prompt_continue_with_0') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8ef6b30> httpx2_mock = mock_openai_responses = .add_response at 0x7fb4c7dd4930> user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_prompt_continue_with_0/user') custom_database_path = False @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("custom_database_path", (False, True)) def test_llm_prompt_continue_with_database( db_factory, tmpdir, monkeypatch, httpx2_mock, mock_openai_responses, user_path, custom_database_path, ): mock_openai_responses( text="Bob, Alice, Eve", response_id="resp_first", message_id="msg_first", ) mock_openai_responses( text="Terry", response_id="resp_second", message_id="msg_second", ) user_path = tmpdir / "user" custom_db_path = tmpdir / "custom_log.db" monkeypatch.setenv("LLM_USER_PATH", str(user_path)) # First prompt runner = CliRunner() args = ["three names \nfor a pet pelican", "--no-stream"] if custom_database_path: args.extend(["--database", str(custom_db_path)]) > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:947: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________________ test_llm_prompt_continue_with_database[True] _________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c8f5e610> tmpdir = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_prompt_continue_with_1') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c7e50b40> httpx2_mock = mock_openai_responses = .add_response at 0x7fb4c8f5f3d0> user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_llm_prompt_continue_with_1/user') custom_database_path = True @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize("custom_database_path", (False, True)) def test_llm_prompt_continue_with_database( db_factory, tmpdir, monkeypatch, httpx2_mock, mock_openai_responses, user_path, custom_database_path, ): mock_openai_responses( text="Bob, Alice, Eve", response_id="resp_first", message_id="msg_first", ) mock_openai_responses( text="Terry", response_id="resp_second", message_id="msg_second", ) user_path = tmpdir / "user" custom_db_path = tmpdir / "custom_log.db" monkeypatch.setenv("LLM_USER_PATH", str(user_path)) # First prompt runner = CliRunner() args = ["three names \nfor a pet pelican", "--no-stream"] if custom_database_path: args.extend(["--database", str(custom_db_path)]) > result = runner.invoke(cli, args, catch_exceptions=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_llm.py:947: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...pelican'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______ test_endpoint_chat_completions_does_not_log_or_leak_default_key ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...llo'}], 'model': 'test-model', 'reasoning_effort': , 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_chat_completions0/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c7e95cc0> def test_endpoint_chat_completions_does_not_log_or_leak_default_key( httpx2_mock, user_path, monkeypatch ): base_url = "https://example.test/v1" _add_chat_response(httpx2_mock, base_url, "Hello from the endpoint") monkeypatch.setenv("OPENAI_API_KEY", "real-default-openai-key") > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "Hello", "-m", "test-model", "--no-stream", "-H", "X-Test", "one", "-o", "reasoning_effort", "low", ], catch_exceptions=False, ) tests/test_openai_endpoint.py:166: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...llo'}], 'model': 'test-model', 'reasoning_effort': , 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError __________________ test_endpoint_chat_completions_attachment ___________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...:image/png;base64,iVBORw0KGgplbmRwb2ludCBhdHRhY2htZW50'}}]}], 'model': 'test-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_chat_completions1/llm.datasette.io') tmp_path = PosixPath('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_chat_completions1') def test_endpoint_chat_completions_attachment(httpx2_mock, user_path, tmp_path): base_url = "https://attachments.example.test/v1" _add_chat_response(httpx2_mock, base_url, "A test image") image_bytes = b"\x89PNG\r\n\x1a\nendpoint attachment" image_path = tmp_path / "image.png" image_path.write_bytes(image_bytes) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "Describe this", "-m", "test-model", "--no-stream", "-a", str(image_path), ], catch_exceptions=False, ) tests/test_openai_endpoint.py:208: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...:image/png;base64,iVBORw0KGgplbmRwb2ludCBhdHRhY2htZW50'}}]}], 'model': 'test-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____________________________ test_endpoint_template ____________________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_schema': {'name': 'output', 'schema': {'type': 'object'}}}, 'stream': False, 'temperature': 0.4}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_template0/llm.datasette.io') templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_template0/llm.datasette.io/templates') def test_endpoint_template(httpx2_mock, user_path, templates_path): base_url = "https://templates.example.test/v1" _add_chat_response(httpx2_mock, base_url, "Template response") (templates_path / "endpoint.yaml").write_text( """ model: template-model system: You are $persona prompt: "Question: $input" options: temperature: 0.4 schema_object: type: object properties: answer: type: string required: - answer attachment_types: - type: image/jpeg value: https://images.example.test/template.jpg """.strip(), "utf-8", ) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "Where?", "--template", "endpoint", "--schema", '{"type": "object"}', "--param", "persona", "concise", "--no-stream", ], catch_exceptions=False, ) tests/test_openai_endpoint.py:269: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_schema': {'name': 'output', 'schema': {'type': 'object'}}}, 'stream': False, 'temperature': 0.4}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________ test_endpoint_template_schema_object_used_when_no_cli_schema _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...: 'object', 'properties': {'answer': {'type': 'string'}}, 'required': ['answer']}}}, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_template_schema_0/llm.datasette.io') templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_template_schema_0/llm.datasette.io/templates') def test_endpoint_template_schema_object_used_when_no_cli_schema( httpx2_mock, user_path, templates_path ): base_url = "https://templates2.example.test/v1" _add_chat_response(httpx2_mock, base_url, "Template response 2") (templates_path / "schemaonly.yaml").write_text( """ model: schema-model schema_object: type: object properties: answer: type: string required: - answer """.strip(), "utf-8", ) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "test question", "--template", "schemaonly", "--no-stream", ], catch_exceptions=False, ) tests/test_openai_endpoint.py:340: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...: 'object', 'properties': {'answer': {'type': 'string'}}, 'required': ['answer']}}}, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________________________ test_endpoint_schema _____________________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...e': {'type': 'string'}, 'age': {'type': 'integer'}}, 'required': ['name', 'age']}}}, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_schema0/llm.datasette.io') def test_endpoint_schema(httpx2_mock, user_path): base_url = "https://schema.example.test/v1" _add_chat_response(httpx2_mock, base_url, '{"name": "Cleo", "age": 10}') > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "Invent a dog", "-m", "test-model", "--schema", "name, age int", "--no-stream", ], catch_exceptions=False, ) tests/test_openai_endpoint.py:373: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...e': {'type': 'string'}, 'age': {'type': 'integer'}}, 'required': ['name', 'age']}}}, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____________ test_endpoint_schema_by_id_from_existing_logs_database ____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ype': 'object', 'properties': {'name': {'type': 'string'}}, 'required': ['name']}}}, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: db_factory = .create at 0x7fb4c8c81e80> httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_schema_by_id_fro0/llm.datasette.io') def test_endpoint_schema_by_id_from_existing_logs_database( db_factory, httpx2_mock, user_path ): base_url = "https://schema-id.example.test/v1" _add_chat_response(httpx2_mock, base_url, '{"name": "Cleo"}') schema = { "type": "object", "properties": {"name": {"type": "string"}}, "required": ["name"], } db = db_factory(str(user_path / "logs.db")) migrate(db) db["schemas"].insert({"id": "dog-schema", "content": json.dumps(schema)}) assert (user_path / "logs.db").exists() > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "Invent a dog", "-m", "test-model", "--schema", "dog-schema", "--no-stream", ], catch_exceptions=False, ) tests/test_openai_endpoint.py:423: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ype': 'object', 'properties': {'name': {'type': 'string'}}, 'required': ['name']}}}, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_endpoint_static_template_runs_once_on_terminal ______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...s': [{'role': 'user', 'content': 'List five pelican names'}], 'model': 'test-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_static_template_0/llm.datasette.io') templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_static_template_0/llm.datasette.io/templates') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c7de2270> def test_endpoint_static_template_runs_once_on_terminal( httpx2_mock, user_path, templates_path, monkeypatch ): base_url = "https://terminal-template.example.test/v1" _add_chat_response(httpx2_mock, base_url, "Five pelicans") (templates_path / "pelican.yaml").write_text( "prompt: List five pelican names\n", "utf-8" ) monkeypatch.setattr("click.testing._NamedTextIOWrapper.isatty", lambda self: True) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "-m", "test-model", "-t", "pelican", "--no-stream", ], catch_exceptions=False, ) tests/test_openai_endpoint.py:477: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...s': [{'role': 'user', 'content': 'List five pelican names'}], 'model': 'test-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ______________________ test_endpoint_tools_and_functions _______________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ption': 'Return the installed version of llm', 'parameters': {'properties': {}, 'type': 'object'}}}]}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_tools_and_functi0/llm.datasette.io') def test_endpoint_tools_and_functions(httpx2_mock, user_path): base_url = "https://tools.example.test/v1" _add_chat_tool_call_response(httpx2_mock, base_url, "multiply", {"a": 6, "b": 7}) _add_chat_response(httpx2_mock, base_url, "The answer is 42") > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "What is 6 * 7?", "-m", "test-model", "--no-stream", "-T", "llm_version", "--functions", ( "def multiply(a: int, b: int) -> int:\n" ' "Multiply two numbers."\n' " return a * b\n" ), ], catch_exceptions=False, ) tests/test_openai_endpoint.py:505: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:3092: in stream_events for event in response_item.stream_events(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ption': 'Return the installed version of llm', 'parameters': {'properties': {}, 'type': 'object'}}}]}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______________________ test_endpoint_streams_by_default _______________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ontent': 'Hello'}], 'model': 'test-model', 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_streams_by_defau0/llm.datasette.io') def test_endpoint_streams_by_default(httpx2_mock, user_path): base_url = "https://stream.example.test/v1" httpx2_mock.add_response( method="POST", url=f"{base_url}/chat/completions", stream=IteratorStream(_chat_stream_events()), headers={"Content-Type": "text/event-stream"}, ) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "Hello", "-m", "test-model", ], catch_exceptions=False, ) tests/test_openai_endpoint.py:570: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1678: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ontent': 'Hello'}], 'model': 'test-model', 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______________________ test_endpoint_uses_explicit_key ________________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...son_data={'messages': [{'role': 'user', 'content': 'Hello'}], 'model': 'test-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_uses_explicit_ke0/llm.datasette.io') def test_endpoint_uses_explicit_key(httpx2_mock, user_path): base_url = "https://example.test/v1" _add_chat_response(httpx2_mock, base_url, "Authenticated") > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "Hello", "-m", "test-model", "--no-stream", "--key", "endpoint-key", ], catch_exceptions=False, ) tests/test_openai_endpoint.py:595: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...son_data={'messages': [{'role': 'user', 'content': 'Hello'}], 'model': 'test-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_endpoint_lists_models_without_model_or_logging ______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='get', url='/models', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_GIVE... 0x7fb4ca216610>, follow_redirects=None, synthesize_event_and_data=None, content=None, json_data=None, extra_json=None) stream = False, stream_cls = None def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_lists_models_wit0/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c82fda20> def test_endpoint_lists_models_without_model_or_logging( httpx2_mock, user_path, monkeypatch ): base_url = "https://models.example.test/v1" monkeypatch.setenv("OPENAI_API_KEY", "real-default-openai-key") httpx2_mock.add_response( method="GET", url=f"{base_url}/models", json={ "object": "list", "data": [ { "id": "first-model", "object": "model", "created": 1, "owned_by": "example", }, { "id": "second-model", "object": "model", "created": 2, "owned_by": "example", }, ], }, headers={"Content-Type": "application/json"}, ) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "--models", "-H", "X-Test", "one", ], catch_exceptions=False, ) tests/test_openai_endpoint.py:646: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:804: in endpoint_prompt available_models = model.get_client(key).models.list() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/models.py:91: in list return self._get_api_list( /usr/lib/python3.15/site-packages/openai/_base_client.py:1383: in get_api_list return self._request_api_list(model, page, opts) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/_base_client.py:1182: in _request_api_list return self.request(page, options, stream=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='get', url='/models', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_GIVE... 0x7fb4ca216610>, follow_redirects=None, synthesize_event_and_data=None, content=None, json_data=None, extra_json=None) stream = False, stream_cls = None def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________ test_endpoint_models_surfaces_error_from_successful_response _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='get', url='/models', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_GIVE... 0x7fb4c8bf47d0>, follow_redirects=None, synthesize_event_and_data=None, content=None, json_data=None, extra_json=None) stream = False, stream_cls = None def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_models_surfaces_0/llm.datasette.io') def test_endpoint_models_surfaces_error_from_successful_response( httpx2_mock, user_path ): base_url = "https://models-error.example.test" httpx2_mock.add_response( method="GET", url=f"{base_url}/models", json={"error": "Unexpected endpoint or method. (GET /models)"}, headers={"Content-Type": "application/json"}, ) > result = CliRunner().invoke( cli, ["openai", "endpoint", base_url, "--models"], catch_exceptions=False, ) tests/test_openai_endpoint.py:679: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:804: in endpoint_prompt available_models = model.get_client(key).models.list() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/models.py:91: in list return self._get_api_list( /usr/lib/python3.15/site-packages/openai/_base_client.py:1383: in get_api_list return self._request_api_list(model, page, opts) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/_base_client.py:1182: in _request_api_list return self.request(page, options, stream=False) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='get', url='/models', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_GIVE... 0x7fb4c8bf47d0>, follow_redirects=None, synthesize_event_and_data=None, content=None, json_data=None, extra_json=None) stream = False, stream_cls = None def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________________________ test_endpoint_responses_api __________________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...num.low: 'low'>}, 'store': False, 'stream': False, 'text': {'verbosity': }}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_responses_api0/llm.datasette.io') def test_endpoint_responses_api(httpx2_mock, user_path): base_url = "https://responses.example.test/v1" httpx2_mock.add_response( method="POST", url=f"{base_url}/responses", json=_responses_payload("Hello from Responses"), headers={"Content-Type": "application/json"}, ) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "Hello", "-m", "test-model", "--responses", "--no-stream", "-o", "verbosity", "low", "-o", "reasoning_effort", "low", ], catch_exceptions=False, ) tests/test_openai_endpoint.py:699: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...num.low: 'low'>}, 'store': False, 'stream': False, 'text': {'verbosity': }}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____________ test_endpoint_responses_reasoning_summary_option[auto] ____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...del', 'reasoning': {'summary': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_responses_reason0/llm.datasette.io') reasoning_summary = 'auto' @pytest.mark.parametrize("reasoning_summary", ("auto", "concise", "detailed")) def test_endpoint_responses_reasoning_summary_option( httpx2_mock, user_path, reasoning_summary ): base_url = "https://responses-summary.example.test/v1" httpx2_mock.add_response( method="POST", url=f"{base_url}/responses", json=_responses_payload("Hello from Responses"), headers={"Content-Type": "application/json"}, ) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "Hello", "-m", "test-model", "--responses", "--no-stream", "-o", "reasoning_summary", reasoning_summary, ], catch_exceptions=False, ) tests/test_openai_endpoint.py:746: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...del', 'reasoning': {'summary': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError __________ test_endpoint_responses_reasoning_summary_option[concise] ___________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...'reasoning': {'summary': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_responses_reason1/llm.datasette.io') reasoning_summary = 'concise' @pytest.mark.parametrize("reasoning_summary", ("auto", "concise", "detailed")) def test_endpoint_responses_reasoning_summary_option( httpx2_mock, user_path, reasoning_summary ): base_url = "https://responses-summary.example.test/v1" httpx2_mock.add_response( method="POST", url=f"{base_url}/responses", json=_responses_payload("Hello from Responses"), headers={"Content-Type": "application/json"}, ) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "Hello", "-m", "test-model", "--responses", "--no-stream", "-o", "reasoning_summary", reasoning_summary, ], catch_exceptions=False, ) tests/test_openai_endpoint.py:746: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...'reasoning': {'summary': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError __________ test_endpoint_responses_reasoning_summary_option[detailed] __________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...easoning': {'summary': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_responses_reason2/llm.datasette.io') reasoning_summary = 'detailed' @pytest.mark.parametrize("reasoning_summary", ("auto", "concise", "detailed")) def test_endpoint_responses_reasoning_summary_option( httpx2_mock, user_path, reasoning_summary ): base_url = "https://responses-summary.example.test/v1" httpx2_mock.add_response( method="POST", url=f"{base_url}/responses", json=_responses_payload("Hello from Responses"), headers={"Content-Type": "application/json"}, ) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "Hello", "-m", "test-model", "--responses", "--no-stream", "-o", "reasoning_summary", reasoning_summary, ], catch_exceptions=False, ) tests/test_openai_endpoint.py:746: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...easoning': {'summary': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____________________ test_endpoint_responses_api_attachment ____________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...ple.test/test.jpg', 'detail': 'original'}]}], 'model': 'test-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_responses_api_at0/llm.datasette.io') def test_endpoint_responses_api_attachment(httpx2_mock, user_path): base_url = "https://responses-attachments.example.test/v1" httpx2_mock.add_response( method="POST", url=f"{base_url}/responses", json=_responses_payload("A remote image"), headers={"Content-Type": "application/json"}, ) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "Describe this", "-m", "test-model", "--responses", "--no-stream", "--at", "https://images.example.test/test.jpg", "image/jpeg", "-o", "image_detail", "original", ], catch_exceptions=False, ) tests/test_openai_endpoint.py:816: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...ple.test/test.jpg', 'detail': 'original'}]}], 'model': 'test-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ___________________ test_endpoint_responses_api_schema_multi ___________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...ge': {'type': 'integer'}}, 'required': ['name', 'age']}}}, 'required': ['items']}, 'strict': False}}}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_responses_api_sc0/llm.datasette.io') def test_endpoint_responses_api_schema_multi(httpx2_mock, user_path): base_url = "https://responses-schema.example.test/v1" httpx2_mock.add_response( method="POST", url=f"{base_url}/responses", json=_responses_payload('{"items": [{"name": "Cleo", "age": 10}]}'), headers={"Content-Type": "application/json"}, ) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "Invent a dog", "-m", "test-model", "--responses", "--schema-multi", "name, age int", "--no-stream", ], catch_exceptions=False, ) tests/test_openai_endpoint.py:867: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...ge': {'type': 'integer'}}, 'required': ['name', 'age']}}}, 'required': ['items']}, 'strict': False}}}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ______________________ test_endpoint_responses_api_tools _______________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...': {'a': {'type': 'integer'}, 'b': {'type': 'integer'}}, 'required': ['a', 'b'], 'type': 'object'}}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_responses_api_to0/llm.datasette.io') def test_endpoint_responses_api_tools(httpx2_mock, user_path): base_url = "https://responses-tools.example.test/v1" httpx2_mock.add_response( method="POST", url=f"{base_url}/responses", json=_responses_tool_call_payload("multiply", {"a": 6, "b": 7}), headers={"Content-Type": "application/json"}, ) httpx2_mock.add_response( method="POST", url=f"{base_url}/responses", json=_responses_payload("The answer is 42"), headers={"Content-Type": "application/json"}, ) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "What is 6 * 7?", "-m", "test-model", "--responses", "--no-stream", "--functions", ( "def multiply(a: int, b: int) -> int:\n" ' "Multiply two numbers."\n' " return a * b\n" ), ], catch_exceptions=False, ) tests/test_openai_endpoint.py:926: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:3092: in stream_events for event in response_item.stream_events(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...': {'a': {'type': 'integer'}, 'b': {'type': 'integer'}}, 'required': ['a', 'b'], 'type': 'object'}}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______________ test_endpoint_responses_api_raw_server_side_tool _______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...{'type': 'openrouter:web_search', 'parameters': {'engine': 'exa', 'max_results': 2, 'max_uses': 1}}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_responses_api_ra0/llm.datasette.io') def test_endpoint_responses_api_raw_server_side_tool(httpx2_mock, user_path): base_url = "https://raw-tools.example.test/v1" response_payload = _responses_payload("Search complete") response_payload["output"].insert( 0, { "id": "st_test", "type": "openrouter:web_search", "status": "completed", "action": { "type": "search", "query": "latest news", "sources": [{"type": "url", "url": "https://example.test/news"}], }, }, ) httpx2_mock.add_response( method="POST", url=f"{base_url}/responses", json=response_payload, headers={"Content-Type": "application/json"}, ) tool_spec = { "type": "openrouter:web_search", "parameters": {"engine": "exa", "max_results": 2, "max_uses": 1}, } > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "Search for the latest news", "-m", "test-model", "--responses", "--no-stream", "-T", f"ServerSideTool(spec={json.dumps(tool_spec)})", ], catch_exceptions=False, ) tests/test_openai_endpoint.py:996: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:3092: in stream_events for event in response_item.stream_events(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...{'type': 'openrouter:web_search', 'parameters': {'engine': 'exa', 'max_results': 2, 'max_uses': 1}}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ________________ test_endpoint_reads_one_off_prompt_from_stdin _________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...messages': [{'role': 'user', 'content': 'Hello from stdin'}], 'model': 'test-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_reads_one_off_pr0/llm.datasette.io') def test_endpoint_reads_one_off_prompt_from_stdin(httpx2_mock, user_path): base_url = "https://stdin.example.test/v1" _add_chat_response(httpx2_mock, base_url, "From stdin") > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "-m", "test-model", "--no-stream", ], input="Hello from stdin", catch_exceptions=False, ) tests/test_openai_endpoint.py:1024: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...messages': [{'role': 'user', 'content': 'Hello from stdin'}], 'model': 'test-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________________ test_endpoint_without_prompt_waits_for_stdin _________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...'role': 'user', 'content': 'Hello after waiting for stdin'}], 'model': 'test-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_without_prompt_w0/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c87d2a50> def test_endpoint_without_prompt_waits_for_stdin(httpx2_mock, user_path, monkeypatch): base_url = "https://terminal-stdin.example.test/v1" _add_chat_response(httpx2_mock, base_url, "From awaited stdin") monkeypatch.setattr("click.testing._NamedTextIOWrapper.isatty", lambda self: True) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "-m", "test-model", "--no-stream", ], input="Hello after waiting for stdin", catch_exceptions=False, ) tests/test_openai_endpoint.py:1049: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...'role': 'user', 'content': 'Hello after waiting for stdin'}], 'model': 'test-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______________ test_endpoint_interactive_chat_preserves_history _______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...rameters': {'properties': {'value': {'type': 'string'}}, 'required': ['value'], 'type': 'object'}}}]}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_interactive_chat0/llm.datasette.io') templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_endpoint_interactive_chat0/llm.datasette.io/templates') def test_endpoint_interactive_chat_preserves_history( httpx2_mock, user_path, templates_path ): base_url = "https://chat.example.test/v1" _add_chat_response(httpx2_mock, base_url, "First answer") _add_chat_response(httpx2_mock, base_url, "Second answer") (templates_path / "endpoint-chat.yaml").write_text( 'prompt: "Question: $input"\n', "utf-8" ) > result = CliRunner().invoke( cli, [ "openai", "endpoint", base_url, "-m", "test-model", "--chat", "--no-stream", "--system", "Be brief", "--template", "endpoint-chat", "--functions", ( "def lookup(value: str) -> str:\n" ' "Look up a value."\n' " return value\n" ), "--at", "https://images.example.test/context.jpg", "image/jpeg", ], input="First question\nSecond question\nquit\n", catch_exceptions=False, ) tests/test_openai_endpoint.py:1082: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:840: in endpoint_prompt _run_chat( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:228: in _run_chat display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:3092: in stream_events for event in response_item.stream_events(): ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...rameters': {'properties': {'value': {'type': 'string'}}, 'required': ['value'], 'type': 'object'}}}]}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______ test_custom_api_base_never_receives_openai_key[chat-none-stored] _______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec0/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8891160> kind = 'chat', key_state = 'none', openai_source = 'stored' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ________ test_custom_api_base_never_receives_openai_key[chat-none-env] _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec1/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c88900c0> kind = 'chat', key_state = 'none', openai_source = 'env' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ________ test_custom_api_base_never_receives_openai_key[chat-none-both] ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec2/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9444c20> kind = 'chat', key_state = 'none', openai_source = 'both' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ______ test_custom_api_base_never_receives_openai_key[chat-stored-stored] ______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec3/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9444750> kind = 'chat', key_state = 'stored', openai_source = 'stored' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______ test_custom_api_base_never_receives_openai_key[chat-stored-env] ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec4/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c93fc280> kind = 'chat', key_state = 'stored', openai_source = 'env' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______ test_custom_api_base_never_receives_openai_key[chat-stored-both] _______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec5/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c93faac0> kind = 'chat', key_state = 'stored', openai_source = 'both' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____ test_custom_api_base_never_receives_openai_key[completion-none-stored] ____ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...ent_and_data=None, content=None, json_data={'model': 'remote-model', 'prompt': 'hi', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec9/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9416740> kind = 'completion', key_state = 'none', openai_source = 'stored' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3264: in execute completion = client.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/completions.py:550: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...ent_and_data=None, content=None, json_data={'model': 'remote-model', 'prompt': 'hi', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____ test_custom_api_base_never_receives_openai_key[completion-none-env] ______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...ent_and_data=None, content=None, json_data={'model': 'remote-model', 'prompt': 'hi', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec10/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9414fa0> kind = 'completion', key_state = 'none', openai_source = 'env' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3264: in execute completion = client.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/completions.py:550: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...ent_and_data=None, content=None, json_data={'model': 'remote-model', 'prompt': 'hi', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____ test_custom_api_base_never_receives_openai_key[completion-none-both] _____ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...ent_and_data=None, content=None, json_data={'model': 'remote-model', 'prompt': 'hi', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec11/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9416890> kind = 'completion', key_state = 'none', openai_source = 'both' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3264: in execute completion = client.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/completions.py:550: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...ent_and_data=None, content=None, json_data={'model': 'remote-model', 'prompt': 'hi', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ___ test_custom_api_base_never_receives_openai_key[completion-stored-stored] ___ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...ent_and_data=None, content=None, json_data={'model': 'remote-model', 'prompt': 'hi', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec12/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c93afe70> kind = 'completion', key_state = 'stored', openai_source = 'stored' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3264: in execute completion = client.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/completions.py:550: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...ent_and_data=None, content=None, json_data={'model': 'remote-model', 'prompt': 'hi', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____ test_custom_api_base_never_receives_openai_key[completion-stored-env] _____ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...ent_and_data=None, content=None, json_data={'model': 'remote-model', 'prompt': 'hi', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec13/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c91677e0> kind = 'completion', key_state = 'stored', openai_source = 'env' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3264: in execute completion = client.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/completions.py:550: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...ent_and_data=None, content=None, json_data={'model': 'remote-model', 'prompt': 'hi', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____ test_custom_api_base_never_receives_openai_key[completion-stored-both] ____ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...ent_and_data=None, content=None, json_data={'model': 'remote-model', 'prompt': 'hi', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec14/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9167540> kind = 'completion', key_state = 'stored', openai_source = 'both' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3264: in execute completion = client.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/completions.py:550: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NO...ent_and_data=None, content=None, json_data={'model': 'remote-model', 'prompt': 'hi', 'stream': False}, extra_json=None) stream = False, stream_cls = openai.Stream[openai.types.completion.Completion] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____ test_custom_api_base_never_receives_openai_key[responses-none-stored] _____ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec18/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c87ff5b0> kind = 'responses', key_state = 'none', openai_source = 'stored' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ______ test_custom_api_base_never_receives_openai_key[responses-none-env] ______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec19/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8315160> kind = 'responses', key_state = 'none', openai_source = 'env' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____ test_custom_api_base_never_receives_openai_key[responses-none-both] ______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec20/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8316eb0> kind = 'responses', key_state = 'none', openai_source = 'both' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ___ test_custom_api_base_never_receives_openai_key[responses-stored-stored] ____ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec21/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c911f2a0> kind = 'responses', key_state = 'stored', openai_source = 'stored' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____ test_custom_api_base_never_receives_openai_key[responses-stored-env] _____ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec22/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c911f1c0> kind = 'responses', key_state = 'stored', openai_source = 'env' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____ test_custom_api_base_never_receives_openai_key[responses-stored-both] _____ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec23/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c90d71c0> kind = 'responses', key_state = 'stored', openai_source = 'both' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_custom_api_base_never_receives_openai_key[responses-chat-completions-none-stored] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec27/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9195630> kind = 'responses-chat-completions', key_state = 'none' openai_source = 'stored' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2777: in execute yield from chat.execute(prompt, stream, response, conversation, key) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_custom_api_base_never_receives_openai_key[responses-chat-completions-none-env] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec28/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9194750> kind = 'responses-chat-completions', key_state = 'none', openai_source = 'env' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2777: in execute yield from chat.execute(prompt, stream, response, conversation, key) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_custom_api_base_never_receives_openai_key[responses-chat-completions-none-both] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec29/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9196ba0> kind = 'responses-chat-completions', key_state = 'none', openai_source = 'both' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2777: in execute yield from chat.execute(prompt, stream, response, conversation, key) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_custom_api_base_never_receives_openai_key[responses-chat-completions-stored-stored] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec30/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c90c6510> kind = 'responses-chat-completions', key_state = 'stored' openai_source = 'stored' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2777: in execute yield from chat.execute(prompt, stream, response, conversation, key) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_custom_api_base_never_receives_openai_key[responses-chat-completions-stored-env] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec31/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c91908a0> kind = 'responses-chat-completions', key_state = 'stored', openai_source = 'env' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2777: in execute yield from chat.execute(prompt, stream, response, conversation, key) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_custom_api_base_never_receives_openai_key[responses-chat-completions-stored-both] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_custom_api_base_never_rec32/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8e80050> kind = 'responses-chat-completions', key_state = 'stored' openai_source = 'both' @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", SYNC_KINDS) def test_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > assert model.prompt("hi", stream=False, **options).text() == ( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "Hello from custom" ) tests/test_openai_key_leaks.py:192: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2777: in execute yield from chat.execute(prompt, stream, response, conversation, key) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____ test_async_custom_api_base_never_receives_openai_key[chat-none-stored] ____ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev0/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9196a50> kind = 'chat', key_state = 'none', openai_source = 'stored' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _____ test_async_custom_api_base_never_receives_openai_key[chat-none-env] ______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev1/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9196ba0> kind = 'chat', key_state = 'none', openai_source = 'env' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _____ test_async_custom_api_base_never_receives_openai_key[chat-none-both] _____ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev2/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9197e00> kind = 'chat', key_state = 'none', openai_source = 'both' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ___ test_async_custom_api_base_never_receives_openai_key[chat-stored-stored] ___ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev3/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9185c50> kind = 'chat', key_state = 'stored', openai_source = 'stored' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ____ test_async_custom_api_base_never_receives_openai_key[chat-stored-env] _____ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev4/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9184ad0> kind = 'chat', key_state = 'stored', openai_source = 'env' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ____ test_async_custom_api_base_never_receives_openai_key[chat-stored-both] ____ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev5/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8e66970> kind = 'chat', key_state = 'stored', openai_source = 'both' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _ test_async_custom_api_base_never_receives_openai_key[responses-none-stored] __ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev9/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8dc31c0> kind = 'responses', key_state = 'none', openai_source = 'stored' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ___ test_async_custom_api_base_never_receives_openai_key[responses-none-env] ___ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev10/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c914a7b0> kind = 'responses', key_state = 'none', openai_source = 'env' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError __ test_async_custom_api_base_never_receives_openai_key[responses-none-both] ___ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev11/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9142430> kind = 'responses', key_state = 'none', openai_source = 'both' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _ test_async_custom_api_base_never_receives_openai_key[responses-stored-stored] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev12/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9140b40> kind = 'responses', key_state = 'stored', openai_source = 'stored' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError __ test_async_custom_api_base_never_receives_openai_key[responses-stored-env] __ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev13/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8dcb230> kind = 'responses', key_state = 'stored', openai_source = 'env' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _ test_async_custom_api_base_never_receives_openai_key[responses-stored-both] __ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev14/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8dca5f0> kind = 'responses', key_state = 'stored', openai_source = 'both' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _ test_async_custom_api_base_never_receives_openai_key[responses-chat-completions-none-stored] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev18/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9140fa0> kind = 'responses-chat-completions', key_state = 'none' openai_source = 'stored' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3025: in execute async for event in chat.execute( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _ test_async_custom_api_base_never_receives_openai_key[responses-chat-completions-none-env] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev19/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8dc02f0> kind = 'responses-chat-completions', key_state = 'none', openai_source = 'env' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3025: in execute async for event in chat.execute( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _ test_async_custom_api_base_never_receives_openai_key[responses-chat-completions-none-both] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev20/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9149cc0> kind = 'responses-chat-completions', key_state = 'none', openai_source = 'both' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3025: in execute async for event in chat.execute( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _ test_async_custom_api_base_never_receives_openai_key[responses-chat-completions-stored-stored] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev21/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8e81630> kind = 'responses-chat-completions', key_state = 'stored' openai_source = 'stored' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3025: in execute async for event in chat.execute( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _ test_async_custom_api_base_never_receives_openai_key[responses-chat-completions-stored-env] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev22/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8694910> kind = 'responses-chat-completions', key_state = 'stored', openai_source = 'env' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3025: in execute async for event in chat.execute( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _ test_async_custom_api_base_never_receives_openai_key[responses-chat-completions-stored-both] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_async_custom_api_base_nev23/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c9161b70> kind = 'responses-chat-completions', key_state = 'stored' openai_source = 'both' @pytest.mark.asyncio @pytest.mark.parametrize("openai_source", OPENAI_SOURCES) @pytest.mark.parametrize("key_state", KEY_STATES) @pytest.mark.parametrize("kind", ASYNC_KINDS) async def test_async_custom_api_base_never_receives_openai_key( custom_endpoint, user_path, monkeypatch, kind, key_state, openai_source ): setup_keys(user_path, monkeypatch, openai_source, key_state) model = llm.get_async_model(model_id_for(kind, key_state)) options = KINDS[kind][1] if key_state == "missing": with pytest.raises(llm.NeedsKeyException) as ex: await model.prompt("hi", stream=False, **options).text() assert str(ex.value) == NO_KEY_MESSAGE assert custom_endpoint.get_requests() == [] else: > text = await model.prompt("hi", stream=False, **options).text() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_key_leaks.py:215: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3025: in execute async for event in chat.execute( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1848: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ___________ test_cli_responses_model_does_not_leak_openai_key[args0] ___________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_cli_responses_model_does_0/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c85f9710> args = [] @pytest.mark.parametrize("args", ([], ["-o", "chat_completions", "1"])) def test_cli_responses_model_does_not_leak_openai_key( custom_endpoint, user_path, monkeypatch, args ): setup_keys(user_path, monkeypatch, "both", "none") > result = CliRunner().invoke( cli, ["hi", "--no-stream", "-m", "custom-responses"] + args, catch_exceptions=False, ) tests/test_openai_key_leaks.py:260: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nput': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ___________ test_cli_responses_model_does_not_leak_openai_key[args1] ___________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_cli_responses_model_does_1/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c85fa890> args = ['-o', 'chat_completions', '1'] @pytest.mark.parametrize("args", ([], ["-o", "chat_completions", "1"])) def test_cli_responses_model_does_not_leak_openai_key( custom_endpoint, user_path, monkeypatch, args ): setup_keys(user_path, monkeypatch, "both", "none") > result = CliRunner().invoke( cli, ["hi", "--no-stream", "-m", "custom-responses"] + args, catch_exceptions=False, ) tests/test_openai_key_leaks.py:260: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2777: in execute yield from chat.execute(prompt, stream, response, conversation, key) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______ test_openai_endpoint_command_responses_chat_completions_no_leak ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: custom_endpoint = user_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_openai_endpoint_command_r0/llm.datasette.io') monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7fb4c8e9ba80> def test_openai_endpoint_command_responses_chat_completions_no_leak( custom_endpoint, user_path, monkeypatch ): # llm openai endpoint URL --responses -o chat_completions 1 without --key # takes the same Responses -> Chat delegate path setup_keys(user_path, monkeypatch, "both", "none") > result = CliRunner().invoke( cli, [ "openai", "endpoint", CUSTOM_BASE, "hi", "-m", "remote-model", "--responses", "--no-stream", "-o", "chat_completions", "1", ], catch_exceptions=False, ) tests/test_openai_key_leaks.py:278: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:885: in endpoint_prompt display_stream_events( ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:111: in display_stream_events for event in events: ^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2777: in execute yield from chat.execute(prompt, stream, response, conversation, key) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'remote-model', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ TestBuildMessagesConversationHistory.test_no_double_emission_from_conversation_prompt_flow _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo... json_data={'messages': [{'role': 'user', 'content': 'Q1'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: self = chat_model = httpx2_mock = def test_no_double_emission_from_conversation_prompt_flow( self, chat_model, httpx2_mock ): # Two staged responses so conv.prompt twice can complete. httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", json={ "model": "gpt-4o-mini", "usage": { "prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2, }, "choices": [ { "message": {"role": "assistant", "content": "A1"}, "finish_reason": "stop", } ], }, headers={"Content-Type": "application/json"}, ) httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", json={ "model": "gpt-4o-mini", "usage": { "prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2, }, "choices": [ { "message": {"role": "assistant", "content": "A2"}, "finish_reason": "stop", } ], }, headers={"Content-Type": "application/json"}, ) model = llm.get_model("gpt-4o-mini") conv = model.conversation() r1 = conv.prompt("Q1", key=API_KEY, stream=False) > r1.text() tests/test_openai_messages.py:371: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo... json_data={'messages': [{'role': 'user', 'content': 'Q1'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError __ TestStreamingExecuteYieldsStreamEvents.test_text_stream_yields_text_events __ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...'content': 'hi'}], 'model': 'gpt-4o-mini', 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: self = httpx2_mock = def test_text_stream_yields_text_events(self, httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", stream=IteratorStream(_text_stream()), headers={"Content-Type": "text/event-stream"}, ) model = llm.get_model("gpt-4o-mini") response = model.prompt("hi", key=API_KEY) > events = list(response.stream_events()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_messages.py:396: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1678: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...'content': 'hi'}], 'model': 'gpt-4o-mini', 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ TestStreamingExecuteYieldsStreamEvents.test_text_stream_plain_iteration_still_returns_strings _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...'content': 'hi'}], 'model': 'gpt-4o-mini', 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: self = httpx2_mock = def test_text_stream_plain_iteration_still_returns_strings(self, httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", stream=IteratorStream(_text_stream()), headers={"Content-Type": "text/event-stream"}, ) model = llm.get_model("gpt-4o-mini") response = model.prompt("hi", key=API_KEY) > chunks = list(response) ^^^^^^^^^^^^^^ tests/test_openai_messages.py:414: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1678: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...'content': 'hi'}], 'model': 'gpt-4o-mini', 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError __ TestStreamingExecuteYieldsStreamEvents.test_text_stream_messages_assembled __ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...'content': 'hi'}], 'model': 'gpt-4o-mini', 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: self = httpx2_mock = def test_text_stream_messages_assembled(self, httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", stream=IteratorStream(_text_stream()), headers={"Content-Type": "text/event-stream"}, ) model = llm.get_model("gpt-4o-mini") response = model.prompt("hi", key=API_KEY) > response.text() tests/test_openai_messages.py:427: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1678: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...'content': 'hi'}], 'model': 'gpt-4o-mini', 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ TestStreamingExecuteYieldsStreamEvents.test_tool_call_stream_yields_name_and_args_events _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...parameters': {'properties': {'city': {'type': 'string'}}, 'required': ['city'], 'type': 'object'}}}]}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: self = httpx2_mock = def test_tool_call_stream_yields_name_and_args_events(self, httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", stream=IteratorStream(_tool_call_stream()), headers={"Content-Type": "text/event-stream"}, ) def get_weather(city: str) -> str: "Look up the weather." return "sunny" model = llm.get_model("gpt-4o-mini") response = model.prompt("weather?", tools=[get_weather], key=API_KEY) > events = list(response.stream_events()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_messages.py:446: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1678: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...parameters': {'properties': {'city': {'type': 'string'}}, 'required': ['city'], 'type': 'object'}}}]}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ TestStreamingExecuteYieldsStreamEvents.test_tool_call_registered_via_add_tool_call _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...parameters': {'properties': {'city': {'type': 'string'}}, 'required': ['city'], 'type': 'object'}}}]}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: self = httpx2_mock = def test_tool_call_registered_via_add_tool_call(self, httpx2_mock): """response.tool_calls() still works — chain/execute relies on it.""" httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", stream=IteratorStream(_tool_call_stream()), headers={"Content-Type": "text/event-stream"}, ) def get_weather(city: str) -> str: "Look up the weather." return "sunny" model = llm.get_model("gpt-4o-mini") response = model.prompt("weather?", tools=[get_weather], key=API_KEY) > response.text() tests/test_openai_messages.py:475: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1678: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...parameters': {'properties': {'city': {'type': 'string'}}, 'required': ['city'], 'type': 'object'}}}]}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ TestStreamingExecuteYieldsStreamEvents.test_text_then_tool_call_part_index_advances _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo....', 'parameters': {'properties': {'c': {'type': 'integer'}}, 'required': ['c'], 'type': 'object'}}}]}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: self = httpx2_mock = def test_text_then_tool_call_part_index_advances(self, httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", stream=IteratorStream(_text_then_tool_call_stream()), headers={"Content-Type": "text/event-stream"}, ) def get_weather(c: int) -> str: "Weather." return "sunny" model = llm.get_model("gpt-4o-mini") response = model.prompt("q", tools=[get_weather], key=API_KEY) > response.text() tests/test_openai_messages.py:496: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1678: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo....', 'parameters': {'properties': {'c': {'type': 'integer'}}, 'required': ['c'], 'type': 'object'}}}]}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ TestAsyncStreamingExecuteYieldsStreamEvents.test_text_stream_yields_text_events _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...'content': 'hi'}], 'model': 'gpt-4o-mini', 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: self = httpx2_mock = @pytest.mark.asyncio async def test_text_stream_yields_text_events(self, httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", stream=IteratorStream(_text_stream()), headers={"Content-Type": "text/event-stream"}, ) model = llm.get_async_model("gpt-4o-mini") response = model.prompt("hi", key=API_KEY) events = [] > async for event in response.astream_events(): tests/test_openai_messages.py:520: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2607: in astream_events chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1797: in execute completion = await client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:2700: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...'content': 'hi'}], 'model': 'gpt-4o-mini', 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True stream_cls = openai.AsyncStream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _ TestReasoningTokenCount.test_redacted_reasoning_part_emitted_when_count_present _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...'content': 'hi'}], 'model': 'gpt-4o-mini', 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: self = httpx2_mock = def test_redacted_reasoning_part_emitted_when_count_present(self, httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", stream=IteratorStream(_text_stream_with_reasoning_usage(150)), headers={"Content-Type": "text/event-stream"}, ) model = llm.get_model("gpt-4o-mini") response = model.prompt("hi", key=API_KEY) > response.text() tests/test_openai_messages.py:557: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1678: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...'content': 'hi'}], 'model': 'gpt-4o-mini', 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ______ TestReasoningTokenCount.test_no_reasoning_part_when_zero_or_absent ______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...'content': 'hi'}], 'model': 'gpt-4o-mini', 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: self = httpx2_mock = def test_no_reasoning_part_when_zero_or_absent(self, httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", stream=IteratorStream(_text_stream_with_reasoning_usage(0)), headers={"Content-Type": "text/event-stream"}, ) model = llm.get_model("gpt-4o-mini") response = model.prompt("hi", key=API_KEY) > response.text() tests/test_openai_messages.py:577: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1678: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...'content': 'hi'}], 'model': 'gpt-4o-mini', 'stream': True, 'stream_options': {'include_usage': True}}, extra_json=None) stream = True stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ TestNonStreamingExecuteYieldsStreamEvents.test_non_streaming_text_yields_single_event _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo... json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: self = httpx2_mock = def test_non_streaming_text_yields_single_event(self, httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", json={ "model": "gpt-4o-mini", "usage": { "prompt_tokens": 1, "completion_tokens": 1, "total_tokens": 2, }, "choices": [ { "message": {"role": "assistant", "content": "Hello"}, "finish_reason": "stop", } ], }, headers={"Content-Type": "application/json"}, ) model = llm.get_model("gpt-4o-mini") response = model.prompt("hi", key=API_KEY, stream=False) > events = list(response.stream_events()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_messages.py:607: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo... json_data={'messages': [{'role': 'user', 'content': 'hi'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_responses_web_search_request_and_result_capture _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_..., 'stream': False, 'tools': [{'type': 'web_search', 'filters': {'allowed_domains': ['openai.com']}}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_responses_web_search_request_and_result_capture(httpx2_mock): sources = [ {"type": "url", "url": "https://openai.com/news/"}, {"type": "url", "url": "https://example.com/report"}, ] results = [ { "type": "image_result", "image_url": "https://example.com/image.jpg", "source_website_url": "https://example.com/report", "thumbnail_url": "https://example.com/thumb.jpg", "caption": "An example image", } ] response_json = _text_response_json(text="A cited answer") response_json["output"].insert( 0, { "type": "web_search_call", "id": "ws_123", "status": "completed", "action": { "type": "search", "query": "OpenAI news", "queries": ["OpenAI news"], "sources": sources, }, "results": results, }, ) httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json=response_json, headers={"Content-Type": "application/json"}, ) response = llm.get_model("gpt-5.6-luna").prompt( "Search for OpenAI news", tools=[ WebSearch( allowed_domains=["openai.com"], include_sources=True, include_results=True, ) ], stream=False, key="test", ) > assert response.text() == "A cited answer" ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:228: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_..., 'stream': False, 'tools': [{'type': 'web_search', 'filters': {'allowed_domains': ['openai.com']}}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ___________ test_responses_mixes_function_and_code_interpreter_tools ___________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...ype': 'object'}}, {'type': 'code_interpreter', 'container': {'type': 'auto', 'memory_limit': '4g'}}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_responses_mixes_function_and_code_interpreter_tools(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json=_text_response_json(), headers={"Content-Type": "application/json"}, ) def multiply(a: int, b: int) -> int: return a * b model = llm.get_model("gpt-5.6-luna") response = model.prompt( "Calculate 111 * 333 using the python tool", tools=[multiply, CodeInterpreter(memory_limit="4g")], stream=False, key="test", ) > assert response.text() == "ok" ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:307: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...ype': 'object'}}, {'type': 'code_interpreter', 'container': {'type': 'auto', 'memory_limit': '4g'}}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ________ test_responses_raw_server_tool_passthrough_on_custom_endpoint _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...stom-model', 'store': False, 'stream': False, 'tools': [{'type': 'browser_search', 'depth': 'deep'}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_responses_raw_server_tool_passthrough_on_custom_endpoint(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://example.test/v1/responses", json=_text_response_json(model="custom-model"), headers={"Content-Type": "application/json"}, ) model = Responses( "custom-model", api_base="https://example.test/v1", supports_tools=False, ) raw_spec = {"type": "browser_search", "depth": "deep"} response = model.prompt( "Search", tools=[llm.ServerSideTool(raw_spec)], stream=False, key="test" ) > assert response.text() == "ok" ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:339: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...stom-model', 'store': False, 'stream': False, 'tools': [{'type': 'browser_search', 'depth': 'deep'}]}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ________________ test_async_responses_code_interpreter_request _________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...alse, 'tools': [{'type': 'code_interpreter', 'container': {'type': 'auto', 'file_ids': ['file-1']}}]}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = @pytest.mark.asyncio async def test_async_responses_code_interpreter_request(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json=_text_response_json(), headers={"Content-Type": "application/json"}, ) model = llm.get_async_model("gpt-5.6-luna") response = model.prompt( "Calculate", tools=[CodeInterpreter(file_ids=["file-1"])], stream=False, key="test", ) > assert await response.text() == "ok" ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:379: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...alse, 'tools': [{'type': 'code_interpreter', 'container': {'type': 'auto', 'file_ids': ['file-1']}}]}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ___________________ test_async_responses_web_search_request ____________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...'}, 'store': False, 'stream': False, 'tools': [{'type': 'web_search', 'external_web_access': False}]}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = @pytest.mark.asyncio async def test_async_responses_web_search_request(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json=_text_response_json(), headers={"Content-Type": "application/json"}, ) response = llm.get_async_model("gpt-5.6-luna").prompt( "Search", tools=[WebSearch(external_web_access=False, include_sources=True)], stream=False, key="test", ) > assert await response.text() == "ok" ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:408: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...'}, 'store': False, 'stream': False, 'tools': [{'type': 'web_search', 'external_web_access': False}]}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _______________ test_chat_completions_opt_out_dispatches_to_chat _______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo..., json_data={'messages': [{'role': 'user', 'content': 'hello'}], 'model': 'gpt-5.5', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_chat_completions_opt_out_dispatches_to_chat(httpx2_mock): """When chat_completions=1 is passed, the request must hit /v1/chat/completions, not /v1/responses.""" httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", json={ "id": "chatcmpl-x", "object": "chat.completion", "model": "gpt-5.5", "choices": [ { "index": 0, "message": {"role": "assistant", "content": "hi from chat"}, "finish_reason": "stop", } ], "usage": {"prompt_tokens": 1, "completion_tokens": 2, "total_tokens": 3}, }, headers={"Content-Type": "application/json"}, ) model = llm.get_model("gpt-5.5") response = model.prompt( "hello", stream=False, chat_completions=True, reasoning_summary="detailed", key="test", ) > assert response.text() == "hi from chat" ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:623: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2777: in execute yield from chat.execute(prompt, stream, response, conversation, key) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo..., json_data={'messages': [{'role': 'user', 'content': 'hello'}], 'model': 'gpt-5.5', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ________ test_default_routes_to_responses_endpoint[None-False-gpt-5.5] _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...t': 'hello'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-5.5', async_ = False, reasoning_effort = None @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...t': 'hello'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______ test_default_routes_to_responses_endpoint[None-False-gpt-6-sol] ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: 'hello'}], 'model': 'gpt-6-sol', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6-sol', async_ = False, reasoning_effort = None @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: 'hello'}], 'model': 'gpt-6-sol', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______ test_default_routes_to_responses_endpoint[None-False-gpt-6-luna] _______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_... 'hello'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6-luna', async_ = False, reasoning_effort = None @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_... 'hello'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____ test_default_routes_to_responses_endpoint[None-False-gpt-6.1-terra] ______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...ello'}], 'model': 'gpt-6.1-terra', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6.1-terra', async_ = False, reasoning_effort = None @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...ello'}], 'model': 'gpt-6.1-terra', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________ test_default_routes_to_responses_endpoint[None-True-gpt-5.5] _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...t': 'hello'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-5.5', async_ = True, reasoning_effort = None @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...t': 'hello'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ________ test_default_routes_to_responses_endpoint[None-True-gpt-6-sol] ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: 'hello'}], 'model': 'gpt-6-sol', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6-sol', async_ = True, reasoning_effort = None @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: 'hello'}], 'model': 'gpt-6-sol', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _______ test_default_routes_to_responses_endpoint[None-True-gpt-6-luna] ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_... 'hello'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6-luna', async_ = True, reasoning_effort = None @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_... 'hello'}], 'model': 'gpt-6-luna', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ______ test_default_routes_to_responses_endpoint[None-True-gpt-6.1-terra] ______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...ello'}], 'model': 'gpt-6.1-terra', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6.1-terra', async_ = True, reasoning_effort = None @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...ello'}], 'model': 'gpt-6.1-terra', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ________ test_default_routes_to_responses_endpoint[none-False-gpt-5.5] _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-5.5', async_ = False, reasoning_effort = 'none' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______ test_default_routes_to_responses_endpoint[none-False-gpt-6-sol] ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6-sol', async_ = False, reasoning_effort = 'none' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______ test_default_routes_to_responses_endpoint[none-False-gpt-6-luna] _______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6-luna', async_ = False, reasoning_effort = 'none' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____ test_default_routes_to_responses_endpoint[none-False-gpt-6.1-terra] ______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6.1-terra', async_ = False, reasoning_effort = 'none' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________ test_default_routes_to_responses_endpoint[none-True-gpt-5.5] _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-5.5', async_ = True, reasoning_effort = 'none' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ________ test_default_routes_to_responses_endpoint[none-True-gpt-6-sol] ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6-sol', async_ = True, reasoning_effort = 'none' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _______ test_default_routes_to_responses_endpoint[none-True-gpt-6-luna] ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6-luna', async_ = True, reasoning_effort = 'none' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ______ test_default_routes_to_responses_endpoint[none-True-gpt-6.1-terra] ______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6.1-terra', async_ = True, reasoning_effort = 'none' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _________ test_default_routes_to_responses_endpoint[max-False-gpt-5.5] _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-5.5', async_ = False, reasoning_effort = 'max' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ________ test_default_routes_to_responses_endpoint[max-False-gpt-6-sol] ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6-sol', async_ = False, reasoning_effort = 'max' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _______ test_default_routes_to_responses_endpoint[max-False-gpt-6-luna] ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6-luna', async_ = False, reasoning_effort = 'max' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ______ test_default_routes_to_responses_endpoint[max-False-gpt-6.1-terra] ______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6.1-terra', async_ = False, reasoning_effort = 'max' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________ test_default_routes_to_responses_endpoint[max-True-gpt-5.5] __________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-5.5', async_ = True, reasoning_effort = 'max' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ________ test_default_routes_to_responses_endpoint[max-True-gpt-6-sol] _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6-sol', async_ = True, reasoning_effort = 'max' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ________ test_default_routes_to_responses_endpoint[max-True-gpt-6-luna] ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6-luna', async_ = True, reasoning_effort = 'max' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ______ test_default_routes_to_responses_endpoint[max-True-gpt-6.1-terra] _______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = model_id = 'gpt-6.1-terra', async_ = True, reasoning_effort = 'max' @pytest.mark.parametrize( "model_id", ("gpt-5.5", "gpt-6-sol", "gpt-6-luna", "gpt-6.1-terra") ) @pytest.mark.parametrize("async_", (False, True)) @pytest.mark.parametrize("reasoning_effort", (None, "none", "max")) @pytest.mark.asyncio async def test_default_routes_to_responses_endpoint( httpx2_mock, model_id, async_, reasoning_effort ): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": model_id, "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from responses", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_async_model(model_id) if async_ else llm.get_model(model_id) response = model.prompt( "hello", stream=False, key="test", reasoning_effort=reasoning_effort ) > text = await response.text() if async_ else response.text() ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:673: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3173: in execute completion = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...g': {'summary': 'auto', 'effort': }, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError ______ test_hide_reasoning_omits_reasoning_summary_from_responses_request ______ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...'input': [{'role': 'user', 'content': 'hello'}], 'model': 'gpt-5.5', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_hide_reasoning_omits_reasoning_summary_from_responses_request(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": "gpt-5.5", "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hidden", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_model("gpt-5.5") response = model.prompt("hello", stream=False, key="test", hide_reasoning=True) > assert response.text() == "hidden" ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:722: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...'input': [{'role': 'user', 'content': 'hello'}], 'model': 'gpt-5.5', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____ test_non_reasoning_responses_model_omits_encrypted_reasoning_include _____ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...'input': [{'role': 'user', 'content': 'hello'}], 'model': 'gpt-4.1', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_non_reasoning_responses_model_omits_encrypted_reasoning_include(httpx2_mock): from llm.default_plugins.openai_models import Responses httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": "gpt-4.1", "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "hi from gpt-4.1", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = Responses("gpt-4.1", vision=True, supports_schema=True, supports_tools=True) response = model.prompt("hello", stream=False, key="test") > assert response.text() == "hi from gpt-4.1" ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:767: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...'input': [{'role': 'user', 'content': 'hello'}], 'model': 'gpt-4.1', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError __________ test_responses_reply_sends_prior_assistant_text_as_string ___________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: first-ok'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_responses_reply_sends_prior_assistant_text_as_string(httpx2_mock): """response.reply() should send the same simple history shape a direct openai-python Responses call would use for a text-only assistant turn.""" def response_json(response_id, message_id, text): return { "id": response_id, "object": "response", "created_at": 1, "model": "gpt-5.5", "output": [ { "type": "message", "id": message_id, "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": text, "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", } httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json=response_json("resp_1", "msg_1", "first-ok"), headers={"Content-Type": "application/json"}, ) httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json=response_json("resp_2", "msg_2", "followup-ok"), headers={"Content-Type": "application/json"}, ) model = llm.get_model("gpt-5.5") first = model.prompt("Say exactly: first-ok", stream=False, key="test") > second = first.reply("Say exactly: followup-ok", stream=False, key="test") ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:893: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1829: in reply self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...: first-ok'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________________ test_service_tier_sent_to_responses_endpoint _________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...-5.6-sol', 'reasoning': {'summary': 'auto'}, 'service_tier': 'fast', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_service_tier_sent_to_responses_endpoint(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_test_1", "object": "response", "created_at": 1, "model": "gpt-5.6-sol", "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ { "type": "output_text", "text": "fast reply", "annotations": [], } ], } ], "usage": { "input_tokens": 5, "output_tokens": 3, "total_tokens": 8, }, "status": "completed", "service_tier": "priority", }, headers={"Content-Type": "application/json"}, ) model = llm.get_model("gpt-5.6-sol") response = model.prompt("hello", stream=False, service_tier="fast", key="test") > assert response.text() == "fast reply" ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:1086: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...-5.6-sol', 'reasoning': {'summary': 'auto'}, 'service_tier': 'fast', 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_service_tier_sent_to_chat_completions_fallback ______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...role': 'user', 'content': 'hello'}], 'model': 'gpt-5.6-sol', 'service_tier': 'fast', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_service_tier_sent_to_chat_completions_fallback(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/chat/completions", json={ "id": "chatcmpl-x", "object": "chat.completion", "model": "gpt-5.6-sol", "choices": [ { "index": 0, "message": {"role": "assistant", "content": "fast chat"}, "finish_reason": "stop", } ], "usage": {"prompt_tokens": 1, "completion_tokens": 2, "total_tokens": 3}, }, headers={"Content-Type": "application/json"}, ) model = llm.get_model("gpt-5.6-sol") response = model.prompt( "hello", stream=False, chat_completions=True, service_tier="fast", key="test" ) > assert response.text() == "fast chat" ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:1116: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2777: in execute yield from chat.execute(prompt, stream, response, conversation, key) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...role': 'user', 'content': 'hello'}], 'model': 'gpt-5.6-sol', 'service_tier': 'fast', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ________________ test_responses_streams_reasoning_summary_text _________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nt': 'hello'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': True}, extra_json=None) stream = True stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_responses_streams_reasoning_summary_text(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", stream=IteratorStream(_responses_reasoning_summary_stream()), headers={"Content-Type": "text/event-stream"}, ) model = llm.get_model("gpt-5.5") response = model.prompt("hello", key="test") > events = list(response.stream_events()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:1131: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2795: in execute stream_obj = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nt': 'hello'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': True}, extra_json=None) stream = True stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ________ test_responses_reasoning_metadata_refreshed_from_final_payload ________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nt': 'hello'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': True}, extra_json=None) stream = True stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_responses_reasoning_metadata_refreshed_from_final_payload(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", stream=IteratorStream(_responses_reasoning_refresh_stream()), headers={"Content-Type": "text/event-stream"}, ) model = llm.get_model("gpt-5.5") response = model.prompt("hello", key="test") > assert response.text() == "done" ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:1436: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2795: in execute stream_obj = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...nt': 'hello'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': True}, extra_json=None) stream = True stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________________ test_code_interpreter_multi_message_response _________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...t': 'count'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_code_interpreter_multi_message_response(httpx2_mock): """Server-side tool execution interleaving multiple message output items must assemble into multiple assistant Messages.""" httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", json={ "id": "resp_multi", "object": "response", "created_at": 1, "model": "gpt-5.5", "output": [ { "type": "message", "id": "msg_1", "role": "assistant", "status": "completed", "content": [ {"type": "output_text", "text": "STEP ONE", "annotations": []} ], }, { "type": "code_interpreter_call", "id": "ci_1", "status": "completed", "container_id": "cntr_1", "code": "print(111*111)", "outputs": [{"type": "logs", "logs": "12321\n"}], }, { "type": "message", "id": "msg_2", "role": "assistant", "status": "completed", "content": [ {"type": "output_text", "text": "DONE 12321", "annotations": []} ], }, ], "usage": {"input_tokens": 5, "output_tokens": 3, "total_tokens": 8}, "status": "completed", }, headers={"Content-Type": "application/json"}, ) model = llm.get_model("gpt-5.5") response = model.prompt("count", stream=False, key="test") > response.text() tests/test_openai_responses.py:1501: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...t': 'count'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ______________ test_code_interpreter_streaming_output_and_request ______________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...tore': False, 'stream': True, 'tools': [{'type': 'code_interpreter', 'container': {'type': 'auto'}}]}, extra_json=None) stream = True stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_code_interpreter_streaming_output_and_request(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", stream=IteratorStream(_code_interpreter_stream()), headers={"Content-Type": "text/event-stream"}, ) model = llm.get_model("gpt-5.6-luna") response = model.prompt("Calculate", tools=[CodeInterpreter()], key="test") > events = list(response.stream_events()) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:1534: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2132: in stream_events for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2795: in execute stream_obj = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...tore': False, 'stream': True, 'tools': [{'type': 'code_interpreter', 'container': {'type': 'auto'}}]}, extra_json=None) stream = True stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ____________ test_web_search_streaming_refreshes_from_final_payload ____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_... 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': True, 'tools': [{'type': 'web_search'}]}, extra_json=None) stream = True stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = def test_web_search_streaming_refreshes_from_final_payload(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", stream=IteratorStream(_web_search_refresh_stream()), headers={"Content-Type": "text/event-stream"}, ) response = llm.get_model("gpt-5.6-luna").prompt( "Search", tools=[WebSearch(include_sources=True, include_results=True)], key="test", ) > assert response.text() == "done" ^^^^^^^^^^^^^^^ tests/test_openai_responses.py:1584: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2795: in execute stream_obj = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_... 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': True, 'tools': [{'type': 'web_search'}]}, extra_json=None) stream = True stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________ test_async_web_search_streaming_refreshes_from_final_payload _________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:394: in handle_async_request resp = await self._pool.handle_async_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:256: in handle_async_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_async/connection_pool.py:236: in handle_async_request response = await connection.handle_async_request( /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:101: in handle_async_request raise exc /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:78: in handle_async_request stream = await self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_async/connection.py:124: in _connect stream = await self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/auto.py:31: in connect_tcp return await self._backend.connect_tcp( /usr/lib/python3.15/site-packages/httpcore/_backends/anyio.py:113: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_... 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': True, 'tools': [{'type': 'web_search'}]}, extra_json=None) stream = True stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1604: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:1629: in send response = await self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:1657: in _send_handling_auth response = await self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:1694: in _send_handling_redirects response = await self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1730: in _send_single_request response = await transport.handle_async_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:393: in handle_async_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: httpx2_mock = @pytest.mark.asyncio async def test_async_web_search_streaming_refreshes_from_final_payload(httpx2_mock): httpx2_mock.add_response( method="POST", url="https://api.openai.com/v1/responses", stream=IteratorStream(_web_search_refresh_stream()), headers={"Content-Type": "text/event-stream"}, ) response = llm.get_async_model("gpt-5.6-luna").prompt( "Search", tools=[WebSearch(include_sources=True, include_results=True)], key="test", ) > assert await response.text() == "done" ^^^^^^^^^^^^^^^^^^^^^ tests/test_openai_responses.py:1602: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2645: in text await self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2633: in _force async for chunk in self: ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2585: in __anext__ chunk = await self._generator.__anext__() ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:3046: in execute stream_obj = await client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:2559: in create return await self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1884: in post return await self.request(cast_to, opts, stream=stream, stream_cls=stream_cls) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_... 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': True, 'tools': [{'type': 'web_search'}]}, extra_json=None) stream = True stream_cls = openai.AsyncStream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] async def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_AsyncStreamT] | None = None, ) -> ResponseT | _AsyncStreamT: if self._platform is None: # `get_platform` can make blocking IO calls so we # execute it earlier while we are in an async context self._platform = await asyncify(get_platform)() cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = await self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) await self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = await self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: await self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1636: APIConnectionError _________________ test_direct_prompt_default_options[kwargs0] __________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...t': 'hello'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: mocked_openai_responses = kwargs = {} @pytest.mark.parametrize("kwargs", ({}, {"options": None}, {"options": {}})) def test_direct_prompt_default_options(mocked_openai_responses, kwargs): model = llm.get_model("gpt-5.5") prompt = llm.Prompt("hello", model, **kwargs) response = llm.Response(prompt=prompt, model=model, stream=False, key="test-key") > assert response.text() == "Bob, Alice, Eve" ^^^^^^^^^^^^^^^ tests/test_options_parameter.py:18: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...t': 'hello'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________________ test_direct_prompt_default_options[kwargs1] __________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...t': 'hello'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: mocked_openai_responses = kwargs = {'options': None} @pytest.mark.parametrize("kwargs", ({}, {"options": None}, {"options": {}})) def test_direct_prompt_default_options(mocked_openai_responses, kwargs): model = llm.get_model("gpt-5.5") prompt = llm.Prompt("hello", model, **kwargs) response = llm.Response(prompt=prompt, model=model, stream=False, key="test-key") > assert response.text() == "Bob, Alice, Eve" ^^^^^^^^^^^^^^^ tests/test_options_parameter.py:18: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...t': 'hello'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _________________ test_direct_prompt_default_options[kwargs2] __________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...t': 'hello'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: mocked_openai_responses = kwargs = {'options': {}} @pytest.mark.parametrize("kwargs", ({}, {"options": None}, {"options": {}})) def test_direct_prompt_default_options(mocked_openai_responses, kwargs): model = llm.get_model("gpt-5.5") prompt = llm.Prompt("hello", model, **kwargs) response = llm.Response(prompt=prompt, model=model, stream=False, key="test-key") > assert response.text() == "Bob, Alice, Eve" ^^^^^^^^^^^^^^^ tests/test_options_parameter.py:18: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...t': 'hello'}], 'model': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________________ test_direct_prompt_preserves_options _____________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...l': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False, 'temperature': 0.5}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: mocked_openai_responses = def test_direct_prompt_preserves_options(mocked_openai_responses): model = llm.get_model("gpt-5.5") options = model.Options(temperature=0.5) prompt = llm.Prompt("hello", model, options=options) response = llm.Response(prompt=prompt, model=model, stream=False, key="test-key") > assert response.text() == "Bob, Alice, Eve" ^^^^^^^^^^^^^^^ tests/test_options_parameter.py:29: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:2920: in execute completion = client.responses.create( /usr/lib/python3.15/site-packages/openai/resources/responses/responses.py:898: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/responses', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeout=NOT_...l': 'gpt-5.5', 'reasoning': {'summary': 'auto'}, 'store': False, 'stream': False, 'temperature': 0.5}, extra_json=None) stream = False stream_cls = openai.Stream[typing.Annotated[openai.types.responses.response_audio_delta_event.ResponseAudioDeltaEvent | openai.type...seCustomToolCallInputDoneEvent, PropertyInfo(alias='None', format=None, format_template='None', discriminator='type')]] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_execute_prompt_with_a_template['Summarize this: $input'-Input text-extra_args0-gpt-4o-mini-Summarize this: Input text-None-None] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...[{'role': 'user', 'content': 'Summarize this: Input text'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_execute_prompt_with_a_tem0/llm.datasette.io/templates') mocked_openai_chat = template = "'Summarize this: $input'", input_text = 'Input text' extra_args = ['-m', 'gpt-4o-mini'], expected_model = 'gpt-4o-mini' expected_input = 'Summarize this: Input text', expected_error = None expected_options = None @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize( "template,input_text,extra_args,expected_model,expected_input,expected_error,expected_options", ( ( "'Summarize this: $input'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'\nmodel: gpt-4o", "Input text", [], "gpt-4o", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'", "Input text", ["-m", "4o"], "gpt-4o", "Summarize this: Input text", None, None, ), # -s system prompt should over-ride template system prompt pytest.param( "boo", "Input text", ["-m", "gpt-4o-mini", "-s", "custom system"], "gpt-4o-mini", [ {"role": "system", "content": "custom system"}, {"role": "user", "content": "boo\nInput text"}, ], None, None, marks=pytest.mark.httpx2_mock(), ), pytest.param( "prompt: 'Say $hello'", "Input text", [], None, None, "Error: Missing variables: hello", None, marks=pytest.mark.httpx2_mock(), ), # Template generated prompt should combine with CLI prompt ( "prompt: 'Say $hello'", "Input text", ["-m", "gpt-4o-mini", "-p", "hello", "Blah"], "gpt-4o-mini", "Say Blah\nInput text", None, None, ), ( "prompt: 'Say pelican'", "", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Say pelican", None, None, ), # Template with just a system prompt ( "system: 'Summarize this'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", [ {"content": "Summarize this", "role": "system"}, {"content": "Input text", "role": "user"}, ], None, None, ), # Options ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.5}, ), # Should be over-ridden by CLI ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini", "-o", "temperature", "0.7"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.7}, ), ), ) def test_execute_prompt_with_a_template( templates_path, mocked_openai_chat, template, input_text, extra_args, expected_model, expected_input, expected_error, expected_options, ): (templates_path / "template.yaml").write_text(template, "utf-8") runner = CliRunner() > result = runner.invoke( cli, ["--no-stream", "-t", "template"] + ([input_text] if input_text else []) + extra_args, catch_exceptions=False, ) tests/test_templates.py:321: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...[{'role': 'user', 'content': 'Summarize this: Input text'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'\nmodel: gpt-4o-Input text-extra_args1-gpt-4o-Summarize this: Input text-None-None] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...es': [{'role': 'user', 'content': 'Summarize this: Input text'}], 'model': 'gpt-4o', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_execute_prompt_with_a_tem1/llm.datasette.io/templates') mocked_openai_chat = template = "prompt: 'Summarize this: $input'\nmodel: gpt-4o" input_text = 'Input text', extra_args = [], expected_model = 'gpt-4o' expected_input = 'Summarize this: Input text', expected_error = None expected_options = None @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize( "template,input_text,extra_args,expected_model,expected_input,expected_error,expected_options", ( ( "'Summarize this: $input'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'\nmodel: gpt-4o", "Input text", [], "gpt-4o", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'", "Input text", ["-m", "4o"], "gpt-4o", "Summarize this: Input text", None, None, ), # -s system prompt should over-ride template system prompt pytest.param( "boo", "Input text", ["-m", "gpt-4o-mini", "-s", "custom system"], "gpt-4o-mini", [ {"role": "system", "content": "custom system"}, {"role": "user", "content": "boo\nInput text"}, ], None, None, marks=pytest.mark.httpx2_mock(), ), pytest.param( "prompt: 'Say $hello'", "Input text", [], None, None, "Error: Missing variables: hello", None, marks=pytest.mark.httpx2_mock(), ), # Template generated prompt should combine with CLI prompt ( "prompt: 'Say $hello'", "Input text", ["-m", "gpt-4o-mini", "-p", "hello", "Blah"], "gpt-4o-mini", "Say Blah\nInput text", None, None, ), ( "prompt: 'Say pelican'", "", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Say pelican", None, None, ), # Template with just a system prompt ( "system: 'Summarize this'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", [ {"content": "Summarize this", "role": "system"}, {"content": "Input text", "role": "user"}, ], None, None, ), # Options ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.5}, ), # Should be over-ridden by CLI ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini", "-o", "temperature", "0.7"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.7}, ), ), ) def test_execute_prompt_with_a_template( templates_path, mocked_openai_chat, template, input_text, extra_args, expected_model, expected_input, expected_error, expected_options, ): (templates_path / "template.yaml").write_text(template, "utf-8") runner = CliRunner() > result = runner.invoke( cli, ["--no-stream", "-t", "template"] + ([input_text] if input_text else []) + extra_args, catch_exceptions=False, ) tests/test_templates.py:321: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...es': [{'role': 'user', 'content': 'Summarize this: Input text'}], 'model': 'gpt-4o', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'-Input text-extra_args2-gpt-4o-Summarize this: Input text-None-None] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...es': [{'role': 'user', 'content': 'Summarize this: Input text'}], 'model': 'gpt-4o', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_execute_prompt_with_a_tem2/llm.datasette.io/templates') mocked_openai_chat = template = "prompt: 'Summarize this: $input'", input_text = 'Input text' extra_args = ['-m', '4o'], expected_model = 'gpt-4o' expected_input = 'Summarize this: Input text', expected_error = None expected_options = None @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize( "template,input_text,extra_args,expected_model,expected_input,expected_error,expected_options", ( ( "'Summarize this: $input'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'\nmodel: gpt-4o", "Input text", [], "gpt-4o", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'", "Input text", ["-m", "4o"], "gpt-4o", "Summarize this: Input text", None, None, ), # -s system prompt should over-ride template system prompt pytest.param( "boo", "Input text", ["-m", "gpt-4o-mini", "-s", "custom system"], "gpt-4o-mini", [ {"role": "system", "content": "custom system"}, {"role": "user", "content": "boo\nInput text"}, ], None, None, marks=pytest.mark.httpx2_mock(), ), pytest.param( "prompt: 'Say $hello'", "Input text", [], None, None, "Error: Missing variables: hello", None, marks=pytest.mark.httpx2_mock(), ), # Template generated prompt should combine with CLI prompt ( "prompt: 'Say $hello'", "Input text", ["-m", "gpt-4o-mini", "-p", "hello", "Blah"], "gpt-4o-mini", "Say Blah\nInput text", None, None, ), ( "prompt: 'Say pelican'", "", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Say pelican", None, None, ), # Template with just a system prompt ( "system: 'Summarize this'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", [ {"content": "Summarize this", "role": "system"}, {"content": "Input text", "role": "user"}, ], None, None, ), # Options ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.5}, ), # Should be over-ridden by CLI ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini", "-o", "temperature", "0.7"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.7}, ), ), ) def test_execute_prompt_with_a_template( templates_path, mocked_openai_chat, template, input_text, extra_args, expected_model, expected_input, expected_error, expected_options, ): (templates_path / "template.yaml").write_text(template, "utf-8") runner = CliRunner() > result = runner.invoke( cli, ["--no-stream", "-t", "template"] + ([input_text] if input_text else []) + extra_args, catch_exceptions=False, ) tests/test_templates.py:321: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...es': [{'role': 'user', 'content': 'Summarize this: Input text'}], 'model': 'gpt-4o', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_execute_prompt_with_a_template[boo-Input text-extra_args3-gpt-4o-mini-expected_input3-None-None] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...m system'}, {'role': 'user', 'content': 'boo\nInput text'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_execute_prompt_with_a_tem3/llm.datasette.io/templates') mocked_openai_chat = template = 'boo', input_text = 'Input text' extra_args = ['-m', 'gpt-4o-mini', '-s', 'custom system'] expected_model = 'gpt-4o-mini' expected_input = [{'role': 'system', 'content': 'custom system'}, {'role': 'user', 'content': 'boo\nInput text'}] expected_error = None, expected_options = None @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize( "template,input_text,extra_args,expected_model,expected_input,expected_error,expected_options", ( ( "'Summarize this: $input'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'\nmodel: gpt-4o", "Input text", [], "gpt-4o", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'", "Input text", ["-m", "4o"], "gpt-4o", "Summarize this: Input text", None, None, ), # -s system prompt should over-ride template system prompt pytest.param( "boo", "Input text", ["-m", "gpt-4o-mini", "-s", "custom system"], "gpt-4o-mini", [ {"role": "system", "content": "custom system"}, {"role": "user", "content": "boo\nInput text"}, ], None, None, marks=pytest.mark.httpx2_mock(), ), pytest.param( "prompt: 'Say $hello'", "Input text", [], None, None, "Error: Missing variables: hello", None, marks=pytest.mark.httpx2_mock(), ), # Template generated prompt should combine with CLI prompt ( "prompt: 'Say $hello'", "Input text", ["-m", "gpt-4o-mini", "-p", "hello", "Blah"], "gpt-4o-mini", "Say Blah\nInput text", None, None, ), ( "prompt: 'Say pelican'", "", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Say pelican", None, None, ), # Template with just a system prompt ( "system: 'Summarize this'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", [ {"content": "Summarize this", "role": "system"}, {"content": "Input text", "role": "user"}, ], None, None, ), # Options ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.5}, ), # Should be over-ridden by CLI ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini", "-o", "temperature", "0.7"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.7}, ), ), ) def test_execute_prompt_with_a_template( templates_path, mocked_openai_chat, template, input_text, extra_args, expected_model, expected_input, expected_error, expected_options, ): (templates_path / "template.yaml").write_text(template, "utf-8") runner = CliRunner() > result = runner.invoke( cli, ["--no-stream", "-t", "template"] + ([input_text] if input_text else []) + extra_args, catch_exceptions=False, ) tests/test_templates.py:321: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...m system'}, {'role': 'user', 'content': 'boo\nInput text'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_execute_prompt_with_a_template[prompt: 'Say $hello'-Input text-extra_args5-gpt-4o-mini-Say Blah\nInput text-None-None] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ges': [{'role': 'user', 'content': 'Say Blah\nInput text'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_execute_prompt_with_a_tem5/llm.datasette.io/templates') mocked_openai_chat = template = "prompt: 'Say $hello'", input_text = 'Input text' extra_args = ['-m', 'gpt-4o-mini', '-p', 'hello', 'Blah'] expected_model = 'gpt-4o-mini', expected_input = 'Say Blah\nInput text' expected_error = None, expected_options = None @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize( "template,input_text,extra_args,expected_model,expected_input,expected_error,expected_options", ( ( "'Summarize this: $input'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'\nmodel: gpt-4o", "Input text", [], "gpt-4o", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'", "Input text", ["-m", "4o"], "gpt-4o", "Summarize this: Input text", None, None, ), # -s system prompt should over-ride template system prompt pytest.param( "boo", "Input text", ["-m", "gpt-4o-mini", "-s", "custom system"], "gpt-4o-mini", [ {"role": "system", "content": "custom system"}, {"role": "user", "content": "boo\nInput text"}, ], None, None, marks=pytest.mark.httpx2_mock(), ), pytest.param( "prompt: 'Say $hello'", "Input text", [], None, None, "Error: Missing variables: hello", None, marks=pytest.mark.httpx2_mock(), ), # Template generated prompt should combine with CLI prompt ( "prompt: 'Say $hello'", "Input text", ["-m", "gpt-4o-mini", "-p", "hello", "Blah"], "gpt-4o-mini", "Say Blah\nInput text", None, None, ), ( "prompt: 'Say pelican'", "", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Say pelican", None, None, ), # Template with just a system prompt ( "system: 'Summarize this'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", [ {"content": "Summarize this", "role": "system"}, {"content": "Input text", "role": "user"}, ], None, None, ), # Options ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.5}, ), # Should be over-ridden by CLI ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini", "-o", "temperature", "0.7"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.7}, ), ), ) def test_execute_prompt_with_a_template( templates_path, mocked_openai_chat, template, input_text, extra_args, expected_model, expected_input, expected_error, expected_options, ): (templates_path / "template.yaml").write_text(template, "utf-8") runner = CliRunner() > result = runner.invoke( cli, ["--no-stream", "-t", "template"] + ([input_text] if input_text else []) + extra_args, catch_exceptions=False, ) tests/test_templates.py:321: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ges': [{'role': 'user', 'content': 'Say Blah\nInput text'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_execute_prompt_with_a_template[prompt: 'Say pelican'--extra_args6-gpt-4o-mini-Say pelican-None-None] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...a={'messages': [{'role': 'user', 'content': 'Say pelican'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_execute_prompt_with_a_tem6/llm.datasette.io/templates') mocked_openai_chat = template = "prompt: 'Say pelican'", input_text = '' extra_args = ['-m', 'gpt-4o-mini'], expected_model = 'gpt-4o-mini' expected_input = 'Say pelican', expected_error = None, expected_options = None @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize( "template,input_text,extra_args,expected_model,expected_input,expected_error,expected_options", ( ( "'Summarize this: $input'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'\nmodel: gpt-4o", "Input text", [], "gpt-4o", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'", "Input text", ["-m", "4o"], "gpt-4o", "Summarize this: Input text", None, None, ), # -s system prompt should over-ride template system prompt pytest.param( "boo", "Input text", ["-m", "gpt-4o-mini", "-s", "custom system"], "gpt-4o-mini", [ {"role": "system", "content": "custom system"}, {"role": "user", "content": "boo\nInput text"}, ], None, None, marks=pytest.mark.httpx2_mock(), ), pytest.param( "prompt: 'Say $hello'", "Input text", [], None, None, "Error: Missing variables: hello", None, marks=pytest.mark.httpx2_mock(), ), # Template generated prompt should combine with CLI prompt ( "prompt: 'Say $hello'", "Input text", ["-m", "gpt-4o-mini", "-p", "hello", "Blah"], "gpt-4o-mini", "Say Blah\nInput text", None, None, ), ( "prompt: 'Say pelican'", "", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Say pelican", None, None, ), # Template with just a system prompt ( "system: 'Summarize this'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", [ {"content": "Summarize this", "role": "system"}, {"content": "Input text", "role": "user"}, ], None, None, ), # Options ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.5}, ), # Should be over-ridden by CLI ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini", "-o", "temperature", "0.7"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.7}, ), ), ) def test_execute_prompt_with_a_template( templates_path, mocked_openai_chat, template, input_text, extra_args, expected_model, expected_input, expected_error, expected_options, ): (templates_path / "template.yaml").write_text(template, "utf-8") runner = CliRunner() > result = runner.invoke( cli, ["--no-stream", "-t", "template"] + ([input_text] if input_text else []) + extra_args, catch_exceptions=False, ) tests/test_templates.py:321: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...a={'messages': [{'role': 'user', 'content': 'Say pelican'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_execute_prompt_with_a_template[system: 'Summarize this'-Input text-extra_args7-gpt-4o-mini-expected_input7-None-None] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ummarize this'}, {'role': 'user', 'content': 'Input text'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_execute_prompt_with_a_tem7/llm.datasette.io/templates') mocked_openai_chat = template = "system: 'Summarize this'", input_text = 'Input text' extra_args = ['-m', 'gpt-4o-mini'], expected_model = 'gpt-4o-mini' expected_input = [{'content': 'Summarize this', 'role': 'system'}, {'content': 'Input text', 'role': 'user'}] expected_error = None, expected_options = None @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize( "template,input_text,extra_args,expected_model,expected_input,expected_error,expected_options", ( ( "'Summarize this: $input'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'\nmodel: gpt-4o", "Input text", [], "gpt-4o", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'", "Input text", ["-m", "4o"], "gpt-4o", "Summarize this: Input text", None, None, ), # -s system prompt should over-ride template system prompt pytest.param( "boo", "Input text", ["-m", "gpt-4o-mini", "-s", "custom system"], "gpt-4o-mini", [ {"role": "system", "content": "custom system"}, {"role": "user", "content": "boo\nInput text"}, ], None, None, marks=pytest.mark.httpx2_mock(), ), pytest.param( "prompt: 'Say $hello'", "Input text", [], None, None, "Error: Missing variables: hello", None, marks=pytest.mark.httpx2_mock(), ), # Template generated prompt should combine with CLI prompt ( "prompt: 'Say $hello'", "Input text", ["-m", "gpt-4o-mini", "-p", "hello", "Blah"], "gpt-4o-mini", "Say Blah\nInput text", None, None, ), ( "prompt: 'Say pelican'", "", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Say pelican", None, None, ), # Template with just a system prompt ( "system: 'Summarize this'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", [ {"content": "Summarize this", "role": "system"}, {"content": "Input text", "role": "user"}, ], None, None, ), # Options ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.5}, ), # Should be over-ridden by CLI ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini", "-o", "temperature", "0.7"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.7}, ), ), ) def test_execute_prompt_with_a_template( templates_path, mocked_openai_chat, template, input_text, extra_args, expected_model, expected_input, expected_error, expected_options, ): (templates_path / "template.yaml").write_text(template, "utf-8") runner = CliRunner() > result = runner.invoke( cli, ["--no-stream", "-t", "template"] + ([input_text] if input_text else []) + extra_args, catch_exceptions=False, ) tests/test_templates.py:321: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ummarize this'}, {'role': 'user', 'content': 'Input text'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5-Input text-extra_args8-gpt-4o-mini-Summarize this: Input text-None-expected_options8] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ontent': 'Summarize this: Input text'}], 'model': 'gpt-4o-mini', 'stream': False, 'temperature': 0.5}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_execute_prompt_with_a_tem8/llm.datasette.io/templates') mocked_openai_chat = template = "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5" input_text = 'Input text', extra_args = ['-m', 'gpt-4o-mini'] expected_model = 'gpt-4o-mini', expected_input = 'Summarize this: Input text' expected_error = None, expected_options = {'temperature': 0.5} @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize( "template,input_text,extra_args,expected_model,expected_input,expected_error,expected_options", ( ( "'Summarize this: $input'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'\nmodel: gpt-4o", "Input text", [], "gpt-4o", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'", "Input text", ["-m", "4o"], "gpt-4o", "Summarize this: Input text", None, None, ), # -s system prompt should over-ride template system prompt pytest.param( "boo", "Input text", ["-m", "gpt-4o-mini", "-s", "custom system"], "gpt-4o-mini", [ {"role": "system", "content": "custom system"}, {"role": "user", "content": "boo\nInput text"}, ], None, None, marks=pytest.mark.httpx2_mock(), ), pytest.param( "prompt: 'Say $hello'", "Input text", [], None, None, "Error: Missing variables: hello", None, marks=pytest.mark.httpx2_mock(), ), # Template generated prompt should combine with CLI prompt ( "prompt: 'Say $hello'", "Input text", ["-m", "gpt-4o-mini", "-p", "hello", "Blah"], "gpt-4o-mini", "Say Blah\nInput text", None, None, ), ( "prompt: 'Say pelican'", "", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Say pelican", None, None, ), # Template with just a system prompt ( "system: 'Summarize this'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", [ {"content": "Summarize this", "role": "system"}, {"content": "Input text", "role": "user"}, ], None, None, ), # Options ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.5}, ), # Should be over-ridden by CLI ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini", "-o", "temperature", "0.7"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.7}, ), ), ) def test_execute_prompt_with_a_template( templates_path, mocked_openai_chat, template, input_text, extra_args, expected_model, expected_input, expected_error, expected_options, ): (templates_path / "template.yaml").write_text(template, "utf-8") runner = CliRunner() > result = runner.invoke( cli, ["--no-stream", "-t", "template"] + ([input_text] if input_text else []) + extra_args, catch_exceptions=False, ) tests/test_templates.py:321: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ontent': 'Summarize this: Input text'}], 'model': 'gpt-4o-mini', 'stream': False, 'temperature': 0.5}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _ test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5-Input text-extra_args9-gpt-4o-mini-Summarize this: Input text-None-expected_options9] _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ontent': 'Summarize this: Input text'}], 'model': 'gpt-4o-mini', 'stream': False, 'temperature': 0.7}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_execute_prompt_with_a_tem9/llm.datasette.io/templates') mocked_openai_chat = template = "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5" input_text = 'Input text' extra_args = ['-m', 'gpt-4o-mini', '-o', 'temperature', '0.7'] expected_model = 'gpt-4o-mini', expected_input = 'Summarize this: Input text' expected_error = None, expected_options = {'temperature': 0.7} @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) @pytest.mark.parametrize( "template,input_text,extra_args,expected_model,expected_input,expected_error,expected_options", ( ( "'Summarize this: $input'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'\nmodel: gpt-4o", "Input text", [], "gpt-4o", "Summarize this: Input text", None, None, ), ( "prompt: 'Summarize this: $input'", "Input text", ["-m", "4o"], "gpt-4o", "Summarize this: Input text", None, None, ), # -s system prompt should over-ride template system prompt pytest.param( "boo", "Input text", ["-m", "gpt-4o-mini", "-s", "custom system"], "gpt-4o-mini", [ {"role": "system", "content": "custom system"}, {"role": "user", "content": "boo\nInput text"}, ], None, None, marks=pytest.mark.httpx2_mock(), ), pytest.param( "prompt: 'Say $hello'", "Input text", [], None, None, "Error: Missing variables: hello", None, marks=pytest.mark.httpx2_mock(), ), # Template generated prompt should combine with CLI prompt ( "prompt: 'Say $hello'", "Input text", ["-m", "gpt-4o-mini", "-p", "hello", "Blah"], "gpt-4o-mini", "Say Blah\nInput text", None, None, ), ( "prompt: 'Say pelican'", "", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Say pelican", None, None, ), # Template with just a system prompt ( "system: 'Summarize this'", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", [ {"content": "Summarize this", "role": "system"}, {"content": "Input text", "role": "user"}, ], None, None, ), # Options ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.5}, ), # Should be over-ridden by CLI ( "prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5", "Input text", ["-m", "gpt-4o-mini", "-o", "temperature", "0.7"], "gpt-4o-mini", "Summarize this: Input text", None, {"temperature": 0.7}, ), ), ) def test_execute_prompt_with_a_template( templates_path, mocked_openai_chat, template, input_text, extra_args, expected_model, expected_input, expected_error, expected_options, ): (templates_path / "template.yaml").write_text(template, "utf-8") runner = CliRunner() > result = runner.invoke( cli, ["--no-stream", "-t", "template"] + ([input_text] if input_text else []) + extra_args, catch_exceptions=False, ) tests/test_templates.py:321: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ontent': 'Summarize this: Input text'}], 'model': 'gpt-4o-mini', 'stream': False, 'temperature': 0.7}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError _____________ test_execute_prompt_with_multiple_templates_in_order _____________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...: 'Be concise. Summarize this: Input text'}], 'model': 'gpt-4o', 'stream': False, 'temperature': 0.5}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_execute_prompt_with_multi0/llm.datasette.io/templates') mocked_openai_chat = @mock.patch.dict(os.environ, {"OPENAI_API_KEY": "X"}) def test_execute_prompt_with_multiple_templates_in_order( templates_path, mocked_openai_chat ): (templates_path / "configuration.yaml").write_text( "model: gpt-4o\noptions:\n temperature: 0.5", "utf-8" ) (templates_path / "instruction.yaml").write_text( "prompt: 'Summarize this: $input'", "utf-8" ) (templates_path / "wrapper.yaml").write_text( "prompt: 'Be concise. $input'", "utf-8" ) > result = CliRunner().invoke( cli, [ "--no-stream", "-t", "configuration", "-t", "instruction", "-t", "wrapper", "Input text", ], catch_exceptions=False, ) tests/test_templates.py:364: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...: 'Be concise. Summarize this: Input text'}], 'model': 'gpt-4o', 'stream': False, 'temperature': 0.5}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError ___________________ test_template_respects_cli_extract_flag ____________________ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: > yield /usr/lib/python3.15/site-packages/httpx/_transports/default.py:101: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:250: in handle_request resp = self._pool.handle_request(req) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:256: in handle_request raise exc from None /usr/lib/python3.15/site-packages/httpcore/_sync/connection_pool.py:236: in handle_request response = connection.handle_request( /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:101: in handle_request raise exc /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:78: in handle_request stream = self._connect(request) ^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_sync/connection.py:124: in _connect stream = self._network_backend.connect_tcp(**kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpcore/_backends/sync.py:207: in connect_tcp with map_exceptions(exc_map): ^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ map = {: , : } @contextlib.contextmanager def map_exceptions(map: ExceptionMapping) -> typing.Iterator[None]: try: yield except Exception as exc: # noqa: PIE786 for from_exc, to_exc in map.items(): if isinstance(exc, from_exc): > raise to_exc(exc) from exc E httpcore.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpcore/_exceptions.py:14: ConnectError The above exception was the direct cause of the following exception: self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ta={'messages': [{'role': 'user', 'content': 'Write code'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: > response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) /usr/lib/python3.15/site-packages/openai/_base_client.py:1005: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/httpx/_client.py:914: in send response = self._send_handling_auth( /usr/lib/python3.15/site-packages/httpx/_client.py:942: in _send_handling_auth response = self._send_handling_redirects( /usr/lib/python3.15/site-packages/httpx/_client.py:979: in _send_handling_redirects response = self._send_single_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_client.py:1014: in _send_single_request response = transport.handle_request(request) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/httpx/_transports/default.py:249: in handle_request with map_httpcore_exceptions(): ^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib64/python3.15/contextlib.py:224: in __exit__ self.gen.throw(value) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ @contextlib.contextmanager def map_httpcore_exceptions() -> typing.Iterator[None]: global HTTPCORE_EXC_MAP if len(HTTPCORE_EXC_MAP) == 0: HTTPCORE_EXC_MAP = _load_httpcore_exceptions() try: yield except Exception as exc: mapped_exc = None for from_exc, to_exc in HTTPCORE_EXC_MAP.items(): if not isinstance(exc, from_exc): continue # We want to map to the most specific exception we can find. # Eg if `exc` is an `httpcore.ReadTimeout`, we want to map to # `httpx.ReadTimeout`, not just `httpx.TimeoutException`. if mapped_exc is None or issubclass(to_exc, mapped_exc): mapped_exc = to_exc if mapped_exc is None: # pragma: no cover raise message = str(exc) > raise mapped_exc(message) from exc E httpx.ConnectError: [Errno -3] Temporary failure in name resolution /usr/lib/python3.15/site-packages/httpx/_transports/default.py:118: ConnectError The above exception was the direct cause of the following exception: mocked_openai_chat_returning_fenced_code = templates_path = local('/tmp/pytest-of-mockbuild/pytest-0/test_template_respects_cli_ext0/llm.datasette.io/templates') def test_template_respects_cli_extract_flag( mocked_openai_chat_returning_fenced_code, templates_path ): (templates_path / "code.yaml").write_text("prompt: Write code", "utf-8") runner = CliRunner() > result = runner.invoke( cli, ["-t", "code", "-m", "gpt-4o-mini", "--key", "x", "-x"], catch_exceptions=False, ) tests/test_templates.py:468: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /usr/lib/python3.15/site-packages/click/testing.py:687: in invoke return_value = cli.main(args=args or (), prog_name=prog_name, **extra) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1490: in main rv = self.invoke(ctx) ^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1970: in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:1353: in invoke return ctx.invoke(self.callback, **ctx.params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/click/core.py:907: in invoke return callback(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/cli.py:1162: in prompt text = response.text() ^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1910: in text self._force() ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:1906: in _force list(self) ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2108: in __iter__ for chunk in self._iter_events(): ^^^^^^^^^^^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/models.py:2097: in _iter_events for chunk in generator: ^^^^^^^^^ ../BUILDROOT/usr/lib/python3.15/site-packages/llm/default_plugins/openai_models.py:1731: in execute completion = client.chat.completions.create( /usr/lib/python3.15/site-packages/openai/_utils/_utils.py:286: in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ /usr/lib/python3.15/site-packages/openai/resources/chat/completions/completions.py:1204: in create return self._post( /usr/lib/python3.15/site-packages/openai/_base_client.py:1297: in post return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = cast_to = options = FinalRequestOptions(method='post', url='/chat/completions', params={}, headers=NOT_GIVEN, max_retries=NOT_GIVEN, timeo...ta={'messages': [{'role': 'user', 'content': 'Write code'}], 'model': 'gpt-4o-mini', 'stream': False}, extra_json=None) stream = False stream_cls = openai.Stream[openai.types.chat.chat_completion_chunk.ChatCompletionChunk] def request( self, cast_to: Type[ResponseT], options: FinalRequestOptions, *, stream: bool = False, stream_cls: type[_StreamT] | None = None, ) -> ResponseT | _StreamT: cast_to = self._maybe_override_cast_to(cast_to, options) # create a copy of the options we were given so that if the # options are mutated later & we then retry, the retries are # given the original options input_options = model_copy(options) if input_options.idempotency_key is None and input_options.method.lower() != "get": # ensure the idempotency key is reused between requests input_options.idempotency_key = self._idempotency_key() response: httpx.Response | None = None max_retries = input_options.get_max_retries(self.max_retries) retries_taken = 0 for retries_taken in range(max_retries + 1): options = model_copy(input_options) options = self._prepare_options(options) remaining_retries = max_retries - retries_taken request = self._build_request(options, retries_taken=retries_taken) self._prepare_request(request) kwargs: HttpxSendArgs = {} if self.custom_auth is not None: kwargs["auth"] = self.custom_auth if options.follow_redirects is not None: kwargs["follow_redirects"] = options.follow_redirects log.debug("Sending HTTP Request: %s %s", request.method, request.url) response = None try: response = self._client.send( request, stream=stream or self._should_stream_response_body(request=request), **kwargs, ) except httpx.TimeoutException as err: log.debug("Encountered httpx.TimeoutException", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising timeout error") raise APITimeoutError(request=request) from err except Exception as err: log.debug("Encountered Exception", exc_info=True) if remaining_retries > 0: self._sleep_for_retry( retries_taken=retries_taken, max_retries=max_retries, options=input_options, response=None, ) continue log.debug("Raising connection error") > raise APIConnectionError(request=request) from err E openai.APIConnectionError: Connection error. /usr/lib/python3.15/site-packages/openai/_base_client.py:1037: APIConnectionError =========================== short test summary info ============================ FAILED tests/test_cli_openai_models.py::test_gpt5_verbosity_option_is_sent_to_openai_chat_completions FAILED tests/test_cli_openai_models.py::test_gpt5_verbosity_option_is_sent_to_openai_responses_by_default FAILED tests/test_cli_openai_models.py::test_code_interpreter_cli_tool_is_resolved_from_model FAILED tests/test_cli_openai_models.py::test_code_interpreter_cli_tool_is_reused_on_continue FAILED tests/test_cli_openai_models.py::test_web_search_cli_tool_is_resolved_from_model FAILED tests/test_cli_openai_models.py::test_openai_image_detail_option_is_sent_on_image_attachments FAILED tests/test_cli_openai_models.py::test_openai_image_detail_original_is_sent_for_gpt54 FAILED tests/test_cli_openai_models.py::test_openai_image_detail_original_is_sent_for_gpt54_responses_by_default FAILED tests/test_cli_openai_models.py::test_gpt4o_mini_sync_and_async[None-False] FAILED tests/test_cli_openai_models.py::test_gpt4o_mini_sync_and_async[None-True] FAILED tests/test_cli_openai_models.py::test_gpt4o_mini_sync_and_async[-u-False] FAILED tests/test_cli_openai_models.py::test_gpt4o_mini_sync_and_async[-u-True] FAILED tests/test_cli_openai_models.py::test_gpt4o_mini_sync_and_async[--usage-False] FAILED tests/test_cli_openai_models.py::test_gpt4o_mini_sync_and_async[--usage-True] FAILED tests/test_cli_openai_models.py::test_chat_completion_without_usage_sync_and_async[missing-False] FAILED tests/test_cli_openai_models.py::test_chat_completion_without_usage_sync_and_async[missing-True] FAILED tests/test_cli_openai_models.py::test_chat_completion_without_usage_sync_and_async[null-False] FAILED tests/test_cli_openai_models.py::test_chat_completion_without_usage_sync_and_async[null-True] FAILED tests/test_fragments_cli.py::test_fragment_url_user_agent - AssertionE... FAILED tests/test_keys.py::test_uses_correct_key - openai.APIConnectionError:... FAILED tests/test_llm.py::test_llm_prompt_creates_log_database[False] - opena... FAILED tests/test_llm.py::test_llm_prompt_creates_log_database[True] - openai... FAILED tests/test_llm.py::test_llm_default_prompt[True-logs_args0-False-True] FAILED tests/test_llm.py::test_llm_default_prompt[True-logs_args0-False-False] FAILED tests/test_llm.py::test_llm_default_prompt[True-logs_args0-False-split] FAILED tests/test_llm.py::test_llm_default_prompt[False-logs_args1-True-True] FAILED tests/test_llm.py::test_llm_default_prompt[False-logs_args1-True-False] FAILED tests/test_llm.py::test_llm_default_prompt[False-logs_args1-True-split] FAILED tests/test_llm.py::test_llm_default_prompt[False-logs_args2-False-True] FAILED tests/test_llm.py::test_llm_default_prompt[False-logs_args2-False-False] FAILED tests/test_llm.py::test_llm_default_prompt[False-logs_args2-False-split] FAILED tests/test_llm.py::test_llm_default_prompt[False-logs_args3-True-True] FAILED tests/test_llm.py::test_llm_default_prompt[False-logs_args3-True-False] FAILED tests/test_llm.py::test_llm_default_prompt[False-logs_args3-True-split] FAILED tests/test_llm.py::test_llm_default_prompt[True-logs_args4-False-True] FAILED tests/test_llm.py::test_llm_default_prompt[True-logs_args4-False-False] FAILED tests/test_llm.py::test_llm_default_prompt[True-logs_args4-False-split] FAILED tests/test_llm.py::test_llm_default_prompt[True-logs_args5-True-True] FAILED tests/test_llm.py::test_llm_default_prompt[True-logs_args5-True-False] FAILED tests/test_llm.py::test_llm_default_prompt[True-logs_args5-True-split] FAILED tests/test_llm.py::test_llm_prompt_continue[False] - openai.APIConnect... FAILED tests/test_llm.py::test_llm_prompt_continue[True] - openai.APIConnecti... FAILED tests/test_llm.py::test_extract_fenced_code[args0-True] - openai.APICo... FAILED tests/test_llm.py::test_extract_fenced_code[args1-True] - openai.APICo... FAILED tests/test_llm.py::test_extract_fenced_code[args2-True] - openai.APICo... FAILED tests/test_llm.py::test_extract_fenced_code[args3-True] - openai.APICo... FAILED tests/test_llm.py::test_extract_fenced_code[args4-False] - openai.APIC... FAILED tests/test_llm.py::test_extract_fenced_code_crlf - openai.APIConnectio... FAILED tests/test_llm.py::test_openai_chat_stream - AssertionError: assert 1 ... FAILED tests/test_llm.py::test_openai_completion - openai.APIConnectionError:... FAILED tests/test_llm.py::test_openai_completion_continue_includes_history - ... FAILED tests/test_llm.py::test_openai_completion_logprobs_stream - openai.API... FAILED tests/test_llm.py::test_openai_completion_logprobs_nostream - openai.A... FAILED tests/test_llm.py::test_openai_localai_configuration - AssertionError:... FAILED tests/test_llm.py::test_llm_prompt_continue_with_database[False] - ope... FAILED tests/test_llm.py::test_llm_prompt_continue_with_database[True] - open... FAILED tests/test_openai_endpoint.py::test_endpoint_chat_completions_does_not_log_or_leak_default_key FAILED tests/test_openai_endpoint.py::test_endpoint_chat_completions_attachment FAILED tests/test_openai_endpoint.py::test_endpoint_template - openai.APIConn... FAILED tests/test_openai_endpoint.py::test_endpoint_template_schema_object_used_when_no_cli_schema FAILED tests/test_openai_endpoint.py::test_endpoint_schema - openai.APIConnec... FAILED tests/test_openai_endpoint.py::test_endpoint_schema_by_id_from_existing_logs_database FAILED tests/test_openai_endpoint.py::test_endpoint_static_template_runs_once_on_terminal FAILED tests/test_openai_endpoint.py::test_endpoint_tools_and_functions - ope... FAILED tests/test_openai_endpoint.py::test_endpoint_streams_by_default - open... FAILED tests/test_openai_endpoint.py::test_endpoint_uses_explicit_key - opena... FAILED tests/test_openai_endpoint.py::test_endpoint_lists_models_without_model_or_logging FAILED tests/test_openai_endpoint.py::test_endpoint_models_surfaces_error_from_successful_response FAILED tests/test_openai_endpoint.py::test_endpoint_responses_api - openai.AP... FAILED tests/test_openai_endpoint.py::test_endpoint_responses_reasoning_summary_option[auto] FAILED tests/test_openai_endpoint.py::test_endpoint_responses_reasoning_summary_option[concise] FAILED tests/test_openai_endpoint.py::test_endpoint_responses_reasoning_summary_option[detailed] FAILED tests/test_openai_endpoint.py::test_endpoint_responses_api_attachment FAILED tests/test_openai_endpoint.py::test_endpoint_responses_api_schema_multi FAILED tests/test_openai_endpoint.py::test_endpoint_responses_api_tools - ope... FAILED tests/test_openai_endpoint.py::test_endpoint_responses_api_raw_server_side_tool FAILED tests/test_openai_endpoint.py::test_endpoint_reads_one_off_prompt_from_stdin FAILED tests/test_openai_endpoint.py::test_endpoint_without_prompt_waits_for_stdin FAILED tests/test_openai_endpoint.py::test_endpoint_interactive_chat_preserves_history FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[chat-none-stored] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[chat-none-env] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[chat-none-both] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[chat-stored-stored] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[chat-stored-env] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[chat-stored-both] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[completion-none-stored] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[completion-none-env] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[completion-none-both] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[completion-stored-stored] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[completion-stored-env] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[completion-stored-both] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[responses-none-stored] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[responses-none-env] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[responses-none-both] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[responses-stored-stored] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[responses-stored-env] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[responses-stored-both] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[responses-chat-completions-none-stored] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[responses-chat-completions-none-env] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[responses-chat-completions-none-both] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[responses-chat-completions-stored-stored] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[responses-chat-completions-stored-env] FAILED tests/test_openai_key_leaks.py::test_custom_api_base_never_receives_openai_key[responses-chat-completions-stored-both] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[chat-none-stored] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[chat-none-env] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[chat-none-both] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[chat-stored-stored] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[chat-stored-env] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[chat-stored-both] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[responses-none-stored] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[responses-none-env] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[responses-none-both] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[responses-stored-stored] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[responses-stored-env] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[responses-stored-both] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[responses-chat-completions-none-stored] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[responses-chat-completions-none-env] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[responses-chat-completions-none-both] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[responses-chat-completions-stored-stored] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[responses-chat-completions-stored-env] FAILED tests/test_openai_key_leaks.py::test_async_custom_api_base_never_receives_openai_key[responses-chat-completions-stored-both] FAILED tests/test_openai_key_leaks.py::test_cli_responses_model_does_not_leak_openai_key[args0] FAILED tests/test_openai_key_leaks.py::test_cli_responses_model_does_not_leak_openai_key[args1] FAILED tests/test_openai_key_leaks.py::test_openai_endpoint_command_responses_chat_completions_no_leak FAILED tests/test_openai_messages.py::TestBuildMessagesConversationHistory::test_no_double_emission_from_conversation_prompt_flow FAILED tests/test_openai_messages.py::TestStreamingExecuteYieldsStreamEvents::test_text_stream_yields_text_events FAILED tests/test_openai_messages.py::TestStreamingExecuteYieldsStreamEvents::test_text_stream_plain_iteration_still_returns_strings FAILED tests/test_openai_messages.py::TestStreamingExecuteYieldsStreamEvents::test_text_stream_messages_assembled FAILED tests/test_openai_messages.py::TestStreamingExecuteYieldsStreamEvents::test_tool_call_stream_yields_name_and_args_events FAILED tests/test_openai_messages.py::TestStreamingExecuteYieldsStreamEvents::test_tool_call_registered_via_add_tool_call FAILED tests/test_openai_messages.py::TestStreamingExecuteYieldsStreamEvents::test_text_then_tool_call_part_index_advances FAILED tests/test_openai_messages.py::TestAsyncStreamingExecuteYieldsStreamEvents::test_text_stream_yields_text_events FAILED tests/test_openai_messages.py::TestReasoningTokenCount::test_redacted_reasoning_part_emitted_when_count_present FAILED tests/test_openai_messages.py::TestReasoningTokenCount::test_no_reasoning_part_when_zero_or_absent FAILED tests/test_openai_messages.py::TestNonStreamingExecuteYieldsStreamEvents::test_non_streaming_text_yields_single_event FAILED tests/test_openai_responses.py::test_responses_web_search_request_and_result_capture FAILED tests/test_openai_responses.py::test_responses_mixes_function_and_code_interpreter_tools FAILED tests/test_openai_responses.py::test_responses_raw_server_tool_passthrough_on_custom_endpoint FAILED tests/test_openai_responses.py::test_async_responses_code_interpreter_request FAILED tests/test_openai_responses.py::test_async_responses_web_search_request FAILED tests/test_openai_responses.py::test_chat_completions_opt_out_dispatches_to_chat FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-False-gpt-5.5] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-False-gpt-6-sol] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-False-gpt-6-luna] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-False-gpt-6.1-terra] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-True-gpt-5.5] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-True-gpt-6-sol] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-True-gpt-6-luna] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-True-gpt-6.1-terra] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-False-gpt-5.5] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-False-gpt-6-sol] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-False-gpt-6-luna] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-False-gpt-6.1-terra] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-True-gpt-5.5] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-True-gpt-6-sol] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-True-gpt-6-luna] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-True-gpt-6.1-terra] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-False-gpt-5.5] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-False-gpt-6-sol] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-False-gpt-6-luna] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-False-gpt-6.1-terra] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-True-gpt-5.5] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-True-gpt-6-sol] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-True-gpt-6-luna] FAILED tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-True-gpt-6.1-terra] FAILED tests/test_openai_responses.py::test_hide_reasoning_omits_reasoning_summary_from_responses_request FAILED tests/test_openai_responses.py::test_non_reasoning_responses_model_omits_encrypted_reasoning_include FAILED tests/test_openai_responses.py::test_responses_reply_sends_prior_assistant_text_as_string FAILED tests/test_openai_responses.py::test_service_tier_sent_to_responses_endpoint FAILED tests/test_openai_responses.py::test_service_tier_sent_to_chat_completions_fallback FAILED tests/test_openai_responses.py::test_responses_streams_reasoning_summary_text FAILED tests/test_openai_responses.py::test_responses_reasoning_metadata_refreshed_from_final_payload FAILED tests/test_openai_responses.py::test_code_interpreter_multi_message_response FAILED tests/test_openai_responses.py::test_code_interpreter_streaming_output_and_request FAILED tests/test_openai_responses.py::test_web_search_streaming_refreshes_from_final_payload FAILED tests/test_openai_responses.py::test_async_web_search_streaming_refreshes_from_final_payload FAILED tests/test_options_parameter.py::test_direct_prompt_default_options[kwargs0] FAILED tests/test_options_parameter.py::test_direct_prompt_default_options[kwargs1] FAILED tests/test_options_parameter.py::test_direct_prompt_default_options[kwargs2] FAILED tests/test_options_parameter.py::test_direct_prompt_preserves_options FAILED tests/test_templates.py::test_execute_prompt_with_a_template['Summarize this: $input'-Input text-extra_args0-gpt-4o-mini-Summarize this: Input text-None-None] FAILED tests/test_templates.py::test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'\nmodel: gpt-4o-Input text-extra_args1-gpt-4o-Summarize this: Input text-None-None] FAILED tests/test_templates.py::test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'-Input text-extra_args2-gpt-4o-Summarize this: Input text-None-None] FAILED tests/test_templates.py::test_execute_prompt_with_a_template[boo-Input text-extra_args3-gpt-4o-mini-expected_input3-None-None] FAILED tests/test_templates.py::test_execute_prompt_with_a_template[prompt: 'Say $hello'-Input text-extra_args5-gpt-4o-mini-Say Blah\nInput text-None-None] FAILED tests/test_templates.py::test_execute_prompt_with_a_template[prompt: 'Say pelican'--extra_args6-gpt-4o-mini-Say pelican-None-None] FAILED tests/test_templates.py::test_execute_prompt_with_a_template[system: 'Summarize this'-Input text-extra_args7-gpt-4o-mini-expected_input7-None-None] FAILED tests/test_templates.py::test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5-Input text-extra_args8-gpt-4o-mini-Summarize this: Input text-None-expected_options8] FAILED tests/test_templates.py::test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5-Input text-extra_args9-gpt-4o-mini-Summarize this: Input text-None-expected_options9] FAILED tests/test_templates.py::test_execute_prompt_with_multiple_templates_in_order FAILED tests/test_templates.py::test_template_respects_cli_extract_flag - ope... ERROR tests/test_cli_openai_models.py::test_gpt5_verbosity_option_is_sent_to_openai_chat_completions ERROR tests/test_cli_openai_models.py::test_gpt5_verbosity_option_is_sent_to_openai_responses_by_default ERROR tests/test_cli_openai_models.py::test_code_interpreter_cli_tool_is_resolved_from_model ERROR tests/test_cli_openai_models.py::test_code_interpreter_cli_tool_is_reused_on_continue ERROR tests/test_cli_openai_models.py::test_web_search_cli_tool_is_resolved_from_model ERROR tests/test_cli_openai_models.py::test_openai_image_detail_option_is_sent_on_image_attachments ERROR tests/test_cli_openai_models.py::test_openai_image_detail_original_is_sent_for_gpt54 ERROR tests/test_cli_openai_models.py::test_openai_image_detail_original_is_sent_for_gpt54_responses_by_default ERROR tests/test_cli_openai_models.py::test_gpt4o_mini_sync_and_async[None-False] ERROR tests/test_cli_openai_models.py::test_gpt4o_mini_sync_and_async[None-True] ERROR tests/test_cli_openai_models.py::test_gpt4o_mini_sync_and_async[-u-False] ERROR tests/test_cli_openai_models.py::test_gpt4o_mini_sync_and_async[-u-True] ERROR tests/test_cli_openai_models.py::test_gpt4o_mini_sync_and_async[--usage-False] ERROR tests/test_cli_openai_models.py::test_gpt4o_mini_sync_and_async[--usage-True] ERROR tests/test_cli_openai_models.py::test_chat_completion_without_usage_sync_and_async[missing-False] ERROR tests/test_cli_openai_models.py::test_chat_completion_without_usage_sync_and_async[missing-True] ERROR tests/test_cli_openai_models.py::test_chat_completion_without_usage_sync_and_async[null-False] ERROR tests/test_cli_openai_models.py::test_chat_completion_without_usage_sync_and_async[null-True] ERROR tests/test_fragments_cli.py::test_fragment_url_user_agent - AssertionEr... ERROR tests/test_keys.py::test_uses_correct_key - AssertionError: The followi... ERROR tests/test_llm.py::test_llm_prompt_creates_log_database[False] - Assert... ERROR tests/test_llm.py::test_llm_prompt_creates_log_database[True] - Asserti... ERROR tests/test_llm.py::test_llm_default_prompt[True-logs_args0-False-True] ERROR tests/test_llm.py::test_llm_default_prompt[True-logs_args0-False-False] ERROR tests/test_llm.py::test_llm_default_prompt[True-logs_args0-False-split] ERROR tests/test_llm.py::test_llm_default_prompt[False-logs_args1-True-True] ERROR tests/test_llm.py::test_llm_default_prompt[False-logs_args1-True-False] ERROR tests/test_llm.py::test_llm_default_prompt[False-logs_args1-True-split] ERROR tests/test_llm.py::test_llm_default_prompt[False-logs_args2-False-True] ERROR tests/test_llm.py::test_llm_default_prompt[False-logs_args2-False-False] ERROR tests/test_llm.py::test_llm_default_prompt[False-logs_args2-False-split] ERROR tests/test_llm.py::test_llm_default_prompt[False-logs_args3-True-True] ERROR tests/test_llm.py::test_llm_default_prompt[False-logs_args3-True-False] ERROR tests/test_llm.py::test_llm_default_prompt[False-logs_args3-True-split] ERROR tests/test_llm.py::test_llm_default_prompt[True-logs_args4-False-True] ERROR tests/test_llm.py::test_llm_default_prompt[True-logs_args4-False-False] ERROR tests/test_llm.py::test_llm_default_prompt[True-logs_args4-False-split] ERROR tests/test_llm.py::test_llm_default_prompt[True-logs_args5-True-True] ERROR tests/test_llm.py::test_llm_default_prompt[True-logs_args5-True-False] ERROR tests/test_llm.py::test_llm_default_prompt[True-logs_args5-True-split] ERROR tests/test_llm.py::test_llm_prompt_continue[False] - AssertionError: Th... ERROR tests/test_llm.py::test_llm_prompt_continue[True] - AssertionError: The... ERROR tests/test_llm.py::test_extract_fenced_code[args0-True] - AssertionErro... ERROR tests/test_llm.py::test_extract_fenced_code[args1-True] - AssertionErro... ERROR tests/test_llm.py::test_extract_fenced_code[args2-True] - AssertionErro... ERROR tests/test_llm.py::test_extract_fenced_code[args3-True] - AssertionErro... ERROR tests/test_llm.py::test_extract_fenced_code[args4-False] - AssertionErr... ERROR tests/test_llm.py::test_extract_fenced_code_crlf - AssertionError: The ... ERROR tests/test_llm.py::test_openai_chat_stream - AssertionError: The follow... ERROR tests/test_llm.py::test_openai_completion - AssertionError: The followi... ERROR tests/test_llm.py::test_openai_completion_continue_includes_history - A... ERROR tests/test_llm.py::test_openai_completion_logprobs_stream - AssertionEr... ERROR tests/test_llm.py::test_openai_completion_logprobs_nostream - Assertion... ERROR tests/test_llm.py::test_openai_localai_configuration - AssertionError: ... ERROR tests/test_llm.py::test_llm_prompt_continue_with_database[False] - Asse... ERROR tests/test_llm.py::test_llm_prompt_continue_with_database[True] - Asser... ERROR tests/test_openai_endpoint.py::test_endpoint_chat_completions_does_not_log_or_leak_default_key ERROR tests/test_openai_endpoint.py::test_endpoint_chat_completions_attachment ERROR tests/test_openai_endpoint.py::test_endpoint_template - AssertionError:... ERROR tests/test_openai_endpoint.py::test_endpoint_template_schema_object_used_when_no_cli_schema ERROR tests/test_openai_endpoint.py::test_endpoint_schema - AssertionError: T... ERROR tests/test_openai_endpoint.py::test_endpoint_schema_by_id_from_existing_logs_database ERROR tests/test_openai_endpoint.py::test_endpoint_static_template_runs_once_on_terminal ERROR tests/test_openai_endpoint.py::test_endpoint_tools_and_functions - Asse... ERROR tests/test_openai_endpoint.py::test_endpoint_streams_by_default - Asser... ERROR tests/test_openai_endpoint.py::test_endpoint_uses_explicit_key - Assert... ERROR tests/test_openai_endpoint.py::test_endpoint_lists_models_without_model_or_logging ERROR tests/test_openai_endpoint.py::test_endpoint_models_surfaces_error_from_successful_response ERROR tests/test_openai_endpoint.py::test_endpoint_responses_api - AssertionE... ERROR tests/test_openai_endpoint.py::test_endpoint_responses_reasoning_summary_option[auto] ERROR tests/test_openai_endpoint.py::test_endpoint_responses_reasoning_summary_option[concise] ERROR tests/test_openai_endpoint.py::test_endpoint_responses_reasoning_summary_option[detailed] ERROR tests/test_openai_endpoint.py::test_endpoint_responses_api_attachment ERROR tests/test_openai_endpoint.py::test_endpoint_responses_api_schema_multi ERROR tests/test_openai_endpoint.py::test_endpoint_responses_api_tools - Asse... ERROR tests/test_openai_endpoint.py::test_endpoint_responses_api_raw_server_side_tool ERROR tests/test_openai_endpoint.py::test_endpoint_reads_one_off_prompt_from_stdin ERROR tests/test_openai_endpoint.py::test_endpoint_without_prompt_waits_for_stdin ERROR tests/test_openai_endpoint.py::test_endpoint_interactive_chat_preserves_history ERROR tests/test_openai_messages.py::TestBuildMessagesConversationHistory::test_no_double_emission_from_conversation_prompt_flow ERROR tests/test_openai_messages.py::TestStreamingExecuteYieldsStreamEvents::test_text_stream_yields_text_events ERROR tests/test_openai_messages.py::TestStreamingExecuteYieldsStreamEvents::test_text_stream_plain_iteration_still_returns_strings ERROR tests/test_openai_messages.py::TestStreamingExecuteYieldsStreamEvents::test_text_stream_messages_assembled ERROR tests/test_openai_messages.py::TestStreamingExecuteYieldsStreamEvents::test_tool_call_stream_yields_name_and_args_events ERROR tests/test_openai_messages.py::TestStreamingExecuteYieldsStreamEvents::test_tool_call_registered_via_add_tool_call ERROR tests/test_openai_messages.py::TestStreamingExecuteYieldsStreamEvents::test_text_then_tool_call_part_index_advances ERROR tests/test_openai_messages.py::TestAsyncStreamingExecuteYieldsStreamEvents::test_text_stream_yields_text_events ERROR tests/test_openai_messages.py::TestReasoningTokenCount::test_redacted_reasoning_part_emitted_when_count_present ERROR tests/test_openai_messages.py::TestReasoningTokenCount::test_no_reasoning_part_when_zero_or_absent ERROR tests/test_openai_messages.py::TestNonStreamingExecuteYieldsStreamEvents::test_non_streaming_text_yields_single_event ERROR tests/test_openai_responses.py::test_responses_web_search_request_and_result_capture ERROR tests/test_openai_responses.py::test_responses_mixes_function_and_code_interpreter_tools ERROR tests/test_openai_responses.py::test_responses_raw_server_tool_passthrough_on_custom_endpoint ERROR tests/test_openai_responses.py::test_async_responses_code_interpreter_request ERROR tests/test_openai_responses.py::test_async_responses_web_search_request ERROR tests/test_openai_responses.py::test_chat_completions_opt_out_dispatches_to_chat ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-False-gpt-5.5] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-False-gpt-6-sol] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-False-gpt-6-luna] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-False-gpt-6.1-terra] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-True-gpt-5.5] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-True-gpt-6-sol] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-True-gpt-6-luna] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[None-True-gpt-6.1-terra] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-False-gpt-5.5] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-False-gpt-6-sol] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-False-gpt-6-luna] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-False-gpt-6.1-terra] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-True-gpt-5.5] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-True-gpt-6-sol] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-True-gpt-6-luna] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[none-True-gpt-6.1-terra] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-False-gpt-5.5] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-False-gpt-6-sol] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-False-gpt-6-luna] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-False-gpt-6.1-terra] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-True-gpt-5.5] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-True-gpt-6-sol] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-True-gpt-6-luna] ERROR tests/test_openai_responses.py::test_default_routes_to_responses_endpoint[max-True-gpt-6.1-terra] ERROR tests/test_openai_responses.py::test_hide_reasoning_omits_reasoning_summary_from_responses_request ERROR tests/test_openai_responses.py::test_non_reasoning_responses_model_omits_encrypted_reasoning_include ERROR tests/test_openai_responses.py::test_responses_reply_sends_prior_assistant_text_as_string ERROR tests/test_openai_responses.py::test_service_tier_sent_to_responses_endpoint ERROR tests/test_openai_responses.py::test_service_tier_sent_to_chat_completions_fallback ERROR tests/test_openai_responses.py::test_responses_streams_reasoning_summary_text ERROR tests/test_openai_responses.py::test_responses_reasoning_metadata_refreshed_from_final_payload ERROR tests/test_openai_responses.py::test_code_interpreter_multi_message_response ERROR tests/test_openai_responses.py::test_code_interpreter_streaming_output_and_request ERROR tests/test_openai_responses.py::test_web_search_streaming_refreshes_from_final_payload ERROR tests/test_openai_responses.py::test_async_web_search_streaming_refreshes_from_final_payload ERROR tests/test_options_parameter.py::test_direct_prompt_default_options[kwargs0] ERROR tests/test_options_parameter.py::test_direct_prompt_default_options[kwargs1] ERROR tests/test_options_parameter.py::test_direct_prompt_default_options[kwargs2] ERROR tests/test_options_parameter.py::test_direct_prompt_preserves_options ERROR tests/test_templates.py::test_execute_prompt_with_a_template['Summarize this: $input'-Input text-extra_args0-gpt-4o-mini-Summarize this: Input text-None-None] ERROR tests/test_templates.py::test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'\nmodel: gpt-4o-Input text-extra_args1-gpt-4o-Summarize this: Input text-None-None] ERROR tests/test_templates.py::test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'-Input text-extra_args2-gpt-4o-Summarize this: Input text-None-None] ERROR tests/test_templates.py::test_execute_prompt_with_a_template[boo-Input text-extra_args3-gpt-4o-mini-expected_input3-None-None] ERROR tests/test_templates.py::test_execute_prompt_with_a_template[prompt: 'Say $hello'-Input text-extra_args5-gpt-4o-mini-Say Blah\nInput text-None-None] ERROR tests/test_templates.py::test_execute_prompt_with_a_template[prompt: 'Say pelican'--extra_args6-gpt-4o-mini-Say pelican-None-None] ERROR tests/test_templates.py::test_execute_prompt_with_a_template[system: 'Summarize this'-Input text-extra_args7-gpt-4o-mini-expected_input7-None-None] ERROR tests/test_templates.py::test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5-Input text-extra_args8-gpt-4o-mini-Summarize this: Input text-None-expected_options8] ERROR tests/test_templates.py::test_execute_prompt_with_a_template[prompt: 'Summarize this: $input'\noptions:\n temperature: 0.5-Input text-extra_args9-gpt-4o-mini-Summarize this: Input text-None-expected_options9] ERROR tests/test_templates.py::test_execute_prompt_with_multiple_templates_in_order ERROR tests/test_templates.py::test_template_respects_cli_extract_flag - Asse... ===== 191 failed, 1294 passed, 6 skipped, 146 errors in 390.14s (0:06:30) ====== RPM build errors: error: Bad exit status from /var/tmp/rpm-tmp.mGIfUr (%check) Bad exit status from /var/tmp/rpm-tmp.mGIfUr (%check) Finish: rpmbuild python-llm-0.37.2-1.fc45.src.rpm Finish: build phase for python-llm-0.37.2-1.fc45.src.rpm INFO: chroot_scan: 1 files copied to /var/lib/copr-rpmbuild/results/chroot_scan INFO: /var/lib/mock/fedora-45-x86_64-1794743501.743658/root/var/log/dnf5.log INFO: chroot_scan: creating tarball /var/lib/copr-rpmbuild/results/chroot_scan.tar.gz /bin/tar: Removing leading `/' from member names ERROR: Exception(/var/lib/copr-rpmbuild/results/python-llm-0.37.2-1.fc45.src.rpm) Config(fedora-45-x86_64) 6 minutes 57 seconds INFO: Results and/or logs in: /var/lib/copr-rpmbuild/results INFO: Cleaning up build root ('cleanup_on_failure=True') Start: clean chroot INFO: unmounting tmpfs. Finish: clean chroot ERROR: Command failed: # /usr/bin/systemd-nspawn -q -M 4306daa603664cedaaaba6a62e108a81 -D /var/lib/mock/fedora-45-x86_64-1794743501.743658/root -a -u mockbuild --capability=cap_ipc_lock --capability=cap_ipc_lock --bind=/dev/btrfs-control --bind=/dev/mapper/control --bind=/dev/fuse --bind=/dev/loop-control --bind=/dev/loop0 --bind=/dev/loop1 --bind=/dev/loop2 --bind=/dev/loop3 --bind=/dev/loop4 --bind=/dev/loop5 --bind=/dev/loop6 --bind=/dev/loop7 --bind=/dev/loop8 --bind=/dev/loop9 --bind=/dev/loop10 --bind=/dev/loop11 --resolv-conf=off --resolv-conf=off --console=pipe --setenv=TERM=vt100 --setenv=SHELL=/bin/bash --setenv=HOME=/builddir --setenv=HOSTNAME=mock --setenv=PATH=/usr/bin:/bin:/usr/sbin:/sbin '--setenv=PROMPT_COMMAND=printf "\033]0;\007"' '--setenv=PS1= \s-\v\$ ' --setenv=LANG=C.UTF-8 bash --login -c '/usr/bin/rpmbuild -ba --noprep --noclean --target x86_64 /builddir/build/originals/python-llm.spec' Copr build error: Build failed