https://github.com/oramasearch/oramacloud-client-swift
Swift client for Orama Cloud
https://github.com/oramasearch/oramacloud-client-swift
Last synced: 3 months ago
JSON representation
Swift client for Orama Cloud
- Host: GitHub
- URL: https://github.com/oramasearch/oramacloud-client-swift
- Owner: oramasearch
- License: other
- Created: 2024-07-15T23:14:15.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-07-24T21:42:38.000Z (about 2 years ago)
- Last Synced: 2026-02-27T13:48:54.075Z (5 months ago)
- Language: Swift
- Size: 59.6 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 Swift Client
[](https://github.com/askorama/oramacloud-client-swift/actions/workflows/swift.yml)
## Installing via CocoaPods
To install the Orama Cloud client in your Swift project, you'll need to install [CocoaPods](https://cocoapods.org/)
```sh
$ gem install cocoapods
```
Then specify the Orama Client dependency in your `PodFile`:
```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!
target '' do
pod 'OramaCloudClient', '~> 0.0.5'
end
```
Then, run `pod install` to install the Pod:
```sh
pod install
```
## Installing via the Swift Package Manager
Add the Orama Cloud repo URL to your `Package.swift` file:
```swift
dependencies: [
.package(url: "https://github.com/askorama/oramacloud-client-swift.git", from: "0.0.4")
]
```
## Usage
Performing full-text, vector, or hybrid search:
```swift
import OramaClient
struct MyDoc: Codable {
let title: String
let description: String
}
let clientParams = OramaClientParams(endpoint: "", apiKey: "")
let orama = OramaClient(params: clientParams)
let searchParams = ClientSearchParams.builder(term: "What is Orama?", mode: .fulltext) // Mode can be .vector or .hybrid too
.limit(10) // optional
.offset(0) // optional
.returning(["title", "description"]) // optional
.build()
let searchResults: SearchResults = try await orama.search(query: searchParams)
print("\(searchResults.count) total results.")
```
Performing an answer session:
```swift
import OramaClient
struct MyDoc: Codable {
let title: String
let description: String
}
let clientParams = OramaClientParams(endpoint: "", apiKey: "")
let orama = OramaClient(params: clientParams)
let answerSessionParams = AnswerParams(
initialMessages: [],
inferenceType: .documentation,
oramaClient: orama,
userContext: nil,
events: nil
)
let answerSession = AnswerSession(params: answerSessionParams)
.on(event: .stateChange) { print($0) }
.on(event: .relatedQueries) { print($0) }
let askParams = AnswerParams.AskParams(
query: "What's the best movie to watch with the family?",
userData: nil,
related: nil
)
let answer = try await answerSession.ask(params: askParams)
```
## License
[Apache 2.0](/LICENSE.md)