|
| 1 | +{ |
| 2 | + "description": "The `friendli_core._hooks` subsystem provides a robust extension mechanism for the Friendli SDK. The `FriendliClient` initiates this by providing custom logic to the `HookRegistrar`, which then configures the `SDKHookOrchestrator`. This orchestrator is central to the subsystem, managing and invoking various hook typesβdefined by `HookDefinitions`βat critical junctures. For instance, the `HttpClient` triggers hooks before sending requests and after receiving responses, while the `SDKErrorProcessor` activates specific hooks when exceptions occur. This design allows for flexible customization of SDK behavior without altering its core implementation, enhancing adaptability and maintainability.", |
| 3 | + "components": [ |
| 4 | + { |
| 5 | + "name": "FriendliClient", |
| 6 | + "description": "The primary interface for users to interact with the SDK and register custom extensions. Initializes the SDK and provides custom hook implementations to the `HookRegistrar`.", |
| 7 | + "referenced_source_code": [ |
| 8 | + { |
| 9 | + "qualified_name": "friendli_core.FriendliClient", |
| 10 | + "reference_file": "src/friendli_core/sdk.py", |
| 11 | + "reference_start_line": null, |
| 12 | + "reference_end_line": null |
| 13 | + } |
| 14 | + ], |
| 15 | + "assigned_files": [], |
| 16 | + "can_expand": true |
| 17 | + }, |
| 18 | + { |
| 19 | + "name": "HookRegistrar", |
| 20 | + "description": "The component responsible for receiving and organizing custom hook implementations. Receives custom hook instances from `FriendliClient` and adds them to the `SDKHookOrchestrator` for later invocation.", |
| 21 | + "referenced_source_code": [ |
| 22 | + { |
| 23 | + "qualified_name": "friendli_core._hooks.registration.init_hooks", |
| 24 | + "reference_file": "src/friendli_core/_hooks/registration.py", |
| 25 | + "reference_start_line": 8, |
| 26 | + "reference_end_line": 12 |
| 27 | + } |
| 28 | + ], |
| 29 | + "assigned_files": [ |
| 30 | + "src/friendli_core/_hooks/registration.py" |
| 31 | + ], |
| 32 | + "can_expand": true |
| 33 | + }, |
| 34 | + { |
| 35 | + "name": "SDKHookOrchestrator", |
| 36 | + "description": "The central component that manages the lifecycle of hooks, invoking them at appropriate stages of SDK operations. Stores and manages different types of hooks. It is responsible for invoking the correct hooks (e.g., `before_request`, `after_success`, `after_error`) when triggered by `HttpClient` or `SDKErrorProcessor`, ensuring they adhere to `HookDefinitions`.", |
| 37 | + "referenced_source_code": [ |
| 38 | + { |
| 39 | + "qualified_name": "friendli_core._hooks.sdkhooks.SDKHooks", |
| 40 | + "reference_file": "src/friendli_core/_hooks/sdkhooks.py", |
| 41 | + "reference_start_line": 22, |
| 42 | + "reference_end_line": 79 |
| 43 | + } |
| 44 | + ], |
| 45 | + "assigned_files": [ |
| 46 | + "src/friendli_core/_hooks/sdkhooks.py" |
| 47 | + ], |
| 48 | + "can_expand": true |
| 49 | + }, |
| 50 | + { |
| 51 | + "name": "HookDefinitions", |
| 52 | + "description": "The collection of abstract interfaces and data structures that define the contract and context for all types of hooks. Defines the abstract base classes for various hook types (e.g., `SDKInitHook`, `BeforeRequestHook`) and their associated context objects, establishing the API for custom extensions.", |
| 53 | + "referenced_source_code": [ |
| 54 | + { |
| 55 | + "qualified_name": "friendli_core._hooks.types.Hooks", |
| 56 | + "reference_file": "src/friendli_core/_hooks/types.py", |
| 57 | + "reference_start_line": 100, |
| 58 | + "reference_end_line": 115 |
| 59 | + }, |
| 60 | + { |
| 61 | + "qualified_name": "friendli_core._hooks.types.SDKInitHook", |
| 62 | + "reference_file": "src/friendli_core/_hooks/types.py", |
| 63 | + "reference_start_line": 67, |
| 64 | + "reference_end_line": 70 |
| 65 | + }, |
| 66 | + { |
| 67 | + "qualified_name": "friendli_core._hooks.types.BeforeRequestHook", |
| 68 | + "reference_file": "src/friendli_core/_hooks/types.py", |
| 69 | + "reference_start_line": 73, |
| 70 | + "reference_end_line": 78 |
| 71 | + }, |
| 72 | + { |
| 73 | + "qualified_name": "friendli_core._hooks.types.AfterSuccessHook", |
| 74 | + "reference_file": "src/friendli_core/_hooks/types.py", |
| 75 | + "reference_start_line": 81, |
| 76 | + "reference_end_line": 86 |
| 77 | + }, |
| 78 | + { |
| 79 | + "qualified_name": "friendli_core._hooks.types.AfterErrorHook", |
| 80 | + "reference_file": "src/friendli_core/_hooks/types.py", |
| 81 | + "reference_start_line": 89, |
| 82 | + "reference_end_line": 97 |
| 83 | + }, |
| 84 | + { |
| 85 | + "qualified_name": "friendli_core._hooks.types.HookContext", |
| 86 | + "reference_file": "src/friendli_core/_hooks/types.py", |
| 87 | + "reference_start_line": 12, |
| 88 | + "reference_end_line": 31 |
| 89 | + } |
| 90 | + ], |
| 91 | + "assigned_files": [ |
| 92 | + "src/friendli_core/_hooks/types.py" |
| 93 | + ], |
| 94 | + "can_expand": false |
| 95 | + }, |
| 96 | + { |
| 97 | + "name": "HttpClient", |
| 98 | + "description": "The underlying mechanism for making external network requests, which integrates with the hook system. Executes network requests. Before sending a request, it notifies the `SDKHookOrchestrator` to run `before_request` hooks. After receiving a response, it notifies the `SDKHookOrchestrator` to run `after_success` hooks.", |
| 99 | + "referenced_source_code": [ |
| 100 | + { |
| 101 | + "qualified_name": "friendli_core.httpclient.HttpClient", |
| 102 | + "reference_file": "src/friendli_core/httpclient.py", |
| 103 | + "reference_start_line": 11, |
| 104 | + "reference_end_line": 47 |
| 105 | + } |
| 106 | + ], |
| 107 | + "assigned_files": [], |
| 108 | + "can_expand": false |
| 109 | + }, |
| 110 | + { |
| 111 | + "name": "SDKErrorProcessor", |
| 112 | + "description": "The part of the SDK responsible for handling exceptions and triggering error-specific hooks. Catches and processes exceptions during SDK operations. Upon an error, it notifies the `SDKHookOrchestrator` to run `after_error` hooks.", |
| 113 | + "referenced_source_code": [ |
| 114 | + { |
| 115 | + "qualified_name": "friendli_core.SDKErrorProcessor", |
| 116 | + "reference_file": "src/friendli_core/models/sdkerror.py", |
| 117 | + "reference_start_line": 12, |
| 118 | + "reference_end_line": 39 |
| 119 | + } |
| 120 | + ], |
| 121 | + "assigned_files": [], |
| 122 | + "can_expand": true |
| 123 | + }, |
| 124 | + { |
| 125 | + "name": "Unclassified", |
| 126 | + "description": "Component for all unclassified files and utility functions (Utility functions/External Libraries/Dependencies)", |
| 127 | + "referenced_source_code": [], |
| 128 | + "assigned_files": [ |
| 129 | + "src/friendli_core/_hooks/__init__.py" |
| 130 | + ], |
| 131 | + "can_expand": false |
| 132 | + } |
| 133 | + ], |
| 134 | + "components_relations": [ |
| 135 | + { |
| 136 | + "relation": "implements", |
| 137 | + "src_name": "SDKHookOrchestrator", |
| 138 | + "dst_name": "HookDefinitions" |
| 139 | + }, |
| 140 | + { |
| 141 | + "relation": "configures", |
| 142 | + "src_name": "HookRegistrar", |
| 143 | + "dst_name": "SDKHookOrchestrator" |
| 144 | + }, |
| 145 | + { |
| 146 | + "relation": "uses", |
| 147 | + "src_name": "SDKHookOrchestrator", |
| 148 | + "dst_name": "HookDefinitions" |
| 149 | + }, |
| 150 | + { |
| 151 | + "relation": "registers hooks with", |
| 152 | + "src_name": "FriendliClient", |
| 153 | + "dst_name": "HookRegistrar" |
| 154 | + }, |
| 155 | + { |
| 156 | + "relation": "registers hooks with", |
| 157 | + "src_name": "HookRegistrar", |
| 158 | + "dst_name": "SDKHookOrchestrator" |
| 159 | + }, |
| 160 | + { |
| 161 | + "relation": "invokes before_request hooks on", |
| 162 | + "src_name": "HttpClient", |
| 163 | + "dst_name": "SDKHookOrchestrator" |
| 164 | + }, |
| 165 | + { |
| 166 | + "relation": "invokes after_success hooks on", |
| 167 | + "src_name": "HttpClient", |
| 168 | + "dst_name": "SDKHookOrchestrator" |
| 169 | + }, |
| 170 | + { |
| 171 | + "relation": "invokes after_error hooks on", |
| 172 | + "src_name": "SDKErrorProcessor", |
| 173 | + "dst_name": "SDKHookOrchestrator" |
| 174 | + } |
| 175 | + ] |
| 176 | +} |
0 commit comments