Skip to content

Commit b409875

Browse files
committed
Update operations handling in accordance with revised interfaces, use generic interface as return type to be future proof.
1 parent 797fb9d commit b409875

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

docs/ARCHITECTURE.md

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -826,26 +826,32 @@ direction LR
826826
827827
namespace AiClientNamespace.Providers.Contracts {
828828
class AuthenticationInterface {
829-
+authenticate(RequestInterface $request) void
829+
+authenticate(Request $request) void
830830
+getJsonSchema() array< string, mixed >$
831831
}
832832
class HttpClientInterface {
833-
+send(RequestInterface $request, array< string, mixed > $options) ResponseInterface
834-
+request(string $method, string $uri, array< string, mixed > $options) ResponseInterface
833+
+send(Request $request, array< string, mixed > $options) Response
834+
+request(string $method, string $uri, array< string, mixed > $options) Response
835835
}
836836
class ModelMetadataDirectoryInterface {
837837
+listModelMetadata() ModelMetadata[]
838838
+hasModelMetadata(string $modelId) bool
839839
+getModelMetadata(string $modelId) ModelMetadata
840840
}
841+
class ProviderAvailabilityInterface {
842+
+isConfigured() bool
843+
}
841844
class ProviderInterface {
842845
+metadata() ProviderMetadata$
843846
+model(string $modelId, ModelConfig|array< string, mixed > $modelConfig) ModelInterface$
844847
+availability() ProviderAvailabilityInterface$
845848
+modelMetadataDirectory() ModelMetadataDirectoryInterface$
846849
}
847-
class ProviderAvailabilityInterface {
848-
+isConfigured() bool
850+
class ProviderOperationsHandlerInterface {
851+
+getOperation(string $operationId) OperationInterface
852+
}
853+
class ProviderWithOperationsHandlerInterface {
854+
+operationsHandler() ProviderOperationsHandlerInterface$
849855
}
850856
}
851857
@@ -888,9 +894,6 @@ direction LR
888894
class WithEmbeddingOperationsInterface {
889895
+getOperation(string $operationId) EmbeddingOperation
890896
}
891-
class WithGenerativeAiOperationsInterface {
892-
+getOperation(string $operationId) GenerativeAiOperation
893-
}
894897
class WithHttpClientInterface {
895898
+setHttpClient(HttpClientInterface $client) void
896899
+getHttpClient() HttpClientInterface
@@ -1050,7 +1053,8 @@ direction LR
10501053
<<interface>> ModelInterface
10511054
<<interface>> ProviderAvailabilityInterface
10521055
<<interface>> ModelMetadataDirectoryInterface
1053-
<<interface>> WithGenerativeAiOperationsInterface
1056+
<<interface>> ProviderOperationsHandlerInterface
1057+
<<interface>> ProviderWithOperationsHandlerInterface
10541058
<<interface>> WithEmbeddingOperationsInterface
10551059
<<interface>> TextGenerationModelInterface
10561060
<<interface>> ImageGenerationModelInterface
@@ -1074,6 +1078,7 @@ direction LR
10741078
ProviderInterface "1" *-- "1" ProviderMetadata
10751079
ProviderInterface "1" *-- "1" ProviderAvailabilityInterface
10761080
ProviderInterface "1" *-- "1" ModelMetadataDirectoryInterface
1081+
ProviderWithOperationsHandlerInterface "1" *-- "1" ProviderOperationsHandlerInterface
10771082
ModelInterface "1" *-- "1" ModelMetadata
10781083
ModelInterface "1" *-- "1" ModelConfig
10791084
ProviderModelsMetadata "1" o-- "1" ProviderMetadata

src/Providers/Contracts/ProviderOperationsHandlerInterface.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace WordPress\AiClient\Providers\Contracts;
66

77
use InvalidArgumentException;
8-
use WordPress\AiClient\Operations\DTO\GenerativeAiOperation;
8+
use WordPress\AiClient\Operations\Contracts\OperationInterface;
99

1010
/**
1111
* Interface for handling provider-level operations.
@@ -24,8 +24,8 @@ interface ProviderOperationsHandlerInterface
2424
* @since n.e.x.t
2525
*
2626
* @param string $operationId Operation identifier.
27-
* @return GenerativeAiOperation The operation.
27+
* @return OperationInterface The operation.
2828
* @throws InvalidArgumentException If operation not found.
2929
*/
30-
public function getOperation(string $operationId): GenerativeAiOperation;
30+
public function getOperation(string $operationId): OperationInterface;
3131
}

0 commit comments

Comments
 (0)