cosmic-ai-genius 0.3.6 → 0.3.7
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 +52 -83
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Genius SDK for React
|
|
1
|
+
# Cosmic AI Genius SDK for React
|
|
2
2
|
|
|
3
3
|
A powerful, customizable AI chatbot SDK for React applications with voice capabilities and modern UI design.
|
|
4
4
|
|
|
@@ -18,59 +18,18 @@ A powerful, customizable AI chatbot SDK for React applications with voice capabi
|
|
|
18
18
|
|
|
19
19
|
## Installation
|
|
20
20
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
#### Prerequisites
|
|
24
|
-
- Google Cloud CLI installed: `gcloud --version`
|
|
25
|
-
- Authenticated with your Juspay Google account: `gcloud auth login`
|
|
26
|
-
- Access to the `genius-dev-393512` GCP project
|
|
27
|
-
|
|
28
|
-
#### Quick Setup
|
|
29
|
-
|
|
30
|
-
1. **Run the authentication script:**
|
|
31
|
-
```bash
|
|
32
|
-
./refresh-npm-auth.sh
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
2. **Install the package in the repository where you want to integrate the Genius SDK:**
|
|
36
|
-
```bash
|
|
37
|
-
npm install @genius/sdk-js
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
#### Manual Setup (Alternative)
|
|
41
|
-
|
|
42
|
-
If you prefer to set up authentication manually:
|
|
43
|
-
|
|
44
|
-
1. **Get an access token:**
|
|
45
|
-
```bash
|
|
46
|
-
gcloud auth print-access-token
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
2. **Update your `~/.npmrc` file:**
|
|
50
|
-
```
|
|
51
|
-
@genius:registry=https://us-central1-npm.pkg.dev/genius-dev-393512/genius-npm-registry/
|
|
52
|
-
//us-central1-npm.pkg.dev/genius-dev-393512/genius-npm-registry/:_authToken="YOUR_ACCESS_TOKEN_HERE"
|
|
53
|
-
//us-central1-npm.pkg.dev/genius-dev-393512/genius-npm-registry/:always-auth=true
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
#### Token Refresh
|
|
57
|
-
|
|
58
|
-
Access tokens expire after ~1 hour. When you get authentication errors:
|
|
21
|
+
Install the package from npm:
|
|
59
22
|
|
|
60
23
|
```bash
|
|
61
|
-
#
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
# Or manually refresh
|
|
65
|
-
gcloud auth print-access-token
|
|
66
|
-
# Update your ~/.npmrc with the new token
|
|
67
|
-
```
|
|
24
|
+
# Using npm
|
|
25
|
+
npm install cosmic-ai-genius
|
|
68
26
|
|
|
69
|
-
|
|
27
|
+
# Using yarn
|
|
28
|
+
yarn add cosmic-ai-genius
|
|
70
29
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
30
|
+
# Using pnpm
|
|
31
|
+
pnpm add cosmic-ai-genius
|
|
32
|
+
```
|
|
74
33
|
|
|
75
34
|
## Quick Start
|
|
76
35
|
|
|
@@ -79,7 +38,7 @@ gcloud auth print-access-token
|
|
|
79
38
|
Wrap your app with the `GeniusChatbotProvider`:
|
|
80
39
|
|
|
81
40
|
```tsx
|
|
82
|
-
import { GeniusChatbotProvider, GeniusToggle } from '
|
|
41
|
+
import { GeniusChatbotProvider, GeniusToggle } from 'cosmic-ai-genius';
|
|
83
42
|
|
|
84
43
|
function App() {
|
|
85
44
|
return (
|
|
@@ -102,7 +61,7 @@ function App() {
|
|
|
102
61
|
Use the `useGeniusChatbot` hook for programmatic control:
|
|
103
62
|
|
|
104
63
|
```tsx
|
|
105
|
-
import { useGeniusChatbot } from '
|
|
64
|
+
import { useGeniusChatbot } from 'cosmic-ai-genius';
|
|
106
65
|
|
|
107
66
|
function MyComponent() {
|
|
108
67
|
const { openChatbot, closeChatbot, toggleChatbot, isOpen } = useGeniusChatbot();
|
|
@@ -131,7 +90,7 @@ The main provider component that manages chatbot state and configuration.
|
|
|
131
90
|
apiEndpoint: "https://your-api.com/chat",
|
|
132
91
|
|
|
133
92
|
// UI Customization
|
|
134
|
-
welcomeMessage: "Welcome to
|
|
93
|
+
welcomeMessage: "Welcome to Cosmic AI Genius!",
|
|
135
94
|
placeholder: "Type your message...",
|
|
136
95
|
suggestions: ['FAQ', 'Pricing', 'Contact'],
|
|
137
96
|
|
|
@@ -480,7 +439,7 @@ import type {
|
|
|
480
439
|
GeniusChatbotConfig,
|
|
481
440
|
Message,
|
|
482
441
|
GeniusChatbotContextType
|
|
483
|
-
} from '
|
|
442
|
+
} from 'cosmic-ai-genius';
|
|
484
443
|
|
|
485
444
|
const config: GeniusChatbotConfig = {
|
|
486
445
|
welcomeMessage: "Hello!",
|
|
@@ -510,36 +469,41 @@ const handleMessage = (message: Message) => {
|
|
|
510
469
|
|
|
511
470
|
## Development
|
|
512
471
|
|
|
513
|
-
###
|
|
514
|
-
|
|
515
|
-
For development team members with publishing access:
|
|
472
|
+
### Local Development
|
|
516
473
|
|
|
517
|
-
1. **
|
|
474
|
+
1. **Clone the repository:**
|
|
475
|
+
```bash
|
|
476
|
+
git clone https://github.com/cosmic-ai/genius-sdk.git
|
|
477
|
+
cd genius-sdk
|
|
478
|
+
```
|
|
518
479
|
|
|
519
|
-
2. **
|
|
480
|
+
2. **Install dependencies:**
|
|
520
481
|
```bash
|
|
521
|
-
npm
|
|
482
|
+
npm install
|
|
522
483
|
```
|
|
523
484
|
|
|
524
|
-
3. **
|
|
485
|
+
3. **Start development server:**
|
|
525
486
|
```bash
|
|
526
|
-
npm
|
|
487
|
+
npm run dev
|
|
527
488
|
```
|
|
528
489
|
|
|
529
|
-
4. **
|
|
490
|
+
4. **Build the SDK:**
|
|
530
491
|
```bash
|
|
531
|
-
npm
|
|
492
|
+
npm run build:sdk
|
|
532
493
|
```
|
|
533
494
|
|
|
534
|
-
###
|
|
495
|
+
### Publishing Updates
|
|
535
496
|
|
|
536
|
-
|
|
497
|
+
1. **Update version:**
|
|
498
|
+
```bash
|
|
499
|
+
npm version patch # or minor/major
|
|
500
|
+
```
|
|
537
501
|
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
```
|
|
502
|
+
2. **Build and publish:**
|
|
503
|
+
```bash
|
|
504
|
+
npm run build:sdk
|
|
505
|
+
npm publish
|
|
506
|
+
```
|
|
543
507
|
|
|
544
508
|
## Troubleshooting
|
|
545
509
|
|
|
@@ -564,17 +528,14 @@ gcloud auth configure-docker us-central1-docker.pkg.dev
|
|
|
564
528
|
3. **TypeScript errors**
|
|
565
529
|
```tsx
|
|
566
530
|
// Import types explicitly
|
|
567
|
-
import type { GeniusChatbotConfig } from '
|
|
531
|
+
import type { GeniusChatbotConfig } from 'cosmic-ai-genius';
|
|
568
532
|
```
|
|
569
533
|
|
|
570
|
-
4. **
|
|
534
|
+
4. **Installation issues**
|
|
571
535
|
```bash
|
|
572
|
-
#
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
# Or check your gcloud authentication
|
|
576
|
-
gcloud auth list
|
|
577
|
-
gcloud auth login # if needed
|
|
536
|
+
# Clear cache and reinstall
|
|
537
|
+
npm cache clean --force
|
|
538
|
+
npm install cosmic-ai-genius
|
|
578
539
|
```
|
|
579
540
|
|
|
580
541
|
### Debug Mode
|
|
@@ -598,7 +559,7 @@ The SDK can be used with ReScript by creating bindings:
|
|
|
598
559
|
|
|
599
560
|
```rescript
|
|
600
561
|
module GeniusChatbotProvider = {
|
|
601
|
-
@module("
|
|
562
|
+
@module("cosmic-ai-genius") @react.component
|
|
602
563
|
external make: (
|
|
603
564
|
~config: GeniusConfig.t,
|
|
604
565
|
~defaultOpen: bool=?,
|
|
@@ -607,7 +568,7 @@ module GeniusChatbotProvider = {
|
|
|
607
568
|
}
|
|
608
569
|
|
|
609
570
|
module GeniusToggle = {
|
|
610
|
-
@module("
|
|
571
|
+
@module("cosmic-ai-genius") @react.component
|
|
611
572
|
external make: (
|
|
612
573
|
~position: [#"bottom-right" | #"bottom-left" | #"top-right" | #"top-left"]=?,
|
|
613
574
|
~offsetX: int=?,
|
|
@@ -615,7 +576,7 @@ module GeniusToggle = {
|
|
|
615
576
|
) => React.element = "GeniusToggle"
|
|
616
577
|
}
|
|
617
578
|
|
|
618
|
-
@module("
|
|
579
|
+
@module("cosmic-ai-genius")
|
|
619
580
|
external useGeniusChatbot: unit => {
|
|
620
581
|
"openChatbot": unit => unit,
|
|
621
582
|
"closeChatbot": unit => unit,
|
|
@@ -686,4 +647,12 @@ let make = () => {
|
|
|
686
647
|
|
|
687
648
|
Check out the `/src/App.tsx` file in this repository for a complete working example with all features demonstrated.
|
|
688
649
|
|
|
689
|
-
|
|
650
|
+
## Contributing
|
|
651
|
+
|
|
652
|
+
We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
|
|
653
|
+
|
|
654
|
+
## License
|
|
655
|
+
|
|
656
|
+
MIT License - see [LICENSE](LICENSE) file for details.
|
|
657
|
+
|
|
658
|
+
Made with ❤️ by the Cosmic AI Team
|
package/package.json
CHANGED