Skip to content

Commit b13e070

Browse files
committed
Revise class diagrams to include fluent API infrastructure, and reorganize overview diagrams for easier understanding.
1 parent 3d8e542 commit b13e070

File tree

1 file changed

+157
-12
lines changed

1 file changed

+157
-12
lines changed

docs/ARCHITECTURE.md

Lines changed: 157 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -198,16 +198,83 @@ This section shows comprehensive class diagrams for the proposed architecture. F
198198

199199
**Note:** The class diagrams are also not meant to be comprehensive in terms of any specific configuration keys or parameters which are or will be supported. For now, the relevant definitions don't include any specific parameter names or constants.
200200

201-
### Zoomed out view
201+
### Overview: Fluent API for AI consumption
202202

203-
Below you find the zoomed out overview class diagram, looking at the two entrypoints for the largely decoupled APIs for:
203+
This is a subset of the overall class diagram, purely focused on the fluent API for AI consumption.
204204

205-
- Consuming AI capabilities.
206-
- This is what the vast majority of developers will use.
207-
- Registering and implementing AI providers.
208-
- This is what only developers that implement additional models or custom providers will use.
205+
```mermaid
206+
---
207+
config:
208+
class:
209+
hideEmptyMembersBox: true
210+
---
211+
classDiagram
212+
direction LR
213+
namespace Ai {
214+
class AiEntrypoint {
215+
+prompt(?string $text) PromptFacade$
216+
+message(?string $text) MessageFacade$
217+
}
218+
219+
class PromptFacade {
220+
+withText(string $text) self
221+
+withImageFile(File $file) self
222+
+withAudioFile(File $file) self
223+
+withVideoFile(File $file) self
224+
+withFunctionResponse(FunctionResponse $functionResponse) self
225+
+withMessageParts(...MessagePart $part) self
226+
+withHistory(Message[] $messages) self
227+
+usingModel(AiModel $model) self
228+
+usingSystemInstruction(string|MessagePart[]|Message $systemInstruction) self
229+
+usingTemperature(float $temperature) self
230+
+usingTopP(float $topP) self
231+
+usingTopK(int $topK) self
232+
+usingStopSequences(...string $stopSequences) self
233+
+usingCandidateCount(int $candidateCount) self
234+
+usingOutputMime(string $mimeType) self
235+
+usingOutputSchema(array< string, mixed > $schema) self
236+
+usingOutputModalities(...AiModality $modalities) self
237+
+generateResult() GenerativeAiResult
238+
+generateOperation() GenerativeAiOperation
239+
+generateTextResult() GenerativeAiResult
240+
+streamGenerateTextResult() Generator< GenerativeAiResult >
241+
+generateImageResult() GenerativeAiResult
242+
+textToSpeechResult() GenerativeAiResult
243+
+generateSpeechResult() GenerativeAiResult
244+
+generateEmbeddingsResult() EmbeddingResult
245+
+generateTextOperation() GenerativeAiOperation
246+
+generateImageOperation() GenerativeAiOperation
247+
+textToSpeechOperation() GenerativeAiOperation
248+
+generateSpeechOperation() GenerativeAiOperation
249+
+generateEmbeddingsOperation() EmbeddingOperation
250+
+generateText() string
251+
+streamGenerateText() Generator< string >
252+
+generateImage() File
253+
+textToSpeech() File
254+
+generateSpeech() File
255+
+generateEmbeddings() Embedding[]
256+
}
257+
258+
class MessageFacade {
259+
+usingRole(MessageRole $role) self
260+
+withText(string $text) self
261+
+withImageFile(File $file) self
262+
+withAudioFile(File $file) self
263+
+withVideoFile(File $file) self
264+
+withFunctionCall(FunctionCall $functionCall) self
265+
+withFunctionResponse(FunctionResponse $functionResponse) self
266+
+withMessageParts(...MessagePart $part) self
267+
+get() Message
268+
}
269+
}
270+
271+
AiEntrypoint .. PromptFacade : creates
272+
AiEntrypoint .. MessageFacade : creates
273+
```
209274

210-
Zoomed in views with detailed specifications for both of the APIs are found in the subsequent sections.
275+
### Overview: Traditional method call API for AI consumption
276+
277+
This is a subset of the overall class diagram, purely focused on the traditional method call API for AI consumption.
211278

212279
```mermaid
213280
---
@@ -219,8 +286,6 @@ classDiagram
219286
direction LR
220287
namespace Ai {
221288
class AiEntrypoint {
222-
+defaultRegistry() AiProviderRegistry
223-
+isConfigured(AiProviderAvailability $availability) bool$
224289
+generateResult(string|MessagePart|MessagePart[]|Message|Message[] $prompt, AiModel $model) GenerativeAiResult$
225290
+generateOperation(string|MessagePart|MessagePart[]|Message|Message[] $prompt, AiModel $model) GenerativeAiOperation$
226291
+generateTextResult(string|MessagePart|MessagePart[]|Message|Message[] $prompt, AiModel $model) GenerativeAiResult$
@@ -236,6 +301,26 @@ direction LR
236301
+generateEmbeddingsOperation(string[]|Message[] $input, AiModel $model) EmbeddingOperation$
237302
}
238303
}
304+
```
305+
306+
### Overview: API for provider registration and implementation
307+
308+
This is a subset of the overall class diagram, purely focused on the API for provider registration and implementation.
309+
310+
```mermaid
311+
---
312+
config:
313+
class:
314+
hideEmptyMembersBox: true
315+
---
316+
classDiagram
317+
direction LR
318+
namespace Ai {
319+
class AiEntrypoint {
320+
+defaultRegistry() AiProviderRegistry$
321+
+isConfigured(AiProviderAvailability $availability) bool$
322+
}
323+
}
239324
namespace Ai.Providers {
240325
class AiProviderRegistry {
241326
+registerProvider(string $className) void
@@ -251,7 +336,7 @@ direction LR
251336
AiEntrypoint "1" o-- "1..*" AiProviderRegistry
252337
```
253338

