restructure into multiple crates
add mcp server collection
This commit is contained in:
+17
-48
@@ -1,23 +1,15 @@
|
||||
pub mod mcp;
|
||||
mod config;
|
||||
mod model;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use ollama_rs::Ollama;
|
||||
use reqwest::header::{HeaderMap, HeaderValue};
|
||||
use rmcp::model::{Implementation};
|
||||
use url::Url;
|
||||
use crate::config::Config;
|
||||
use crate::mcp::chat::MCPServerData;
|
||||
use crate::mcp::guaranteed_mcp_server_name;
|
||||
use crate::model::create_model_from_config;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
env_logger::init();
|
||||
|
||||
let config = Config::from_file().await.inspect_err(|e|{
|
||||
log::error!("error loading assist.toml {}", e);
|
||||
let config = Config::from_file().inspect_err(|e|{
|
||||
log::error!("error loading assist.toml: {}", e);
|
||||
std::process::exit(1);
|
||||
}).unwrap();
|
||||
|
||||
@@ -28,49 +20,26 @@ async fn main() {
|
||||
let model_name = &config.ollama_config().model.name;
|
||||
|
||||
create_model_from_config(&ollama, &config.ollama_config().model).await.inspect_err(|e|{
|
||||
log::error!("failed creating ollama model {model_name}: {e}")
|
||||
log::error!("failed creating ollama model {model_name}: {e}");
|
||||
std::process::exit(1);
|
||||
}).unwrap();
|
||||
|
||||
let mut agent_chat = mcp::chat::AgentChat::new(ollama, model_name.clone(), mcp_clients).await.inspect_err(
|
||||
|
||||
let system_prompt = "Du bist ein Assistent, der per Sprache bedient wird. Du erhälst die Transkription. \
|
||||
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.".to_string();
|
||||
|
||||
let mut agent_chat = own_mcp::AgentChat::new(ollama, model_name.clone(), mcp_clients, system_prompt).await.inspect_err(
|
||||
|e| {
|
||||
log::error!("error creating agent: {}", e);
|
||||
std::process::exit(1);
|
||||
}
|
||||
);
|
||||
).unwrap();
|
||||
|
||||
log::debug!("chat: {:#?}", agent_chat);
|
||||
|
||||
|
||||
/*
|
||||
let ollama = Ollama::default();
|
||||
log::info!("all tools: {:#?}", agent_chat.get_all_tools());
|
||||
|
||||
let fetch_client = mcp::get_client(
|
||||
"https://remote.mcpservers.org/fetch/mcp",
|
||||
None::<String>,
|
||||
Implementation::new("OwnAssist", "0.0.1"),
|
||||
).await.unwrap();
|
||||
let answer = agent_chat.message("Welche Tools kannst du benutzten?".to_string()).await;
|
||||
let answer = agent_chat.message("Teste beide Server aus. Nutze bei fetch https://example.com/. Melde mir die Ergebnisse zurück.".to_string()).await;
|
||||
|
||||
let mcp_clients = HashMap::from([
|
||||
("fetch".to_string(), fetch_client),
|
||||
]);
|
||||
|
||||
let mut agent_chat = mcp::chat::AgentChat::new(ollama, "ollama:e2b".to_string(), mcp_clients).await.unwrap();
|
||||
log::debug!("chat: {:#?}", agent_chat);
|
||||
agent_chat.message(String::from("Was ist auf der Website https://uno.mboemer.com zu finden?")).await.unwrap();
|
||||
*/
|
||||
|
||||
/*let ollama = Ollama::default();
|
||||
let mut history = vec![
|
||||
ChatMessage::system("Du bist ein Assistent, der per Sprache bedient wird. Du erhälst die Transkription. \
|
||||
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).".to_string())
|
||||
];
|
||||
|
||||
let user_message = vec![
|
||||
ChatMessage::user("Welche Funktionen stehen dir zur Verfügung?".to_string()),
|
||||
];
|
||||
|
||||
let response = ollama.send_chat_messages_with_history(&mut history, ChatMessageRequest::new("gemma4:e2b".to_string(), user_message).tools(vec![])).await.unwrap();
|
||||
|
||||
log::info!("response: {response:?}");
|
||||
log::debug!("history: {history:?}");*/
|
||||
dbg!(answer);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user