4.8 KiB
graph LR
API_Client_Core["API Client Core"]
Synchronous_HTTP_Client["Synchronous HTTP Client"]
Asynchronous_HTTP_Client["Asynchronous HTTP Client"]
API_Error_Handling["API Error Handling"]
API_Client_Core -- "Delegates To" --> Synchronous_HTTP_Client
API_Client_Core -- "Manages" --> Synchronous_HTTP_Client
API_Client_Core -- "Delegates To" --> Asynchronous_HTTP_Client
API_Client_Core -- "Manages" --> Asynchronous_HTTP_Client
API_Client_Core -- "Consumes" --> API_Error_Handling
Synchronous_HTTP_Client -- "Raises" --> API_Error_Handling
Synchronous_HTTP_Client -- "Handles" --> API_Error_Handling
Asynchronous_HTTP_Client -- "Raises" --> API_Error_Handling
Asynchronous_HTTP_Client -- "Handles" --> API_Error_Handling
click API_Client_Core href "https://github.com/ollama/ollama-python/blob/main/.codeboarding//API_Client_Core.md" "Details"
Component Details
This subsystem provides the core functionality for interacting with the Ollama API, offering both synchronous and asynchronous interfaces, robust error handling, and foundational HTTP communication.
API Client Core
This component serves as the primary entry point for users, providing both synchronous (Client) and asynchronous (AsyncClient) interfaces to interact with the Ollama API. It encapsulates the foundational setup, including host URL parsing, HTTP client initialization (httpx), and default configurations (headers, timeouts). It acts as the orchestrator, exposing high-level methods that delegate to specific API functionalities.
Related Classes/Methods:
Synchronous HTTP Client
This component provides the functionality for making synchronous HTTP requests to the Ollama API. It handles the low-level network communication, request preparation, and initial error detection for blocking operations. It is a specialized part of the API Client Core, specifically implemented within the Client class.
Related Classes/Methods:
Asynchronous HTTP Client
This component mirrors the Synchronous HTTP Client but is designed for non-blocking, asynchronous operations. It enables concurrent communication with the Ollama API, which is essential for applications requiring high performance or integration into asynchronous frameworks. It is a specialized part of the API Client Core, specifically implemented within the AsyncClient class.
Related Classes/Methods:
API Error Handling
This component defines a custom exception class (ResponseError) specifically for errors returned by the Ollama API. It standardizes how API-specific errors are represented, providing details like the error message and HTTP status code. This ensures consistent and user-friendly error management across both synchronous and asynchronous client interactions.
Related Classes/Methods: