refactoring
different default system prompts for cli and audio
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
{
|
||||
"translations": {
|
||||
"system_prompt": "Du bist ein Assistent, der per Sprache bedient wird. Du erhälst die Transkription und dein Output wird per Sprache ausgegeben und sollte dementsprechend auch kurz sein und kein Markdown enthalten. Wichtiger als deine Antworten sind deine Aktionen. Nutze bitte die tools, falls du sie brauchst um Informationen zu bekommen (z.B. über das aktuelle Datum oder den aktuellen Wochentag). Du bist in einem Agent Loop und kannst mehrere Tools hintereinander nutzen. Falls der Nutzer das Nutzen eines Tools ablehnt, sag ihm bescheid, dass du es brauchst.",
|
||||
"system_prompt_cli": "Du bist ein Assistent. Wichtiger als deine Antworten sind deine Aktionen. Nutze bitte die tools, falls du sie brauchst um Informationen zu bekommen (z.B. über das aktuelle Datum oder den aktuellen Wochentag). Du bist in einem Agent Loop und kannst mehrere Tools hintereinander nutzen. Falls der Nutzer das Nutzen eines Tools ablehnt, sag ihm bescheid, dass du es brauchst.",
|
||||
"system_prompt_audio": "Du bist ein Assistent, der per Sprache bedient wird. Du erhälst die Transkription und dein Output wird per Sprache ausgegeben und sollte dementsprechend auch kurz sein und kein Markdown enthalten. Wichtiger als deine Antworten sind deine Aktionen. Nutze bitte die tools, falls du sie brauchst um Informationen zu bekommen (z.B. über das aktuelle Datum oder den aktuellen Wochentag). Du bist in einem Agent Loop und kannst mehrere Tools hintereinander nutzen. Falls der Nutzer das Nutzen eines Tools ablehnt, sag ihm bescheid, dass du es brauchst.",
|
||||
"you": "Du",
|
||||
"assistant": "Assistent",
|
||||
"username": "Nutzername",
|
||||
|
||||
+5
-16
@@ -12,6 +12,7 @@ use clap::Parser;
|
||||
use cpal::traits::HostTrait;
|
||||
use own_mcp::AgentChat;
|
||||
use std::fmt::Display;
|
||||
use own_assist_common::exit_msg;
|
||||
|
||||
/// partial mcp client with cli and voice interaction
|
||||
#[derive(Parser, Debug)]
|
||||
@@ -84,7 +85,7 @@ async fn main() {
|
||||
let ollama = config.ollama_instance();
|
||||
let model_name = &config.ollama_config().model.name;
|
||||
|
||||
create_model_from_config(&ollama, &config.ollama_config().model)
|
||||
create_model_from_config(&ollama, &config.ollama_config().model, &config.interface)
|
||||
.await
|
||||
.inspect_err(exit_msg!(format!(
|
||||
"failed creating ollama model `{model_name}`"
|
||||
@@ -123,7 +124,8 @@ async fn main() {
|
||||
.expect("no default device"),
|
||||
)
|
||||
.await
|
||||
.inspect_err(exit_msg!("failed creating audio client")).unwrap();
|
||||
.inspect_err(exit_msg!("failed creating audio client"))
|
||||
.unwrap();
|
||||
|
||||
chat_loop(human_interface, agent_chat).await;
|
||||
}
|
||||
@@ -133,17 +135,4 @@ async fn main() {
|
||||
};
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
fn exit_with_error_message(error: impl Display, message: impl Display) {
|
||||
log::error!("{message}: {error}");
|
||||
eprintln!("{}", message); // makes sure that message is printed even if logging is deactivated
|
||||
std::process::exit(1);
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! exit_msg {
|
||||
($message:expr) => {
|
||||
|e| exit_with_error_message(e, $message)
|
||||
};
|
||||
}
|
||||
}
|
||||
+6
-2
@@ -1,4 +1,4 @@
|
||||
use crate::config::OllamaModelConfig;
|
||||
use crate::config::{HumanInterface, OllamaModelConfig};
|
||||
use crate::tlt;
|
||||
use crate::translate;
|
||||
use ollama_rs::Ollama;
|
||||
@@ -9,6 +9,7 @@ use ollama_rs::models::create::{CreateModelRequest, CreateModelStatus};
|
||||
pub async fn create_model_from_config(
|
||||
ollama: &Ollama,
|
||||
config: &OllamaModelConfig,
|
||||
interface: &HumanInterface
|
||||
) -> Result<CreateModelStatus, OllamaError> {
|
||||
let model_options = ModelOptions::default()
|
||||
.num_ctx(config.context_size.unwrap_or(2048)) // 2048 is the ollama default.
|
||||
@@ -17,7 +18,10 @@ pub async fn create_model_from_config(
|
||||
let system_prompt = config
|
||||
.system_prompt
|
||||
.clone()
|
||||
.unwrap_or(tlt!("system_prompt"));
|
||||
.unwrap_or(match interface {
|
||||
HumanInterface::Cli => tlt!("system_prompt_cli"),
|
||||
HumanInterface::Audio => tlt!("system_prompt_audio"),
|
||||
});
|
||||
|
||||
// print message to warn user of long waiting times
|
||||
if let Ok(models) = ollama.list_local_models().await
|
||||
|
||||
Reference in New Issue
Block a user