Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 21 additions & 1 deletion crates/goose/src/agents/summarize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use async_trait::async_trait;
use futures::stream::BoxStream;
use std::collections::HashMap;
use std::sync::Arc;
use tokio::sync::mpsc;
use tokio::sync::Mutex;
use tracing::{debug, error, instrument, warn};
Expand All @@ -20,6 +21,7 @@ use crate::providers::base::Provider;
use crate::providers::base::ProviderUsage;
use crate::providers::errors::ProviderError;
use crate::register_agent;
use crate::session;
use crate::token_counter::TokenCounter;
use crate::truncate::{truncate_messages, OldestFirstTruncation};
use anyhow::{anyhow, Result};
Expand Down Expand Up @@ -164,6 +166,7 @@ impl Agent for SummarizeAgent {
async fn reply(
&self,
messages: &[Message],
session_id: Option<session::Identifier>,
) -> anyhow::Result<BoxStream<'_, anyhow::Result<Message>>> {
let mut messages = messages.to_vec();
let reply_span = tracing::Span::current();
Expand Down Expand Up @@ -240,7 +243,19 @@ impl Agent for SummarizeAgent {
&tools,
).await {
Ok((response, usage)) => {
capabilities.record_usage(usage).await;
capabilities.record_usage(usage.clone()).await;

// record usage for the session in the session file
if let Some(session_id) = session_id.clone() {
// TODO: track session_id in langfuse tracing
let session_file = session::get_path(session_id);
let mut metadata = session::read_metadata(&session_file)?;
metadata.total_tokens = usage.usage.total_tokens;
// The message count is the number of messages in the session + 1 for the response
// The message count does not include the tool response till next iteration
metadata.message_count = messages.len() + 1;
session::update_metadata(&session_file, &metadata).await?;
}

// Reset truncation attempt
truncation_attempt = 0;
Expand Down Expand Up @@ -452,6 +467,11 @@ impl Agent for SummarizeAgent {

Err(anyhow!("Prompt '{}' not found", name))
}

async fn provider(&self) -> Arc<Box<dyn Provider>> {
let capabilities = self.capabilities.lock().await;
capabilities.provider()
}
}

register_agent!("summarize", SummarizeAgent);
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ const fakeProviderState: ProviderState[] = [
isConfigured: false,
metadata: { location: null },
},
{
id: 'gcp_vertex_ai',
name: 'GCP Vertex AI',
isConfigured: true,
metadata: { location: null },
},
];

export default function ProviderSettings({ onClose }: { onClose: () => void }) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import GroqLogo from './icons/groq@3x.png';
import OllamaLogo from './icons/ollama@3x.png';
import DatabricksLogo from './icons/databricks@3x.png';
import OpenRouterLogo from './icons/openrouter@3x.png';
import DefaultLogo from './icons/default@3x.png';

// Map provider names to their logos
const providerLogos = {
Expand All @@ -16,12 +17,13 @@ const providerLogos = {
ollama: OllamaLogo,
databricks: DatabricksLogo,
openrouter: OpenRouterLogo,
default: DefaultLogo,
};

export default function ProviderLogo({ providerName }) {
// Convert provider name to lowercase and fetch the logo
const logoKey = providerName.toLowerCase();
const logo = providerLogos[logoKey] || OpenAILogo; // TODO: need default icon
const logo = providerLogos[logoKey] || DefaultLogo;

return (
<div className="flex justify-center mb-2">
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading