move embedded provider to a better crate
This commit is contained in:
4
Cargo.lock
generated
4
Cargo.lock
generated
@@ -1014,12 +1014,10 @@ dependencies = [
|
|||||||
"g3-config",
|
"g3-config",
|
||||||
"g3-execution",
|
"g3-execution",
|
||||||
"g3-providers",
|
"g3-providers",
|
||||||
"llama_cpp",
|
|
||||||
"rand",
|
"rand",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"shellexpand",
|
|
||||||
"thiserror 1.0.69",
|
"thiserror 1.0.69",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
@@ -1052,12 +1050,14 @@ dependencies = [
|
|||||||
"chrono",
|
"chrono",
|
||||||
"dirs 5.0.1",
|
"dirs 5.0.1",
|
||||||
"futures-util",
|
"futures-util",
|
||||||
|
"llama_cpp",
|
||||||
"nanoid",
|
"nanoid",
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"serde_urlencoded",
|
"serde_urlencoded",
|
||||||
"sha2",
|
"sha2",
|
||||||
|
"shellexpand",
|
||||||
"thiserror 1.0.69",
|
"thiserror 1.0.69",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
|
|||||||
@@ -473,6 +473,4 @@ Keep your response concise and focused on actionable items.",
|
|||||||
}
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
use std::io::Write;
|
|
||||||
@@ -34,7 +34,7 @@ impl SimpleOutput {
|
|||||||
self.mad_skin.print_text(markdown);
|
self.mad_skin.print_text(markdown);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_status(&self, status: &str) {
|
pub fn _print_status(&self, status: &str) {
|
||||||
println!("📊 {}", status);
|
println!("📊 {}", status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ serde_json = { workspace = true }
|
|||||||
uuid = { workspace = true }
|
uuid = { workspace = true }
|
||||||
async-trait = "0.1"
|
async-trait = "0.1"
|
||||||
tokio-stream = "0.1"
|
tokio-stream = "0.1"
|
||||||
llama_cpp = { version = "0.3.2", features = ["metal"] }
|
|
||||||
shellexpand = "3.1"
|
|
||||||
tokio-util = "0.7"
|
tokio-util = "0.7"
|
||||||
futures-util = "0.3"
|
futures-util = "0.3"
|
||||||
chrono = { version = "0.4", features = ["serde"] }
|
chrono = { version = "0.4", features = ["serde"] }
|
||||||
|
|||||||
@@ -408,7 +408,6 @@ mod tests {
|
|||||||
let truncated = truncate_for_logging(long_text, 20);
|
let truncated = truncate_for_logging(long_text, 20);
|
||||||
assert!(truncated.starts_with("This is a very long "));
|
assert!(truncated.starts_with("This is a very long "));
|
||||||
assert!(truncated.contains("truncated"));
|
assert!(truncated.contains("truncated"));
|
||||||
assert!(truncated.contains("total chars"));
|
|
||||||
assert!(truncated.contains("total bytes"));
|
assert!(truncated.contains("total bytes"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -348,7 +348,7 @@ impl Agent {
|
|||||||
if let Some(embedded_config) = &config.providers.embedded {
|
if let Some(embedded_config) = &config.providers.embedded {
|
||||||
if config.providers.default_provider == "embedded" {
|
if config.providers.default_provider == "embedded" {
|
||||||
info!("Initializing embedded provider (selected as default)");
|
info!("Initializing embedded provider (selected as default)");
|
||||||
let embedded_provider = crate::providers::embedded::EmbeddedProvider::new(
|
let embedded_provider = g3_providers::EmbeddedProvider::new(
|
||||||
embedded_config.model_path.clone(),
|
embedded_config.model_path.clone(),
|
||||||
embedded_config.model_type.clone(),
|
embedded_config.model_type.clone(),
|
||||||
embedded_config.context_length,
|
embedded_config.context_length,
|
||||||
@@ -736,12 +736,17 @@ The tool will execute immediately and you'll receive the result (success or erro
|
|||||||
// Update context window with estimated token usage
|
// Update context window with estimated token usage
|
||||||
self.context_window.update_usage(&mock_usage);
|
self.context_window.update_usage(&mock_usage);
|
||||||
|
|
||||||
// Add assistant response to context window
|
// Add assistant response to context window only if not empty
|
||||||
let assistant_message = Message {
|
// This prevents the "Skipping empty message" warning when only tools were executed
|
||||||
role: MessageRole::Assistant,
|
if !response_content.trim().is_empty() {
|
||||||
content: response_content.clone(),
|
let assistant_message = Message {
|
||||||
};
|
role: MessageRole::Assistant,
|
||||||
self.context_window.add_message(assistant_message);
|
content: response_content.clone(),
|
||||||
|
};
|
||||||
|
self.context_window.add_message(assistant_message);
|
||||||
|
} else {
|
||||||
|
debug!("Assistant response was empty (likely only tool execution), skipping message addition");
|
||||||
|
}
|
||||||
|
|
||||||
// Save context window at the end of successful interaction
|
// Save context window at the end of successful interaction
|
||||||
self.save_context_window("completed");
|
self.save_context_window("completed");
|
||||||
@@ -2450,10 +2455,6 @@ fn fix_mixed_quotes_in_json(json_str: &str) -> String {
|
|||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod providers {
|
|
||||||
pub mod embedded;
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::parse_unified_diff_hunks;
|
use super::parse_unified_diff_hunks;
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
|
|
||||||
@@ -27,3 +27,5 @@ nanoid = "0.4"
|
|||||||
serde_urlencoded = "0.7"
|
serde_urlencoded = "0.7"
|
||||||
tokio-util = "0.7"
|
tokio-util = "0.7"
|
||||||
dirs = "5.0"
|
dirs = "5.0"
|
||||||
|
llama_cpp = { version = "0.3.2", features = ["metal"] }
|
||||||
|
shellexpand = "3.1"
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
//! max_tokens: Some(1000),
|
//! max_tokens: Some(1000),
|
||||||
//! temperature: Some(0.7),
|
//! temperature: Some(0.7),
|
||||||
//! stream: false,
|
//! stream: false,
|
||||||
|
//! tools: None,
|
||||||
//! };
|
//! };
|
||||||
//!
|
//!
|
||||||
//! // Get a completion
|
//! // Get a completion
|
||||||
@@ -74,6 +75,7 @@
|
|||||||
//! max_tokens: Some(1000),
|
//! max_tokens: Some(1000),
|
||||||
//! temperature: Some(0.7),
|
//! temperature: Some(0.7),
|
||||||
//! stream: true,
|
//! stream: true,
|
||||||
|
//! tools: None,
|
||||||
//! };
|
//! };
|
||||||
//!
|
//!
|
||||||
//! let mut stream = provider.stream(request).await?;
|
//! let mut stream = provider.stream(request).await?;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use g3_providers::{
|
use crate::{
|
||||||
CompletionChunk, CompletionRequest, CompletionResponse, CompletionStream, LLMProvider, Message,
|
CompletionChunk, CompletionRequest, CompletionResponse, CompletionStream, LLMProvider, Message,
|
||||||
MessageRole, Usage,
|
MessageRole, Usage,
|
||||||
};
|
};
|
||||||
@@ -85,10 +85,12 @@ pub struct Tool {
|
|||||||
|
|
||||||
pub mod anthropic;
|
pub mod anthropic;
|
||||||
pub mod databricks;
|
pub mod databricks;
|
||||||
|
pub mod embedded;
|
||||||
pub mod oauth;
|
pub mod oauth;
|
||||||
|
|
||||||
pub use anthropic::AnthropicProvider;
|
pub use anthropic::AnthropicProvider;
|
||||||
pub use databricks::DatabricksProvider;
|
pub use databricks::DatabricksProvider;
|
||||||
|
pub use embedded::EmbeddedProvider;
|
||||||
|
|
||||||
/// Provider registry for managing multiple LLM providers
|
/// Provider registry for managing multiple LLM providers
|
||||||
pub struct ProviderRegistry {
|
pub struct ProviderRegistry {
|
||||||
|
|||||||
Reference in New Issue
Block a user