agenticaichat 1.0.1 → 1.0.4

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.
Files changed (54) hide show
  1. package/README.md +208 -26
  2. package/bin/cli.js +406 -118
  3. package/dist/adapters/angular.d.ts +9 -0
  4. package/dist/adapters/angular.js +6 -0
  5. package/dist/adapters/react.d.ts +1 -0
  6. package/dist/adapters/react.js +8 -0
  7. package/dist/adapters/vue.d.ts +9 -0
  8. package/dist/adapters/vue.js +6 -0
  9. package/dist/core/ChatbotEngine.d.ts +9 -1
  10. package/dist/core/ChatbotEngine.js +52 -19
  11. package/dist/core/EngineFactory.d.ts +45 -0
  12. package/dist/core/EngineFactory.js +126 -0
  13. package/dist/core/NLToSQLConverter.d.ts +6 -15
  14. package/dist/core/NLToSQLConverter.js +9 -114
  15. package/dist/engines/base/DatabaseEngine.d.ts +46 -0
  16. package/dist/engines/base/DatabaseEngine.js +42 -0
  17. package/dist/engines/nosql/MongoEngine.d.ts +13 -0
  18. package/dist/engines/nosql/MongoEngine.js +194 -0
  19. package/dist/engines/nosql/NoSqlEngine.d.ts +20 -0
  20. package/dist/engines/nosql/NoSqlEngine.js +29 -0
  21. package/dist/engines/sql/SqlEngine.d.ts +19 -0
  22. package/dist/engines/sql/SqlEngine.js +52 -0
  23. package/dist/engines/sql/dialects/MySQLDialect.d.ts +12 -0
  24. package/dist/engines/sql/dialects/MySQLDialect.js +109 -0
  25. package/dist/engines/sql/dialects/PostgresDialect.d.ts +11 -0
  26. package/dist/engines/sql/dialects/PostgresDialect.js +109 -0
  27. package/dist/engines/sql/dialects/SQLiteDialect.d.ts +10 -0
  28. package/dist/engines/sql/dialects/SQLiteDialect.js +101 -0
  29. package/dist/index.d.ts +20 -4
  30. package/dist/index.js +63 -8
  31. package/dist/llm/LLMFactory.d.ts +25 -0
  32. package/dist/llm/LLMFactory.js +137 -0
  33. package/dist/llm/providers/ClaudeProvider.d.ts +13 -0
  34. package/dist/llm/providers/ClaudeProvider.js +132 -0
  35. package/dist/llm/providers/DeepInfraProvider.d.ts +14 -0
  36. package/dist/llm/providers/DeepInfraProvider.js +144 -0
  37. package/dist/llm/providers/GeminiProvider.d.ts +13 -0
  38. package/dist/llm/providers/GeminiProvider.js +105 -0
  39. package/dist/llm/providers/GrokProvider.d.ts +14 -0
  40. package/dist/llm/providers/GrokProvider.js +144 -0
  41. package/dist/llm/providers/GroqProvider.d.ts +0 -0
  42. package/dist/llm/providers/GroqProvider.js +148 -0
  43. package/dist/llm/providers/OpenAIProvider.d.ts +13 -0
  44. package/dist/llm/providers/OpenAIProvider.js +136 -0
  45. package/dist/llm/providers/TogetherAIProvider.d.ts +14 -0
  46. package/dist/llm/providers/TogetherAIProvider.js +144 -0
  47. package/dist/llm/types.d.ts +34 -0
  48. package/dist/llm/types.js +2 -0
  49. package/dist/types/index.d.ts +23 -3
  50. package/dist/widget/ChatbotWidget.d.ts +1 -1
  51. package/dist/widget/ChatbotWidget.js +406 -125
  52. package/package.json +19 -4
  53. package/scripts/postinstall.js +126 -0
  54. package/templates/api-route.template.ts +24 -14
package/README.md CHANGED
@@ -1,30 +1,55 @@
1
- # 🤖 AgenticAIChat
2
-
1
+ # AgenticAIChat
3
2
  AI-powered chatbot for business analytics with natural language database queries.
4
3
 
5
- ## ✨ Features
4
+ ## Highlights
5
+
6
+ - Five-minute setup with an interactive CLI wizard
7
+ - Natural language questions in English or Hindi
8
+ - Works with PostgreSQL, MySQL, SQLite, Turso, and MongoDB
9
+ - Ready-to-use React/Next.js widget for dashboards and full pages
10
+ - Configuration files generated for you (`.env.chatbot`, `chatbot-config.json`)
11
+ - Fully typed TypeScript package
12
+
13
+ ## Requirements
14
+
15
+ - Node.js 18+ and npm 9+
16
+ - React 18+ and Next.js 13+ (app router recommended) for the built-in widget
17
+
18
+ ## Installation and Setup
6
19
 
