Skip to content

Commit 32b6f26

Browse files
AlexMikhalevclaude
andcommitted
fix(doctests): fix failing doctests in zai module and tool_base
Mark zai usage example as `ignore` since it requires runtime setup. Fix tool_base schema doctest to include `use serde_json::json` import. Run cargo fmt to fix whitespace in test files. Refs #1 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b247e44 commit 32b6f26

16 files changed

Lines changed: 23 additions & 50 deletions

src/adapter/adapters/zai/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
//!
2020
//! ## For example
2121
//!
22-
//! ```rust
22+
//! ```rust,ignore
2323
//! use genai::resolver::{Endpoint, ServiceTargetResolver};
2424
//! use genai::{Client, AdapterKind, ModelIden};
2525
//!
2626
//! let client = Client::builder().with_service_target_resolver(target_resolver).build();
2727
//!
2828
//! // Use regular API
29-
//! let response = client.exec_chat("glm-4.6", chat_request, None).await?;
29+
//! let response = client.exec_chat("glm-4.6", chat_request.clone(), None).await?;
3030
//! // Same, regular API
31-
//! let response = client.exec_chat("zai::glm-4.6", chat_request, None).await?;
31+
//! let response = client.exec_chat("zai::glm-4.6", chat_request.clone(), None).await?;
3232
//!
3333
//! // Use coding plan
3434
//! let response = client.exec_chat("zai-coding::glm-4.6", chat_request, None).await?;

