fix: suppress verbose httpx request logging at INFO level

By default, httpx logs HTTP request/response information at INFO level,
which clutters application logs with messages like:
  "HTTP Request: POST http://... 'HTTP/1.1 200 OK'"

This change sets the httpx logger to WARNING level by default, suppressing
these verbose logs. Users who want to see HTTP request logs can still enable
them by setting the httpx logger level back to INFO or DEBUG in their application:

    import logging
    logging.getLogger('httpx').setLevel(logging.INFO)

Fixes #539

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
yurekami 2025-12-29 05:40:23 +09:00
parent d1d704050b
commit 5a38afe5e0

View File

@ -1,6 +1,7 @@
import contextlib
import ipaddress
import json
import logging
import os
import platform
import sys
@ -26,6 +27,11 @@ from typing import (
import anyio
from pydantic.json_schema import JsonSchemaValue
# Set httpx logger to WARNING level to suppress verbose HTTP request logs at INFO level.
# Users who want to see these logs can set the level back to INFO or DEBUG in their application.
# See: https://github.com/ollama/ollama-python/issues/539
logging.getLogger('httpx').setLevel(logging.WARNING)
from ollama._utils import convert_function_to_tool
if sys.version_info < (3, 9):