inline assistant: Use tools and remove insertion mode (#44248)
Co-authored by: Mikayla Maki <mikayla.c.maki@gmail.com> Co-authored-by: Danilo Leal <daniloleal09@gmail.com> Release Notes: - N/A
This commit is contained in:
@@ -707,6 +707,40 @@ pub trait LanguageModel: Send + Sync {
|
||||
.boxed()
|
||||
}
|
||||
|
||||
fn stream_completion_tool(
|
||||
&self,
|
||||
request: LanguageModelRequest,
|
||||
cx: &AsyncApp,
|
||||
) -> BoxFuture<'static, Result<LanguageModelToolUse, LanguageModelCompletionError>> {
|
||||
let future = self.stream_completion(request, cx);
|
||||
|
||||
async move {
|
||||
let events = future.await?;
|
||||
let mut events = events.fuse();
|
||||
|
||||
// Iterate through events until we find a complete ToolUse
|
||||
while let Some(event) = events.next().await {
|
||||
match event {
|
||||
Ok(LanguageModelCompletionEvent::ToolUse(tool_use))
|
||||
if tool_use.is_input_complete =>
|
||||
{
|
||||
return Ok(tool_use);
|
||||
}
|
||||
Err(err) => {
|
||||
return Err(err);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
// Stream ended without a complete tool use
|
||||
Err(LanguageModelCompletionError::Other(anyhow::anyhow!(
|
||||
"Stream ended without receiving a complete tool use"
|
||||
)))
|
||||
}
|
||||
.boxed()
|
||||
}
|
||||
|
||||
fn cache_configuration(&self) -> Option<LanguageModelCacheConfiguration> {
|
||||
None
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user