You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: API.md
+45Lines changed: 45 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -245,6 +245,35 @@ Frees the current inference context.
245
245
SELECT llm_context_free();
246
246
```
247
247
248
+
---
249
+
## `llm_context_size()`
250
+
251
+
**Returns:**`INTEGER`
252
+
253
+
**Description**:
254
+
Returns the total token capacity (context window) of the current llama context. Use this after `llm_context_create` to confirm the configured `context_size`. Raises an error if no context is active.
255
+
256
+
```sql
257
+
SELECT llm_context_size();
258
+
-- 4096
259
+
```
260
+
261
+
---
262
+
263
+
## `llm_context_used()`
264
+
265
+
**Returns:**`INTEGER`
266
+
267
+
**Description:**
268
+
Returns how many tokens of the current llama context have already been consumed. Combine this with `llm_context_size()` to monitor usage. Raises an error if no context is active.
Returns how many tokens the current model would consume for the supplied `text`, using the active context’s vocabulary. Requires a context created via `llm_context_create`.
0 commit comments