7
- - 🚀 **5-Minute Setup**: Interactive CLI wizard
8
- - 💬 **Natural Language**: Ask in English/Hindi
9
- - 🗄️ **Multi-Database**: PostgreSQL, MySQL, MongoDB
10
- - 🎨 **Beautiful Widget**: Pre-built React component
11
- - 🔒 **Secure**: Encrypted API keys
12
- - 💰 **Free**: User pays OpenAI API only
13
- - 📦 **TypeScript**: Full type safety
20
+ Install the package:
14
21
 
15
- ## 📦 Installation
16
22
  ```bash
23
+ # npm
17
24
  npm install agenticaichat
25
+
26
+ # yarn
27
+ yarn add agenticaichat
28
+
29
+ # pnpm
30
+ pnpm add agenticaichat
18
31
  ```
19
32
 
20
- ## 🚀 Quick Start
33
+ Run the setup wizard to configure your database and AI provider:
21
34
 
22
- ### Step 1: Run Setup Wizard
23
35
  ```bash
24
36
  npx agenticai-setup
25
37
  ```
26
38
 
27
- ### Step 2: Add Widget
39
+ The wizard will:
40
+
41
+ - Ask for your database type and connection details
42
+ - Collect your AI provider, model, and API key
43
+ - Generate `.env.chatbot` and `chatbot-config.json`
44
+ - For Next.js: Generate API route and chat page
45
+ - Update `.gitignore` to exclude generated secrets
46
+
47
+ If the wizard doesn't run automatically after install (e.g., in CI or non-interactive environments), run the command above manually.
48
+
49
+ ## Quick Start (Next.js)
50
+
51
+ Add the widget to any page or component:
52
+
28
53
  ```tsx
29
54
  // app/dashboard/page.tsx
30
55
  import { ChatbotWidget } from 'agenticaichat';
@@ -39,7 +64,8 @@ export default function Dashboard() {
39
64
  }
40
65
  ```
41
66
 
42
- ### Step 3: Full Page Chat (Optional)
67
+ Create a full-page chat experience:
68
+
43
69
  ```tsx
44
70
  // app/chat/page.tsx
45
71
  import { ChatbotWidget } from 'agenticaichat';
@@ -49,23 +75,179 @@ export default function ChatPage() {
49
75
  }
50
76
  ```
51
77
 
52
- ## 📖 Documentation
78
+ Start your Next.js app:
53
79
 
54
- Coming soon!
80
+ ```bash
81
+ npm run dev
82
+ ```
55
83
 
56
- ## 🤝 Contributing
84
+ ## Setting up the Backend API
57
85
 
58
- Contributions welcome!
86
+ For all frameworks, you need a backend endpoint that handles chatbot queries. The setup wizard generates configuration files, but you must implement the API route yourself unless using Next.js.
59
87
 
60
- ## 📄 License
88
+ 1. Run the setup wizard to generate `.env.chatbot` and `chatbot-config.json`:
61
89
 
62
- MIT License
90
+ ```bash
91
+ npx agenticai-setup
92
+ ```
63
93
 
64
- ## 🙋‍♂️ Support
94
+ 2. Create an HTTP POST endpoint at `/api/chatbot/query` (or any path you choose).
65
95
 
