gentiq 0.8.0 → 0.8.2
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 +99 -0
- package/dist/{checkbox-CjhpdOWd.js → checkbox-BZPTGt7D.js} +2076 -1406
- package/dist/gentiq-admin.es.js +1274 -1212
- package/dist/gentiq-index.es.js +972 -926
- package/dist/gentiq.css +1 -1
- package/dist/src/ChatReferencesContext.d.ts +27 -0
- package/dist/src/ComponentsContext.d.ts +2 -1
- package/dist/src/components/PromptInputArea.d.ts +2 -1
- package/dist/src/hooks/useGentiqChat.d.ts +2 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/locales/en.json.d.ts +8 -0
- package/dist/src/locales/fa.json.d.ts +8 -0
- package/dist/src/parts/ChoiceQuestionPart.d.ts +5 -0
- package/dist/src/parts/ReferencePart.d.ts +3 -0
- package/dist/src/parts/TextPart.d.ts +1 -1
- package/dist/src/parts/index.d.ts +2 -0
- package/dist/src/types.d.ts +114 -1
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { HTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
import { ChatReference, ChatReferenceInput } from './types';
|
|
3
|
+
interface ChatReferencesContextValue {
|
|
4
|
+
references: ChatReference[];
|
|
5
|
+
addReference: (reference: ChatReferenceInput) => ChatReference | null;
|
|
6
|
+
removeReference: (id: string) => void;
|
|
7
|
+
clearReferences: () => void;
|
|
8
|
+
focusReference: (reference: ChatReference) => boolean;
|
|
9
|
+
registerSource: (reference: ChatReferenceInput) => void;
|
|
10
|
+
unregisterSource: (sourceId?: string) => void;
|
|
11
|
+
enabled: boolean;
|
|
12
|
+
}
|
|
13
|
+
interface ChatReferencesProviderProps {
|
|
14
|
+
enabled?: boolean;
|
|
15
|
+
readonly?: boolean;
|
|
16
|
+
maxItems?: number;
|
|
17
|
+
maxExcerptLength?: number;
|
|
18
|
+
children: ReactNode;
|
|
19
|
+
}
|
|
20
|
+
export declare function ChatReferencesProvider({ enabled, readonly, maxItems, maxExcerptLength, children, }: ChatReferencesProviderProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export declare function useChatReferences(): ChatReferencesContextValue;
|
|
22
|
+
export interface ReferenceableProps extends HTMLAttributes<HTMLDivElement> {
|
|
23
|
+
reference: ChatReferenceInput;
|
|
24
|
+
showAction?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare function Referenceable({ reference, showAction, className, children, ...props }: ReferenceableProps): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
export {};
|
|
@@ -4,8 +4,9 @@ import { GentiqComponents } from './types';
|
|
|
4
4
|
* The resolved component map: every key is guaranteed to be defined.
|
|
5
5
|
* Leaf components read from this context — no prop drilling required.
|
|
6
6
|
*/
|
|
7
|
-
type ResolvedComponents = Required<Omit<GentiqComponents, 'toolComponents' | 'textComponents' | 'remarkPlugins' | 'rehypePlugins'>> & {
|
|
7
|
+
type ResolvedComponents = Required<Omit<GentiqComponents, 'toolComponents' | 'referenceAdapters' | 'textComponents' | 'remarkPlugins' | 'rehypePlugins'>> & {
|
|
8
8
|
toolComponents?: GentiqComponents['toolComponents'];
|
|
9
|
+
referenceAdapters?: GentiqComponents['referenceAdapters'];
|
|
9
10
|
textComponents?: GentiqComponents['textComponents'];
|
|
10
11
|
remarkPlugins?: GentiqComponents['remarkPlugins'];
|
|
11
12
|
rehypePlugins?: GentiqComponents['rehypePlugins'];
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { ChatReference } from '../types';
|
|
1
2
|
interface PromptInputAreaProps {
|
|
2
|
-
onSend: (text: string, files?: FileList) => void;
|
|
3
|
+
onSend: (text: string, files?: FileList, references?: ChatReference[]) => void;
|
|
3
4
|
status: string;
|
|
4
5
|
isLastMessageFinished: boolean;
|
|
5
6
|
stop: () => void;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { ChatReference } from '../types';
|
|
1
2
|
export type ChatStatus = 'idle' | 'loading-history' | 'ready' | 'streaming' | 'error' | 'submitted';
|
|
2
3
|
export interface UseGentiqChatOptions {
|
|
3
4
|
onFinish?: () => void;
|
|
4
5
|
}
|
|
5
6
|
export declare function useGentiqChat({ onFinish }?: UseGentiqChatOptions): {
|
|
6
|
-
sendMessage: (text: string, files?: FileList) => Promise<void>;
|
|
7
|
+
sendMessage: (text: string, files?: FileList, references?: ChatReference[]) => Promise<void>;
|
|
7
8
|
stop: () => void;
|
|
8
9
|
clearError: () => void;
|
|
9
10
|
error: Error | null;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ export { TextPart } from './parts/TextPart';
|
|
|
8
8
|
export { ReasoningPart } from './parts/ReasoningPart';
|
|
9
9
|
export { ToolPart } from './parts/ToolPart';
|
|
10
10
|
export { FilePart } from './parts/FilePart';
|
|
11
|
+
export { ReferencePart } from './parts/ReferencePart';
|
|
12
|
+
export { ChoiceQuestionPart } from './parts/ChoiceQuestionPart';
|
|
13
|
+
export { Referenceable, useChatReferences } from './ChatReferencesContext';
|
|
11
14
|
export { MessageList } from './components/MessageList';
|
|
12
15
|
export { PromptInputArea } from './components/PromptInputArea';
|
|
13
16
|
export { SettingsDialog } from './components/SettingsDialog';
|
|
@@ -39,6 +39,13 @@ declare const _default: {
|
|
|
39
39
|
"dislike": "Dislike",
|
|
40
40
|
"attach_file": "Attach file",
|
|
41
41
|
"remove_file": "Remove file",
|
|
42
|
+
"reference": "Reference",
|
|
43
|
+
"reference_selection": "Reference selection",
|
|
44
|
+
"remove_reference": "Remove reference",
|
|
45
|
+
"referenced_context": "Referenced context",
|
|
46
|
+
"source_unavailable": "Source unavailable",
|
|
47
|
+
"tool_reference": "Tool reference",
|
|
48
|
+
"card_reference": "Card reference",
|
|
42
49
|
"used_sources": "Used {{count}} sources",
|
|
43
50
|
"welcome": {
|
|
44
51
|
"title": "Hello! How can I help you today?",
|
|
@@ -204,6 +211,7 @@ declare const _default: {
|
|
|
204
211
|
"threads_chart": "Threads",
|
|
205
212
|
"messages_chart": "Messages",
|
|
206
213
|
"token_usage_chart": "Token Usage",
|
|
214
|
+
"cost_chart": "Cost Per Day",
|
|
207
215
|
"active_users": "Active Users",
|
|
208
216
|
"conversations": "conversations",
|
|
209
217
|
"threads": "threads",
|
|
@@ -39,6 +39,13 @@ declare const _default: {
|
|
|
39
39
|
"dislike": "نپسندیدم",
|
|
40
40
|
"attach_file": "پیوست فایل",
|
|
41
41
|
"remove_file": "حذف فایل",
|
|
42
|
+
"reference": "ارجاع",
|
|
43
|
+
"reference_selection": "ارجاع به بخش انتخابشده",
|
|
44
|
+
"remove_reference": "حذف ارجاع",
|
|
45
|
+
"referenced_context": "بخش ارجاعشده",
|
|
46
|
+
"source_unavailable": "منبع در دسترس نیست",
|
|
47
|
+
"tool_reference": "ارجاع به ابزار",
|
|
48
|
+
"card_reference": "ارجاع به کارت",
|
|
42
49
|
"used_sources": "از {{count}} منبع استفاده شد",
|
|
43
50
|
"welcome": {
|
|
44
51
|
"title": "سلام! چطور میتونم کمکت کنم؟",
|
|
@@ -203,6 +210,7 @@ declare const _default: {
|
|
|
203
210
|
"threads_chart": "گفتگوها",
|
|
204
211
|
"messages_chart": "پیامها",
|
|
205
212
|
"token_usage_chart": "مصرف توکن",
|
|
213
|
+
"cost_chart": "هزینه روزانه",
|
|
206
214
|
"active_users": "کاربران فعال",
|
|
207
215
|
"conversations": "گفتگو",
|
|
208
216
|
"threads": "گفتگو",
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { ChoiceQuestion, ChoiceQuestionPartProps } from '../types';
|
|
2
|
+
export type { ChoiceQuestionPartProps } from '../types';
|
|
3
|
+
export declare function normalizeChoiceQuestion(data: unknown): ChoiceQuestion | null;
|
|
4
|
+
export declare function extractChoiceQuestionFromText(text: string | undefined): ChoiceQuestion | null;
|
|
5
|
+
export declare function ChoiceQuestionPart({ part, disabled, onAnswer }: ChoiceQuestionPartProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { TextPartProps } from '../types';
|
|
2
2
|
export type { TextPartProps } from '../types';
|
|
3
|
-
export declare function TextPart({ part, message, status, isFinished, lastMessage, isLastVisiblePart, regen, feedback, handleFeedback, copyHost, feedbackEnabled, retryEnabled, }: TextPartProps): import("react/jsx-runtime").JSX.Element;
|
|
3
|
+
export declare function TextPart({ part, message, status, isFinished, lastMessage, isLastVisiblePart, regen, feedback, handleFeedback, copyHost, feedbackEnabled, retryEnabled, reference, }: TextPartProps): import("react/jsx-runtime").JSX.Element;
|
package/dist/src/types.d.ts
CHANGED
|
@@ -198,6 +198,15 @@ export interface ComposerConfig {
|
|
|
198
198
|
/** Allowed MIME types for files. */
|
|
199
199
|
types?: string[];
|
|
200
200
|
};
|
|
201
|
+
/** Configuration for chat references. */
|
|
202
|
+
references?: {
|
|
203
|
+
/** Whether users can reference earlier chat content from the composer. */
|
|
204
|
+
enabled?: boolean;
|
|
205
|
+
/** Maximum number of active references in the composer. Defaults to 5. */
|
|
206
|
+
maxItems?: number;
|
|
207
|
+
/** Maximum excerpt length stored/sent for each reference. Defaults to 500. */
|
|
208
|
+
maxExcerptLength?: number;
|
|
209
|
+
};
|
|
201
210
|
}
|
|
202
211
|
/**
|
|
203
212
|
* Configuration for the UI theme and styling.
|
|
@@ -401,6 +410,90 @@ export interface TextPartProps {
|
|
|
401
410
|
feedbackEnabled?: boolean;
|
|
402
411
|
/** Whether the retry button is enabled. */
|
|
403
412
|
retryEnabled?: boolean;
|
|
413
|
+
/** Reference metadata for the visible text content. */
|
|
414
|
+
reference?: ChatReferenceInput;
|
|
415
|
+
}
|
|
416
|
+
/**
|
|
417
|
+
* Structured reference context selected from an earlier message or explicit UI card.
|
|
418
|
+
*/
|
|
419
|
+
export interface ChatReference {
|
|
420
|
+
/** Unique ID for this reference instance. */
|
|
421
|
+
id: string;
|
|
422
|
+
/** Reference source type. */
|
|
423
|
+
kind: 'text' | 'card' | 'tool' | 'file' | string;
|
|
424
|
+
/** Source message ID, when the source belongs to a chat message. */
|
|
425
|
+
messageId?: string;
|
|
426
|
+
/** Source part index, when the source belongs to a message part. */
|
|
427
|
+
partIndex?: number;
|
|
428
|
+
/** Stable DOM/source identifier used for focus and highlighting. */
|
|
429
|
+
sourceId?: string;
|
|
430
|
+
/** Human-readable source label shown in UI and sent as context. */
|
|
431
|
+
label: string;
|
|
432
|
+
/** Human-readable selected or summarized content. */
|
|
433
|
+
excerpt: string;
|
|
434
|
+
/** Role of the source message. */
|
|
435
|
+
role?: UIMessage['role'];
|
|
436
|
+
/** Optional structured data for custom cards/tools. */
|
|
437
|
+
data?: unknown;
|
|
438
|
+
/** Optional source metadata for apps that need provenance. */
|
|
439
|
+
metadata?: Record<string, unknown>;
|
|
440
|
+
}
|
|
441
|
+
export type ChatReferenceInput = Omit<ChatReference, 'id'> & {
|
|
442
|
+
id?: string;
|
|
443
|
+
};
|
|
444
|
+
export interface ReferenceAdapterContext {
|
|
445
|
+
/** The source part being referenced. */
|
|
446
|
+
part: UIMessagePart<any, any>;
|
|
447
|
+
/** The parent message object. */
|
|
448
|
+
message: UIMessage;
|
|
449
|
+
/** Resolved tool name for tool parts, when available. */
|
|
450
|
+
toolName?: string;
|
|
451
|
+
/** Direct access to the chat state if needed. */
|
|
452
|
+
chat?: any;
|
|
453
|
+
}
|
|
454
|
+
export type ReferenceAdapter = (context: ReferenceAdapterContext) => Partial<ChatReferenceInput> | null | undefined;
|
|
455
|
+
export interface ReferencePartProps {
|
|
456
|
+
/** Reference part stored on a user message. */
|
|
457
|
+
part: UIMessagePart<any, any> & {
|
|
458
|
+
type: 'data-reference';
|
|
459
|
+
data?: ChatReference;
|
|
460
|
+
reference?: ChatReference;
|
|
461
|
+
};
|
|
462
|
+
/** Parent message. */
|
|
463
|
+
message: UIMessage;
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* One selectable option shown in a Gentiq choice question.
|
|
467
|
+
*/
|
|
468
|
+
export interface ChoiceQuestionChoice {
|
|
469
|
+
/** Human-readable option shown to the user and sent when selected. */
|
|
470
|
+
label: string;
|
|
471
|
+
/** Optional app-specific value for custom renderers. */
|
|
472
|
+
value?: unknown;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Structured assistant question that can be answered with one tap.
|
|
476
|
+
*/
|
|
477
|
+
export interface ChoiceQuestion {
|
|
478
|
+
/** The question shown above the options. */
|
|
479
|
+
question: string;
|
|
480
|
+
/** Choices the user can select. */
|
|
481
|
+
choices: ChoiceQuestionChoice[];
|
|
482
|
+
/** Whether the default renderer should show a custom answer field. Defaults to true. */
|
|
483
|
+
allowCustom?: boolean;
|
|
484
|
+
}
|
|
485
|
+
export interface ChoiceQuestionPartProps {
|
|
486
|
+
/** Choice-question data part produced by the Gentiq backend. */
|
|
487
|
+
part: UIMessagePart<any, any> & {
|
|
488
|
+
type: 'data-choice-question';
|
|
489
|
+
data?: ChoiceQuestion | ChoiceQuestion[];
|
|
490
|
+
};
|
|
491
|
+
/** Parent message. */
|
|
492
|
+
message: UIMessage;
|
|
493
|
+
/** Whether the controls should accept an answer. */
|
|
494
|
+
disabled?: boolean;
|
|
495
|
+
/** Submit a selected/custom answer as a normal user message. */
|
|
496
|
+
onAnswer?: (answer: string) => void | Promise<void>;
|
|
404
497
|
}
|
|
405
498
|
/**
|
|
406
499
|
* Props for the ReasoningPart component, which renders chain-of-thought steps.
|
|
@@ -484,7 +577,7 @@ export interface MessageListProps {
|
|
|
484
577
|
*/
|
|
485
578
|
export interface PromptInputProps {
|
|
486
579
|
/** Callback to send a message. */
|
|
487
|
-
onSend: (text: string, files?: FileList) => void;
|
|
580
|
+
onSend: (text: string, files?: FileList, references?: ChatReference[]) => void;
|
|
488
581
|
/** Current chat status. */
|
|
489
582
|
status: string;
|
|
490
583
|
/** Whether the last message has finished streaming. */
|
|
@@ -538,12 +631,32 @@ export interface GentiqComponents {
|
|
|
538
631
|
ToolPart?: ComponentType<ToolPartProps>;
|
|
539
632
|
/** Replaces the file attachment renderer */
|
|
540
633
|
FilePart?: ComponentType<FilePartProps>;
|
|
634
|
+
/** Replaces the reference renderer */
|
|
635
|
+
ReferencePart?: ComponentType<ReferencePartProps>;
|
|
636
|
+
/** Replaces the multiple-choice question renderer */
|
|
637
|
+
ChoiceQuestionPart?: ComponentType<ChoiceQuestionPartProps>;
|
|
541
638
|
/**
|
|
542
639
|
* Per-tool-name component overrides.
|
|
543
640
|
* Takes priority over a custom ToolPart if the tool name matches.
|
|
544
641
|
* @example { get_weather: WeatherCard, run_code: CodeCard }
|
|
545
642
|
*/
|
|
546
643
|
toolComponents?: Record<string, ComponentType<ToolCallComponentProps>>;
|
|
644
|
+
/**
|
|
645
|
+
* Per-tool/card reference display adapters.
|
|
646
|
+
* Return label/excerpt/data overrides used in composer chips, sent context,
|
|
647
|
+
* and reference badges.
|
|
648
|
+
*
|
|
649
|
+
* @example
|
|
650
|
+
* ```ts
|
|
651
|
+
* referenceAdapters: {
|
|
652
|
+
* get_weather: ({ part }) => ({
|
|
653
|
+
* label: 'Weather',
|
|
654
|
+
* excerpt: `Weather: ${part.output.city}: ${part.output.condition}`,
|
|
655
|
+
* }),
|
|
656
|
+
* }
|
|
657
|
+
* ```
|
|
658
|
+
*/
|
|
659
|
+
referenceAdapters?: Record<string, ReferenceAdapter>;
|
|
547
660
|
/** Custom components mapping for markdown rendering overrides. */
|
|
548
661
|
textComponents?: Record<string, ComponentType<any>>;
|
|
549
662
|
/** Custom remark plugins for markdown parsing. */
|