Skip to content

Commit 60cff9c

Browse files
committed
docs: update codeboarding architecture documentation
## πŸ“š Architecture Documentation Update This commit contains updated documentation files fetched from the CodeBoarding service and copied to the architecture documentation section. ### πŸ“Š Summary - Documentation files created/updated: 7 - JSON files created/updated: 8 - Documentation directory: .codeboarding/ - JSON directory: .codeboarding/ - Output format: .md - Repository analyzed: https://github.com/CodeBoarding/friendli-python - Destination: docs/architecture/ The generated .md files have been automatically copied to the architecture documentation section and referenced in on_boarding.md. πŸ€– This commit was automatically generated by the CodeBoarding documentation update workflow.
1 parent c098d4c commit 60cff9c

File tree

8 files changed

+386
-42
lines changed

8 files changed

+386
-42
lines changed
Lines changed: 176 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,176 @@
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+
}
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
```mermaid
2+
graph LR
3+
FriendliClient["FriendliClient"]
4+
HookRegistrar["HookRegistrar"]
5+
SDKHookOrchestrator["SDKHookOrchestrator"]
6+
HookDefinitions["HookDefinitions"]
7+
HttpClient["HttpClient"]
8+
SDKErrorProcessor["SDKErrorProcessor"]
9+
Unclassified["Unclassified"]
10+
SDKHookOrchestrator -- "implements" --> HookDefinitions
11+
HookRegistrar -- "configures" --> SDKHookOrchestrator
12+
SDKHookOrchestrator -- "uses" --> HookDefinitions
13+
FriendliClient -- "registers hooks with" --> HookRegistrar
14+
HookRegistrar -- "registers hooks with" --> SDKHookOrchestrator
15+
HttpClient -- "invokes before_request hooks on" --> SDKHookOrchestrator
16+
HttpClient -- "invokes after_success hooks on" --> SDKHookOrchestrator
17+
SDKErrorProcessor -- "invokes after_error hooks on" --> SDKHookOrchestrator
18+
```
19+
20+
[![CodeBoarding](https://img.shields.io/badge/Generated%20by-CodeBoarding-9cf?style=flat-square)](https://github.com/CodeBoarding/CodeBoarding)[![Demo](https://img.shields.io/badge/Try%20our-Demo-blue?style=flat-square)](https://www.codeboarding.org/diagrams)[![Contact](https://img.shields.io/badge/Contact%20us%20-%20contact@codeboarding.org-lightgrey?style=flat-square)](mailto:contact@codeboarding.org)
21+
22+
## Details
23+
24+
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.
25+
26+
### FriendliClient
27+
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`.
28+
29+
30+
**Related Classes/Methods**:
31+
32+
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/sdk.py" target="_blank" rel="noopener noreferrer">`friendli_core.FriendliClient`</a>
33+
34+
35+
### HookRegistrar
36+
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.
37+
38+
39+
**Related Classes/Methods**:
40+
41+
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/registration.py#L8-L12" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.registration.init_hooks`:8-12</a>
42+
43+
44+
### SDKHookOrchestrator
45+
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`.
46+
47+
48+
**Related Classes/Methods**:
49+
50+
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/sdkhooks.py#L22-L79" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.sdkhooks.SDKHooks`:22-79</a>
51+
52+
53+
### HookDefinitions
54+
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.
55+
56+
57+
**Related Classes/Methods**:
58+
59+
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/types.py#L100-L115" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.types.Hooks`:100-115</a>
60+
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/types.py#L67-L70" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.types.SDKInitHook`:67-70</a>
61+
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/types.py#L73-L78" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.types.BeforeRequestHook`:73-78</a>
62+
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/types.py#L81-L86" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.types.AfterSuccessHook`:81-86</a>
63+
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/types.py#L89-L97" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.types.AfterErrorHook`:89-97</a>
64+
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/_hooks/types.py#L12-L31" target="_blank" rel="noopener noreferrer">`friendli_core._hooks.types.HookContext`:12-31</a>
65+
66+
67+
### HttpClient
68+
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.
69+
70+
71+
**Related Classes/Methods**:
72+
73+
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/httpclient.py#L11-L47" target="_blank" rel="noopener noreferrer">`friendli_core.httpclient.HttpClient`:11-47</a>
74+
75+
76+
### SDKErrorProcessor
77+
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.
78+
79+
80+
**Related Classes/Methods**:
81+
82+
- <a href="https://github.com/CodeBoarding/friendli-python/blob/main/.codeboardingsrc/friendli_core/models/sdkerror.py#L12-L39" target="_blank" rel="noopener noreferrer">`friendli_core.SDKErrorProcessor`:12-39</a>
83+
84+
85+
### Unclassified
86+
Component for all unclassified files and utility functions (Utility functions/External Libraries/Dependencies)
87+
88+
89+
**Related Classes/Methods**: _None_
90+
91+
92+
93+
### [FAQ](https://github.com/CodeBoarding/GeneratedOnBoardings/tree/main?tab=readme-ov-file#faq)

β€Ž.codeboarding/analysis.jsonβ€Ž

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414
],
1515
"assigned_files": [
1616
"src/friendli/friendli.py",
17-
"src/friendli/__init__.py",
18-
"src/friendli_core/sdk.py"
17+
"src/friendli/__init__.py"
1918
],
2019
"can_expand": true
2120
},
@@ -34,9 +33,8 @@
3433
"src/friendli/httpclient.py",
3534
"src/friendli/config.py",
3635
"src/friendli_core/__init__.py",
37-
"src/friendli_core/container.py",
36+
"src/friendli_core/sdk.py",
3837
"src/friendli_core/endpoint.py",
39-
"src/friendli_core/model.py",
4038
"src/friendli_core/basesdk.py",
4139
"src/friendli_core/httpclient.py",
4240
"src/friendli_core/sdkconfiguration.py"
@@ -77,6 +75,20 @@
7775
"src/friendli/container/__init__.py",
7876
"src/friendli/container/chat.py",
7977
"src/friendli/container/token.py",
78+
"src/friendli/serverless/completions.py",
79+
"src/friendli/serverless/__init__.py",
80+
"src/friendli/serverless/chat.py",
81+
"src/friendli/serverless/tool_assisted_chat.py",
82+
"src/friendli/serverless/model.py",
83+
"src/friendli/serverless/token.py",
84+
"src/friendli/serverless/knowledge.py",
85+
"src/friendli/dedicated/completions.py",
86+
"src/friendli/dedicated/__init__.py",
87+
"src/friendli/dedicated/chat.py",
88+
"src/friendli/dedicated/endpoint.py",
89+
"src/friendli/dedicated/image.py",
90+
"src/friendli/dedicated/token.py",
91+
"src/friendli/dedicated/audio.py",
8092
"src/friendli/dataset/__init__.py",
8193
"src/friendli/dataset/dataset.py",
8294
"src/friendli/file/__init__.py",
@@ -111,6 +123,7 @@
111123
"assigned_files": [
112124
"src/friendli/models.py",
113125
"src/friendli/types.py",
126+
"src/friendli_core/model.py",
114127
"src/friendli_core/models/containerdetokenizationop.py",
115128
"src/friendli_core/models/splitinfo.py",
116129
"src/friendli_core/models/dedicatedgetendpointstatusop.py",
@@ -344,22 +357,9 @@
344357
}
345358
],
346359
"assigned_files": [
347-
"src/friendli/serverless/completions.py",
348-
"src/friendli/serverless/__init__.py",
349-
"src/friendli/serverless/chat.py",
350-
"src/friendli/serverless/tool_assisted_chat.py",
351-
"src/friendli/serverless/model.py",
352-
"src/friendli/serverless/token.py",
353-
"src/friendli/serverless/knowledge.py",
354-
"src/friendli/dedicated/completions.py",
355-
"src/friendli/dedicated/__init__.py",
356-
"src/friendli/dedicated/chat.py",
357-
"src/friendli/dedicated/endpoint.py",
358-
"src/friendli/dedicated/image.py",
359-
"src/friendli/dedicated/token.py",
360-
"src/friendli/dedicated/audio.py",
361360
"src/friendli_core/friendlicore_serverless_chat.py",
362361
"src/friendli_core/dedicated.py",
362+
"src/friendli_core/container.py",
363363
"src/friendli_core/friendlicore_serverless_token.py",
364364
"src/friendli_core/serverless.py",
365365
"src/friendli_core/friendlicore_serverless_completions.py"
@@ -383,7 +383,7 @@
383383
"src/friendli_core/_hooks/registration.py",
384384
"src/friendli_core/_hooks/types.py"
385385
],
386-
"can_expand": false
386+
"can_expand": true
387387
},
388388
{
389389
"name": "Unclassified",
@@ -456,6 +456,13 @@
456456
"assigned_files": [],
457457
"can_expand": false
458458
},
459+
{
460+
"name": "Unclassified",
461+
"description": "Component for all unclassified files and utility functions (Utility functions/External Libraries/Dependencies)",
462+
"referenced_source_code": [],
463+
"assigned_files": [],
464+
"can_expand": false
465+
},
459466
{
460467
"name": "Unclassified",
461468
"description": "Component for all unclassified files and utility functions (Utility functions/External Libraries/Dependencies)",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"commit_hash": "5f170958411e5d2334a02b79ff5033b41b4ae9e1",
2+
"commit_hash": "c098d4cf4fef2de945984f3f69232dbbfa5b882e",
33
"code_boarding_version": "0.2.0"
44
}

0 commit comments

Comments
Β (0)