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
package/README.md
CHANGED
|
@@ -105,6 +105,105 @@ const components: GentiqComponents = {
|
|
|
105
105
|
};
|
|
106
106
|
```
|
|
107
107
|
|
|
108
|
+
### References for Text, Tools, and Custom Cards
|
|
109
|
+
|
|
110
|
+
Gentiq includes a built-in reference UX similar to modern AI chat apps. Users can select text in previous messages, click the reference action, and Gentiq will add a compact quote chip to the composer. When the message is sent, the referenced context is sent to the backend/model and shown as a clickable badge in the chat.
|
|
111
|
+
|
|
112
|
+
For normal text messages, this works automatically. For custom cards, use `Referenceable` or `useChatReferences` so Gentiq knows exactly what should be referenced and how it should appear to the user.
|
|
113
|
+
|
|
114
|
+
#### Reference a custom card
|
|
115
|
+
|
|
116
|
+
Use `Referenceable` when your component has a clear card-like boundary. Gentiq will add a hover reference action, register the source for click-to-highlight, and send the structured reference with the next user message.
|
|
117
|
+
|
|
118
|
+
```tsx
|
|
119
|
+
import { Referenceable } from 'gentiq';
|
|
120
|
+
|
|
121
|
+
function CarCard({ car }) {
|
|
122
|
+
return (
|
|
123
|
+
<Referenceable
|
|
124
|
+
reference={{
|
|
125
|
+
kind: 'car',
|
|
126
|
+
sourceId: `car-${car.id}`,
|
|
127
|
+
label: 'Car',
|
|
128
|
+
excerpt: `${car.year} ${car.make} ${car.model} · ${car.price}`,
|
|
129
|
+
data: {
|
|
130
|
+
carId: car.id,
|
|
131
|
+
make: car.make,
|
|
132
|
+
model: car.model,
|
|
133
|
+
year: car.year,
|
|
134
|
+
price: car.price,
|
|
135
|
+
},
|
|
136
|
+
}}
|
|
137
|
+
>
|
|
138
|
+
<div className="car-card">
|
|
139
|
+
<CarImageCarousel images={car.images} />
|
|
140
|
+
<h3>{car.year} {car.make} {car.model}</h3>
|
|
141
|
+
<p>{car.price}</p>
|
|
142
|
+
</div>
|
|
143
|
+
</Referenceable>
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`excerpt` is the human-readable text shown in the composer chip and reference badge. `data` is optional structured context, useful for IDs or machine-readable values like `{ carId }`.
|
|
149
|
+
|
|
150
|
+
#### Use your own reference button
|
|
151
|
+
|
|
152
|
+
If you do not want the built-in hover action, call `addReference` yourself. Keep the `sourceId` on the element you want highlighted later.
|
|
153
|
+
|
|
154
|
+
```tsx
|
|
155
|
+
import { useChatReferences } from 'gentiq';
|
|
156
|
+
|
|
157
|
+
function CarCard({ car }) {
|
|
158
|
+
const { addReference } = useChatReferences();
|
|
159
|
+
|
|
160
|
+
const reference = {
|
|
161
|
+
kind: 'car',
|
|
162
|
+
sourceId: `car-${car.id}`,
|
|
163
|
+
label: 'Car',
|
|
164
|
+
excerpt: `${car.year} ${car.make} ${car.model} · ${car.price}`,
|
|
165
|
+
data: { carId: car.id },
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
return (
|
|
169
|
+
<div data-gentiq-reference-source-id={reference.sourceId}>
|
|
170
|
+
<CarImageCarousel images={car.images} />
|
|
171
|
+
<h3>{car.year} {car.make} {car.model}</h3>
|
|
172
|
+
|
|
173
|
+
<button type="button" onClick={() => addReference(reference)}>
|
|
174
|
+
Reference this car
|
|
175
|
+
</button>
|
|
176
|
+
</div>
|
|
177
|
+
);
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
#### Customize tool/card reference text
|
|
182
|
+
|
|
183
|
+
For tool-rendered cards, use `referenceAdapters` to control what appears in the composer and sent reference context. This avoids showing raw JSON to users.
|
|
184
|
+
|
|
185
|
+
```tsx
|
|
186
|
+
const components: GentiqComponents = {
|
|
187
|
+
toolComponents: {
|
|
188
|
+
get_weather: WeatherCard,
|
|
189
|
+
},
|
|
190
|
+
referenceAdapters: {
|
|
191
|
+
get_weather: ({ part }) => ({
|
|
192
|
+
label: 'Weather',
|
|
193
|
+
excerpt: `Weather: ${part.output.city}: ${part.output.condition}`,
|
|
194
|
+
data: {
|
|
195
|
+
city: part.output.city,
|
|
196
|
+
condition: part.output.condition,
|
|
197
|
+
},
|
|
198
|
+
}),
|
|
199
|
+
},
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
<ChatUI components={components} />
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
For markdown patterns like `[CarCard](car_id)`, render your `CarCard` from the markdown override, fetch the car data as usual, and wrap the rendered card with `Referenceable` as shown above.
|
|
206
|
+
|
|
108
207
|
---
|
|
109
208
|
|
|
110
209
|
## ⚓ Headless Mode
|