Skip to content
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

Make "user" the default role. #66

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ For example, with just a few lines of code, you can access Gemini's multimodal c

```kotlin
val generativeModel = GenerativeModel(
modelName = "gemini-pro-vision",
modelName = "gemini-1.0-pro-vision-latest",
apiKey = BuildConfig.apiKey
)

Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ val GenerativeViewModelFactory = object : ViewModelProvider.Factory {
// Initialize a GenerativeModel with the `gemini-pro` AI model
// for text generation
val generativeModel = GenerativeModel(
modelName = "gemini-pro",
modelName = "gemini-1.0-pro",
apiKey = BuildConfig.apiKey,
generationConfig = config
)
@@ -51,7 +51,7 @@ val GenerativeViewModelFactory = object : ViewModelProvider.Factory {
// Initialize a GenerativeModel with the `gemini-pro-vision` AI model
// for multimodal text generation
val generativeModel = GenerativeModel(
modelName = "gemini-pro-vision",
modelName = "gemini-1.0-pro-vision-latest",
apiKey = BuildConfig.apiKey,
generationConfig = config
)
@@ -61,7 +61,7 @@ val GenerativeViewModelFactory = object : ViewModelProvider.Factory {
isAssignableFrom(ChatViewModel::class.java) -> {
// Initialize a GenerativeModel with the `gemini-pro` AI model for chat
val generativeModel = GenerativeModel(
modelName = "gemini-pro",
modelName = "gemini-1.0-pro",
apiKey = BuildConfig.apiKey,
generationConfig = config
)
Original file line number Diff line number Diff line change
@@ -73,7 +73,7 @@ class Chat(private val model: GenerativeModel, val history: MutableList<Content>
* @throws InvalidStateException if the [Chat] instance has an active request.
*/
suspend fun sendMessage(prompt: String): GenerateContentResponse {
val content = content("user") { text(prompt) }
val content = content { text(prompt) }
return sendMessage(content)
}

@@ -84,7 +84,7 @@ class Chat(private val model: GenerativeModel, val history: MutableList<Content>
* @throws InvalidStateException if the [Chat] instance has an active request.
*/
suspend fun sendMessage(prompt: Bitmap): GenerateContentResponse {
val content = content("user") { image(prompt) }
val content = content { image(prompt) }
return sendMessage(content)
}

@@ -150,7 +150,7 @@ class Chat(private val model: GenerativeModel, val history: MutableList<Content>
* @throws InvalidStateException if the [Chat] instance has an active request.
*/
fun sendMessageStream(prompt: String): Flow<GenerateContentResponse> {
val content = content("user") { text(prompt) }
val content = content { text(prompt) }
return sendMessageStream(content)
}

@@ -162,7 +162,7 @@ class Chat(private val model: GenerativeModel, val history: MutableList<Content>
* @throws InvalidStateException if the [Chat] instance has an active request.
*/
fun sendMessageStream(prompt: Bitmap): Flow<GenerateContentResponse> {
val content = content("user") { image(prompt) }
val content = content { image(prompt) }
return sendMessageStream(content)
}

Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ internal enum class HarmCategory {

typealias Base64 = String

@Serializable internal data class Content(val role: String? = null, val parts: List<Part>)
@Serializable internal data class Content(val role: String? = "user", val parts: List<Part>)

@Serializable(PartSerializer::class) internal sealed interface Part