feat(ai): add custom prompt templates
This commit is contained in:
1 parent
01fde8879f
commit
1fb3e2816b
58 files changed
+2381
-502
No files matched your search
@@ -25,6 +25,7 @@ pub mod mongo_cmd;
|
||||
pub mod mq_cmd;
|
||||
pub mod nacos_cmd;
|
||||
pub mod plugins;
|
||||
pub mod prompt_template;
|
||||
pub mod query;
|
||||
pub mod query_cancel;
|
||||
pub mod query_result_export;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
use std::sync::Arc;
|
||||
use tauri::State;
|
||||
|
||||
use dbx_core::prompt_template::PromptTemplate;
|
||||
|
||||
use super::connection::AppState;
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn load_prompt_templates(state: State<'_, Arc<AppState>>) -> Result<Vec<PromptTemplate>, String> {
|
||||
state.storage.load_prompt_templates().await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn save_prompt_template(
|
||||
state: State<'_, Arc<AppState>>,
|
||||
id: String,
|
||||
name: String,
|
||||
content: String,
|
||||
) -> Result<PromptTemplate, String> {
|
||||
state.storage.save_prompt_template(&id, &name, &content).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn delete_prompt_template(state: State<'_, Arc<AppState>>, id: String) -> Result<(), String> {
|
||||
state.storage.delete_prompt_template(&id).await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn get_ai_global_custom_instructions(state: State<'_, Arc<AppState>>) -> Result<String, String> {
|
||||
state.storage.load_ai_global_custom_instructions().await
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub async fn set_ai_global_custom_instructions(state: State<'_, Arc<AppState>>, content: String) -> Result<(), String> {
|
||||
state.storage.save_ai_global_custom_instructions(&content).await
|
||||
}
|
||||
Reference in new issue
Block a user