generated from nhcarrigan/template
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
05af2d3695
|
+6
-19
@@ -115,31 +115,18 @@ fn build_user_gemini_parts(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct GeminiCallParams {
|
|
||||||
pub mode: String,
|
|
||||||
pub aspect_ratio: Option<String>,
|
|
||||||
pub image_size: String,
|
|
||||||
pub user_text: Option<String>,
|
|
||||||
pub user_image_base64: Option<String>,
|
|
||||||
pub user_image_mime: Option<String>,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn call_gemini(
|
pub async fn call_gemini(
|
||||||
api_key: String,
|
api_key: String,
|
||||||
|
mode: String,
|
||||||
|
aspect_ratio: Option<String>,
|
||||||
|
image_size: String,
|
||||||
history: Vec<ThreadMessage>,
|
history: Vec<ThreadMessage>,
|
||||||
params: GeminiCallParams,
|
user_text: Option<String>,
|
||||||
|
user_image_base64: Option<String>,
|
||||||
|
user_image_mime: Option<String>,
|
||||||
) -> Result<(Vec<MessagePart>, f64), String> {
|
) -> Result<(Vec<MessagePart>, f64), String> {
|
||||||
let client = reqwest::Client::new();
|
let client = reqwest::Client::new();
|
||||||
|
|
||||||
let GeminiCallParams {
|
|
||||||
mode,
|
|
||||||
aspect_ratio,
|
|
||||||
image_size,
|
|
||||||
user_text,
|
|
||||||
user_image_base64,
|
|
||||||
user_image_mime,
|
|
||||||
} = params;
|
|
||||||
|
|
||||||
let is_first_message = history.is_empty();
|
let is_first_message = history.is_empty();
|
||||||
|
|
||||||
let mut contents: Vec<Value> = history
|
let mut contents: Vec<Value> = history
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
mod gemini;
|
mod gemini;
|
||||||
mod storage;
|
mod storage;
|
||||||
|
|
||||||
use gemini::{call_gemini, read_reference_image_base64, GeminiCallParams};
|
use gemini::{call_gemini, read_reference_image_base64};
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use storage::{
|
use storage::{
|
||||||
delete_thread_from_disk, load_config_from_disk, load_threads_from_disk, save_config_to_disk,
|
delete_thread_from_disk, load_config_from_disk, load_threads_from_disk, save_config_to_disk,
|
||||||
@@ -46,7 +46,6 @@ async fn save_config(config: Config) -> Result<(), String> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[tauri::command]
|
#[tauri::command]
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
async fn send_message(
|
async fn send_message(
|
||||||
api_key: String,
|
api_key: String,
|
||||||
mode: String,
|
mode: String,
|
||||||
@@ -59,15 +58,13 @@ async fn send_message(
|
|||||||
) -> Result<SendMessageResult, String> {
|
) -> Result<SendMessageResult, String> {
|
||||||
let (parts, cost_usd) = call_gemini(
|
let (parts, cost_usd) = call_gemini(
|
||||||
api_key,
|
api_key,
|
||||||
history,
|
|
||||||
GeminiCallParams {
|
|
||||||
mode,
|
mode,
|
||||||
aspect_ratio,
|
aspect_ratio,
|
||||||
image_size,
|
image_size,
|
||||||
|
history,
|
||||||
user_text,
|
user_text,
|
||||||
user_image_base64,
|
user_image_base64,
|
||||||
user_image_mime,
|
user_image_mime,
|
||||||
},
|
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
Ok(SendMessageResult { parts, cost_usd })
|
Ok(SendMessageResult { parts, cost_usd })
|
||||||
|
|||||||
Reference in New Issue
Block a user