agenticaichat 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.
@@ -0,0 +1,75 @@
1
+ // @ts-nocheck
2
+ // This is a template file - TypeScript errors are expected here
3
+ // When copied to user's project, 'agenticaichat' will be installed
4
+ import { NextRequest, NextResponse } from 'next/server';
5
+ import { ChatbotEngine } from 'agenticaichat';
6
+ import { ChatbotConfig } from 'agenticaichat';
7
+
8
+ // Initialize chatbot engine
9
+ let chatbotEngine: ChatbotEngine | null = null;
10
+
11
+ async function getEngine(): Promise<ChatbotEngine> {
12
+ if (!chatbotEngine) {
13
+ const config: ChatbotConfig = {
14
+ database: {
15
+ type: (process.env.DB_TYPE as any) || 'postgresql',
16
+ url: process.env.DATABASE_URL || ''
17
+ },
18
+ openai: {
19
+ apiKey: process.env.OPENAI_API_KEY || '',
20
+ model: (process.env.GPT_MODEL as any) || 'gpt-3.5-turbo'
21
+ },
22
+ debug: process.env.NODE_ENV === 'development'
23
+ };
24
+
25
+ chatbotEngine = new ChatbotEngine(config);
26
+ await chatbotEngine.initialize();
27
+ }
28
+
29
+ return chatbotEngine;
30
+ }
31
+
32
+ export async function POST(request: NextRequest) {
33
+ try {
34
+ const body = await request.json();
35
+ const { query } = body;
36
+
37
+ if (!query || typeof query !== 'string') {
38
+ return NextResponse.json(
39
+ { error: 'Query is required' },
40
+ { status: 400 }
41
+ );
42
+ }
43
+
44
+ // Get chatbot engine
45
+ const engine = await getEngine();
46
+
47
+ // Process query
48
+ const response = await engine.processQuery({ query });
49
+
50
+ return NextResponse.json({
51
+ success: true,
52
+ answer: response.answer,
53
+ sql: response.sql,
54
+ data: response.data
55
+ });
56
+ } catch (error) {
57
+ console.error('Chatbot API error:', error);
58
+
59
+ return NextResponse.json(
60
+ {
61
+ success: false,
62
+ error: 'Failed to process query',
63
+ message: (error as Error).message
64
+ },
65
+ { status: 500 }
66
+ );
67
+ }
68
+ }
69
+
70
+ export async function GET(request: NextRequest) {
71
+ return NextResponse.json({
72
+ status: 'ok',
73
+ message: 'Chatbot API is running'
74
+ });
75
+ }
@@ -0,0 +1,13 @@
1
+ // @ts-nocheck
2
+ // This is a template file - TypeScript errors are expected here
3
+ // When copied to user's project, 'agenticaichat' will be installed
4
+ 'use client';
5
+ import { ChatbotWidget } from 'agenticaichat';
6
+
7
+ export default function ChatPage() {
8
+ return (
9
+ <div style={{ width: '100vw', height: '100vh' }}>
10
+ <ChatbotWidget fullScreen />
11
+ </div>
12
+ );
13
+ }