@akropolys/sdk 1.0.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/README.md +130 -0
- package/dist/chunk-BDDPLGUO.mjs +1164 -0
- package/dist/chunk-BDDPLGUO.mjs.map +1 -0
- package/dist/chunk-FBM65EZM.mjs +1127 -0
- package/dist/chunk-FBM65EZM.mjs.map +1 -0
- package/dist/chunk-NWQKZTKU.mjs +1127 -0
- package/dist/chunk-NWQKZTKU.mjs.map +1 -0
- package/dist/commerce.d.mts +2 -0
- package/dist/commerce.d.ts +2 -0
- package/dist/commerce.js +1171 -0
- package/dist/commerce.js.map +1 -0
- package/dist/commerce.mjs +41 -0
- package/dist/commerce.mjs.map +1 -0
- package/dist/index.d.mts +377 -0
- package/dist/index.d.ts +377 -0
- package/dist/index.js +1168 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +38 -0
- package/dist/index.mjs.map +1 -0
- package/dist/property.d.mts +2 -0
- package/dist/property.d.ts +2 -0
- package/dist/property.js +1171 -0
- package/dist/property.js.map +1 -0
- package/dist/property.mjs +41 -0
- package/dist/property.mjs.map +1 -0
- package/package.json +71 -0
package/README.md
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
# @akropolys/sdk
|
|
2
|
+
|
|
3
|
+
> Headless AI search, chat, and commerce SDK — the engine behind Kiku.
|
|
4
|
+
|
|
5
|
+
`@akropolys/sdk` is the zero-UI core of the Akropolys platform. It gives you raw data streams, React hooks, and a typed API client that you wire up however you like — chat bubbles, spreadsheets, Remotion videos, analytics pipelines. Your call.
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## Install
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
npm install @akropolys/sdk
|
|
13
|
+
# or
|
|
14
|
+
pnpm add @akropolys/sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
React and react-dom are optional peer dependencies. Only required if you use the React hooks or `<AkropolysProvider>`.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## Quick start (React)
|
|
22
|
+
|
|
23
|
+
```tsx
|
|
24
|
+
import { AkropolysProvider, useKiku } from '@akropolys/sdk';
|
|
25
|
+
|
|
26
|
+
function App() {
|
|
27
|
+
return (
|
|
28
|
+
<AkropolysProvider
|
|
29
|
+
siteId="your-site-id"
|
|
30
|
+
apiUrl="https://api.akropolys.io"
|
|
31
|
+
apiToken="your-api-token"
|
|
32
|
+
>
|
|
33
|
+
<Chat />
|
|
34
|
+
</AkropolysProvider>
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function Chat() {
|
|
39
|
+
const { send, messages, loading } = useKiku();
|
|
40
|
+
|
|
41
|
+
return (
|
|
42
|
+
<div>
|
|
43
|
+
{messages.map((m, i) => <p key={i}><b>{m.role}:</b> {m.content}</p>)}
|
|
44
|
+
<button onClick={() => send('What is the cheapest phone?')} disabled={loading}>
|
|
45
|
+
Ask
|
|
46
|
+
</button>
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
---
|
|
53
|
+
|
|
54
|
+
## Vanilla JS — event-driven streaming
|
|
55
|
+
|
|
56
|
+
```ts
|
|
57
|
+
import { AkropolysClient } from '@akropolys/sdk';
|
|
58
|
+
|
|
59
|
+
const client = new AkropolysClient({
|
|
60
|
+
siteId: 'your-site-id',
|
|
61
|
+
apiUrl: 'https://api.akropolys.io',
|
|
62
|
+
apiToken: 'your-api-token',
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
const stream = client.chat('Best laptop under KSh 80,000?');
|
|
66
|
+
|
|
67
|
+
stream
|
|
68
|
+
.on('token', (token: string) => process.stdout.write(token))
|
|
69
|
+
.on('meta', (meta) => console.log('Sources:', meta.sources))
|
|
70
|
+
.on('done', (full: string) => console.log('\nFinished:', full))
|
|
71
|
+
.on('error', (err: Error) => console.error(err));
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Hooks
|
|
77
|
+
|
|
78
|
+
| Hook | Description |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `useKiku(options?)` | Chat hook — streams AI responses, manages message history |
|
|
81
|
+
| `useSearch()` | Real-time vector product search |
|
|
82
|
+
| `useIngest()` | Fire-and-forget product ingestion |
|
|
83
|
+
| `usePageIngest(product)` | Auto-ingest current product page on mount |
|
|
84
|
+
| `useListIngest(products)` | Auto-ingest a catalog list on mount |
|
|
85
|
+
| `useCart()` | Read shopper cart state |
|
|
86
|
+
| `usePaymentPolling(props)` | Poll for M-Pesa / payment confirmation |
|
|
87
|
+
| `useAkropolysContext()` | Access the `AkropolysClient` from context |
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Environment variables
|
|
92
|
+
|
|
93
|
+
Set these instead of passing props to `<AkropolysProvider>`:
|
|
94
|
+
|
|
95
|
+
```env
|
|
96
|
+
NEXT_PUBLIC_AKROPOLYS_SITE_ID=your-site-id
|
|
97
|
+
NEXT_PUBLIC_AKROPOLYS_API_URL=https://api.akropolys.io
|
|
98
|
+
NEXT_PUBLIC_AKROPOLYS_API_TOKEN=your-api-token
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Vite equivalents (`VITE_AKROPOLYS_*`) are also supported.
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## Sub-paths
|
|
106
|
+
|
|
107
|
+
```ts
|
|
108
|
+
// Commerce-specific helpers
|
|
109
|
+
import { ... } from '@akropolys/sdk/commerce';
|
|
110
|
+
|
|
111
|
+
// Property vertical helpers
|
|
112
|
+
import { ... } from '@akropolys/sdk/property';
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## KikuStream events
|
|
118
|
+
|
|
119
|
+
| Event | Payload | Description |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `token` | `string` | Each word/token as it streams |
|
|
122
|
+
| `meta` | `ChatMetadata` | Sources, intent, cart updates |
|
|
123
|
+
| `done` | `string` | Full assembled message |
|
|
124
|
+
| `error` | `Error` | Stream or network error |
|
|
125
|
+
|
|
126
|
+
---
|
|
127
|
+
|
|
128
|
+
## License
|
|
129
|
+
|
|
130
|
+
MIT © Akropolys
|