Skip to content

Commit

Permalink
fixed image calling
Browse files Browse the repository at this point in the history
  • Loading branch information
vineyrawat committed Apr 21, 2024
1 parent d7eec91 commit 3247c61
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/providers/gemini_chat_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class GeminiChatProvider extends StateNotifier<GeminiChatState> {

getPrompt(String prompt, XFile? result) async {
var model = GenerativeModel(
model: 'gemini-pro',
model: result == null ? 'gemini-pro' : 'gemini-pro-vision',
apiKey: ref.read(appSettingsProvider).geminiApiKey);
var filteredMessage = state.messages.whereType<types.TextMessage>();
// return;
Expand Down Expand Up @@ -118,12 +118,14 @@ class GeminiChatProvider extends StateNotifier<GeminiChatState> {
try {
if (prompt.isEmpty && result == null) return;
if (result != null) {}
var res = await chat.sendMessage(result == null
? Content.text(prompt)
: Content.multi([
TextPart(prompt),
...[DataPart("image/jpeg", await result.readAsBytes())]
]));
var res = result == null
? await chat.sendMessage(Content.text(prompt))
: await model.generateContent([
Content.multi([
TextPart(prompt),
...[DataPart("image/jpeg", await result.readAsBytes())]
])
]);
log(res.text!);
addMessage(types.TextMessage(
author: state.users[1],
Expand Down

0 comments on commit 3247c61

Please sign in to comment.