bitrouter_core/models/language/generate_result.rs
1use http::HeaderMap;
2
3use crate::models::shared::{
4 provider::ProviderMetadata, types::TimestampMillis, warnings::Warning,
5};
6
7use super::{
8 content::LanguageModelContent, finish_reason::LanguageModelFinishReason,
9 usage::LanguageModelUsage,
10};
11
12/// Represents the result of a Language Model generation.
13#[derive(Debug, Clone)]
14pub struct LanguageModelGenerateResult {
15 /// The generated content
16 pub content: LanguageModelContent,
17 /// The finish reason, if the generation is complete
18 pub finish_reason: LanguageModelFinishReason,
19 /// The usage information for this generation
20 pub usage: LanguageModelUsage,
21 /// Provider-specific metadata for this generation result
22 pub provider_metadata: Option<ProviderMetadata>,
23 /// The original request that led to this generation result, if available
24 pub request: Option<LanguageModelRawRequest>,
25 /// The original response from the provider, if available
26 pub response_metadata: Option<LanguageModelRawResponse>,
27 /// Any warnings related to this generation result
28 pub warnings: Option<Vec<Warning>>,
29}
30
31/// Represents the raw request sent to a Language Model provider.
32#[derive(Debug, Clone)]
33pub struct LanguageModelRawRequest {
34 /// The request headers as a map of header name to value
35 pub headers: Option<HeaderMap>,
36 /// The request body as JSON value
37 pub body: serde_json::Value,
38}
39
40/// Represents the raw response received from a Language Model provider.
41#[derive(Debug, Clone)]
42pub struct LanguageModelRawResponse {
43 /// The unique identifier for this response
44 pub id: Option<String>,
45 /// The timestamp when the response was received, in milliseconds since the Unix epoch
46 pub timestamp: Option<TimestampMillis>,
47 /// The model identifier used for this response
48 pub model_id: Option<String>,
49 /// The response headers as a map of header name to value
50 pub headers: Option<HeaderMap>,
51 /// The response body as JSON value
52 pub body: Option<serde_json::Value>,
53}