@sahan-sac/chat-kit 0.2.0 → 0.3.0
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/CHANGELOG.md +13 -0
- package/README.md +4 -2
- package/dist/handler.js +4 -1
- package/dist/prompts.js +6 -1
- package/dist/types.d.ts +2 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @sahan-sac/chat-kit
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- f465908: Owner guidance and per-post steering. `BlogSiteProfile.guidance` and `ChatSite.guidance` add the site owner's standing guidance to every blog, SEO, helper and chatbot prompt, after the fixed rules. `BlogGenerationInput` takes optional `instructions` (up to `MAX_INSTRUCTIONS_LENGTH`, 2,000 characters) and `resources` (pasted reference text, up to `MAX_RESOURCES_LENGTH`, 12,000), both fenced as untrusted data: resources are used as facts, never as instructions, and nothing is fetched from a link.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [b9d2dd6]
|
|
12
|
+
- Updated dependencies [4fa21e3]
|
|
13
|
+
- Updated dependencies [f465908]
|
|
14
|
+
- @sahan-sac/ai-core@0.3.0
|
|
15
|
+
|
|
3
16
|
## 0.2.0
|
|
4
17
|
|
|
5
18
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -35,7 +35,9 @@ Only `handler` imports `server-only`. The other subpaths are pure, and `session-
|
|
|
35
35
|
Uses `@sahan-sac/ai-core`'s variables; see its README for the full table. The chatbot runs only when `chatbotEnabled(env)` from `@sahan-sac/ai-core/availability` is true:
|
|
36
36
|
|
|
37
37
|
- `ENABLE_CHATBOT` is on. It defaults to `true`; `false`, `0`, `no` or `off` turns it off.
|
|
38
|
-
- At least one
|
|
38
|
+
- At least one provider can answer chat: its key is set, it is in `AI_PROVIDER_ORDER_CHAT` (or `AI_PROVIDER_ORDER`) when one is set, and a paid one also has `AI_ALLOW_PAID=true`.
|
|
39
|
+
|
|
40
|
+
The chat chain falls through providers on any failure (quota, timeout, bad key, bad output), so one provider's outage does not stop the chatbot. Set `AI_PROVIDER_ORDER_CHAT` to choose which providers answer and in what order; see `@sahan-sac/ai-core`'s README.
|
|
39
41
|
|
|
40
42
|
When the chatbot is off, return 503 from the route and do not render the widget.
|
|
41
43
|
|
|
@@ -51,7 +53,7 @@ const result = await runChat(
|
|
|
51
53
|
history: await store.getRecentMessages(sessionId, 10),
|
|
52
54
|
knowledge: await getKnowledge(), // cached by the app
|
|
53
55
|
config: { tone: "professional" },
|
|
54
|
-
site: chatSite,
|
|
56
|
+
site: { ...chatSite, guidance: ownerGuidance }, // optional: added after the fixed rules
|
|
55
57
|
siteHostname: new URL(env.SITE_URL).hostname,
|
|
56
58
|
extraHosts: ["wa.me", "t.me"],
|
|
57
59
|
},
|
package/dist/handler.js
CHANGED
|
@@ -66,6 +66,7 @@ function knowledgeHosts(knowledge) {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
// src/prompts.ts
|
|
69
|
+
import { guidanceSection } from "@sahan-sac/ai-core/guard";
|
|
69
70
|
function toneDescription(tone, site) {
|
|
70
71
|
const kind = site.kind ?? "site";
|
|
71
72
|
switch (tone) {
|
|
@@ -134,7 +135,9 @@ Use markdown formatting for readability:`,
|
|
|
134
135
|
`
|
|
135
136
|
- Use inline links like ${linkExample}.`,
|
|
136
137
|
`
|
|
137
|
-
- Structure responses with short paragraphs, not walls of text
|
|
138
|
+
- Structure responses with short paragraphs, not walls of text.`,
|
|
139
|
+
// The owner's standing guidance (AI context settings): after the fixed rules, which it cannot override.
|
|
140
|
+
guidanceSection(site.guidance)
|
|
138
141
|
];
|
|
139
142
|
if (knowledge) {
|
|
140
143
|
systemParts.push("\n\n<<<BEGIN_REFERENCE_DATA>>>\n");
|
package/dist/prompts.js
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// src/prompts.ts
|
|
2
|
+
import { guidanceSection } from "@sahan-sac/ai-core/guard";
|
|
3
|
+
|
|
1
4
|
// src/guard.ts
|
|
2
5
|
import { wrapUserData, looksLikeLeak } from "@sahan-sac/ai-core/guard";
|
|
3
6
|
function guardUserMessage(message) {
|
|
@@ -73,7 +76,9 @@ Use markdown formatting for readability:`,
|
|
|
73
76
|
`
|
|
74
77
|
- Use inline links like ${linkExample}.`,
|
|
75
78
|
`
|
|
76
|
-
- Structure responses with short paragraphs, not walls of text
|
|
79
|
+
- Structure responses with short paragraphs, not walls of text.`,
|
|
80
|
+
// The owner's standing guidance (AI context settings): after the fixed rules, which it cannot override.
|
|
81
|
+
guidanceSection(site.guidance)
|
|
77
82
|
];
|
|
78
83
|
if (knowledge) {
|
|
79
84
|
systemParts.push("\n\n<<<BEGIN_REFERENCE_DATA>>>\n");
|
package/dist/types.d.ts
CHANGED
|
@@ -26,6 +26,8 @@ interface ChatSite {
|
|
|
26
26
|
scope?: string;
|
|
27
27
|
/** How the assistant should format a site link, e.g. "[Project Name](/works) when referencing portfolio content". */
|
|
28
28
|
linkExample?: string;
|
|
29
|
+
/** Standing guidance from the owner (voice, facts, do and don't), appended after the fixed rules. Empty adds nothing. */
|
|
30
|
+
guidance?: string;
|
|
29
31
|
}
|
|
30
32
|
/** One earlier turn of the conversation, oldest first. */
|
|
31
33
|
interface ChatTurn {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sahan-sac/chat-kit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Headless chatbot core for the portfolio site: guarded prompt building, prompt-injection and output-link guards, an anonymous-visitor rate-limit cookie, a knowledge-base builder that tolerates a failing source, and runChat, the pure request/response path behind /api/chat. Depends on @sahan-sac/ai-core; never on @sahan-sac/blog-kit or @sahan-sac/media-kit.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"types": "./dist/index.d.ts",
|
|
62
62
|
"main": "./dist/index.js",
|
|
63
63
|
"dependencies": {
|
|
64
|
-
"@sahan-sac/ai-core": "^0.
|
|
64
|
+
"@sahan-sac/ai-core": "^0.3.0",
|
|
65
65
|
"server-only": "^0.0.1"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|