@gemina/sdk 0.1.2 → 0.2.1
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 +37 -0
- package/dist/index.cjs +553 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +639 -6
- package/dist/index.d.ts +639 -6
- package/dist/index.js +521 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -112,6 +112,30 @@ for (const row of rows ?? []) {
|
|
|
112
112
|
|
|
113
113
|
Check how many of your documents are indexed with `client.retrieval.retrievalStatus()` (returns `{ indexedDocuments }`).
|
|
114
114
|
|
|
115
|
+
**Advanced filters & match highlights.** Beyond the promoted `filters`, filter on *any* structured field a document has with `structuredFilters` (`op` is one of `eq` / `neq` / `gt` / `lt` / `contains` / `exists`, max 8), and read back the line-item snippet that made a document match via `matchedChunks`:
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
const { items } = await client.retrieval.retrievalQuery({
|
|
119
|
+
retrievalQueryInDTO: {
|
|
120
|
+
mode: "hybrid",
|
|
121
|
+
text: "27-inch monitors",
|
|
122
|
+
structuredFilters: [{ path: "position", op: "contains", value: "engineer" }],
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
for (const item of items ?? []) {
|
|
126
|
+
for (const chunk of item.matchedChunks ?? []) {
|
|
127
|
+
console.log(item.documentId, "matched on:", chunk.text);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Discover which fields you can filter on with `client.retrieval.retrievalFields()` — it returns the structured field names per document type (names only, never values), so you can build a field picker from real data:
|
|
133
|
+
|
|
134
|
+
```ts
|
|
135
|
+
const { fields } = await client.retrieval.retrievalFields();
|
|
136
|
+
// -> [{ documentType: "invoice", field: "vendor_name", count: 42 }, ...]
|
|
137
|
+
```
|
|
138
|
+
|
|
115
139
|
## Chat with your documents
|
|
116
140
|
|
|
117
141
|
Ask free-form questions over everything you've processed. Answers come back with a confidence signal and citations to the source documents:
|
|
@@ -128,6 +152,19 @@ console.log("citations:", reply.citations);
|
|
|
128
152
|
|
|
129
153
|
Chat requires a plan with Document Intelligence enabled — see [pricing](https://gemina.co/pricing). Without it the API responds `402`/`403`.
|
|
130
154
|
|
|
155
|
+
**Multi-turn conversations (memory).** For a back-and-forth where follow-ups keep context, use a **conversation** — it threads the server-issued `sessionId` for you:
|
|
156
|
+
|
|
157
|
+
```ts
|
|
158
|
+
const chat = client.conversation();
|
|
159
|
+
await chat.send("How much did we spend on cleaning in 2020?");
|
|
160
|
+
const follow = await chat.send("And which vendor was most expensive?"); // remembers 2020 / cleaning
|
|
161
|
+
console.log(follow.answer, "· session:", chat.sessionId);
|
|
162
|
+
|
|
163
|
+
await chat.delete(); // end it server-side (or chat.reset() to just forget it locally)
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
A conversation expires after 24h of inactivity; the next `send` then throws the API's `404 CHAT_SESSION_NOT_FOUND` — call `chat.reset()` and resend to continue in a fresh one. One-shot `client.chat.chatQuery({ chatQueryInDTO: { message, sessionId } })` is still available if you'd rather hold the id yourself; every response returns a `sessionId`.
|
|
167
|
+
|
|
131
168
|
## Session tokens (browser embedding)
|
|
132
169
|
|
|
133
170
|
To embed search or chat in your own frontend, mint a short-lived session token **server-side** and hand that to the browser — never the API key:
|