chat-nest-sdk 1.1.1 → 1.1.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.
Files changed (2) hide show
  1. package/README.md +29 -11
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -45,6 +45,9 @@ import { useAiChat } from "chat-nest-sdk";
45
45
  function App() {
46
46
  const chat = useAiChat({
47
47
  endpoint: "http://localhost:3001/api/chat",
48
+ initialProfile: "balanced",
49
+ dailyTokenLimit: 50_000, // optional: cap daily tokens
50
+ maxTokensPerRequest: 4096, // optional: cap per request
48
51
  });
49
52
 
50
53
  return (
@@ -64,6 +67,11 @@ function App() {
64
67
  <button onClick={chat.cancel}>
65
68
  Cancel
66
69
  </button>
70
+ <select value={chat.profile} onChange={(e) => chat.setProfile(e.target.value)}>
71
+ <option value="constrained">Constrained</option>
72
+ <option value="balanced">Balanced</option>
73
+ <option value="expanded">Expanded</option>
74
+ </select>
67
75
  </>
68
76
  );
69
77
  }
@@ -75,17 +83,27 @@ function App() {
75
83
 
76
84
  ### useAiChat(options)
77
85
 
78
- | Field | Type | Description |
79
- | -------- | ------ | -------------------- |
80
- | endpoint | string | Backend API endpoint |
81
-
82
- | Field | Description |
83
- | ----------------- | ------------------------ |
84
- | messages | Chat message list |
85
- | sendMessage(text) | Sends user message |
86
- | cancel() | Cancels active request |
87
- | isStreaming | Whether stream is active |
88
- | error | Last error |
86
+ | Field | Type | Description |
87
+ | ------------------- | ------ | --------------------------------------------------------------------------- |
88
+ | endpoint | string | Backend API endpoint |
89
+ | initialMessages | Message[] | Optional. Initial messages |
90
+ | maxMessages | number | Optional. Max messages to keep in context (default 10) |
91
+ | initialProfile | AiUsageProfile | Optional. Profile: `constrained`, `balanced`, `expanded` |
92
+ | dailyTokenLimit | number | Optional. Cap daily tokens; server applies min(profile limit, this) |
93
+ | maxTokensPerRequest | number | Optional. Cap tokens per request (input + output); server applies min |
94
+
95
+ ### Return value
96
+
97
+ | Field | Description |
98
+ | ----------------- | ----------------------------- |
99
+ | messages | Chat message list |
100
+ | sendMessage(text) | Sends user message |
101
+ | cancel() | Cancels active request |
102
+ | isStreaming | Whether stream is active |
103
+ | error | Last error |
104
+ | profile | Current profile |
105
+ | setProfile(p) | Set profile; persisted to localStorage |
106
+ | reset() | Reset messages and error |
89
107
 
90
108
  ---
91
109
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "chat-nest-sdk",
3
3
  "description": "Frontend React SDK for consuming streaming AI APIs with cancellation and retry safety.",
4
- "version": "1.1.1",
4
+ "version": "1.1.2",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",