gemini_ai/content_gen/
forgetful.rsuse std::fs;
use base64::encode;
use rusty_scrap::Scrap;
use crate::{
format::{json, schema, text},
GeminiContentGen, Kind,
};
use super::content::gemini;
pub fn forgetFul(forgetful: &GeminiContentGen) -> String {
let instruction = forgetful.instruction;
let t = forgetful.text;
let model = forgetful.model;
let max_len = forgetful.max_len;
match forgetful.config.response {
Kind::Text => {
let response = text(&forgetful.instruction, &forgetful.text, forgetful.max_len);
let response = gemini(
response,
&forgetful.env_variable,
forgetful.model,
"application/json",
);
response
}
Kind::Json(jsons) => {
let response = json(
forgetful.instruction,
forgetful.text,
&jsons,
forgetful.max_len,
);
let json = gemini(
response,
&forgetful.env_variable,
forgetful.model,
"application/json",
);
json
}
Kind::Image(path) => {
let images = fs::read(path).unwrap();
let encode = encode(images);
let response = schema(instruction, t, "image/jpeg", &encode, max_len);
gemini(
response,
&forgetful.env_variable,
forgetful.model,
"image/jpeg",
)
}
Kind::Audio(path) => {
let audioo = fs::read(path).unwrap();
let audioo = encode(audioo);
let auth = schema(instruction, t, "audio/mpeg", &audioo, max_len);
gemini(auth, forgetful.env_variable, forgetful.model, "audio/mpeg");
String::new()
}
Kind::Pdf(path) => {
let path = fs::read(path).unwrap();
let encode = encode(path);
let pdf = schema(instruction, t, "application/pdf", &encode, max_len);
gemini(
pdf,
forgetful.env_variable,
forgetful.model,
"application/pdf",
)
}
Kind::Video(path) => {
let videoo = fs::read(path).unwrap();
let videoo = encode(videoo);
let video = schema(instruction, t, "video/mp4", &videoo, max_len);
gemini(video, &forgetful.env_variable, forgetful.model, "video/mp4")
}
Kind::Transcribe(path) => {
let videoo = fs::read(path).unwrap();
let videoo = encode(videoo);
let video = schema(instruction, t, "video/mp4", &videoo, max_len);
gemini(video, &forgetful.env_variable, forgetful.model, "video/mp4")
}
Kind::Csv(path) => {
let path = fs::read(path).unwrap();
let csv_file = encode(path);
let send = schema(instruction, t, "text/plain", &csv_file, max_len);
gemini(
send,
forgetful.env_variable,
forgetful.model,
"application/json",
)
}
Kind::Rag(data) => {
let ask = Scrap::new()
.urls(data)
.build()
.element_values()
.replace("\"", "");
let encode = encode(ask);
let response = schema(instruction, t, "text/plain", &encode, max_len);
gemini(
response,
forgetful.env_variable,
forgetful.model,
"application/json",
)
}
}
}