hank9999 commited on
Commit
ba31618
·
1 Parent(s): 9ab6db4

refactor: 移除无用的模型方法及测试

Browse files
Files changed (1) hide show
  1. src/kiro/model/common/types.rs +0 -186
src/kiro/model/common/types.rs CHANGED
@@ -17,23 +17,6 @@ pub struct ContentSpan {
17
  pub end: i32,
18
  }
19
 
20
- impl ContentSpan {
21
- /// 创建新的内容范围
22
- pub fn new(start: i32, end: i32) -> Self {
23
- Self { start, end }
24
- }
25
-
26
- /// 获取范围长度
27
- pub fn len(&self) -> i32 {
28
- self.end - self.start
29
- }
30
-
31
- /// 判断范围是否为空
32
- pub fn is_empty(&self) -> bool {
33
- self.start >= self.end
34
- }
35
- }
36
-
37
  /// 补充网页链接
38
  ///
39
  /// 助手响应中包含的相关网页链接
@@ -53,36 +36,6 @@ pub struct SupplementaryWebLink {
53
  pub score: Option<f64>,
54
  }
55
 
56
- impl SupplementaryWebLink {
57
- /// 创建新的网页链接
58
- pub fn new(url: impl Into<String>) -> Self {
59
- Self {
60
- url: url.into(),
61
- title: None,
62
- snippet: None,
63
- score: None,
64
- }
65
- }
66
-
67
- /// 设置标题
68
- pub fn with_title(mut self, title: impl Into<String>) -> Self {
69
- self.title = Some(title.into());
70
- self
71
- }
72
-
73
- /// 设置摘要
74
- pub fn with_snippet(mut self, snippet: impl Into<String>) -> Self {
75
- self.snippet = Some(snippet.into());
76
- self
77
- }
78
-
79
- /// 设置评分
80
- pub fn with_score(mut self, score: f64) -> Self {
81
- self.score = Some(score);
82
- self
83
- }
84
- }
85
-
86
  /// 最相关的错过的替代方案
87
  ///
88
  /// 当存在更好的替代方案时,提供相关信息
@@ -99,17 +52,6 @@ pub struct MostRelevantMissedAlternative {
99
  pub repository: Option<String>,
100
  }
101
 
102
- impl MostRelevantMissedAlternative {
103
- /// 创建新的替代方案
104
- pub fn new(url: impl Into<String>) -> Self {
105
- Self {
106
- url: url.into(),
107
- license_name: None,
108
- repository: None,
109
- }
110
- }
111
- }
112
-
113
  /// 代码引用
114
  ///
115
  /// 助手响应中引用的代码来源信息
@@ -148,24 +90,6 @@ impl Reference {
148
  most_relevant_missed_alternative: None,
149
  }
150
  }
151
-
152
- /// 设置许可证名称
153
- pub fn with_license_name(mut self, name: impl Into<String>) -> Self {
154
- self.license_name = Some(name.into());
155
- self
156
- }
157
-
158
- /// 设置仓库名称
159
- pub fn with_repository(mut self, repo: impl Into<String>) -> Self {
160
- self.repository = Some(repo.into());
161
- self
162
- }
163
-
164
- /// 设置 URL
165
- pub fn with_url(mut self, url: impl Into<String>) -> Self {
166
- self.url = Some(url.into());
167
- self
168
- }
169
  }
170
 
