Wrapping up bedrock implementation
This commit is contained in:
@@ -13,13 +13,13 @@ pub use convert_from::{
|
||||
pub use r#impl::generate_multi_agent_output;
|
||||
|
||||
use futures_lite::Stream;
|
||||
use galaxy_core::channel::ChannelState;
|
||||
use galaxy_core::execution_mode::AppExecutionMode;
|
||||
use galaxy_core::features::FeatureFlag;
|
||||
use serde::Serialize;
|
||||
use std::path::Path;
|
||||
use std::pin::Pin;
|
||||
use std::sync::Arc;
|
||||
use galaxy_core::channel::ChannelState;
|
||||
use galaxy_core::execution_mode::AppExecutionMode;
|
||||
use galaxy_core::features::FeatureFlag;
|
||||
|
||||
use crate::ai::agent::conversation::AIConversationId;
|
||||
use crate::ai::ambient_agents::AmbientAgentTaskId;
|
||||
@@ -137,7 +137,8 @@ pub struct RequestParams {
|
||||
/// Populated by the Bedrock path after building the message list.
|
||||
/// Contains the full messages sent (old history + new input) so the controller
|
||||
/// can store them back into the conversation for the next request cycle.
|
||||
pub bedrock_messages_sent: std::sync::Arc<std::sync::Mutex<Vec<crate::ai::bedrock::convert::ConversationMessage>>>,
|
||||
pub bedrock_messages_sent:
|
||||
std::sync::Arc<std::sync::Mutex<Vec<crate::ai::bedrock::convert::ConversationMessage>>>,
|
||||
}
|
||||
|
||||
pub type Event = Result<warp_multi_agent_api::ResponseEvent, Arc<AIApiError>>;
|
||||
|
||||
@@ -39,10 +39,10 @@ use ai::agent::action_result::{
|
||||
};
|
||||
use ai::skills::ParsedSkill;
|
||||
use chrono::{DateTime, Local, TimeZone};
|
||||
use galaxy_core::command::ExitCode;
|
||||
use persistence::model::AgentConversationData;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
use galaxy_core::command::ExitCode;
|
||||
use warp_multi_agent_api as api;
|
||||
use warp_multi_agent_api::ask_user_question_result::answer_item::Answer as AskUserQuestionAnswer;
|
||||
|
||||
|
||||
@@ -207,9 +207,7 @@ pub async fn generate_multi_agent_output(
|
||||
// immediately after, and that the conversation starts with a
|
||||
// user message. Without this, interrupted tool calls cause
|
||||
// Bedrock ValidationException errors.
|
||||
crate::ai::bedrock::convert_request::sanitize_messages_for_bedrock(
|
||||
&mut messages,
|
||||
);
|
||||
crate::ai::bedrock::convert_request::sanitize_messages_for_bedrock(&mut messages);
|
||||
|
||||
let system_prompt =
|
||||
crate::ai::bedrock::convert_request::extract_system_prompt(&request);
|
||||
@@ -329,7 +327,9 @@ pub async fn generate_multi_agent_output(
|
||||
log::error!("[bedrock] No Bedrock config available and server fallback is disabled. Cannot process request.");
|
||||
let err = Arc::new(crate::server::server_api::AIApiError::Stream {
|
||||
stream_type: "bedrock_converse",
|
||||
source: anyhow::anyhow!("No AI backend available. Please configure Bedrock credentials in Settings > AI."),
|
||||
source: anyhow::anyhow!(
|
||||
"No AI backend available. Please configure Bedrock credentials in Settings > AI."
|
||||
),
|
||||
});
|
||||
let (tx, rx) = async_channel::unbounded();
|
||||
let _ = tx.send(Err(err)).await;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use super::{
|
||||
artifact_from_fork_proto, AIConversation, AIConversationAutoexecuteMode, AIConversationId,
|
||||
AIConversation, AIConversationAutoexecuteMode, AIConversationId, artifact_from_fork_proto,
|
||||
};
|
||||
use crate::ai::artifacts::Artifact;
|
||||
use crate::persistence::model::AgentConversationData;
|
||||
|
||||
+34
-12
@@ -766,11 +766,18 @@ impl Task {
|
||||
.apply()
|
||||
.map_err(UpdateTaskError::from)?;
|
||||
|
||||
let text_len = updated_message.message.as_ref().map(|m| match m {
|
||||
api::message::Message::AgentOutput(o) => o.text.len(),
|
||||
_ => 0,
|
||||
}).unwrap_or(0);
|
||||
log::info!("[bedrock-debug] append_to_message_content: accumulated text_len={}", text_len);
|
||||
let text_len = updated_message
|
||||
.message
|
||||
.as_ref()
|
||||
.map(|m| match m {
|
||||
api::message::Message::AgentOutput(o) => o.text.len(),
|
||||
_ => 0,
|
||||
})
|
||||
.unwrap_or(0);
|
||||
log::info!(
|
||||
"[bedrock-debug] append_to_message_content: accumulated text_len={}",
|
||||
text_len
|
||||
);
|
||||
|
||||
let id = self.id.clone();
|
||||
let exchange_to_update = self
|
||||
@@ -999,12 +1006,24 @@ impl AIAgentExchange {
|
||||
.iter()
|
||||
.position(|m| m.id.0 == task_message.id);
|
||||
|
||||
let proto_text = task_message.message.as_ref().map(|m| match m {
|
||||
api::message::Message::AgentOutput(o) => format!("AgentOutput(text_len={})", o.text.len()),
|
||||
api::message::Message::ToolCall(t) => format!("ToolCall(id={})", t.tool_call_id),
|
||||
other => format!("{:?}", std::mem::discriminant(other)),
|
||||
}).unwrap_or_else(|| "None".to_string());
|
||||
log::info!("[bedrock-debug] upsert_output_for_message: id={}, proto_type={}", task_message.id, proto_text);
|
||||
let proto_text = task_message
|
||||
.message
|
||||
.as_ref()
|
||||
.map(|m| match m {
|
||||
api::message::Message::AgentOutput(o) => {
|
||||
format!("AgentOutput(text_len={})", o.text.len())
|
||||
}
|
||||
api::message::Message::ToolCall(t) => {
|
||||
format!("ToolCall(id={})", t.tool_call_id)
|
||||
}
|
||||
other => format!("{:?}", std::mem::discriminant(other)),
|
||||
})
|
||||
.unwrap_or_else(|| "None".to_string());
|
||||
log::info!(
|
||||
"[bedrock-debug] upsert_output_for_message: id={}, proto_type={}",
|
||||
task_message.id,
|
||||
proto_text
|
||||
);
|
||||
|
||||
match task_message
|
||||
.clone()
|
||||
@@ -1014,7 +1033,10 @@ impl AIAgentExchange {
|
||||
task_id,
|
||||
})? {
|
||||
MaybeAIAgentOutputMessage::Message(m) => {
|
||||
log::info!("[bedrock-debug] upsert_output_for_message: client_message_type={:?}", std::mem::discriminant(&m.message));
|
||||
log::info!(
|
||||
"[bedrock-debug] upsert_output_for_message: client_message_type={:?}",
|
||||
std::mem::discriminant(&m.message)
|
||||
);
|
||||
output.extend_citations(m.citations.clone());
|
||||
if let Some(message_idx) = message_idx {
|
||||
output.messages[message_idx] = m;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use serde::Serialize;
|
||||
use galaxyui::{AppContext, SingletonEntity};
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::ai::llms::LLMId;
|
||||
use crate::CloudModel;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
use crate::ai::blocklist::{BlocklistAIContextEvent, BlocklistAIContextModel};
|
||||
use pathfinder_color::ColorU;
|
||||
use galaxy_core::ui::appearance::Appearance;
|
||||
use galaxy_core::ui::theme::Fill;
|
||||
use galaxyui::elements::{
|
||||
@@ -18,6 +17,7 @@ use galaxyui::{
|
||||
keymap::FixedBinding,
|
||||
AppContext, Element, Entity, EntityId, TypedActionView, View, ViewContext,
|
||||
};
|
||||
use pathfinder_color::ColorU;
|
||||
|
||||
use crate::ai::agent::icons::{in_progress_icon, pending_icon, succeeded_icon};
|
||||
use crate::ai::agent::todos::AIAgentTodoList;
|
||||
|
||||
@@ -5,6 +5,7 @@ use super::{
|
||||
use crate::code::editor_management::CodeSource;
|
||||
use crate::features::FeatureFlag;
|
||||
use ai::gfm_table::{format_gfm_table, maybe_collect_gfm_table_lines};
|
||||
use galaxy_util::path::LineAndColumnArg;
|
||||
use itertools::Itertools;
|
||||
use lazy_static::lazy_static;
|
||||
use markdown_parser::{
|
||||
@@ -13,7 +14,6 @@ use markdown_parser::{
|
||||
use mermaid_to_svg::is_mermaid_diagram;
|
||||
use regex::Regex;
|
||||
use std::{collections::HashMap, path::PathBuf};
|
||||
use galaxy_util::path::LineAndColumnArg;
|
||||
|
||||
lazy_static! {
|
||||
/// Markdown prefix for code blocks. Matches on triple backticks followed by a language.
|
||||
|
||||
Reference in New Issue
Block a user