-
Notifications
You must be signed in to change notification settings - Fork 140
[Jules] Refactor to use Firebase AI Logic SDK #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,12 +21,13 @@ import androidx.lifecycle.MutableLiveData | |
| import androidx.lifecycle.ViewModel | ||
| import androidx.lifecycle.viewModelScope | ||
| import com.google.firebase.Firebase | ||
| import com.google.firebase.vertexai.type.HarmBlockThreshold | ||
| import com.google.firebase.vertexai.type.HarmCategory | ||
| import com.google.firebase.vertexai.type.SafetySetting | ||
| import com.google.firebase.vertexai.type.content | ||
| import com.google.firebase.vertexai.type.generationConfig | ||
| import com.google.firebase.vertexai.vertexAI | ||
| import com.google.firebase.ai.ai | ||
| import com.google.firebase.ai.type.HarmBlockThreshold | ||
| import com.google.firebase.ai.type.HarmCategory | ||
| import com.google.firebase.ai.type.SafetySetting | ||
| import com.google.firebase.ai.type.content | ||
| import com.google.firebase.ai.type.generationConfig | ||
| import com.google.firebase.ai.type.GenerativeBackend | ||
| import kotlinx.coroutines.flow.MutableStateFlow | ||
| import kotlinx.coroutines.flow.StateFlow | ||
| import kotlinx.coroutines.launch | ||
|
|
@@ -41,7 +42,7 @@ class GeminiMultimodalViewModel @Inject constructor(): ViewModel() { | |
| val isGenerating: LiveData<Boolean> = _isGenerating | ||
|
|
||
| private val generativeModel by lazy { | ||
| Firebase.vertexAI.generativeModel( | ||
| Firebase.ai(backend = GenerativeBackend.vertexAI()).generativeModel( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should use |
||
| "gemini-2.0-flash", | ||
| generationConfig = generationConfig { | ||
| temperature = 0.9f | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,8 +22,9 @@ import android.util.Log | |
| import androidx.lifecycle.ViewModel | ||
| import androidx.lifecycle.viewModelScope | ||
| import com.google.firebase.Firebase | ||
| import com.google.firebase.vertexai.type.content | ||
| import com.google.firebase.vertexai.vertexAI | ||
| import com.google.firebase.ai.ai | ||
| import com.google.firebase.ai.type.content | ||
| import com.google.firebase.ai.type.GenerativeBackend | ||
| import kotlinx.coroutines.flow.MutableStateFlow | ||
| import kotlinx.coroutines.flow.StateFlow | ||
| import kotlinx.coroutines.launch | ||
|
|
@@ -50,7 +51,7 @@ class VideoSummarizationViewModel @Inject constructor() : ViewModel() { | |
| _outputText.value = OutputTextState.Loading | ||
|
|
||
| try { | ||
| val generativeModel = Firebase.vertexAI.generativeModel("gemini-2.0-flash") | ||
| val generativeModel = Firebase.ai(backend = GenerativeBackend.vertexAI()).generativeModel("gemini-2.0-flash") | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should use |
||
|
|
||
| val requestContent = content { | ||
| fileData(videoSource.toString(), "video/mp4") | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -23,11 +23,12 @@ import androidx.lifecycle.MutableLiveData | |
| import androidx.lifecycle.ViewModel | ||
| import androidx.lifecycle.viewModelScope | ||
| import com.google.firebase.Firebase | ||
| import com.google.firebase.vertexai.type.ImagenAspectRatio | ||
| import com.google.firebase.vertexai.type.ImagenGenerationConfig | ||
| import com.google.firebase.vertexai.type.ImagenImageFormat | ||
| import com.google.firebase.vertexai.type.PublicPreviewAPI | ||
| import com.google.firebase.vertexai.vertexAI | ||
| import com.google.firebase.ai.ai | ||
| import com.google.firebase.ai.type.GenerativeBackend | ||
| import com.google.firebase.ai.type.ImagenAspectRatio | ||
| import com.google.firebase.ai.type.ImagenGenerationConfig | ||
| import com.google.firebase.ai.type.ImagenImageFormat | ||
| import com.google.firebase.ai.type.PublicPreviewAPI | ||
| import kotlinx.coroutines.flow.MutableStateFlow | ||
| import kotlinx.coroutines.launch | ||
| import javax.inject.Inject | ||
|
|
@@ -41,7 +42,7 @@ class ImagenViewModel @Inject constructor(): ViewModel() { | |
| val isGenerating: LiveData<Boolean> = _isGenerating | ||
|
|
||
| @OptIn(PublicPreviewAPI::class) | ||
| private val imagenModel = Firebase.vertexAI.imagenModel( | ||
| private val imagenModel = Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| modelName = "imagen-3.0-generate-002", | ||
| generationConfig = ImagenGenerationConfig( | ||
| numberOfImages = 1, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,11 +25,12 @@ import androidx.lifecycle.MutableLiveData | |
| import androidx.lifecycle.ViewModel | ||
| import androidx.lifecycle.viewModelScope | ||
| import com.google.firebase.Firebase | ||
| import com.google.firebase.vertexai.type.ImagenAspectRatio | ||
| import com.google.firebase.vertexai.type.ImagenGenerationConfig | ||
| import com.google.firebase.vertexai.type.ImagenImageFormat | ||
| import com.google.firebase.vertexai.type.PublicPreviewAPI | ||
| import com.google.firebase.vertexai.vertexAI | ||
| import com.google.firebase.ai.ai | ||
| import com.google.firebase.ai.type.GenerativeBackend | ||
| import com.google.firebase.ai.type.ImagenAspectRatio | ||
| import com.google.firebase.ai.type.ImagenGenerationConfig | ||
| import com.google.firebase.ai.type.ImagenImageFormat | ||
| import com.google.firebase.ai.type.PublicPreviewAPI | ||
| import com.google.mlkit.vision.common.InputImage | ||
| import com.google.mlkit.vision.segmentation.subject.SubjectSegmentation | ||
| import com.google.mlkit.vision.segmentation.subject.SubjectSegmenterOptions | ||
|
|
@@ -48,7 +49,7 @@ class MagicSelfieViewModel @Inject constructor(): ViewModel() { | |
| private val _progress = MutableLiveData<String?>(null) | ||
| val progress: LiveData<String?> = _progress | ||
|
|
||
| private val imagenModel = Firebase.vertexAI.imagenModel( | ||
| private val imagenModel = Firebase.ai(backend = GenerativeBackend.vertexAI()).imagenModel( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| modelName = "imagen-3.0-generate-002", | ||
| generationConfig = ImagenGenerationConfig( | ||
| numberOfImages = 1, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should use
googleAI()as an API provider.