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
//! This module defines the data models used for interacting with different LLM APIs.
//!
//! The main strategy employed to support multiple LLM APIs is to define separate response
//! structs for each API (`AnthropicResponse` and `OpenAIResponse`) and use an enum
//! (`ResponseMessage`) to represent the different response types. The `ResponseMessage` enum
//! provides a unified interface for accessing common fields and methods across different APIs.
//!
//! To add support for a new LLM API:
//! 1. Define a new response struct for the API, implementing the necessary deserialization logic.
//! 2. Add a new variant to the `ResponseMessage` enum for the new API response type.
//! 3. Update the implementation of the `ResponseMessage` methods to handle the new variant and
//! provide the appropriate logic for accessing the fields and data.
//!
//! By following this approach, the `ResponseMessage` enum acts as a common interface for handling
//! responses from different LLM APIs, while the individual response structs encapsulate the
//! specific details of each API's response format.
use ;
/// Represents a message in the conversation.
/// Represents the request body sent to the Anthropic API.