adk_studio/schema/
agent.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct AgentSchema {
6 #[serde(rename = "type")]
7 pub agent_type: AgentType,
8 #[serde(default)]
9 pub model: Option<String>,
10 #[serde(default)]
11 pub instruction: String,
12 #[serde(default)]
13 pub tools: Vec<String>,
14 #[serde(default)]
15 pub sub_agents: Vec<String>,
16 #[serde(default)]
17 pub position: Position,
18 #[serde(default)]
19 pub max_iterations: Option<u32>,
20 #[serde(default, skip_serializing_if = "Option::is_none")]
22 pub temperature: Option<f32>,
23 #[serde(default, skip_serializing_if = "Option::is_none")]
25 pub top_p: Option<f32>,
26 #[serde(default, skip_serializing_if = "Option::is_none")]
28 pub top_k: Option<i32>,
29 #[serde(default, skip_serializing_if = "Option::is_none")]
31 pub max_output_tokens: Option<i32>,
32 #[serde(default)]
34 pub routes: Vec<Route>,
35}
36
37#[derive(Debug, Clone, Serialize, Deserialize)]
39pub struct Route {
40 pub condition: String,
41 pub target: String,
42}
43
44impl AgentSchema {
45 pub fn llm(model: impl Into<String>) -> Self {
46 Self {
47 agent_type: AgentType::Llm,
48 model: Some(model.into()),
49 instruction: String::new(),
50 tools: Vec::new(),
51 sub_agents: Vec::new(),
52 position: Position::default(),
53 max_iterations: None,
54 temperature: None,
55 top_p: None,
56 top_k: None,
57 max_output_tokens: None,
58 routes: Vec::new(),
59 }
60 }
61
62 pub fn with_instruction(mut self, instruction: impl Into<String>) -> Self {
63 self.instruction = instruction.into();
64 self
65 }
66
67 pub fn with_tools(mut self, tools: Vec<String>) -> Self {
68 self.tools = tools;
69 self
70 }
71
72 pub fn with_position(mut self, x: f64, y: f64) -> Self {
73 self.position = Position { x, y };
74 self
75 }
76}
77
78#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
80#[serde(rename_all = "snake_case")]
81pub enum AgentType {
82 Llm,
83 Tool,
84 Sequential,
85 Parallel,
86 Loop,
87 Router,
88 Graph,
89 Custom,
90}
91
92#[derive(Debug, Clone, Serialize, Deserialize, Default)]
94pub struct Position {
95 pub x: f64,
96 pub y: f64,
97}