@@ -73,7 +73,7 @@ $texts = AiClient::generateTextResult(
73
73
74
74
##### Fluent API
75
75
``` php
76
- $imageFile = AiClient::prompt('Generate an illustration of the PHP elephant in the Carribean sea.')
76
+ $imageFile = AiClient::prompt('Generate an illustration of the PHP elephant in the Caribbean sea.')
77
77
->usingProvider('openai')
78
78
->generateImage();
79
79
```
@@ -85,7 +85,7 @@ $modelsMetadata = AiClient::defaultRegistry()->findProviderModelsMetadataForSupp
85
85
new ModelRequirements([CapabilityEnum::IMAGE_GENERATION])
86
86
);
87
87
$imageFile = AiClient::generateImageResult(
88
- 'Generate an illustration of the PHP elephant in the Carribean sea.',
88
+ 'Generate an illustration of the PHP elephant in the Caribbean sea.',
89
89
AiClient::defaultRegistry()->getProviderModel(
90
90
'openai',
91
91
$modelsMetadata[0]->getId()
@@ -97,7 +97,7 @@ $imageFile = AiClient::generateImageResult(
97
97
98
98
##### Fluent API
99
99
``` php
100
- $imageFile = AiClient::prompt('Generate an illustration of the PHP elephant in the Carribean sea.')
100
+ $imageFile = AiClient::prompt('Generate an illustration of the PHP elephant in the Caribbean sea.')
101
101
->generateImage();
102
102
```
103
103
@@ -107,7 +107,7 @@ $providerModelsMetadata = AiClient::defaultRegistry()->findModelsMetadataForSupp
107
107
new ModelRequirements([CapabilityEnum::IMAGE_GENERATION])
108
108
);
109
109
$imageFile = AiClient::generateImageResult(
110
- 'Generate an illustration of the PHP elephant in the Carribean sea.',
110
+ 'Generate an illustration of the PHP elephant in the Caribbean sea.',
111
111
AiClient::defaultRegistry()->getProviderModel(
112
112
$providerModelsMetadata[0]->getProvider()->getId(),
113
113
$providerModelsMetadata[0]->getModels()[0]->getId()
@@ -304,7 +304,6 @@ direction LR
304
304
class PromptBuilder {
305
305
+withText(string $text) self
306
306
+withInlineImage(string $base64Blob, string $mimeType)
307
- +withLocalImage(string $path, string $mimeType)
308
307
+withRemoteImage(string $uri, string $mimeType)
309
308
+withImageFile(File $file) self
310
309
+withAudioFile(File $file) self
@@ -340,12 +339,12 @@ direction LR
340
339
+generateText() string
341
340
+generateTexts(?int $candidateCount) string[]
342
341
+streamGenerateText() Generator< string >
343
- +generateImage() FileInterface
344
- +generateImages(?int $candidateCount) FileInterface []
345
- +convertTextToSpeech() FileInterface
346
- +convertTextToSpeeches(?int $candidateCount) FileInterface []
347
- +generateSpeech() FileInterface
348
- +generateSpeeches(?int $candidateCount) FileInterface []
342
+ +generateImage() File
343
+ +generateImages(?int $candidateCount) File []
344
+ +convertTextToSpeech() File
345
+ +convertTextToSpeeches(?int $candidateCount) File []
346
+ +generateSpeech() File
347
+ +generateSpeeches(?int $candidateCount) File []
349
348
+generateEmbeddings() Embedding[]
350
349
+getModelRequirements() ModelRequirements
351
350
+isSupported() bool
@@ -468,7 +467,6 @@ direction LR
468
467
class PromptBuilder {
469
468
+withText(string $text) self
470
469
+withInlineImage(string $base64Blob, string $mimeType)
471
- +withLocalImage(string $path, string $mimeType)
472
470
+withRemoteImage(string $uri, string $mimeType)
473
471
+withImageFile(File $file) self
474
472
+withAudioFile(File $file) self
@@ -504,12 +502,12 @@ direction LR
504
502
+generateText() string
505
503
+generateTexts(?int $candidateCount) string[]
506
504
+streamGenerateText() Generator< string >
507
- +generateImage() FileInterface
508
- +generateImages(?int $candidateCount) FileInterface []
509
- +convertTextToSpeech() FileInterface
510
- +convertTextToSpeeches(?int $candidateCount) FileInterface []
511
- +generateSpeech() FileInterface
512
- +generateSpeeches(?int $candidateCount) FileInterface []
505
+ +generateImage() File
506
+ +generateImages(?int $candidateCount) File []
507
+ +convertTextToSpeech() File
508
+ +convertTextToSpeeches(?int $candidateCount) File []
509
+ +generateSpeech() File
510
+ +generateSpeeches(?int $candidateCount) File []
513
511
+generateEmbeddings() Embedding[]
514
512
+getModelRequirements() ModelRequirements
515
513
+isSupported() bool
@@ -535,26 +533,20 @@ direction LR
535
533
}
536
534
}
537
535
538
- namespace AiClientNamespace.Files.Contracts {
539
- class FileInterface {
540
- }
541
- }
542
-
543
536
namespace AiClientNamespace.Files.DTO {
544
- class InlineFile {
537
+ class File {
538
+ +getFileType() FileTypeEnum
545
539
+getMimeType() string
546
- +getBase64Data() string
540
+ +getUrl() ?string
541
+ +getBase64Data() ?string
547
542
+getJsonSchema() array< string, mixed >$
548
543
}
549
- class LocalFile {
550
- +getMimeType() string
551
- +getPath() string
552
- +getJsonSchema() array< string, mixed >$
553
- }
554
- class RemoteFile {
555
- +getMimeType() string
556
- +getUrl() string
557
- +getJsonSchema() array< string, mixed >$
544
+ }
545
+
546
+ namespace AiClientNamespace.Files.Enums {
547
+ class FileTypeEnum {
548
+ INLINE
549
+ REMOTE
558
550
}
559
551
}
560
552
@@ -567,8 +559,7 @@ direction LR
567
559
class MessagePart {
568
560
+getType() MessagePartTypeEnum
569
561
+getText() string?
570
- +getInlineFile() InlineFile?
571
- +getRemoteFile() RemoteFile?
562
+ +getFile() File?
572
563
+getFunctionCall() FunctionCall?
573
564
+getFunctionResponse() FunctionResponse?
574
565
+getJsonSchema() array< string, mixed >$
@@ -584,8 +575,7 @@ direction LR
584
575
namespace AiClientNamespace.Messages.Enums {
585
576
class MessagePartTypeEnum {
586
577
TEXT
587
- INLINE_FILE
588
- REMOTE_FILE
578
+ FILE
589
579
FUNCTION_CALL
590
580
FUNCTION_RESPONSE
591
581
}
@@ -667,14 +657,14 @@ direction LR
667
657
+getJsonSchema() array< string, mixed >$
668
658
%% The following utility methods transform the result candidates into a specific shape.
669
659
+toText() string
670
- +toImageFile() FileInterface
671
- +toAudioFile() FileInterface
672
- +toVideoFile() FileInterface
660
+ +toImageFile() File
661
+ +toAudioFile() File
662
+ +toVideoFile() File
673
663
+toMessage() Message
674
664
+toTexts() string[]
675
- +toImageFiles() FileInterface []
676
- +toAudioFiles() FileInterface []
677
- +toVideoFiles() FileInterface []
665
+ +toImageFiles() File []
666
+ +toAudioFiles() File []
667
+ +toVideoFiles() File []
678
668
+toMessages() Message[]
679
669
}
680
670
class TokenUsage {
@@ -697,8 +687,8 @@ direction LR
697
687
698
688
namespace AiClientNamespace.Tools.DTO {
699
689
class FunctionCall {
700
- +getId() string
701
- +getName() string
690
+ +getId() ? string
691
+ +getName() ? string
702
692
+getArgs() array< string, mixed >
703
693
+getJsonSchema() array< string, mixed >$
704
694
}
@@ -709,8 +699,8 @@ direction LR
709
699
+getJsonSchema() array< string, mixed >$
710
700
}
711
701
class FunctionResponse {
712
- +getId() string
713
- +getName() string
702
+ +getId() ? string
703
+ +getName() ? string
714
704
+getResponse() mixed
715
705
+getJsonSchema() array< string, mixed >$
716
706
}
@@ -730,26 +720,25 @@ direction LR
730
720
namespace AiClientNamespace.Util {
731
721
class CandidatesUtil {
732
722
+toTexts(Candidate[] $candidates) string[]$
733
- +toImageFiles(Candidate[] $candidates) FileInterface []$
734
- +toAudioFiles(Candidate[] $candidates) FileInterface []$
735
- +toVideoFiles(Candidate[] $candidates) FileInterface []$
723
+ +toImageFiles(Candidate[] $candidates) File []$
724
+ +toAudioFiles(Candidate[] $candidates) File []$
725
+ +toVideoFiles(Candidate[] $candidates) File []$
736
726
+toFirstText(Candidate[] $candidates) string$
737
- +toFirstImageFile(Candidate[] $candidates) FileInterface $
738
- +toFirstAudioFile(Candidate[] $candidates) FileInterface $
739
- +toFirstVideoFile(Candidate[] $candidates) FileInterface $
727
+ +toFirstImageFile(Candidate[] $candidates) File $
728
+ +toFirstAudioFile(Candidate[] $candidates) File $
729
+ +toFirstVideoFile(Candidate[] $candidates) File $
740
730
}
741
731
class MessageUtil {
742
732
+toText(Message $message) string$
743
- +toImageFile(Message $message) FileInterface $
744
- +toAudioFile(Message $message) FileInterface $
745
- +toVideoFile(Message $message) FileInterface $
733
+ +toImageFile(Message $message) File $
734
+ +toAudioFile(Message $message) File $
735
+ +toVideoFile(Message $message) File $
746
736
}
747
737
class RequirementsUtil {
748
738
+inferRequirements(Message[] $messages, ModelConfig $modelConfig) ModelRequirements$
749
739
}
750
740
}
751
741
752
- <<interface>> FileInterface
753
742
<<interface>> OperationInterface
754
743
<<interface>> ResultInterface
755
744
<<Enumeration>> MessageRoleEnum
@@ -772,8 +761,7 @@ direction LR
772
761
PromptBuilder .. EmbeddingOperation : creates
773
762
MessageBuilder .. Message : creates
774
763
Message "1" *-- "1..*" MessagePart
775
- MessagePart "1" o-- "0..1" InlineFile
776
- MessagePart "1" o-- "0..1" RemoteFile
764
+ MessagePart "1" o-- "0..1" File
777
765
MessagePart "1" o-- "0..1" FunctionCall
778
766
MessagePart "1" o-- "0..1" FunctionResponse
779
767
GenerativeAiOperation "1" o-- "0..1" GenerativeAiResult
@@ -788,9 +776,6 @@ direction LR
788
776
OperationInterface ..> OperationStateEnum
789
777
GenerativeAiOperation ..> OperationStateEnum
790
778
Candidate ..> FinishReasonEnum
791
- FileInterface <|-- InlineFile
792
- FileInterface <|-- RemoteFile
793
- FileInterface <|-- LocalFile
794
779
Message <|-- UserMessage
795
780
Message <|-- ModelMessage
796
781
Message <|-- SystemMessage
@@ -985,23 +970,25 @@ direction LR
985
970
}
986
971
987
972
namespace AiClientNamespace.Providers.Contracts {
988
- class AuthenticationInterface {
989
- +authenticate(Request $request) void
990
- +getJsonSchema() array< string, mixed >$
991
- }
992
973
class ModelMetadataDirectoryInterface {
993
974
+listModelMetadata() ModelMetadata[]
994
975
+hasModelMetadata(string $modelId) bool
995
976
+getModelMetadata(string $modelId) ModelMetadata
996
977
}
978
+ class ProviderAvailabilityInterface {
979
+ +isConfigured() bool
980
+ }
997
981
class ProviderInterface {
998
982
+metadata() ProviderMetadata$
999
983
+model(string $modelId, ModelConfig|array< string, mixed > $modelConfig) ModelInterface$
1000
984
+availability() ProviderAvailabilityInterface$
1001
985
+modelMetadataDirectory() ModelMetadataDirectoryInterface$
1002
986
}
1003
- class ProviderAvailabilityInterface {
1004
- +isConfigured() bool
987
+ class ProviderOperationsHandlerInterface {
988
+ +getOperation(string $operationId) OperationInterface
989
+ }
990
+ class ProviderWithOperationsHandlerInterface {
991
+ +operationsHandler() ProviderOperationsHandlerInterface$
1005
992
}
1006
993
}
1007
994
@@ -1031,19 +1018,51 @@ direction LR
1031
1018
}
1032
1019
}
1033
1020
1021
+ namespace AiClientNamespace.Providers.Http.Contracts {
1022
+ class HttpTransporterInterface {
1023
+ +send(Request $request) Response
1024
+ }
1025
+ class RequestAuthenticationInterface {
1026
+ +authenticate(Request $request) void
1027
+ +getJsonSchema() array< string, mixed >$
1028
+ }
1029
+ class WithHttpTransporterInterface {
1030
+ +setHttpTransporter(HttpTransporterInterface $transporter) void
1031
+ +getHttpTransporter() HttpTransporterInterface
1032
+ }
1033
+ class WithRequestAuthenticationInterface {
1034
+ +setRequestAuthentication(RequestAuthenticationInterface $authentication) void
1035
+ +getRequestAuthentication() RequestAuthenticationInterface
1036
+ }
1037
+ }
1038
+
1039
+ namespace AiClientNamespace.Providers.Http.DTO {
1040
+ class Request {
1041
+ +getMethod() string
1042
+ +getUri() string
1043
+ +getHeaders() array< string, string[] >
1044
+ +getBody() ?string
1045
+ +getData() ?array< string, mixed >
1046
+ +getJsonSchema() array< string, mixed >$
1047
+ }
1048
+
1049
+ class Response {
1050
+ +getStatusCode() int
1051
+ +getHeaders() array< string, string[] >
1052
+ +getBody() ?string
1053
+ +getData() ?array< string, mixed >
1054
+ +getJsonSchema() array< string, mixed >$
1055
+ }
1056
+ }
1057
+
1034
1058
namespace AiClientNamespace.Providers.Models.Contracts {
1035
1059
class ModelInterface {
1036
1060
+metadata() ModelMetadata
1037
1061
+setConfig(ModelConfig $config) void
1038
1062
+getConfig() ModelConfig
1039
1063
}
1040
- class WithAuthenticationInterface {
1041
- +setAuthentication(AuthenticationInterface $authentication) void
1042
- +getAuthentication() AuthenticationInterface
1043
- }
1044
- class WithHttpTransporterInterface {
1045
- +setHttpTransporter(HttpTransporterInterface $transporter) void
1046
- +getHttpTransporter() HttpTransporterInterface
1064
+ class WithEmbeddingOperationsInterface {
1065
+ +getOperation(string $operationId) EmbeddingOperation
1047
1066
}
1048
1067
}
1049
1068
@@ -1192,6 +1211,9 @@ direction LR
1192
1211
<<interface>> ModelInterface
1193
1212
<<interface>> ProviderAvailabilityInterface
1194
1213
<<interface>> ModelMetadataDirectoryInterface
1214
+ <<interface>> ProviderOperationsHandlerInterface
1215
+ <<interface>> ProviderWithOperationsHandlerInterface
1216
+ <<interface>> WithEmbeddingOperationsInterface
1195
1217
<<interface>> TextGenerationModelInterface
1196
1218
<<interface>> ImageGenerationModelInterface
1197
1219
<<interface>> TextToSpeechConversionModelInterface
@@ -1200,9 +1222,11 @@ direction LR
1200
1222
<<interface>> ImageGenerationOperationModelInterface
1201
1223
<<interface>> TextToSpeechConversionOperationModelInterface
1202
1224
<<interface>> SpeechGenerationOperationModelInterface
1225
+ <<interface>> EmbeddingGenerationOperationModelInterface
1226
+ <<interface>> HttpTransporterInterface
1203
1227
<<interface>> WithHttpTransporterInterface
1204
- <<interface>> WithAuthenticationInterface
1205
- <<interface>> AuthenticationInterface
1228
+ <<interface>> RequestAuthenticationInterface
1229
+ <<interface>> WithRequestAuthenticationInterface
1206
1230
<<Enumeration>> CapabilityEnum
1207
1231
<<Enumeration>> OptionEnum
1208
1232
<<Enumeration>> ProviderTypeEnum
@@ -1211,6 +1235,7 @@ direction LR
1211
1235
ProviderInterface "1" *-- "1" ProviderMetadata
1212
1236
ProviderInterface "1" *-- "1" ProviderAvailabilityInterface
1213
1237
ProviderInterface "1" *-- "1" ModelMetadataDirectoryInterface
1238
+ ProviderWithOperationsHandlerInterface "1" *-- "1" ProviderOperationsHandlerInterface
1214
1239
ModelInterface "1" *-- "1" ModelMetadata
1215
1240
ModelInterface "1" *-- "1" ModelConfig
1216
1241
ProviderModelsMetadata "1" o-- "1" ProviderMetadata
0 commit comments