171
  impl Default for Reference {
@@ -187,22 +111,6 @@ pub struct FollowupPrompt {
187
  pub user_intent: Option<UserIntent>,
188
  }
189
 
190
- impl FollowupPrompt {
191
- /// 创建新的后续提示
192
- pub fn new(content: impl Into<String>) -> Self {
193
- Self {
194
- content: content.into(),
195
- user_intent: None,
196
- }
197
- }
198
-
199
- /// 设置用户意图
200
- pub fn with_user_intent(mut self, intent: UserIntent) -> Self {
201
- self.user_intent = Some(intent);
202
- self
203
- }
204
- }
205
-
206
  /// 编程语言
207
  ///
208
  /// 表示代码的编程语言信息
@@ -213,15 +121,6 @@ pub struct ProgrammingLanguage {
213
  pub language_name: String,
214
  }
215
 
216
- impl ProgrammingLanguage {
217
- /// 创建新的编程语言
218
- pub fn new(name: impl Into<String>) -> Self {
219
- Self {
220
- language_name: name.into(),
221
- }
222
- }
223
- }
224
-
225
  /// 定制化配置
226
  ///
227
  /// 自定义模型配置信息
@@ -249,56 +148,10 @@ pub struct CodeQuery {
249
  #[serde(skip_serializing_if = "Option::is_none")]
250
  pub user_input_message_id: Option<String>,
251
  }
252
-
253
- impl CodeQuery {
254
- /// 创建新的代码查询
255
- pub fn new(code_query_id: impl Into<String>) -> Self {
256
- Self {
257
- code_query_id: code_query_id.into(),
258
- programming_language: None,
259
- user_input_message_id: None,
260
- }
261
- }
262
-
263
- /// 设置编程语言
264
- pub fn with_programming_language(mut self, lang: ProgrammingLanguage) -> Self {
265
- self.programming_language = Some(lang);
266
- self
267
- }
268
-
269
- /// 设置用户输入消息 ID
270
- pub fn with_user_input_message_id(mut self, id: impl Into<String>) -> Self {
271
- self.user_input_message_id = Some(id.into());
272
- self
273
- }
274
- }
275
-
276
  #[cfg(test)]
277
  mod tests {
278
  use super::*;
279
 
280
- #[test]
281
- fn test_content_span() {
282
- let span = ContentSpan::new(10, 20);
283
- assert_eq!(span.len(), 10);
284
- assert!(!span.is_empty());
285
-
286
- let empty_span = ContentSpan::new(5, 5);
287
- assert!(empty_span.is_empty());
288
- }
289
-
290
- #[test]
291
- fn test_supplementary_web_link_serialize() {
292
- let link = SupplementaryWebLink::new("https://example.com")
293
- .with_title("Example")
294
- .with_score(0.95);
295
-
296
- let json = serde_json::to_string(&link).unwrap();
297
- assert!(json.contains("\"url\":\"https://example.com\""));
298
- assert!(json.contains("\"title\":\"Example\""));
299
- assert!(json.contains("\"score\":0.95"));
300
- }
301
-
302
  #[test]
303
  fn test_supplementary_web_link_deserialize() {
304
  let json = r#"{"url":"https://test.com","title":"Test","snippet":"A test link","score":0.8}"#;
@@ -308,43 +161,4 @@ mod tests {
308
  assert_eq!(link.snippet, Some("A test link".to_string()));
309
  assert_eq!(link.score, Some(0.8));
310
  }
311
-
312
- #[test]
313
- fn test_reference_builder() {
314
- let reference = Reference::new()
315
- .with_license_name("MIT")
316
- .with_repository("example/repo")
317
- .with_url("https://github.com/example/repo");
318
-
319
- assert_eq!(reference.license_name, Some("MIT".to_string()));
320
- assert_eq!(reference.repository, Some("example/repo".to_string()));
321
- }
322
-
323
- #[test]
324
- fn test_followup_prompt_serialize() {
325
- let prompt = FollowupPrompt::new("How can I improve this code?")
326
- .with_user_intent(UserIntent::ImproveCode);
327
-
328
- let json = serde_json::to_string(&prompt).unwrap();
329
- assert!(json.contains("\"content\":\"How can I improve this code?\""));
330
- assert!(json.contains("\"userIntent\":\"IMPROVE_CODE\""));
331
- }
332
-
333
- #[test]
334
- fn test_programming_language() {
335
- let lang = ProgrammingLanguage::new("rust");
336
- let json = serde_json::to_string(&lang).unwrap();
337
- assert_eq!(json, r#"{"languageName":"rust"}"#);
338
- }
339
-
340
- #[test]
341
- fn test_code_query() {
342
- let query = CodeQuery::new("query-123")
343
- .with_programming_language(ProgrammingLanguage::new("python"))
344
- .with_user_input_message_id("msg-456");
345
-
346
- let json = serde_json::to_string(&query).unwrap();
347
- assert!(json.contains("\"codeQueryId\":\"query-123\""));
348
- assert!(json.contains("\"languageName\":\"python\""));
349
- }
350
  }
 
17
  pub end: i32,
18
  }
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  /// 补充网页链接
21
  ///
22
  /// 助手响应中包含的相关网页链接
 
36
  pub score: Option<f64>,
37
  }
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  /// 最相关的错过的替代方案
40
  ///
41
  /// 当存在更好的替代方案时,提供相关信息
 
52
  pub repository: Option<String>,
53
  }
54
 
 
 
 
 
 
 
 
 
 
 
 
55
  /// 代码引用
56
  ///
57
  /// 助手响应中引用的代码来源信息
 
90
  most_relevant_missed_alternative: None,
91
  }
92
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
94
 
95
  impl Default for Reference {
 
111
  pub user_intent: Option<UserIntent>,
112
  }
113
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
114
  /// 编程语言
115
  ///
116
  /// 表示代码的编程语言信息
 
121
  pub language_name: String,
122
  }
123
 
 
 
 
 
 
 
 
 
 
124
  /// 定制化配置
125
  ///
126
  /// 自定义模型配置信息
 
148
  #[serde(skip_serializing_if = "Option::is_none")]
149
  pub user_input_message_id: Option<String>,
150
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
  #[cfg(test)]
152
  mod tests {
153
  use super::*;
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  #[test]
156
  fn test_supplementary_web_link_deserialize() {
157
  let json = r#"{"url":"https://test.com","title":"Test","snippet":"A test link","score":0.8}"#;
 
161
  assert_eq!(link.snippet, Some("A test link".to_string()));
162
  assert_eq!(link.score, Some(0.8));
163
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
164
  }