src/chat/tool/tool_base.rs

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,25 +15,26 @@ pub struct Tool {
1515
/// JSON Schema for the tool parameters.
1616
/// Example:
1717
/// ```rust
18-
/// json!({
19-
/// "type": "object",
20-
/// "properties": {
21-
/// "city": {
22-
/// "type": "string",
23-
/// "description": "The city name"
24-
/// },
25-
/// "country": {
26-
/// "type": "string",
27-
/// "description": "The most likely country of this city name"
28-
/// },
29-
/// "unit": {
30-
/// "type": "string",
31-
/// "enum": ["C", "F"],
32-
/// "description": "The temperature unit for the country. C for Celsius, and F for Fahrenheit"
33-
/// }
34-
/// },
35-
/// "required": ["city", "country", "unit"],
36-
/// })
18+
/// use serde_json::json;
19+
/// let schema = json!({
20+
/// "type": "object",
21+
/// "properties": {
22+
/// "city": {
23+
/// "type": "string",
24+
/// "description": "The city name"
25+
/// },
26+
/// "country": {
27+
/// "type": "string",
28+
/// "description": "The most likely country of this city name"
29+
/// },
30+
/// "unit": {
31+
/// "type": "string",
32+
/// "enum": ["C", "F"],
33+
/// "description": "The temperature unit for the country. C for Celsius, and F for Fahrenheit"
34+
/// }
35+
/// },
36+
/// "required": ["city", "country", "unit"],
37+
/// });
3738
/// ```
3839
pub schema: Option<Value>,
3940

tests/tests_p_anthropic.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,6 @@ async fn test_chat_stop_sequences_ok() -> TestResult<()> {
7474
// endregion: --- Chat
7575

7676
// region: --- Chat Explicit Cache
77-
7877
#[tokio::test]
7978
#[ignore]
8079
#[serial(anthropic)]
@@ -142,7 +141,6 @@ async fn test_chat_stream_capture_all_ok() -> TestResult<()> {
142141
// async fn test_chat_image_url_ok() -> TestResult<()> {
143142
// common_tests::common_test_chat_image_url_ok(MODEL).await
144143
// }
145-
146144
#[tokio::test]
147145
#[ignore]
148146
async fn test_chat_binary_image_b64_ok() -> TestResult<()> {

tests/tests_p_deepseek.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ async fn test_chat_stream_capture_all_ok() -> TestResult<()> {
100100
// endregion: --- Binary Tests
101101

102102
// region: --- Resolver Tests
103-
104103
#[tokio::test]
105104
#[ignore]
106105
async fn test_resolver_auth_ok() -> TestResult<()> {

tests/tests_p_deepseek_reasoning.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ async fn test_chat_multi_system_ok() -> TestResult<()> {
2727
// async fn test_chat_json_mode_ok() -> TestResult<()> {
2828
// common_tests::common_test_chat_json_mode_ok(MODEL, true).await
2929
// }
30-
3130
#[tokio::test]
3231
#[ignore]
3332
async fn test_chat_temperature_ok() -> TestResult<()> {

tests/tests_p_fireworks.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ async fn test_chat_stop_sequences_ok() -> TestResult<()> {
6767
// endregion: --- Chat Implicit Cache
6868

6969
// region: --- Chat Stream Tests
70-
7170
#[tokio::test]
7271
#[ignore]
7372
async fn test_chat_stream_simple_ok() -> TestResult<()> {
@@ -95,7 +94,6 @@ async fn test_chat_stream_capture_all_ok() -> TestResult<()> {
9594
// async fn test_chat_binary_image_url_ok() -> TestResult<()> {
9695
// common_tests::common_test_chat_image_url_ok(MODEL_IMAGE).await
9796
// }
98-
9997
#[tokio::test]
10098
#[ignore]
10199
async fn test_chat_binary_image_b64_ok() -> TestResult<()> {
@@ -119,7 +117,6 @@ async fn test_chat_binary_image_b64_ok() -> TestResult<()> {
119117
// endregion: --- Binary Tests
120118

121119
// region: --- Tool Tests
122-
123120
#[tokio::test]
124121
#[ignore]
125122
async fn test_tool_simple_ok() -> TestResult<()> {

tests/tests_p_gemini.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ async fn test_chat_stop_sequences_ok() -> TestResult<()> {
7676
// endregion: --- Chat Implicit Cache
7777

7878
// region: --- Chat Stream Tests
79-
8079
#[tokio::test]
8180
#[ignore]
8281
async fn test_chat_stream_simple_ok() -> TestResult<()> {
@@ -105,7 +104,6 @@ async fn test_chat_stream_capture_all_ok() -> TestResult<()> {
105104
// async fn test_chat_binary_image_url_ok() -> TestResult<()> {
106105
// common_tests::common_test_chat_image_url_ok(MODEL).await
107106
// }
108-
109107
#[tokio::test]
110108
#[ignore]
111109
async fn test_chat_binary_image_b64_ok() -> TestResult<()> {

tests/tests_p_groq_reasoning.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ async fn test_chat_multi_system_ok() -> TestResult<()> {
3030
// async fn test_chat_json_mode_ok() -> TestResult<()> {
3131
// common_tests::common_test_chat_json_mode_ok(MODEL, Some(Check::USAGE)).await
3232
// }
33-
3433
#[tokio::test]
3534
#[ignore]
3635
async fn test_chat_temperature_ok() -> TestResult<()> {

tests/tests_p_ollama.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ async fn test_chat_stream_capture_content_ok() -> TestResult<()> {
7777
// endregion: --- Chat Stream Tests
7878

7979
// region: --- Tool Tests
80-
8180
#[tokio::test]
8281
#[ignore]
8382
async fn test_tool_simple_ok() -> TestResult<()> {
@@ -124,7 +123,6 @@ async fn test_tool_full_flow_ok() -> TestResult<()> {
124123
// endregion: --- Binary Tests
125124

126125
// region: --- Resolver Tests
127-
128126
#[tokio::test]
129127
#[ignore]
130128
async fn test_resolver_auth_ok() -> TestResult<()> {

tests/tests_p_ollama_reasoning.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,6 @@ async fn test_chat_stream_non_empty_chunk_deepseek_ok() -> TestResult<()> {
156156
// endregion: --- Chat Stream Tests
157157

158158
// region: --- Resolver Tests
159-
160159
#[tokio::test]
161160
#[ignore]
162161
#[serial(ollama)]

0 commit comments

Comments
 (0)