vertexai-kt
1.1.0indexedSimplifies integration with Vertex AI PaLM API for creating and training generative models. Supports Android and iOS with an intuitive abstraction layer, enhancing mobile app development.
Simplifies integration with Vertex AI PaLM API for creating and training generative models. Supports Android and iOS with an intuitive abstraction layer, enhancing mobile app development.
VertexAI-KT is a Kotlin multiplatform library designed to simplify the integration with the Vertex AI PaLM API, a powerful service provided by Google Cloud for creating and training generative models. This library provides an abstraction layer on top of the VertexAI API, enabling seamless integration with Android and iOS platforms.
To get started with the SDK, you'll need the following information for initialization:
It's important to have these details ready before proceeding with the SDK setup.
Add the following line to import the library via Gradle. First, make sure Maven Central has been added:
repositories {
mavenCentral()
// ...
}
Then, simply import the dependency to your build.gradle dependencies:
implementation("com.hexascribe:vertexai-kt-jvm:LATEST-VERSION")
Take a look at the Java code snippet below for an example of how to initialize and use one of the supported features:
Add the following line to import the library via Gradle. First, make sure Maven Central has been added:
repositories {
mavenCentral()
// ...
}
Then, simply import the dependency to your build.gradle dependencies:
implementation("com.hexascribe:vertexai-kt:LATEST-VERSION")
Take a look at the Kotlin code snippet below for an example of how to initialize and use one of the supported features:
val vertexAI by lazy {
VertexAI.Builder()
.setAccessToken("YOUR_ACCESS_TOKEN")
.setProjectId("YOUR_GOOGLE_CLOUD_PROJECT_ID")
.build()
}
val textRequest by lazy {
vertexAI.textRequest()
.setModel("some-model")
.setTemperature(0.8)
.setMaxTokens(256)
.setTopK(40)
.setTopP(0.8)
}
viewModelScope.launch {
val result = textRequest.execute("Say this is a test")
print(result.getOrThrow())
}
To use this library in your iOS project, follow these steps:
You can now start using the VertexAI-KT in your iOS project!
Take a look at the Swift code snippet below for an example of how to initialize and use one of the supported features:
var vertexAI: VertexAI {
VertexAI.Builder()
.setAccessToken(accessToken: "YOUR_ACCESS_TOKEN")
.setProjectId(projectId: )
.build()
}
textRequest: {
vertexAI.textRequest()
.setModel(model: )
.setTemperature(temperature: )
.setMaxTokens(maxTokens: )
.setTopK(topK: )
.setTopP(topP: )
}
. {
result textRequest.execute(prompt: )
(result.getOrThrow())
}
Take a look at our sample apps to learn how to use the SDK on different platforms:
Android Sample
iOS Sample
JVM Sample
Feel free to make a suggestion or if you find any error in this project, please open an issue. Make sure to read our contribution guidelines before.
Copyright 2023 Hexa Scribe
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance the License.
You may obtain a copy of the License at
http:
Unless applicable law agreed to writing, software
distributed under the License distributed an BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
See the License the specific language governing permissions
limitations under the License.
VertexAI vertexAI = new VertexAI.Builder()
.setAccessToken("YOUR_ACCESS_TOKEN")
.setProjectId("YOUR_GOOGLE_CLOUD_PROJECT_ID")
.build();
TextRequest textRequest = vertexAI.textRequest()
.setModel("some-model")
.setTemperature(0.8)
.setMaxTokens(256)
.setTopK(40)
.setTopP(0.8);
textRequest.execute("Say this is a test", new VertexAI.Callback<String>() {
@Override
public void onSuccess(@NotNull String result) {
// handle success
}
@Override
public void onError(@NotNull Throwable throwable) {
// handle error
}
});
Surfaced from shared tags and platforms — no rankings paid for.