GRPC API
You can access services in Caila via the GRPC API.
You can download the GRPC API specification from this link.
To make a grpc call, you will need to specify the gate.caila.io server address and an API token.
For grpc clients, only one method is available: Gate.process, which can be used to call the predict method. The remaining methods in the specification describe the contract by which services within Caila operate and are not available for client applications.
The GRPC API can be used from any programming language for which grpc adapters can be generated. For Java and Python, you can use our SDK.
Example in Java
Import the dependency:
<dependency>
<artifactId>mpl-java-sdk</artifactId>
<groupId>com.platform.mpl</groupId>
<version>release-SNAPSHOT</version>
</dependency>
Sample code:
import com.mlp.sdk.MlpClientSDK
import com.mlp.sdk.utils.JSON
import kotlinx.coroutines.runBlocking
fun main() = runBlocking {
val clientSDK = MlpClientSDK()
val payload = JSON.stringify("hello")
val res = clientSDK.predict("just-ai", "test-action", payload)
println(res)
clientSDK.shutdown()
}
The access token is passed in the MLP_CLIENT_TOKEN environment variable.
Link to the example in the repository:
https://gitlab.just-ai.com/ml-platform-pub/mlp-java-sdk/-/tree/dev/mlp-examples/mlp-client-app
Example in Python
Import the dependency:
git+https://gitlab.just-ai.com/ml-platform-pub/mlp-python-sdk@release#mlp_sdk
Sample code:
from mlp_sdk.transport.MlpClientSDK import MlpClientSDK
from mlp_sdk.types import TextsCollection
ACCOUNT = "just-ai"
MODEL = "platform-vectorizer-ru-test"
sdk = MlpClientSDK()
sdk.init()
req = TextsCollection(texts=["Hello"])
res = sdk.predict(account=ACCOUNT, model=MODEL, data=req.json())
print(res)
sdk.shutdown()
The access token is passed in the MLP_CLIENT_TOKEN environment variable.
Link to the example in the repository:
https://gitlab.just-ai.com/ml-platform-pub/mlp-python-examples/-/tree/main/python-client