devops_models/llm/
types.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
4pub struct ChatMessage {
5 pub role: String,
6 pub content: String,
7}
8
9#[derive(Debug, Clone, Serialize, Deserialize)]
10pub struct ChatRequest {
11 pub model: String,
12 pub messages: Vec<ChatMessage>,
13 #[serde(default)]
14 pub temperature: Option<f64>,
15 #[serde(default)]
16 pub max_tokens: Option<u32>,
17 #[serde(default)]
18 pub stream: bool,
19}
20
21#[derive(Debug, Clone, Serialize, Deserialize)]
23pub struct ChatResponse {
24 pub id: String,
25 pub choices: Vec<ChatChoice>,
26 #[serde(default)]
27 pub usage: Option<Usage>,
28}
29
30#[derive(Debug, Clone, Serialize, Deserialize)]
31pub struct ChatChoice {
32 pub index: u32,
33 pub message: ChatMessage,
34 #[serde(default)]
35 pub finish_reason: Option<String>,
36}
37
38#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct Usage {
40 pub prompt_tokens: u32,
41 pub completion_tokens: u32,
42 pub total_tokens: u32,
43}
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
47pub struct AnthropicResponse {
48 pub id: String,
49 pub content: Vec<AnthropicContentBlock>,
50 pub model: String,
51 pub stop_reason: Option<String>,
52 #[serde(default)]
53 pub usage: Option<AnthropicUsage>,
54}
55
56#[derive(Debug, Clone, Serialize, Deserialize)]
57#[serde(tag = "type")]
58pub enum AnthropicContentBlock {
59 #[serde(rename = "text")]
60 Text { text: String },
61}
62
63#[derive(Debug, Clone, Serialize, Deserialize)]
64pub struct AnthropicUsage {
65 pub input_tokens: u32,
66 pub output_tokens: u32,
67}
68
69#[derive(Debug, Clone, Serialize, Deserialize)]
71pub struct StreamChunk {
72 pub id: String,
73 pub choices: Vec<StreamChoice>,
74}
75
76#[derive(Debug, Clone, Serialize, Deserialize)]
77pub struct StreamChoice {
78 pub index: u32,
79 pub delta: StreamDelta,
80 #[serde(default)]
81 pub finish_reason: Option<String>,
82}
83
84#[derive(Debug, Clone, Serialize, Deserialize)]
85pub struct StreamDelta {
86 #[serde(default)]
87 pub role: Option<String>,
88 #[serde(default)]
89 pub content: Option<String>,
90}
91
92#[derive(Debug, Deserialize)]
94pub struct AnthropicSseEvent {
95 #[serde(rename = "type")]
96 pub event_type: String,
97 pub delta: Option<AnthropicSseDelta>,
98}
99
100#[derive(Debug, Deserialize)]
101pub struct AnthropicSseDelta {
102 #[serde(rename = "type")]
103 pub delta_type: Option<String>,
104 pub text: Option<String>,
105}