1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// <auto-generated by typra-emitter>
// Code generated by Typra emitter; DO NOT EDIT.
#![allow(
unused_imports,
dead_code,
non_camel_case_types,
unused_variables,
clippy::all
)]
use super::super::conversation::message::Message;
use super::super::agent::prompty::Prompty;
use super::super::conversation::tool_call::ToolCall;
/// Calls an LLM provider with messages and returns the raw provider response.
#[async_trait::async_trait]
pub trait Executor: Send + Sync {
/// Call an LLM provider with messages and return the raw response
async fn execute(
&self,
agent: &Prompty,
messages: &Vec<Message>,
) -> Result<serde_json::Value, Box<dyn std::error::Error + Send + Sync>>;
/// Call an LLM provider and return a streaming response. Returns a language-specific async iterable/stream of raw chunks. Not all providers support streaming; the default implementation should signal lack of support.
async fn execute_stream(
&self,
agent: &Prompty,
messages: &Vec<Message>,
) -> Result<serde_json::Value, Box<dyn std::error::Error + Send + Sync>> {
Err("not supported".into())
}
/// Format tool call results into messages for the next iteration
fn format_tool_messages(
&self,
raw_response: &serde_json::Value,
tool_calls: &Vec<ToolCall>,
tool_results: &Vec<String>,
text_content: &Option<String>,
) -> Vec<Message>;
}