prompty 2.0.0-beta.1

Prompty is an asset class and format for LLM prompts
Documentation
// Code generated by Prompty 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>;
}