@serenity-star/sdk 2.4.0 → 2.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@serenity-star/sdk",
3
- "version": "2.4.0",
3
+ "version": "2.4.2",
4
4
  "description": "The Serenity Star JavaScript SDK provides a convenient way to interact with the Serenity Star API, enabling you to build custom applications.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
package/readme.md CHANGED
@@ -31,6 +31,7 @@ The Serenity Star JS/TS SDK provides a comprehensive interface for interacting w
31
31
  - [Execute a chat completion](#execute-a-chat-completion)
32
32
  - [Stream responses with SSE](#stream-responses-with-sse-2)
33
33
  - [Shared Features](#shared-features)
34
+ - [Stop Streaming Response](#stop-streaming-response)
34
35
  - [Upload Files (Volatile Knowledge)](#upload-files-volatile-knowledge)
35
36
  - [Audio Input](#audio-input)
36
37
  - [Send Audio Messages (Assistants/Copilots)](#send-audio-messages-assistantscopilots)
@@ -584,6 +585,50 @@ console.log(
584
585
 
585
586
  # Shared Features
586
587
 
588
+ ## Stop Streaming Response
589
+
590
+ You can stop a streaming response at any time by calling `stop()`. This works across all agent types: **Assistants**, **Copilots**, **Activities**, **Proxies**, and **Chat Completions**.
591
+
592
+ ```tsx
593
+ import SerenityClient from '@serenity-star/sdk';
594
+
595
+ const client = new SerenityClient({
596
+ apiKey: '<SERENITY_API_KEY>',
597
+ });
598
+
599
+ // Stop a streaming conversation (Assistants / Copilots)
600
+ const conversation = await client.agents.assistants.createConversation("chef-assistant");
601
+
602
+ conversation
603
+ .on("content", (chunk) => {
604
+ console.log(chunk);
605
+
606
+ // Stop the stream based on any condition
607
+ if (shouldStop) {
608
+ conversation.stop();
609
+ }
610
+ });
611
+
612
+ await conversation.streamMessage("Tell me a long story about pasta");
613
+
614
+ // Stop a streaming activity (Activities / Proxies / Chat Completions)
615
+ const activity = client.agents.activities.create("translator-activity", {
616
+ inputParameters: {
617
+ targetLanguage: "russian",
618
+ textToTranslate: "hello world"
619
+ }
620
+ })
621
+ .on("content", (chunk) => {
622
+ console.log(chunk);
623
+
624
+ if (shouldStop) {
625
+ activity.stop();
626
+ }
627
+ });
628
+
629
+ await activity.stream();
630
+ ```
631
+
587
632
  ## Upload Files (Volatile Knowledge)
588
633
 
589
634
  Upload files to be used as context in your agent executions. This feature is available for all agent types: **Assistants**, **Copilots**, **Activities**, **Proxies**, and **Chat Completions**. Files are automatically included in the next message or execution.