Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ahau-square committed Jan 7, 2025
1 parent 6c21f7b commit 3ca25e7
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 34 deletions.
13 changes: 4 additions & 9 deletions crates/goose-cli/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ use std::fs;
use std::path::PathBuf;
use tracing_appender::rolling::Rotation;
use tracing_subscriber::{
fmt,
Layer,
layer::SubscriberExt,
util::SubscriberInitExt,
EnvFilter,
filter::LevelFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer,
Registry,
filter::LevelFilter,
};

use goose::tracing::langfuse_layer;
Expand Down Expand Up @@ -83,8 +78,8 @@ pub fn setup_logging() -> Result<()> {

// Build the subscriber with required layers
let subscriber = Registry::default()
.with(file_layer.with_filter(env_filter)) // Gets all logs
.with(console_layer.with_filter(LevelFilter::INFO)); // Controls log levels
.with(file_layer.with_filter(env_filter)) // Gets all logs
.with(console_layer.with_filter(LevelFilter::INFO)); // Controls log levels

// Initialize with Langfuse if available
if let Some(langfuse) = langfuse_layer::create_langfuse_observer() {
Expand All @@ -99,4 +94,4 @@ pub fn setup_logging() -> Result<()> {
}

Ok(())
}
}
6 changes: 3 additions & 3 deletions crates/goose-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ mod commands {
pub mod version;
}
pub mod agents;
mod logging;
mod profile;
mod prompt;
pub mod session;
mod logging;

mod systems;

Expand All @@ -16,9 +16,9 @@ use clap::{Parser, Subcommand};
use commands::configure::handle_configure;
use commands::session::build_session;
use commands::version::print_version;
use logging::setup_logging;
use profile::has_no_profiles;
use std::io::{self, Read};
use logging::setup_logging;

mod log_usage;

Expand Down Expand Up @@ -198,7 +198,7 @@ enum CliProviderVariant {
#[tokio::main]
async fn main() -> Result<()> {
setup_logging();

let cli = Cli::parse();

if cli.version {
Expand Down
13 changes: 4 additions & 9 deletions crates/goose-server/src/logging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,8 @@ use std::fs;
use std::path::PathBuf;
use tracing_appender::rolling::Rotation;
use tracing_subscriber::{
fmt,
Layer,
layer::SubscriberExt,
util::SubscriberInitExt,
EnvFilter,
filter::LevelFilter, fmt, layer::SubscriberExt, util::SubscriberInitExt, EnvFilter, Layer,
Registry,
filter::LevelFilter,
};

use goose::tracing::langfuse_layer;
Expand Down Expand Up @@ -84,8 +79,8 @@ pub fn setup_logging() -> Result<()> {

// Build the subscriber with required layers
let subscriber = Registry::default()
.with(file_layer)
.with(console_layer.with_filter(env_filter));
.with(file_layer)
.with(console_layer.with_filter(env_filter));

// Initialize with Langfuse if available
if let Some(langfuse) = langfuse_layer::create_langfuse_observer() {
Expand All @@ -100,4 +95,4 @@ pub fn setup_logging() -> Result<()> {
}

Ok(())
}
}
2 changes: 1 addition & 1 deletion crates/goose-server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ async fn main() -> anyhow::Result<()> {
info!("listening on {}", listener.local_addr()?);
axum::serve(listener, app).await?;
Ok(())
}
}
20 changes: 11 additions & 9 deletions crates/goose/src/agent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,12 @@ impl Agent {
let system_tool_call = ToolCall::new(tool_name, call.arguments);
let result = system.call(system_tool_call.clone()).await;

debug!("input"=serde_json::to_string(&system_tool_call).unwrap(),
"output"=serde_json::to_string(&result).unwrap(),
debug!(
"input" = serde_json::to_string(&system_tool_call).unwrap(),
"output" = serde_json::to_string(&result).unwrap(),
);

result
result
}

fn get_system_prompt(&self) -> AgentResult<String> {
Expand Down Expand Up @@ -345,13 +346,14 @@ impl Agent {
let reply_span = tracing::Span::current();
let mut messages = messages.to_vec();
let tools = self.get_prefixed_tools();

// Set the user_message field in the span instead of creating a new event
if let Some(content) = messages.last()
if let Some(content) = messages
.last()
.and_then(|msg| msg.content.first())
.and_then(|c| c.as_text())
.and_then(|c| c.as_text())
{
debug!("user_message"=&content);
debug!("user_message" = &content);
}

let system_prompt = self.get_system_prompt()?;
Expand All @@ -371,7 +373,7 @@ impl Agent {

Ok(Box::pin(async_stream::try_stream! {
let _reply_guard = reply_span.enter();

loop {
// Get completion from provider
let (response, usage) = self.provider.complete(
Expand Down Expand Up @@ -408,7 +410,7 @@ impl Agent {
})
.collect();



// Process all the futures in parallel but wait until all are finished
let outputs = futures::future::join_all(futures)
Expand Down
16 changes: 13 additions & 3 deletions crates/goose/src/providers/databricks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ use crate::providers::openai_utils::{
openai_response_to_message, tools_to_openai_spec,
};
use mcp_core::tool::Tool;
use tracing::{debug};

use tracing::debug;

pub const DATABRICKS_DEFAULT_MODEL: &str = "claude-3-5-sonnet-2";

Expand Down Expand Up @@ -76,7 +75,18 @@ impl Provider for DatabricksProvider {
self.config.model_config()
}

#[tracing::instrument(skip(self, system, messages, tools), fields(model_config, input, output, input_tokens, output_tokens, total_tokens, cost))]
#[tracing::instrument(
skip(self, system, messages, tools),
fields(
model_config,
input,
output,
input_tokens,
output_tokens,
total_tokens,
cost
)
)]
async fn complete(
&self,
system: &str,
Expand Down

0 comments on commit 3ca25e7

Please sign in to comment.