AIConnector

Trait AIConnector 

Source
pub trait AIConnector: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn build_request(
        &self,
        trace: &Trace,
        api_key: &str,
    ) -> Result<AIRequest, TramexError>;
    fn parse_response(&self, response_body: &str) -> Result<String, TramexError>;
}
Expand description

Trait abstracting an AI chatbot connector.

Implementations build the HTTP request and parse the response. The actual HTTP call is handled by the UI layer (using ehttp).

Required Methods§

Source

fn name(&self) -> &'static str

Human-readable name of the AI provider

Source

fn build_request( &self, trace: &Trace, api_key: &str, ) -> Result<AIRequest, TramexError>

Build the HTTP request for explaining a trace.

§Arguments
  • trace - The trace to explain
  • api_key - The API key for authentication
§Errors

Returns an error if the request cannot be built

Source

fn parse_response(&self, response_body: &str) -> Result<String, TramexError>

Parse the API response body into a human-readable explanation.

§Arguments
  • response_body - The raw JSON response from the API
§Errors

Returns an error if the response cannot be parsed

Implementors§