254-
### Class diagram zoomed in on AI consumption
339+
### Details: Class diagram for AI consumption
255340

256341
```mermaid
257342
---
@@ -263,7 +348,9 @@ classDiagram
263348
direction LR
264349
namespace Ai {
265350
class AiEntrypoint {
266-
+defaultRegistry() AiProviderRegistry
351+
+prompt(?string $text) PromptFacade$
352+
+message(?string $text) MessageFacade$
353+
+defaultRegistry() AiProviderRegistry$
267354
+isConfigured(AiProviderAvailability $availability) bool$
268355
+generateResult(string|MessagePart|MessagePart[]|Message|Message[] $prompt, AiModel $model) GenerativeAiResult$
269356
+generateOperation(string|MessagePart|MessagePart[]|Message|Message[] $prompt, AiModel $model) GenerativeAiOperation$
@@ -279,6 +366,57 @@ direction LR
279366
+generateSpeechOperation(string|MessagePart|MessagePart[]|Message|Message[] $prompt, AiModel $model) GenerativeAiOperation$
280367
+generateEmbeddingsOperation(string[]|Message[] $input, AiModel $model) EmbeddingOperation$
281368
}
369+
370+
class PromptFacade {
371+
+withText(string $text) self
372+
+withImageFile(File $file) self
373+
+withAudioFile(File $file) self
374+
+withVideoFile(File $file) self
375+
+withFunctionResponse(FunctionResponse $functionResponse) self
376+
+withMessageParts(...MessagePart $part) self
377+
+withHistory(Message[] $messages) self
378+
+usingModel(AiModel $model) self
379+
+usingSystemInstruction(string|MessagePart[]|Message $systemInstruction) self
380+
+usingTemperature(float $temperature) self
381+
+usingTopP(float $topP) self
382+
+usingTopK(int $topK) self
383+
+usingStopSequences(...string $stopSequences) self
384+
+usingCandidateCount(int $candidateCount) self
385+
+usingOutputMime(string $mimeType) self
386+
+usingOutputSchema(array< string, mixed > $schema) self
387+
+usingOutputModalities(...AiModality $modalities) self
388+
+generateResult() GenerativeAiResult
389+
+generateOperation() GenerativeAiOperation
390+
+generateTextResult() GenerativeAiResult
391+
+streamGenerateTextResult() Generator< GenerativeAiResult >
392+
+generateImageResult() GenerativeAiResult
393+
+textToSpeechResult() GenerativeAiResult
394+
+generateSpeechResult() GenerativeAiResult
395+
+generateEmbeddingsResult() EmbeddingResult
396+
+generateTextOperation() GenerativeAiOperation
397+
+generateImageOperation() GenerativeAiOperation
398+
+textToSpeechOperation() GenerativeAiOperation
399+
+generateSpeechOperation() GenerativeAiOperation
400+
+generateEmbeddingsOperation() EmbeddingOperation
401+
+generateText() string
402+
+streamGenerateText() Generator< string >
403+
+generateImage() File
404+
+textToSpeech() File
405+
+generateSpeech() File
406+
+generateEmbeddings() Embedding[]
407+
}
408+
409+
class MessageFacade {
410+
+usingRole(MessageRole $role) self
411+
+withText(string $text) self
412+
+withImageFile(File $file) self
413+
+withAudioFile(File $file) self
414+
+withVideoFile(File $file) self
415+
+withFunctionCall(FunctionCall $functionCall) self
416+
+withFunctionResponse(FunctionResponse $functionResponse) self
417+
+withMessageParts(...MessagePart $part) self
418+
+get() Message
419+
}
282420
}
283421
namespace Ai.Types {
284422
class Message {
@@ -454,10 +592,17 @@ direction LR
454592
455593
AiEntrypoint .. Message : receives
456594
AiEntrypoint .. MessagePart : receives
595+
AiEntrypoint .. PromptFacade : creates
596+
AiEntrypoint .. MessageFacade : creates
457597
AiEntrypoint .. GenerativeAiResult : creates
458598
AiEntrypoint .. EmbeddingResult : creates
459599
AiEntrypoint .. GenerativeAiOperation : creates
460600
AiEntrypoint .. EmbeddingOperation : creates
601+
PromptFacade .. GenerativeAiResult : creates
602+
PromptFacade .. EmbeddingResult : creates
603+
PromptFacade .. GenerativeAiOperation : creates
604+
PromptFacade .. EmbeddingOperation : creates
605+
MessageFacade .. Message : creates
461606
Message "1" *-- "1..*" MessagePart
462607
MessagePart "1" o-- "0..1" InlineFile
463608
MessagePart "1" o-- "0..1" RemoteFile
@@ -484,7 +629,7 @@ direction LR
484629
Result <|-- EmbeddingResult
485630
```
486631

487-
### Class diagram zoomed in on AI provider registration and implementation
632+
### Details: Class diagram for AI provider registration and implementation
488633

489634
```mermaid
490635
---

0 commit comments

Comments
 (0)