https://github.com/oramasearch/oramacloud-client-kotlin
https://github.com/oramasearch/oramacloud-client-kotlin
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/oramasearch/oramacloud-client-kotlin
- Owner: oramasearch
- License: other
- Created: 2024-07-29T22:13:29.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-09-09T19:25:45.000Z (almost 2 years ago)
- Last Synced: 2026-02-27T13:48:54.203Z (5 months ago)
- Language: Kotlin
- Size: 101 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
Orama Cloud Kotlin Client
---
This repository contains Orama's Cloud Multiplatform Kotlin Client.
Developers can use this library to interact with Orama using Kotlin in multiple plataforms,
## Installing using Maven
To install, make sure to enable Maven repository and include the dependency in your build file `gradle.build.kts`.
```
repositories {
mavenCentral()
}
dependencies {
implementation "com.orama:oramasearch-client-kotlin:$OramaClientVersion"
}
```
## Usage
Performing full-text, vector, or hybrid search:
First, you need to do is to instantiate the client passing your `endpoint` and `apiKey`.
After that, use the `SearchParams` to prepare you query.
Now, just call the `client.search` method with the parameters and a proper callback handler.
```kotlin
@Serializable
data class MyDoc (
val title: String,
val category: String,
val path: String,
val content: String,
val section: String
)
val client = OramaClient(
endpoint = "",
apiKey = ""
)
val searchParams = SearchParams.builder(
term = "install",
mode = Mode.FULLTEXT // Modes: FULLTEXT, VECTOR and HYBRID
).build()
launch {
val results = client.search(searchParams, MyDoc.serializer())
}
```
Performing an answer session:
```kotlin
val client = OramaClient(
endpoint = "",
apiKey = ""
)
val answerParams = AnswerParams(
userContext = null,
oramaClient = client,
inferenceType = InferenceType.DOCUMENTATION,
initialMessages = mutableListOf()
)
val answerSession = AnswerSession(
answerParams = answerParams,
events = object : AnswerEventListener {
override fun onStateChange(interactions: MutableList) {
// Process list of interaction post-response
}
}
)
runBlocking {
val answer = answerSession.ask(AskParams(
query = "What's the best movie to watch with the family?"
))
println(answer)
}
```
## License
[Apache 2.0](/LICENSE.md)