@djangocfg/ext-knowbase 1.0.6 → 1.0.8
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/dist/config.cjs +3 -2
- package/dist/config.js +3 -2
- package/dist/hooks.cjs +14 -12
- package/dist/hooks.js +13 -12
- package/dist/index.cjs +3 -2
- package/dist/index.d.cts +0 -97
- package/dist/index.d.ts +0 -97
- package/dist/index.js +3 -2
- package/package.json +9 -8
- package/src/api/generated/ext_knowbase/CLAUDE.md +64 -0
- package/src/api/generated/ext_knowbase/_utils/fetchers/ext_knowbase__knowbase.ts +1 -8
- package/src/api/generated/ext_knowbase/_utils/fetchers/index.ts +1 -8
- package/src/api/generated/ext_knowbase/_utils/hooks/ext_knowbase__knowbase.ts +1 -8
- package/src/api/generated/ext_knowbase/_utils/hooks/index.ts +1 -8
- package/src/api/generated/ext_knowbase/_utils/schemas/index.ts +1 -8
- package/src/api/generated/ext_knowbase/api-instance.ts +1 -8
- package/src/api/generated/ext_knowbase/enums.ts +1 -8
- package/src/api/generated/ext_knowbase/errors.ts +1 -8
- package/src/api/generated/ext_knowbase/ext_knowbase__knowbase/index.ts +1 -8
- package/src/api/generated/ext_knowbase/ext_knowbase__knowbase/models.ts +1 -8
- package/src/api/generated/ext_knowbase/http.ts +1 -8
- package/src/api/generated/ext_knowbase/index.ts +1 -8
- package/src/api/generated/ext_knowbase/logger.ts +1 -8
- package/src/api/generated/ext_knowbase/retry.ts +1 -8
- package/src/api/generated/ext_knowbase/storage.ts +1 -8
- package/src/api/generated/ext_knowbase/validation-events.ts +1 -8
- package/src/api/index.ts +2 -1
- package/src/components/Chat/ChatUIContext.tsx +2 -1
- package/src/components/Chat/ChatWidget.tsx +9 -11
- package/src/components/Chat/components/MessageInput.tsx +5 -2
- package/src/components/Chat/components/MessageList.tsx +15 -8
- package/src/components/Chat/components/SessionList.tsx +8 -12
- package/src/components/Chat/hooks/useInfiniteSessions.ts +2 -1
- package/src/components/Chat/index.tsx +2 -0
- package/src/components/Chat/types.ts +3 -1
- package/src/config.ts +1 -0
- package/src/contexts/knowbase/ChatContext.tsx +6 -9
- package/src/contexts/knowbase/DocumentsContext.tsx +11 -17
- package/src/contexts/knowbase/KnowbaseProvider.tsx +1 -0
- package/src/contexts/knowbase/SessionsContext.tsx +6 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/ext-knowbase",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "Knowledge base and chat extension for DjangoCFG",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"django",
|
|
@@ -59,9 +59,9 @@
|
|
|
59
59
|
"check": "tsc --noEmit"
|
|
60
60
|
},
|
|
61
61
|
"peerDependencies": {
|
|
62
|
-
"@djangocfg/api": "^2.1.
|
|
63
|
-
"@djangocfg/ext-base": "^1.0.
|
|
64
|
-
"@djangocfg/ui-nextjs": "^2.1.
|
|
62
|
+
"@djangocfg/api": "^2.1.91",
|
|
63
|
+
"@djangocfg/ext-base": "^1.0.8",
|
|
64
|
+
"@djangocfg/ui-nextjs": "^2.1.91",
|
|
65
65
|
"consola": "^3.4.2",
|
|
66
66
|
"lucide-react": "^0.545.0",
|
|
67
67
|
"next": "^15.5.7",
|
|
@@ -70,12 +70,13 @@
|
|
|
70
70
|
"react-dom": "^18 || ^19",
|
|
71
71
|
"react-markdown": "^9.0.0 || ^10.0.0",
|
|
72
72
|
"swr": "^2.3.7",
|
|
73
|
-
"zod": "^4.1.13"
|
|
73
|
+
"zod": "^4.1.13",
|
|
74
|
+
"moment": "^2.30.1"
|
|
74
75
|
},
|
|
75
76
|
"devDependencies": {
|
|
76
|
-
"@djangocfg/api": "^2.1.
|
|
77
|
-
"@djangocfg/ext-base": "^1.0.
|
|
78
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
77
|
+
"@djangocfg/api": "^2.1.91",
|
|
78
|
+
"@djangocfg/ext-base": "^1.0.8",
|
|
79
|
+
"@djangocfg/typescript-config": "^2.1.91",
|
|
79
80
|
"@types/node": "^24.7.2",
|
|
80
81
|
"@types/react": "^19.0.0",
|
|
81
82
|
"consola": "^3.4.2",
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Django CFG API - Typescript Client
|
|
2
|
+
|
|
3
|
+
Auto-generated. **Do not edit manually.**
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
python manage.py generate_client --groups ext_knowbase --typescript
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Stats
|
|
10
|
+
|
|
11
|
+
| | |
|
|
12
|
+
|---|---|
|
|
13
|
+
| Version | 3.0.3 |
|
|
14
|
+
| Operations | 57 |
|
|
15
|
+
| Schemas | 52 |
|
|
16
|
+
|
|
17
|
+
## Resources
|
|
18
|
+
|
|
19
|
+
- **knowbase** (57 ops)
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { APIClient } from './';
|
|
25
|
+
|
|
26
|
+
const client = new APIClient({ baseUrl, token });
|
|
27
|
+
|
|
28
|
+
await client.knowbase.list();
|
|
29
|
+
await client.knowbase.retrieve({ id: 1 });
|
|
30
|
+
await client.knowbase.create({ ... });
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
**SWR Hooks:**
|
|
34
|
+
```typescript
|
|
35
|
+
import { useKnowbaseList } from './hooks';
|
|
36
|
+
const { data, isLoading } = useKnowbaseList();
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## How It Works
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
DRF ViewSets → drf-spectacular → OpenAPI → IR Parser → Generator → This Client
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
**Configuration** (`api/config.py`):
|
|
46
|
+
```python
|
|
47
|
+
openapi_client = OpenAPIClientConfig(
|
|
48
|
+
enabled=True,
|
|
49
|
+
groups=[OpenAPIGroupConfig(name="ext_knowbase", apps=["..."])],
|
|
50
|
+
generate_zod_schemas=True, # → schemas.ts
|
|
51
|
+
generate_fetchers=True, # → fetchers.ts
|
|
52
|
+
generate_swr_hooks=True, # → hooks.ts
|
|
53
|
+
)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
**Copy to Next.js** (if `nextjs_admin` configured):
|
|
57
|
+
```python
|
|
58
|
+
nextjs_admin = NextJsAdminConfig(
|
|
59
|
+
project_path="../frontend/apps/...",
|
|
60
|
+
api_output_path="app/_lib/api/generated",
|
|
61
|
+
)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
@see https://djangocfg.com/docs/features/api-generation
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
/**
|
|
10
3
|
* Typed fetchers for Knowbase
|
|
11
4
|
*
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
/**
|
|
10
3
|
* Typed Fetchers - Universal API functions
|
|
11
4
|
*
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
'use client';
|
|
10
3
|
|
|
11
4
|
/**
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
'use client';
|
|
10
3
|
|
|
11
4
|
/**
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
/**
|
|
10
3
|
* Zod Schemas - Runtime validation and type inference
|
|
11
4
|
*
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
/**
|
|
10
3
|
* Global API Instance - Singleton configuration
|
|
11
4
|
*
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
/**
|
|
10
3
|
* Content classification
|
|
11
4
|
* * `document` - Document
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
/**
|
|
10
3
|
* API Error Classes
|
|
11
4
|
*
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
export * from "./client";
|
|
10
3
|
export * as Models from "./models";
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
import * as Enums from "../enums";
|
|
10
3
|
|
|
11
4
|
/**
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
/**
|
|
10
3
|
* HTTP Client Adapter Pattern
|
|
11
4
|
*
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
/**
|
|
10
3
|
* Django CFG API - API Client with JWT Management
|
|
11
4
|
*
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
/**
|
|
10
3
|
* API Logger with Consola
|
|
11
4
|
* Beautiful console logging for API requests and responses
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
/**
|
|
10
3
|
* Retry Configuration and Utilities
|
|
11
4
|
*
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
/**
|
|
10
3
|
* Storage adapters for cross-platform token storage.
|
|
11
4
|
*
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
3
|
-
*
|
|
4
|
-
* This file is automatically generated by DjangoCFG.
|
|
5
|
-
* Any manual changes will be lost when the code is regenerated.
|
|
6
|
-
*
|
|
7
|
-
* @see https://djangocfg.com/docs/features/modules/django-client/overview/
|
|
8
|
-
*/
|
|
1
|
+
// Auto-generated by DjangoCFG - see CLAUDE.md
|
|
9
2
|
/**
|
|
10
3
|
* Zod Validation Events - Browser CustomEvent integration
|
|
11
4
|
*
|
package/src/api/index.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { createExtensionAPI } from '@djangocfg/ext-base/api';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Knowbase Extension API
|
|
3
5
|
*
|
|
4
6
|
* Pre-configured API instance with shared authentication
|
|
5
7
|
*/
|
|
6
8
|
import { API } from './generated/ext_knowbase';
|
|
7
|
-
import { createExtensionAPI } from '@djangocfg/ext-base/api';
|
|
8
9
|
|
|
9
10
|
export const apiKnowbase = createExtensionAPI(API);
|
|
10
11
|
|
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
'use client';
|
|
7
7
|
|
|
8
|
-
import React, { createContext,
|
|
8
|
+
import React, { createContext, ReactNode, useCallback, useContext, useState } from 'react';
|
|
9
|
+
|
|
9
10
|
import type { ChatUIState } from './types';
|
|
10
11
|
|
|
11
12
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -5,23 +5,21 @@
|
|
|
5
5
|
|
|
6
6
|
'use client';
|
|
7
7
|
|
|
8
|
+
import { List, Maximize2, MessageSquare, Minimize2, Plus, X } from 'lucide-react';
|
|
9
|
+
import { usePathname } from 'next/navigation';
|
|
8
10
|
import React, { useCallback, useEffect, useState } from 'react';
|
|
9
11
|
import { createPortal } from 'react-dom';
|
|
10
|
-
|
|
11
|
-
import { Card, CardContent, CardHeader, Button, useIsMobile, useLocalStorage } from '@djangocfg/ui-nextjs';
|
|
12
|
+
|
|
12
13
|
import {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
Minimize2,
|
|
17
|
-
Plus,
|
|
18
|
-
List,
|
|
19
|
-
} from 'lucide-react';
|
|
14
|
+
Button, Card, CardContent, CardHeader, useIsMobile, useLocalStorage
|
|
15
|
+
} from '@djangocfg/ui-nextjs';
|
|
16
|
+
|
|
20
17
|
import { useKnowbaseChatContext, useKnowbaseSessionsContext } from '../../contexts/knowbase';
|
|
21
|
-
import { Enums } from './types';
|
|
22
18
|
import { chatLogger } from '../../utils/logger';
|
|
23
19
|
import { useChatUI } from './ChatUIContext';
|
|
24
|
-
import {
|
|
20
|
+
import { MessageInput, MessageList, SessionList } from './components';
|
|
21
|
+
import { Enums } from './types';
|
|
22
|
+
|
|
25
23
|
import type { ChatWidgetProps, ChatMessageWithSources } from './types';
|
|
26
24
|
|
|
27
25
|
const WIDGET_MAX_WIDTH = 800;
|
|
@@ -5,10 +5,13 @@
|
|
|
5
5
|
|
|
6
6
|
'use client';
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import { Loader2, Send } from 'lucide-react';
|
|
9
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
10
|
+
|
|
9
11
|
import { Button, Textarea } from '@djangocfg/ui-nextjs';
|
|
10
|
-
|
|
12
|
+
|
|
11
13
|
import { chatLogger } from '../../../utils/logger';
|
|
14
|
+
|
|
12
15
|
import type { MessageInputProps } from '../types';
|
|
13
16
|
|
|
14
17
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -5,13 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
'use client';
|
|
7
7
|
|
|
8
|
+
import { Bot, ExternalLink, Loader2, User } from 'lucide-react';
|
|
9
|
+
import moment from 'moment';
|
|
8
10
|
import React, { useEffect, useRef } from 'react';
|
|
9
|
-
|
|
10
|
-
import { Bot, User, ExternalLink, Loader2 } from 'lucide-react';
|
|
11
|
+
|
|
11
12
|
import { useAuth } from '@djangocfg/api/auth';
|
|
12
|
-
import
|
|
13
|
+
import {
|
|
14
|
+
Avatar, AvatarFallback, AvatarImage, Badge, Card, CardContent, ScrollArea
|
|
15
|
+
} from '@djangocfg/ui-nextjs';
|
|
16
|
+
|
|
13
17
|
import { Enums } from '../types';
|
|
14
18
|
|
|
19
|
+
import type { MessageListProps } from '../types';
|
|
15
20
|
// ─────────────────────────────────────────────────────────────────────────
|
|
16
21
|
// Message List Component
|
|
17
22
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -38,10 +43,14 @@ export const MessageList: React.FC<MessageListProps> = ({
|
|
|
38
43
|
}, [messages, isLoading, autoScroll]);
|
|
39
44
|
|
|
40
45
|
const formatTimestamp = (timestamp: string) => {
|
|
41
|
-
|
|
42
|
-
return date.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit' });
|
|
46
|
+
return moment.utc(timestamp).local().format('hh:mm A');
|
|
43
47
|
};
|
|
44
48
|
|
|
49
|
+
// Get user initial for avatar
|
|
50
|
+
const userInitial = user?.display_username?.charAt(0)?.toUpperCase()
|
|
51
|
+
|| user?.email?.charAt(0)?.toUpperCase()
|
|
52
|
+
|| null;
|
|
53
|
+
|
|
45
54
|
return (
|
|
46
55
|
<ScrollArea className={`h-full bg-muted/50 ${className}`} viewportRef={scrollRef}>
|
|
47
56
|
<div className="space-y-4 p-4">
|
|
@@ -133,9 +142,7 @@ export const MessageList: React.FC<MessageListProps> = ({
|
|
|
133
142
|
<Avatar className="h-8 w-8 shrink-0">
|
|
134
143
|
{user?.avatar && <AvatarImage src={user.avatar} alt={user.display_username || user.email || 'User'} />}
|
|
135
144
|
<AvatarFallback className="bg-primary/10 text-primary font-semibold">
|
|
136
|
-
{
|
|
137
|
-
user?.email?.charAt(0)?.toUpperCase() ||
|
|
138
|
-
<User className="h-5 w-5" />}
|
|
145
|
+
{userInitial || <User className="h-5 w-5" />}
|
|
139
146
|
</AvatarFallback>
|
|
140
147
|
</Avatar>
|
|
141
148
|
)}
|
|
@@ -5,20 +5,17 @@
|
|
|
5
5
|
|
|
6
6
|
'use client';
|
|
7
7
|
|
|
8
|
-
import
|
|
8
|
+
import { Archive, Clock, Loader2, MessageSquare, Trash2 } from 'lucide-react';
|
|
9
|
+
import moment from 'moment';
|
|
10
|
+
import React, { useCallback, useEffect, useRef } from 'react';
|
|
11
|
+
|
|
9
12
|
import {
|
|
10
|
-
|
|
11
|
-
SheetContent,
|
|
12
|
-
SheetHeader,
|
|
13
|
-
SheetTitle,
|
|
14
|
-
SheetDescription,
|
|
15
|
-
Button,
|
|
16
|
-
ScrollArea,
|
|
17
|
-
Badge,
|
|
13
|
+
Badge, Button, ScrollArea, Sheet, SheetContent, SheetDescription, SheetHeader, SheetTitle
|
|
18
14
|
} from '@djangocfg/ui-nextjs';
|
|
19
|
-
|
|
15
|
+
|
|
20
16
|
import { useKnowbaseSessionsContext } from '../../../contexts/knowbase';
|
|
21
17
|
import { useInfiniteSessions } from '../hooks/useInfiniteSessions';
|
|
18
|
+
|
|
22
19
|
import type { SessionListProps } from '../types';
|
|
23
20
|
|
|
24
21
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -68,8 +65,7 @@ export const SessionList: React.FC<SessionListProps> = ({
|
|
|
68
65
|
}, [handleScroll]);
|
|
69
66
|
|
|
70
67
|
const formatDate = (dateString: string) => {
|
|
71
|
-
|
|
72
|
-
return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
|
|
68
|
+
return moment.utc(dateString).local().format('MMM D');
|
|
73
69
|
};
|
|
74
70
|
|
|
75
71
|
return (
|
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
import useSWRInfinite from 'swr/infinite';
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
import { apiKnowbase, ExtKnowbaseFetchers, ExtKnowbaseTypes } from '../../../api';
|
|
8
9
|
|
|
9
10
|
type PaginatedChatSessionList = ExtKnowbaseTypes.PaginatedChatSessionList;
|
|
10
11
|
type ChatSession = ExtKnowbaseTypes.ChatSession;
|
|
@@ -7,9 +7,11 @@
|
|
|
7
7
|
'use client';
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
|
+
|
|
10
11
|
import { KnowbaseChatProvider, KnowbaseSessionsProvider } from '../../contexts/knowbase';
|
|
11
12
|
import { ChatUIProvider } from './ChatUIContext';
|
|
12
13
|
import { ChatWidget } from './ChatWidget';
|
|
14
|
+
|
|
13
15
|
import type { ChatWidgetProps } from './types';
|
|
14
16
|
|
|
15
17
|
// ─────────────────────────────────────────────────────────────────────────
|
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
// Import types from local generated API
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
Enums as GeneratedEnums, ExtKnowbaseKnowbaseTypes
|
|
9
|
+
} from '../../api/generated/ext_knowbase';
|
|
8
10
|
|
|
9
11
|
// ============================================================================
|
|
10
12
|
// Extract types from generated API
|
package/src/config.ts
CHANGED
|
@@ -5,19 +5,16 @@
|
|
|
5
5
|
|
|
6
6
|
'use client';
|
|
7
7
|
|
|
8
|
-
import React, { createContext,
|
|
8
|
+
import React, { createContext, ReactNode, useContext } from 'react';
|
|
9
9
|
|
|
10
10
|
import { apiKnowbase } from '../../api';
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
usePartialUpdateKnowbaseAdminChatPartialUpdate,
|
|
17
|
-
useDeleteKnowbaseAdminChatDestroy,
|
|
18
|
-
useKnowbaseAdminChatHistoryRetrieve,
|
|
19
|
-
useCreateKnowbaseAdminChatQueryCreate,
|
|
12
|
+
useCreateKnowbaseAdminChatCreate, useCreateKnowbaseAdminChatQueryCreate,
|
|
13
|
+
useDeleteKnowbaseAdminChatDestroy, useKnowbaseAdminChatHistoryRetrieve,
|
|
14
|
+
useKnowbaseAdminChatList, useKnowbaseAdminChatRetrieve,
|
|
15
|
+
usePartialUpdateKnowbaseAdminChatPartialUpdate, useUpdateKnowbaseAdminChatUpdate
|
|
20
16
|
} from '../../api/generated/ext_knowbase/_utils/hooks';
|
|
17
|
+
|
|
21
18
|
import type {
|
|
22
19
|
PaginatedChatResponseList,
|
|
23
20
|
ChatResponse,
|
|
@@ -5,27 +5,21 @@
|
|
|
5
5
|
|
|
6
6
|
'use client';
|
|
7
7
|
|
|
8
|
-
import React, { createContext,
|
|
8
|
+
import React, { createContext, ReactNode, useContext } from 'react';
|
|
9
9
|
|
|
10
10
|
import { apiKnowbase } from '../../api';
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
useKnowbaseSystemArchivesList,
|
|
22
|
-
useKnowbaseSystemArchivesRetrieve,
|
|
23
|
-
useCreateKnowbaseSystemArchivesCreate,
|
|
24
|
-
useUpdateKnowbaseSystemArchivesUpdate,
|
|
25
|
-
usePartialUpdateKnowbaseSystemArchivesPartialUpdate,
|
|
26
|
-
useDeleteKnowbaseSystemArchivesDestroy,
|
|
27
|
-
useKnowbaseSystemArchivesStatisticsRetrieve,
|
|
12
|
+
useCreateKnowbaseAdminDocumentsCreate, useCreateKnowbaseAdminDocumentsReprocessCreate,
|
|
13
|
+
useCreateKnowbaseSystemArchivesCreate, useDeleteKnowbaseAdminDocumentsDestroy,
|
|
14
|
+
useDeleteKnowbaseSystemArchivesDestroy, useKnowbaseAdminDocumentsList,
|
|
15
|
+
useKnowbaseAdminDocumentsRetrieve, useKnowbaseAdminDocumentsStatsRetrieve,
|
|
16
|
+
useKnowbaseAdminDocumentsStatusRetrieve, useKnowbaseSystemArchivesList,
|
|
17
|
+
useKnowbaseSystemArchivesRetrieve, useKnowbaseSystemArchivesStatisticsRetrieve,
|
|
18
|
+
usePartialUpdateKnowbaseAdminDocumentsPartialUpdate,
|
|
19
|
+
usePartialUpdateKnowbaseSystemArchivesPartialUpdate, useUpdateKnowbaseAdminDocumentsUpdate,
|
|
20
|
+
useUpdateKnowbaseSystemArchivesUpdate
|
|
28
21
|
} from '../../api/generated/ext_knowbase/_utils/hooks';
|
|
22
|
+
|
|
29
23
|
import type {
|
|
30
24
|
PaginatedDocumentList,
|
|
31
25
|
Document,
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import type { ReactNode } from 'react';
|
|
10
10
|
import { ExtensionProvider } from '@djangocfg/ext-base/hooks';
|
|
11
|
+
|
|
11
12
|
import { extensionConfig } from '../../config';
|
|
12
13
|
import { KnowbaseChatProvider } from './ChatContext';
|
|
13
14
|
import { KnowbaseDocumentsProvider } from './DocumentsContext';
|
|
@@ -5,19 +5,16 @@
|
|
|
5
5
|
|
|
6
6
|
'use client';
|
|
7
7
|
|
|
8
|
-
import React, { createContext,
|
|
8
|
+
import React, { createContext, ReactNode, useContext } from 'react';
|
|
9
9
|
|
|
10
10
|
import { apiKnowbase } from '../../api';
|
|
11
11
|
import {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
usePartialUpdateKnowbaseAdminSessionsPartialUpdate,
|
|
17
|
-
useDeleteKnowbaseAdminSessionsDestroy,
|
|
18
|
-
useCreateKnowbaseAdminSessionsActivateCreate,
|
|
19
|
-
useCreateKnowbaseAdminSessionsArchiveCreate,
|
|
12
|
+
useCreateKnowbaseAdminSessionsActivateCreate, useCreateKnowbaseAdminSessionsArchiveCreate,
|
|
13
|
+
useCreateKnowbaseAdminSessionsCreate, useDeleteKnowbaseAdminSessionsDestroy,
|
|
14
|
+
useKnowbaseAdminSessionsList, useKnowbaseAdminSessionsRetrieve,
|
|
15
|
+
usePartialUpdateKnowbaseAdminSessionsPartialUpdate, useUpdateKnowbaseAdminSessionsUpdate
|
|
20
16
|
} from '../../api/generated/ext_knowbase/_utils/hooks';
|
|
17
|
+
|
|
21
18
|
import type {
|
|
22
19
|
PaginatedChatSessionList,
|
|
23
20
|
ChatSession,
|