alexa-ai 2.1.1
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 +136 -0
- package/LICENSE +15 -0
- package/README.md +862 -0
- package/examples/bot-ai.js +531 -0
- package/examples/demo.js +147 -0
- package/index.js +75 -0
- package/package.json +50 -0
- package/src/AlexaAI.js +1099 -0
- package/src/core/Config.js +249 -0
- package/src/core/DeepAIClient.js +789 -0
- package/src/core/Endpoints.js +74 -0
- package/src/core/Persona.js +102 -0
- package/src/core/StreamParser.js +157 -0
- package/src/core/SystemPrompt.js +7 -0
- package/src/core/errors.js +51 -0
- package/src/db/Database.js +161 -0
- package/src/db/schema.sql +214 -0
- package/src/repositories/ConversationRepository.js +206 -0
- package/src/repositories/IdentityRepository.js +244 -0
- package/src/repositories/MemoryRepository.js +215 -0
- package/src/repositories/UserRepository.js +275 -0
- package/src/services/AmnesiaGuard.js +176 -0
- package/src/services/FactMiner.js +151 -0
- package/src/services/IdentityGuard.js +203 -0
- package/src/services/IdentityResolver.js +179 -0
- package/src/services/ImageDescriber.js +335 -0
- package/src/services/MathDetector.js +64 -0
- package/src/services/MemoryExtractor.js +142 -0
- package/src/services/PromptBuilder.js +216 -0
- package/src/services/ResponseFormatter.js +121 -0
- package/src/services/TriggerDetector.js +182 -0
- package/src/services/WebAnswer.js +573 -0
- package/src/utils/JidParser.js +148 -0
- package/src/utils/Media.js +235 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `alexa-ai` are documented here. The format follows
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project uses
|
|
5
|
+
[Semantic Versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [2.1.1] — 2026-09-06
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
- `searchWeb()` returned one or two sentences with a `Sources:` list dumped
|
|
11
|
+
inside `text` and an empty `sources` array. The prompt asked for *"a short,
|
|
12
|
+
direct answer"*, and sources were only read from DeepAI's structured
|
|
13
|
+
web-results packet, which some models (`gpt-4o-mini`) never send — they
|
|
14
|
+
write the list as prose instead. The method now asks for a long-form,
|
|
15
|
+
sectioned answer (intro, 3–5 `*Heading:*` sections with numbered
|
|
16
|
+
`*Title*: detail` points, ~300–450 words), lifts any `Sources:` list,
|
|
17
|
+
inline `(Source: url)` citation or trailing link lines out of the prose
|
|
18
|
+
into `sources`, merges them with the packet (de-duplicated by URL), and
|
|
19
|
+
renders one `*Sources:*` block at the end of `text`.
|
|
20
|
+
- Sentences in which the model talks about itself — *"I'm a large language
|
|
21
|
+
model"*, *"I don't have the ability to browse the web"*, *"based on my
|
|
22
|
+
training data"* — are removed from web answers. Third-party mentions of AI
|
|
23
|
+
companies in the research itself are kept verbatim: `IdentityGuard.sanitise()`
|
|
24
|
+
gained a `{ vendors: false }` mode used for research output.
|
|
25
|
+
- `IdentityGuard.sanitise()` could drop the first letter of a reply that began
|
|
26
|
+
with "A" after repairing it (a character-class typo in the clean-up regex).
|
|
27
|
+
- The example scripts no longer embed a real DeepAI key; `examples/demo.js`
|
|
28
|
+
requires `DEEPAI_KEY` (or `DEEPAI_API_KEY`) in the environment.
|
|
29
|
+
|
|
30
|
+
### Added
|
|
31
|
+
- `searchWeb()` hands the model the layout as a fill-in template and, when a
|
|
32
|
+
long-form answer still comes back under `minWords` (default 150), asks once
|
|
33
|
+
for a full rewrite and keeps the longer reply. Leftover `<placeholder>`
|
|
34
|
+
tokens are dropped.
|
|
35
|
+
- `searchWeb()` options: `detail: 'short' | 'long'` (default `long`),
|
|
36
|
+
`minWords`, `includeSources`, `maxSources`, `language`, `instructions`.
|
|
37
|
+
- `searchWeb()` result fields `answer` (the prose without the sources block),
|
|
38
|
+
`words` and `attempts`.
|
|
39
|
+
- `WebAnswer` service (exported) — the prompt, the sources parser, the
|
|
40
|
+
disclaimer filter and the renderer, so a host bot can reuse them on its own
|
|
41
|
+
text.
|
|
42
|
+
|
|
43
|
+
## [2.1.0] — 2026-09-06
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
- `Media` utility: one normaliser for every media input shape — `Buffer`,
|
|
47
|
+
`Uint8Array`, `ArrayBuffer`, data URI, raw base64, `http(s)` URL and
|
|
48
|
+
`{ buffer | base64 | data | url }` objects. Content type is sniffed from the
|
|
49
|
+
bytes when missing or mislabelled. Used by `chat({ image })`, `ask()`,
|
|
50
|
+
`describeImage()`, `upscaleImage()`, `editImage()`, `colorizeImage()` and
|
|
51
|
+
`detectNsfw()`, so Baileys and whatsapp-web.js media objects work as-is.
|
|
52
|
+
- `generateImage()` falls back to DeepAI's in-chat `generate_image` tool when
|
|
53
|
+
`/api/text2img` is refused, so image generation works on free `tryit-…`
|
|
54
|
+
keys. The result reports the route used (`via: 'api' | 'chat'`); new
|
|
55
|
+
options `apiOnly`, `chatToolOnly`, `aspectRatio`.
|
|
56
|
+
- `summarizeText()` falls back to a stateless chat request when
|
|
57
|
+
`/api/summarization` is refused.
|
|
58
|
+
- `colorizeImage()`, `isBlocked()` and `isGroupEnabled()` on the engine.
|
|
59
|
+
- `AlexaAI.version` and `AlexaAI.methods()` so a host application can verify
|
|
60
|
+
the installed build at startup.
|
|
61
|
+
- `describeImage()` now returns a WhatsApp-ready `text` alongside the raw
|
|
62
|
+
`description`.
|
|
63
|
+
- `detectNsfw()` returns a boolean `nsfw` verdict (`threshold` option,
|
|
64
|
+
default 0.7) alongside the score.
|
|
65
|
+
- `test/wrapper-methods.js`: every method exposed to the bot, run against a
|
|
66
|
+
mock of DeepAI's free tier and — with `POSTGRES_URL` — a real database.
|
|
67
|
+
- `CHANGELOG.md`, `LICENSE`, `files` whitelist in `package.json`.
|
|
68
|
+
|
|
69
|
+
### Fixed
|
|
70
|
+
- `blockUser()`, `unblockUser()` and `setGroupEnabled()` matched the canonical
|
|
71
|
+
jid only. Blocking a person by the `@lid` seen in a group (when their row
|
|
72
|
+
was created from a DM phone jid), or muting a group Alexa had not yet
|
|
73
|
+
spoken in, returned `null` and silently did nothing. They now follow the
|
|
74
|
+
alias graph, create the row for pre-emptive blocks and mutes, and throw
|
|
75
|
+
`ValidationError` for the wrong jid kind.
|
|
76
|
+
- `describeImage(buffer)` reported `unreadable` for a bare `Buffer`.
|
|
77
|
+
- `upscaleImage()` / `editImage()` / `detectNsfw()` given `{ base64 }` or a
|
|
78
|
+
raw base64 string uploaded no image at all.
|
|
79
|
+
- `runApi()` treated `{"status": "Out of API credits"}` (HTTP 200) as a
|
|
80
|
+
successful response with `url: null`; such bodies are now errors and quota
|
|
81
|
+
wording maps to `DEEPAI_QUOTA_EXCEEDED`.
|
|
82
|
+
- `/api/*` uploads now carry a real content type and filename; URL inputs are
|
|
83
|
+
sent as plain fields instead of being dropped.
|
|
84
|
+
- `searchWeb()` rejects an empty query instead of sending a bare prompt,
|
|
85
|
+
passes replies through `IdentityGuard`, normalises `sources` to
|
|
86
|
+
`{ title, url, description }`, and never throws.
|
|
87
|
+
- `chat()` accepts `file`, `media` and `attachment` as aliases of `image`.
|
|
88
|
+
|
|
89
|
+
### Changed
|
|
90
|
+
- `examples/bot-ai.js` updated to the bot's current wrapper, with a startup
|
|
91
|
+
engine-version check and simplified media handling (the engine now
|
|
92
|
+
normalises everything except local file paths).
|
|
93
|
+
- `npm test` runs both suites.
|
|
94
|
+
- README rewritten as reference documentation.
|
|
95
|
+
|
|
96
|
+
## [2.0.0] — 2026-09-05
|
|
97
|
+
|
|
98
|
+
### Added
|
|
99
|
+
- Cross-chat identity: `wa_user_identities` alias graph, `IdentityResolver`,
|
|
100
|
+
automatic row merging, `linkIdentity()`, `getAliases()`, `whoIs()`,
|
|
101
|
+
`mergeUsers()`. A person is one row whether they write from a DM phone jid
|
|
102
|
+
or a group `@lid`.
|
|
103
|
+
- `AmnesiaGuard`: a `[MEMORY CHECK]` directive on recall questions and
|
|
104
|
+
deterministic repair of *"as a bot I can't remember"* replies from the
|
|
105
|
+
database.
|
|
106
|
+
- `IdentityGuard`: identity lock on identity questions and post-flight
|
|
107
|
+
scrubbing of vendor names, model-tier renames (`Alexa Mini`) and
|
|
108
|
+
self-denials.
|
|
109
|
+
- `StreamParser`: splits DeepAI's streamed body into text, tool activity,
|
|
110
|
+
web results, generated images and chain-of-thought.
|
|
111
|
+
- Full DeepAI endpoint surface in `DeepAIClient`: reasoning tasks,
|
|
112
|
+
attachments, sessions, account settings, `/api/*`. Routes live in an
|
|
113
|
+
overridable `endpoints` map.
|
|
114
|
+
- Vision provider chain (document extraction → DeepAI vision → OCR → honest
|
|
115
|
+
fallback) with a per-model fallback list, a cooldown instead of a permanent
|
|
116
|
+
latch, and attachment passthrough to the real conversation.
|
|
117
|
+
- `FactMiner`: local first-person fact extraction as a safety net when the
|
|
118
|
+
model omits the `@MEMORY` tag.
|
|
119
|
+
- Key rotation on quota refusals; optional anonymous key minting.
|
|
120
|
+
|
|
121
|
+
### Fixed
|
|
122
|
+
- `attachment_uuids` is sent as a top-level form field; inside a message
|
|
123
|
+
object it forced DeepAI to downgrade the request to a text-only model.
|
|
124
|
+
- Control characters, JSON packets and model reasoning no longer reach
|
|
125
|
+
WhatsApp.
|
|
126
|
+
|
|
127
|
+
## [1.0.0]
|
|
128
|
+
|
|
129
|
+
Initial release: DeepAI chat with the Alexa persona, PostgreSQL-backed
|
|
130
|
+
memory and conversation history, deterministic command triggers and
|
|
131
|
+
WhatsApp output formatting.
|
|
132
|
+
|
|
133
|
+
[2.1.1]: https://github.com/AlexaInc/deepai/compare/v2.1.0...v2.1.1
|
|
134
|
+
[2.1.0]: https://github.com/AlexaInc/deepai/compare/v2.0.0...v2.1.0
|
|
135
|
+
[2.0.0]: https://github.com/AlexaInc/deepai/compare/v1.0.0...v2.0.0
|
|
136
|
+
[1.0.0]: https://github.com/AlexaInc/deepai/releases/tag/v1.0.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Hansaka
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|