expo-ai-core 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/LICENSE +21 -0
- package/README.md +162 -0
- package/dist/index.cjs +1345 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +218 -0
- package/dist/index.d.ts +218 -0
- package/dist/index.js +1321 -0
- package/dist/index.js.map +1 -0
- package/package.json +87 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 expo-ai-core contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
# expo-ai-core β‘
|
|
2
|
+
|
|
3
|
+
> Add AI (ChatGPT-style chat, streaming, voice) to your Expo app in **5 lines of code**
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## π Why this exists
|
|
8
|
+
|
|
9
|
+
Building AI features in Expo is painful:
|
|
10
|
+
|
|
11
|
+
- Too much boilerplate
|
|
12
|
+
- No streaming support
|
|
13
|
+
- Voice is messy
|
|
14
|
+
- UI takes forever
|
|
15
|
+
|
|
16
|
+
**expo-ai-core fixes all of that.**
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## β‘ Quick Demo
|
|
21
|
+
|
|
22
|
+
```tsx
|
|
23
|
+
import { AIChatView, useAIChat } from "expo-ai-core";
|
|
24
|
+
|
|
25
|
+
export default function Screen() {
|
|
26
|
+
const chat = useAIChat({
|
|
27
|
+
provider: "openai",
|
|
28
|
+
apiKey: "YOUR_API_KEY",
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
return <AIChatView {...chat} />;
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
π Thatβs it. You now have a working AI chat UI.
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## β¨ Features
|
|
40
|
+
|
|
41
|
+
- π§ **AI Chat Hook** β `useAIChat`
|
|
42
|
+
- β‘ **Streaming Responses** (real-time typing effect)
|
|
43
|
+
- π€ **Voice Input + TTS**
|
|
44
|
+
- π **Multi-Provider Support**
|
|
45
|
+
- OpenAI
|
|
46
|
+
- Google Gemini
|
|
47
|
+
|
|
48
|
+
- π¬ **Prebuilt UI Components**
|
|
49
|
+
- πΎ **Offline Cache + Persistence**
|
|
50
|
+
- βοΈ **Zero Backend Required**
|
|
51
|
+
- π¦ **Tiny & Tree-shakable**
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## π¦ Installation
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
npm install expo-ai-core
|
|
59
|
+
npm install expo-speech expo-av @react-native-async-storage/async-storage
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## π§ Providers
|
|
65
|
+
|
|
66
|
+
### OpenAI
|
|
67
|
+
|
|
68
|
+
```tsx
|
|
69
|
+
useAIChat({
|
|
70
|
+
provider: "openai",
|
|
71
|
+
apiKey: process.env.EXPO_PUBLIC_OPENAI_API_KEY!,
|
|
72
|
+
model: "gpt-4o-mini",
|
|
73
|
+
});
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Gemini
|
|
77
|
+
|
|
78
|
+
```tsx
|
|
79
|
+
useAIChat({
|
|
80
|
+
provider: "gemini",
|
|
81
|
+
apiKey: process.env.EXPO_PUBLIC_GEMINI_API_KEY!,
|
|
82
|
+
model: "gemini-2.5-flash",
|
|
83
|
+
});
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## π€ Voice (Speech-to-Text + TTS)
|
|
89
|
+
|
|
90
|
+
```tsx
|
|
91
|
+
import { useAIVoice } from "expo-ai-core";
|
|
92
|
+
|
|
93
|
+
const voice = useAIVoice();
|
|
94
|
+
|
|
95
|
+
await voice.startListening();
|
|
96
|
+
await voice.stopListening();
|
|
97
|
+
await voice.speak("Hello from Expo");
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
---
|
|
101
|
+
|
|
102
|
+
## π§© Components
|
|
103
|
+
|
|
104
|
+
- `AIChatView` β full chat UI
|
|
105
|
+
- `AIInput` β input box
|
|
106
|
+
- `AIMessageBubble` β messages
|
|
107
|
+
- `AITypingIndicator` β streaming state
|
|
108
|
+
|
|
109
|
+
All components are:
|
|
110
|
+
|
|
111
|
+
- Customizable
|
|
112
|
+
- NativeWind-compatible
|
|
113
|
+
- Lightweight
|
|
114
|
+
|
|
115
|
+
---
|
|
116
|
+
|
|
117
|
+
## π§ How it works
|
|
118
|
+
|
|
119
|
+
- Uses `fetch` (no backend needed)
|
|
120
|
+
- Streams tokens in real-time
|
|
121
|
+
- Stores chats via AsyncStorage
|
|
122
|
+
- Works in Expo Go
|
|
123
|
+
|
|
124
|
+
---
|
|
125
|
+
|
|
126
|
+
## β οΈ Notes
|
|
127
|
+
|
|
128
|
+
- Native speech recognition requires platform support
|
|
129
|
+
- Works best with Expo SDK 50+
|
|
130
|
+
- No Node.js APIs used
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## π± Example App
|
|
135
|
+
|
|
136
|
+
See `/example` for a full working demo.
|
|
137
|
+
|
|
138
|
+
---
|
|
139
|
+
|
|
140
|
+
## π‘ Coming Soon
|
|
141
|
+
|
|
142
|
+
- Image generation support
|
|
143
|
+
- Markdown + code block rendering
|
|
144
|
+
- Better voice transcription
|
|
145
|
+
- More providers
|
|
146
|
+
|
|
147
|
+
---
|
|
148
|
+
|
|
149
|
+
## β Support
|
|
150
|
+
|
|
151
|
+
If this helped you:
|
|
152
|
+
|
|
153
|
+
- Star the repo β
|
|
154
|
+
- Share on Twitter/X
|
|
155
|
+
- Build something cool π
|
|
156
|
+
|
|
157
|
+
---
|
|
158
|
+
|
|
159
|
+
## π§βπ» Author
|
|
160
|
+
|
|
161
|
+
Built by Arhan Ansari
|
|
162
|
+
[Twitter](https://twitter.com/codewitharhan) | [GitHub](https://github.com/ArhanAnsari)
|