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-execution",
|
||||
"g3-providers",
|
||||
"llama_cpp",
|
||||
"rand",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"shellexpand",
|
||||
"thiserror 1.0.69",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
@@ -1052,12 +1050,14 @@ dependencies = [
|
||||
"chrono",
|
||||
"dirs 5.0.1",
|
||||
"futures-util",
|
||||
"llama_cpp",
|
||||
"nanoid",
|
||||
"reqwest",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_urlencoded",
|
||||
"sha2",
|
||||
"shellexpand",
|
||||
"thiserror 1.0.69",
|
||||
"tokio",
|
||||
"tokio-stream",
|
||||
|
||||
@@ -474,5 +474,3 @@ Keep your response concise and focused on actionable items.",
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
use std::io::Write;
|
||||
@@ -34,7 +34,7 @@ impl SimpleOutput {
|
||||
self.mad_skin.print_text(markdown);
|
||||
}
|
||||
|
||||
pub fn print_status(&self, status: &str) {
|
||||
pub fn _print_status(&self, status: &str) {
|
||||
println!("📊 {}", status);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,8 +18,6 @@ serde_json = { workspace = true }
|
||||
uuid = { workspace = true }
|
||||
async-trait = "0.1"
|
||||
tokio-stream = "0.1"
|
||||
llama_cpp = { version = "0.3.2", features = ["metal"] }
|
||||
shellexpand = "3.1"
|
||||
tokio-util = "0.7"
|
||||
futures-util = "0.3"
|
||||
chrono = { version = "0.4", features = ["serde"] }
|
||||
|
||||
@@ -408,7 +408,6 @@ mod tests {
|
||||
let truncated = truncate_for_logging(long_text, 20);
|
||||
assert!(truncated.starts_with("This is a very long "));
|
||||
assert!(truncated.contains("truncated"));
|
||||
assert!(truncated.contains("total chars"));
|
||||
assert!(truncated.contains("total bytes"));
|
||||
}
|
||||
|
||||
|
||||
@@ -348,7 +348,7 @@ impl Agent {
|
||||
if let Some(embedded_config) = &config.providers.embedded {
|
||||
if config.providers.default_provider == "embedded" {
|
||||
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_type.clone(),
|
||||
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
|
||||
self.context_window.update_usage(&mock_usage);
|
||||
|
||||
// Add assistant response to context window
|
||||
let assistant_message = Message {
|
||||
role: MessageRole::Assistant,
|
||||
content: response_content.clone(),
|
||||
};
|
||||
self.context_window.add_message(assistant_message);
|
||||
// Add assistant response to context window only if not empty
|
||||
// This prevents the "Skipping empty message" warning when only tools were executed
|
||||
if !response_content.trim().is_empty() {
|
||||
let assistant_message = Message {
|
||||
role: MessageRole::Assistant,
|
||||
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
|
||||
self.save_context_window("completed");
|
||||
@@ -2450,10 +2455,6 @@ fn fix_mixed_quotes_in_json(json_str: &str) -> String {
|
||||
result
|
||||
}
|
||||
|
||||
pub mod providers {
|
||||
pub mod embedded;
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::parse_unified_diff_hunks;
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
|
||||
@@ -27,3 +27,5 @@ nanoid = "0.4"
|
||||
serde_urlencoded = "0.7"
|
||||
tokio-util = "0.7"
|
||||
dirs = "5.0"
|
||||
llama_cpp = { version = "0.3.2", features = ["metal"] }
|
||||
shellexpand = "3.1"
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
//! max_tokens: Some(1000),
|
||||
//! temperature: Some(0.7),
|
||||
//! stream: false,
|
||||
//! tools: None,
|
||||
//! };
|
||||
//!
|
||||
//! // Get a completion
|
||||
@@ -74,6 +75,7 @@
|
||||
//! max_tokens: Some(1000),
|
||||
//! temperature: Some(0.7),
|
||||
//! stream: true,
|
||||
//! tools: None,
|
||||
//! };
|
||||
//!
|
||||
//! let mut stream = provider.stream(request).await?;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use anyhow::Result;
|
||||
use g3_providers::{
|
||||
use crate::{
|
||||
CompletionChunk, CompletionRequest, CompletionResponse, CompletionStream, LLMProvider, Message,
|
||||
MessageRole, Usage,
|
||||
};
|
||||
@@ -85,10 +85,12 @@ pub struct Tool {
|
||||
|
||||
pub mod anthropic;
|
||||
pub mod databricks;
|
||||
pub mod embedded;
|
||||
pub mod oauth;
|
||||
|
||||
pub use anthropic::AnthropicProvider;
|
||||
pub use databricks::DatabricksProvider;
|
||||
pub use embedded::EmbeddedProvider;
|
||||
|
||||
/// Provider registry for managing multiple LLM providers
|
||||
pub struct ProviderRegistry {
|
||||
|
||||
Reference in New Issue
Block a user