Skip to content

Commit

Permalink
Release v3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
marinPassio committed May 17, 2024
1 parent a7dcac0 commit 366917c
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 15 deletions.
55 changes: 53 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Passio SDK

[![release](https://img.shields.io/badge/release-v3.0.3-brightgreen)](https://github.com/Passiolife/Passio-Nutrition-AI-Android-SDK-Distribution/releases/tag/v3.0.3) [![release](https://img.shields.io/badge/platform-Android-lightgray)]() [![release](https://img.shields.io/badge/minimum--suported--version-26-lightgray)](https://developer.android.com/about/versions/oreo) [![release](https://img.shields.io/badge/Kotlin-v1.6.10-informational)](https://github.com/JetBrains/kotlin/releases/tag/v1.6.10) [![release](https://img.shields.io/badge/codelab-Get_started-important)](https://musing-gates-4e7160.netlify.app/#0)
[![release](https://img.shields.io/badge/release-v3.1.0-brightgreen)](https://github.com/Passiolife/Passio-Nutrition-AI-Android-SDK-Distribution/releases/tag/v3.1.0) [![release](https://img.shields.io/badge/platform-Android-lightgray)]() [![release](https://img.shields.io/badge/minimum--suported--version-26-lightgray)](https://developer.android.com/about/versions/oreo) [![release](https://img.shields.io/badge/Kotlin-v1.6.10-informational)](https://github.com/JetBrains/kotlin/releases/tag/v1.6.10) [![release](https://img.shields.io/badge/codelab-Get_started-important)](https://musing-gates-4e7160.netlify.app/#0)

## Overview:

Expand Down Expand Up @@ -305,4 +305,55 @@ data class PassioIngredient(

* For a simple way to use the camera functionality of the SDK, extend the `PassioCameraFragment`. It contains the logic to ask for the camera permission, and if granted, start the camera preview. An example of the PassioCameraFragment can be seen in the `FoodRecognizerFragment` of the PassioSDKDemo project.

<sup>Copyright 2023 Passio Inc</sup>
### 7. Nutrition AI Advisor

## Configure the Nutrition Advisor and start a conversation

#### Note: Make sure you don't utilize the PassioNutritionAISDK Key. Instead, enter the key you obtained from Passio for NutritionAdvisor.

- Configure the Nutrition Advisor using the license key.
```kotlin
NutritionAdvisor.instance.configure(
applicationContext,
"your key here"
) { result ->
when (result) {
is PassioResult.Success -> /* continue with init conversation */
is PassioResult.Error -> /* handle configuration error */
}
}
```

- Start a new conversation by calling ```initConversation```.
```kotlin
NutritionAdvisor.instance.initConversation { result ->
when (result) {
is PassioResult.Success -> /* the advisor can start acceping messages */
is PassioResult.Error -> /* handle conversation init error */
}
}
```

### Send messages to chat with the advisor or images for recognition

1. Send a text message to the advisor
```kotlin
NutritionAdvisor.instance.sendMessage("Hi! I would like a recipe for a healthy burger!") { result ->
when (result) {
is PassioResult.Success -> /* parse the response from the result.value */
is PassioResult.Error -> /* handle message error */
}
}
```
2. Use this method to send image to Nutrition Advisor
```kotlin
val bitmap = loadBitmap()
NutritionAdvisor.instance.sendImage(bitmap) { result ->
when (result) {
is PassioResult.Success -> /* the food items are found in result.value.extractedIngredients */
is PassioResult.Error -> /* handle message error */
}
}
```

<sup>Copyright 2024 Passio Inc</sup>
68 changes: 66 additions & 2 deletions ReleaseNotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,72 @@

Full project was build with **Kotlin 1.6.10**

## V3.1.0

### Introducing the Nutrition AI Advisor!

* To access the API od the Advisor use ```NutritionAdvisor.instance```

```kotlin
fun configure(
appContext: Context,
licenseKey: String,
callback: (result: PassioResult<Any>) -> Unit
)

fun initConversation(callback: (result: PassioResult<Any>) -> Unit)

fun sendMessage(
message: String,
callback: (response: PassioResult<PassioAdvisorResponse>) -> Unit
)

fun sendImage(
bitmap: Bitmap,
callback: (response: PassioResult<PassioAdvisorResponse>) -> Unit
)

fun fetchIngredients(
response: PassioAdvisorResponse,
callback: (response: PassioResult<PassioAdvisorResponse>) -> Unit
)
```

### Refactored APIs

* Nutrition facts scanning has been separated out in different recognition flow. The ```FoodDetectionConfiguration``` object no longer has the *detectNutritionFacts* parameter.
* The scanning now is controled by these new functions

```kotlin
fun startNutritionFactsDetection(listener: NutritionFactsRecognitionListener)

fun stopNutritionFactsDetection()

interface NutritionFactsRecognitionListener {
fun onRecognitionResult(nutritionFacts: PassioNutritionFacts?, text: String)
}
```

### Added APIs

* Added speech recognition API that retrieves a list of recognized foods from the input text query.

```kotlin
fun recognizeSpeechRemote(text: String, callback: (result: List<PassioSpeechRecognitionModel>) -> Unit)
```

* Added LLM image detection, that works remotely through Passio's backend.

```kotlin
fun recognizeImageRemote(bitmap: Bitmap, callback: (result: List<PassioAdvisorFoodInfo>) -> Unit)
```

* Added a function to retrieve a PassioFoodItem for a *v2 PassioID*

```kotlin
fun fetchFoodItemLegacy(passioID: PassioID, callback: (foodItem: PassioFoodItem?) -> Unit)
```

## V3.0.3

* Added APIs
Expand All @@ -28,8 +94,6 @@ fun fetchMealPlanForDay(

* fetchFoodItemForSuggestion was removed. Instead ```fetchFoodItemForDataInfo``` is used.

*

## V3.0.2

## Added APIs
Expand Down
68 changes: 57 additions & 11 deletions SDK_API.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,17 +414,6 @@ interface PassioSDK {
onDetectionCompleted: (candidates: FoodCandidates?) -> Unit
): Boolean

// /**
// * @deprecated use [lookupIconsFor] instead.
// */
// @Deprecated("Use lookupIconsFor instead")
// fun lookupIconFor(
// context: Context,
// passioID: PassioID,
// iconSize: IconSize = IconSize.PX90,
// type: PassioIDEntityType = PassioIDEntityType.item,
// ): Pair<Drawable, Boolean>

fun lookupIconsFor(
context: Context,
passioID: PassioID,
Expand Down Expand Up @@ -513,6 +502,63 @@ interface PassioSDK {
day: Int,
callback: (result: List<PassioMealPlanItem>) -> Unit
)

fun recognizeSpeechRemote(text: String, callback: (result: List<PassioSpeechRecognitionModel>) -> Unit)

fun recognizeImageRemote(bitmap: Bitmap, callback: (result: List<PassioAdvisorFoodInfo>) -> Unit)

fun fetchFoodItemForRefCode(refCode: String, callback: (foodItem: PassioFoodItem?) -> Unit)

fun startNutritionFactsDetection(listener: NutritionFactsRecognitionListener)

fun stopNutritionFactsDetection()

fun fetchFoodItemLegacy(passioID: PassioID, callback: (foodItem: PassioFoodItem?) -> Unit)
}

@Keep
interface NutritionAdvisor {

@Keep
companion object {

private var internalInstance: NutritionAdvisor? = null

/**
* Use this singleton to access the Passio SDK.
*/
@JvmStatic
val instance: NutritionAdvisor
get() {
if (internalInstance == null) {
internalInstance = AdvisorService()
}
return internalInstance!!
}
}

fun configure(
appContext: Context,
licenseKey: String,
callback: (result: PassioResult<Any>) -> Unit
)

fun initConversation(callback: (result: PassioResult<Any>) -> Unit)

fun sendMessage(
message: String,
callback: (response: PassioResult<PassioAdvisorResponse>) -> Unit
)

fun sendImage(
bitmap: Bitmap,
callback: (response: PassioResult<PassioAdvisorResponse>) -> Unit
)

fun fetchIngredients(
response: PassioAdvisorResponse,
callback: (response: PassioResult<PassioAdvisorResponse>) -> Unit
)
}
```

Expand Down

0 comments on commit 366917c

Please sign in to comment.