mirror of
https://github.com/FranP-code/ChatGPT.git
synced 2025-10-13 00:13:25 +00:00
feat: dalle2 (#122)
This commit is contained in:
@@ -1,16 +1,23 @@
|
||||
use crate::{
|
||||
app::window,
|
||||
conf::{ChatConfJson, GITHUB_PROMPTS_CSV_URL},
|
||||
utils::{self, exists},
|
||||
utils,
|
||||
};
|
||||
use log::info;
|
||||
use std::{collections::HashMap, fs, path::PathBuf};
|
||||
use tauri::{api, command, AppHandle, Manager};
|
||||
use walkdir::WalkDir;
|
||||
|
||||
#[command]
|
||||
pub fn drag_window(app: AppHandle) {
|
||||
app.get_window("core").unwrap().start_dragging().unwrap();
|
||||
}
|
||||
|
||||
#[command]
|
||||
pub fn dalle2_window(app: AppHandle, query: String) {
|
||||
window::dalle2_window(&app.app_handle(), query);
|
||||
}
|
||||
|
||||
#[command]
|
||||
pub fn fullscreen(app: AppHandle) {
|
||||
let win = app.get_window("core").unwrap();
|
||||
@@ -122,9 +129,6 @@ pub fn window_reload(app: AppHandle, label: &str) {
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
use utils::chat_root;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
|
||||
pub struct ModelRecord {
|
||||
pub cmd: String,
|
||||
@@ -137,7 +141,7 @@ pub struct ModelRecord {
|
||||
#[command]
|
||||
pub fn cmd_list() -> Vec<ModelRecord> {
|
||||
let mut list = vec![];
|
||||
for entry in WalkDir::new(chat_root().join("cache_model"))
|
||||
for entry in WalkDir::new(utils::chat_root().join("cache_model"))
|
||||
.into_iter()
|
||||
.filter_map(|e| e.ok())
|
||||
{
|
||||
@@ -177,11 +181,13 @@ pub async fn sync_prompts(app: AppHandle, time: u64) -> Option<Vec<ModelRecord>>
|
||||
|
||||
let data2 = data.clone();
|
||||
|
||||
let model = chat_root().join("chat.model.json");
|
||||
let model_cmd = chat_root().join("chat.model.cmd.json");
|
||||
let chatgpt_prompts = chat_root().join("cache_model").join("chatgpt_prompts.json");
|
||||
let model = utils::chat_root().join("chat.model.json");
|
||||
let model_cmd = utils::chat_root().join("chat.model.cmd.json");
|
||||
let chatgpt_prompts = utils::chat_root()
|
||||
.join("cache_model")
|
||||
.join("chatgpt_prompts.json");
|
||||
|
||||
if !exists(&model) {
|
||||
if !utils::exists(&model) {
|
||||
fs::write(
|
||||
&model,
|
||||
serde_json::json!({
|
||||
|
||||
Reference in New Issue
Block a user