Get tests working
Co-authored-by: Antonio Scandurra <me@as-cii.com>
This commit is contained in:
parent
63b625236d
commit
970b5fe06e
3 changed files with 776 additions and 1002 deletions
|
@ -920,10 +920,7 @@ pub struct ToolCallEventStream {
|
||||||
|
|
||||||
impl ToolCallEventStream {
|
impl ToolCallEventStream {
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub fn test() -> (
|
pub fn test() -> (Self, ToolCallEventStreamReceiver) {
|
||||||
Self,
|
|
||||||
mpsc::UnboundedReceiver<Result<AgentResponseEvent, LanguageModelCompletionError>>,
|
|
||||||
) {
|
|
||||||
let (events_tx, events_rx) =
|
let (events_tx, events_rx) =
|
||||||
mpsc::unbounded::<Result<AgentResponseEvent, LanguageModelCompletionError>>();
|
mpsc::unbounded::<Result<AgentResponseEvent, LanguageModelCompletionError>>();
|
||||||
|
|
||||||
|
@ -939,7 +936,7 @@ impl ToolCallEventStream {
|
||||||
AgentResponseEventStream(events_tx),
|
AgentResponseEventStream(events_tx),
|
||||||
);
|
);
|
||||||
|
|
||||||
(stream, events_rx)
|
(stream, ToolCallEventStreamReceiver(events_rx))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn new(
|
fn new(
|
||||||
|
@ -975,3 +972,36 @@ impl ToolCallEventStream {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
pub struct ToolCallEventStreamReceiver(
|
||||||
|
mpsc::UnboundedReceiver<Result<AgentResponseEvent, LanguageModelCompletionError>>,
|
||||||
|
);
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
impl ToolCallEventStreamReceiver {
|
||||||
|
pub async fn expect_tool_authorization(&mut self) -> ToolCallAuthorization {
|
||||||
|
let event = self.0.next().await;
|
||||||
|
if let Some(Ok(AgentResponseEvent::ToolCallAuthorization(auth))) = event {
|
||||||
|
auth
|
||||||
|
} else {
|
||||||
|
panic!("Expected ToolCallAuthorization but got: {:?}", event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
impl std::ops::Deref for ToolCallEventStreamReceiver {
|
||||||
|
type Target = mpsc::UnboundedReceiver<Result<AgentResponseEvent, LanguageModelCompletionError>>;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
impl std::ops::DerefMut for ToolCallEventStreamReceiver {
|
||||||
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
||||||
|
&mut self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -29,7 +29,6 @@ use serde::{Deserialize, Serialize};
|
||||||
use std::{cmp, iter, mem, ops::Range, path::PathBuf, pin::Pin, sync::Arc, task::Poll};
|
use std::{cmp, iter, mem, ops::Range, path::PathBuf, pin::Pin, sync::Arc, task::Poll};
|
||||||
use streaming_diff::{CharOperation, StreamingDiff};
|
use streaming_diff::{CharOperation, StreamingDiff};
|
||||||
use streaming_fuzzy_matcher::StreamingFuzzyMatcher;
|
use streaming_fuzzy_matcher::StreamingFuzzyMatcher;
|
||||||
use util::debug_panic;
|
|
||||||
|
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
struct CreateFilePromptTemplate {
|
struct CreateFilePromptTemplate {
|
||||||
|
@ -682,11 +681,6 @@ impl EditAgent {
|
||||||
if last_message.content.is_empty() {
|
if last_message.content.is_empty() {
|
||||||
conversation.messages.pop();
|
conversation.messages.pop();
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
debug_panic!(
|
|
||||||
"Last message must be an Assistant tool calling! Got {:?}",
|
|
||||||
last_message.content
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue