catalyst-ai 0.1.0 → 0.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/README.md +70 -0
- package/package.json +8 -1
- package/android/.gradle/8.9/checksums/checksums.lock +0 -0
- package/android/.gradle/8.9/dependencies-accessors/gc.properties +0 -0
- package/android/.gradle/8.9/fileChanges/last-build.bin +0 -0
- package/android/.gradle/8.9/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/8.9/gc.properties +0 -0
- package/android/.gradle/9.2.0/checksums/checksums.lock +0 -0
- package/android/.gradle/9.2.0/fileChanges/last-build.bin +0 -0
- package/android/.gradle/9.2.0/fileHashes/fileHashes.bin +0 -0
- package/android/.gradle/9.2.0/fileHashes/fileHashes.lock +0 -0
- package/android/.gradle/9.2.0/gc.properties +0 -0
- package/android/.gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0
- package/android/.gradle/buildOutputCleanup/cache.properties +0 -2
- package/android/.gradle/vcs-1/gc.properties +0 -0
package/README.md
CHANGED
|
@@ -3,6 +3,76 @@
|
|
|
3
3
|
Multi-provider AI integration for catalyst-core apps — OpenAI/Gemini SSE routes plus
|
|
4
4
|
`useCloudAI`, `useWebAI`, and `useNativeAI` React hooks.
|
|
5
5
|
|
|
6
|
+
> **Requires `catalyst-core` as a peer dependency.** This package does not work standalone —
|
|
7
|
+
> `catalyst-core`'s `useAI` hook loads it via `require("catalyst-ai")` at runtime, and its
|
|
8
|
+
> Express router is meant to be mounted by `catalyst-core`'s server. See `peerDependencies` in
|
|
9
|
+
> `package.json` for the minimum compatible `catalyst-core` version.
|
|
10
|
+
|
|
11
|
+
## Install
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install catalyst-ai
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`catalyst-core` must already be installed in the app (`>=0.3.0-0`, per this package's
|
|
18
|
+
`peerDependencies`) — install will fail its `preinstall` peer check otherwise.
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
### 1. Configure the server (`AI_CONFIG` env var)
|
|
23
|
+
|
|
24
|
+
`catalyst-core`'s `expressServer.js` auto-mounts this package's router when it's installed and
|
|
25
|
+
`AI_CONFIG.enabled` is `true`. Set `AI_CONFIG` as a JSON string in your app's environment:
|
|
26
|
+
|
|
27
|
+
```json
|
|
28
|
+
{
|
|
29
|
+
"enabled": true,
|
|
30
|
+
"basePath": "/ai",
|
|
31
|
+
"providers": {
|
|
32
|
+
"openai": { "apiKey": "sk-...", "model": "gpt-5" },
|
|
33
|
+
"gemini": { "apiKey": "...", "model": "gemini-2.5-flash" }
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
No `providers.<name>.apiKey` means that provider's routes are disabled. See the **Security**
|
|
39
|
+
section below before exposing `/ai/*` beyond a trusted internal network.
|
|
40
|
+
|
|
41
|
+
### 2. Call the hook from a component
|
|
42
|
+
|
|
43
|
+
Prefer `catalyst-core`'s `useAI` — it picks the right sub-hook (`useCloudAI` / `useWebAI` /
|
|
44
|
+
`useNativeAI`) based on `options.provider`:
|
|
45
|
+
|
|
46
|
+
```jsx
|
|
47
|
+
import { useAI } from "catalyst-core/hooks"
|
|
48
|
+
|
|
49
|
+
function Chat() {
|
|
50
|
+
const { output, streaming, generate, cancel, error } = useAI({
|
|
51
|
+
provider: "openai", // "openai" | "gemini" → cloud, "transformers" → web, "native" → native
|
|
52
|
+
systemPrompt: "You are a helpful assistant.",
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div>
|
|
57
|
+
<button onClick={() => generate("Hello!")} disabled={streaming}>Send</button>
|
|
58
|
+
<p>{output}</p>
|
|
59
|
+
</div>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Or import a specific hook directly from `catalyst-ai` if you don't need provider auto-routing:
|
|
65
|
+
|
|
66
|
+
```jsx
|
|
67
|
+
import { useCloudAI } from "catalyst-ai"
|
|
68
|
+
|
|
69
|
+
const { output, streaming, generate, cancel, error } = useCloudAI({
|
|
70
|
+
basePath: "/ai", // must match AI_CONFIG.basePath
|
|
71
|
+
provider: "openai", // or "gemini"
|
|
72
|
+
sessionMode: "stateless", // or "stateful"
|
|
73
|
+
})
|
|
74
|
+
```
|
|
75
|
+
|
|
6
76
|
## Security: authentication and rate limiting
|
|
7
77
|
|
|
8
78
|
The Express router exposed by this package (`src/route.js`, mounted at `AI_CONFIG.basePath`
|
package/package.json
CHANGED
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "catalyst-ai",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "AI provider for catalyst-core — cloud/web/native useAI hooks + OpenAI/Gemini SSE route",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./src/index.js",
|
|
8
8
|
"./route": "./src/route.js"
|
|
9
9
|
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src",
|
|
12
|
+
"scripts",
|
|
13
|
+
"android/src",
|
|
14
|
+
"android/build.gradle.kts",
|
|
15
|
+
"README.md"
|
|
16
|
+
],
|
|
10
17
|
"scripts": {
|
|
11
18
|
"preinstall": "node ./scripts/check-peer.js"
|
|
12
19
|
},
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
File without changes
|