66
- - GitHub: [Issues](https://github.com/Bhaviraj2004/agenticaichat/issues)
67
- - Email: bhaviraj001@gmail.com
96
+ Use the template from `templates/api-route.template.ts` as a guide. Load environment variables from `.env.chatbot` and use the `ChatbotEngine` from `agenticaichat/core`.
97
+
98
+ Example (Node.js/Express):
99
+
100
+ ```javascript
101
+ const express = require('express');
102
+ const { ChatbotEngine } = require('agenticaichat/core');
103
+ require('dotenv').config({ path: '.env.chatbot' });
104
+
105
+ const app = express();
106
+ app.use(express.json());
107
+
108
+ app.post('/api/chatbot/query', async (req, res) => {
109
+ const { query } = req.body;
110
+ const engine = new ChatbotEngine();
111
+ try {
112
+ const result = await engine.processQuery(query);
113
+ res.json(result);
114
+ } catch (error) {
115
+ res.status(500).json({ error: error.message });
116
+ }
117
+ });
118
+
119
+ app.listen(3000);
120
+ ```
121
+
122
+ For Next.js, the wizard generates this automatically.
123
+
124
+ ## Setup for Angular
125
+
126
+ 1. Install the package and run setup:
127
+
128
+ ```bash
129
+ npm install agenticaichat
130
+ npx agenticai-setup
131
+ ```
132
+
133
+ 2. Set up the backend API as described above (e.g., using Express or your preferred Node.js framework).
134
+
135
+ 3. In your Angular app, create a chatbot component:
68
136
 
69
- ---
137
+ ```typescript
138
+ // chatbot.component.ts
139
+ import { Component } from '@angular/core';
140
+ import { HttpClient } from '@angular/common/http';
141
+ import { AngularChatRequest, AngularChatResponse } from 'agenticaichat/angular';
70
142
 
71
- Made with ❤️ for developers
143
+ @Component({
144
+ selector: 'app-chatbot',
145
+ template: `
146
+ <div>
147
+ <input [(ngModel)]="query" placeholder="Ask a question..." />
148
+ <button (click)="ask()">Ask</button>
149
+ <div *ngIf="response">{{ response.answer }}</div>
150
+ </div>
151
+ `
152
+ })
153
+ export class ChatbotComponent {
154
+ query = '';
155
+ response: AngularChatResponse | null = null;
156
+
157
+ constructor(private http: HttpClient) {}
158
+
159
+ ask() {
160
+ const request: AngularChatRequest = { query: this.query };
161
+ this.http.post<AngularChatResponse>('/api/chatbot/query', request)
162
+ .subscribe(res => this.response = res);
163
+ }
164
+ }
165
+ ```
166
+
167
+ 4. Add the component to your app and ensure CORS is configured on your backend.
168
+
169
+ ## Setup for Vue
170
+
171
+ 1. Install the package and run setup:
172
+
173
+ ```bash
174
+ npm install agenticaichat
175
+ npx agenticai-setup
176
+ ```
177
+
178
+ 2. Set up the backend API as described above.
179
+
180
+ 3. In your Vue app, create a chatbot component:
181
+
182
+ ```vue
183
+ <!-- Chatbot.vue -->
184
+ <template>
185
+ <div>
186
+ <input v-model="query" placeholder="Ask a question..." />
187
+ <button @click="ask">Ask</button>
188
+ <div v-if="response">{{ response.answer }}</div>
189
+ </div>
190
+ </template>
191
+
192
+ <script setup lang="ts">
193
+ import { ref } from 'vue';
194
+ import { VueChatRequest, VueChatResponse } from 'agenticaichat/vue';
195
+
196
+ const query = ref('');
197
+ const response = ref<VueChatResponse | null>(null);
198
+
199
+ const ask = async () => {
200
+ const request: VueChatRequest = { query: query.value };
201
+ const res = await fetch('/api/chatbot/query', {
202
+ method: 'POST',
203
+ headers: { 'Content-Type': 'application/json' },
204
+ body: JSON.stringify(request)
205
+ });
206
+ response.value = await res.json();
207
+ };
208
+ </script>
209
+ ```
210
+
211
+ 4. Use the component in your app and configure CORS on your backend.
212
+
213
+ ## Setup for Other React Frameworks
214
+
215
+ - Create an HTTP POST endpoint (e.g., `/api/chatbot/query`) that follows `templates/api-route.template.ts`.
216
+ - Load `.env.chatbot` on the server and wire `DATABASE_URL`, `DB_TYPE`, `LLM_PROVIDER`, `LLM_MODEL`, and `LLM_API_KEY` into the handler.
217
+ - Return JSON responses in the same shape as the template handler.
218
+ - Configure CORS/auth so the widget can call your endpoint from the browser.
219
+
220
+ Frontend usage stays the same:
221
+
222
+ ```tsx
223
+ import { ChatbotWidget } from 'agenticaichat';
224
+
225
+ export default function Page() {
226
+ return <ChatbotWidget apiPath="/api/chatbot/query" />;
227
+ }
228
+ ```
229
+
230
+ ## Configuration Files
231
+
232
+ - `.env.chatbot` holds database connection, LLM provider, model, and API key.
233
+ - `chatbot-config.json` stores non-secret metadata (database/LLM selection).
234
+ - `.gitignore` is updated automatically to keep generated secrets out of version control.
235
+
236
+ ## Troubleshooting
237
+
238
+ - CI environments skip the wizard; run `npx agenticai-setup` locally after install.
239
+ - If the wizard cannot run (non-interactive terminal), rerun manually with the command above.
240
+ - To switch databases or AI providers, rerun the wizard; existing files will be replaced.
241
+
242
+ ## Contributing
243
+
244
+ Contributions are welcome. Please open an issue or pull request with details and reproduction steps.
245
+
246
+ ## License
247
+
248
+ MIT License
249
+
250
+ ## Support
251
+
252
+ - GitHub: [Issues](https://github.com/Bhaviraj2004/agenticaichat/issues)
253
+ - Email: bhaviraj001@gmail.com