@@ -198,16 +198,83 @@ This section shows comprehensive class diagrams for the proposed architecture. F
198
198
199
199
** 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.
200
200
201
- ### Zoomed out view
201
+ ### Overview: Fluent API for AI consumption
202
202
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.
204
204
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
+ ```
209
274
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.
211
278
212
279
``` mermaid
213
280
---
@@ -219,8 +286,6 @@ classDiagram
219
286
direction LR
220
287
namespace Ai {
221
288
class AiEntrypoint {
222
- +defaultRegistry() AiProviderRegistry
223
- +isConfigured(AiProviderAvailability $availability) bool$
224
289
+generateResult(string|MessagePart|MessagePart[]|Message|Message[] $prompt, AiModel $model) GenerativeAiResult$
225
290
+generateOperation(string|MessagePart|MessagePart[]|Message|Message[] $prompt, AiModel $model) GenerativeAiOperation$
226
291
+generateTextResult(string|MessagePart|MessagePart[]|Message|Message[] $prompt, AiModel $model) GenerativeAiResult$
@@ -236,6 +301,26 @@ direction LR
236
301
+generateEmbeddingsOperation(string[]|Message[] $input, AiModel $model) EmbeddingOperation$
237
302
}
238
303
}
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
+ }
239
324
namespace Ai.Providers {
240
325
class AiProviderRegistry {
241
326
+registerProvider(string $className) void
@@ -251,7 +336,7 @@ direction LR
251
336
AiEntrypoint "1" o-- "1..*" AiProviderRegistry
252
337
```
253
338
254
- ### Class diagram zoomed in on AI consumption
339
+ ### Details: Class diagram for AI consumption
255
340
256
341
``` mermaid
257
342
---
@@ -263,7 +348,9 @@ classDiagram
263
348
direction LR
264
349
namespace Ai {
265
350
class AiEntrypoint {
266
- +defaultRegistry() AiProviderRegistry
351
+ +prompt(?string $text) PromptFacade$
352
+ +message(?string $text) MessageFacade$
353
+ +defaultRegistry() AiProviderRegistry$
267
354
+isConfigured(AiProviderAvailability $availability) bool$
268
355
+generateResult(string|MessagePart|MessagePart[]|Message|Message[] $prompt, AiModel $model) GenerativeAiResult$
269
356
+generateOperation(string|MessagePart|MessagePart[]|Message|Message[] $prompt, AiModel $model) GenerativeAiOperation$
@@ -279,6 +366,57 @@ direction LR
279
366
+generateSpeechOperation(string|MessagePart|MessagePart[]|Message|Message[] $prompt, AiModel $model) GenerativeAiOperation$
280
367
+generateEmbeddingsOperation(string[]|Message[] $input, AiModel $model) EmbeddingOperation$
281
368
}
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
+ }
282
420
}
283
421
namespace Ai.Types {
284
422
class Message {
@@ -454,10 +592,17 @@ direction LR
454
592
455
593
AiEntrypoint .. Message : receives
456
594
AiEntrypoint .. MessagePart : receives
595
+ AiEntrypoint .. PromptFacade : creates
596
+ AiEntrypoint .. MessageFacade : creates
457
597
AiEntrypoint .. GenerativeAiResult : creates
458
598
AiEntrypoint .. EmbeddingResult : creates
459
599
AiEntrypoint .. GenerativeAiOperation : creates
460
600
AiEntrypoint .. EmbeddingOperation : creates
601
+ PromptFacade .. GenerativeAiResult : creates
602
+ PromptFacade .. EmbeddingResult : creates
603
+ PromptFacade .. GenerativeAiOperation : creates
604
+ PromptFacade .. EmbeddingOperation : creates
605
+ MessageFacade .. Message : creates
461
606
Message "1" *-- "1..*" MessagePart
462
607
MessagePart "1" o-- "0..1" InlineFile
463
608
MessagePart "1" o-- "0..1" RemoteFile
@@ -484,7 +629,7 @@ direction LR
484
629
Result <|-- EmbeddingResult
485
630
```
486
631
487
- ### Class diagram zoomed in on AI provider registration and implementation
632
+ ### Details: Class diagram for AI provider registration and implementation
488
633
489
634
``` mermaid
490
635
---
0 commit comments