chore: update samples make client close (#67)
This commit is contained in:
parent
6085d253d6
commit
9d7bfe6268
29 changed files with 44 additions and 1 deletions
|
|
@ -67,6 +67,8 @@ public class AgentExample {
|
|||
} catch (Exception e) {
|
||||
System.err.println("Exception occurred: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -65,6 +65,8 @@ public class AgentVideoExample {
|
|||
} catch (Exception e) {
|
||||
System.err.println("Exception occurred: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -36,6 +36,8 @@ public class AudioSpeechExample {
|
|||
} catch (Exception e) {
|
||||
System.err.println("Exception occurred: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -52,6 +52,8 @@ public class ChatAsyncCompletionExample {
|
|||
} catch (Exception e) {
|
||||
System.err.println("Exception occurred: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -62,5 +62,6 @@ public class ChatCompletionBase64Example {
|
|||
} else {
|
||||
System.err.println("Error: " + response.getMsg());
|
||||
}
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
|
@ -50,6 +50,8 @@ public class ChatCompletionExample {
|
|||
} catch (Exception e) {
|
||||
System.err.println("Exception occurred: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -48,5 +48,6 @@ public class ChatCompletionMultiFileExample {
|
|||
} else {
|
||||
System.err.println("Error: " + response.getMsg());
|
||||
}
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
|
@ -83,6 +83,8 @@ public class ChatCompletionWithCustomHeadersExample {
|
|||
} catch (Exception e) {
|
||||
System.err.println("Exception occurred: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -70,6 +70,8 @@ public class ChatCompletionWithMcpServerUrlExample {
|
|||
} catch (Exception e) {
|
||||
System.err.println("Exception occurred: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -29,6 +29,7 @@ public class CogVideoX3Example {
|
|||
textToVideoExample(client);
|
||||
imageToVideoExample(client);
|
||||
firstLastFrameVideoExample(client);
|
||||
client.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ public class CogVideoXExample {
|
|||
|
||||
// Basic Video Generation
|
||||
generateBasicVideo(client);
|
||||
client.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -55,6 +55,8 @@ public class CustomTimeoutExample {
|
|||
} catch (Exception e) {
|
||||
System.err.println("Exception occurred: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -43,6 +43,8 @@ public class EmbeddingsExample {
|
|||
} catch (Exception e) {
|
||||
System.err.println("Embedding exception: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,6 +34,8 @@ public class FileParsingExample {
|
|||
} catch (Exception e) {
|
||||
System.err.println("Exception occurred: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@ public class FileParsingSyncExample {
|
|||
} catch (Exception e) {
|
||||
System.err.println("Exception occurred: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -85,5 +85,6 @@ public class FunctionCallingExample {
|
|||
} else {
|
||||
System.err.println("Error: " + response.getMsg());
|
||||
}
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
|
@ -47,6 +47,7 @@ public class GLM41VThinkingExample {
|
|||
} else {
|
||||
System.err.println("Error: " + response.getMsg());
|
||||
}
|
||||
client.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,5 +55,6 @@ public class GLM45VExample {
|
|||
} else {
|
||||
System.err.println("Error: " + response.getMsg());
|
||||
}
|
||||
client.chat();
|
||||
}
|
||||
}
|
||||
|
|
@ -45,5 +45,6 @@ public class GLM4VPlusExample {
|
|||
} else {
|
||||
System.err.println("Error: " + response.getMsg());
|
||||
}
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,9 @@ public class HandwritingOcrExample {
|
|||
} catch (Exception e) {
|
||||
System.err.println("Exception occurred: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -24,5 +24,6 @@ public class ImageGenerationExample {
|
|||
.build();
|
||||
ImageResponse response = client.images().createImage(request);
|
||||
System.out.println(response.getData());
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
|
@ -23,6 +23,7 @@ public class ModerationExample {
|
|||
// Example 2: Image moderation
|
||||
System.out.println("\n=== Image Moderation Example ===");
|
||||
moderateImage(client);
|
||||
client.close();
|
||||
}
|
||||
|
||||
private static void moderateText(ZaiClient client) {
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ public class ViduAspectVideoExample {
|
|||
ZaiClient client = ZaiClient.builder().build();
|
||||
|
||||
generateVideoStartEnd(client);
|
||||
client.close();
|
||||
}
|
||||
|
||||
private static void generateVideoStartEnd(ZaiClient client) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public class ViduImageToVideoExample {
|
|||
ZaiClient client = ZaiClient.builder().build();
|
||||
|
||||
generateVideoFromImage(client);
|
||||
client.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ public class ViduStartEndVideoExample {
|
|||
ZaiClient client = ZaiClient.builder().build();
|
||||
|
||||
generateVideoStartEnd(client);
|
||||
client.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ public class ViduTextToVideoExample {
|
|||
|
||||
// Example: Generate video from text using Vidu
|
||||
generateVideoFromText(client);
|
||||
client.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -48,6 +48,8 @@ public class VoiceCloneExample {
|
|||
} catch (Exception e) {
|
||||
System.err.println("Exception occurred: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -75,6 +75,8 @@ public class WebReaderExample {
|
|||
catch (Exception e) {
|
||||
System.err.println("Exception occurred: " + e.getMessage());
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -34,6 +34,7 @@ public class WebSearchExample {
|
|||
|
||||
// Example 1: Basic Web Search
|
||||
basicWebSearch(client);
|
||||
client.close();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue