Grid agents
Grid agents
Ask your data in plain words. YuktAI turns a question into filters, sorting and summaries with rules, not a remote model, so it is instant, private and gives the same answer every time.
1. Question bar and assistant on a grid
Try the example buttons, or type your own question. The assistant (the chat button inside the grid) also takes voice and Telugu custom rules such as ఎక్కువ జీతం.
Live demo
Loading…
WebMCP: checking…
"use client"
import { YuktaiGrid, useAgenticGrid, AgenticGridBar } from "@yuktishaalaa/yuktai"
import { rows, columns } from "./data"
export default function StaffPage() {
// The question bar filters/sorts the rows; the grid shows the result.
const agent = useAgenticGrid({ data: rows, columns, rowKey: "id" })
return (
<main>
<AgenticGridBar
grid={agent}
examples={["salary over 1 lakh", "Engineering in Hyderabad", "average salary by department"]}
/>
<YuktaiGrid
data={agent.gridData}
highlightIds={agent.highlightIds}
columns={columns}
rowKey="id"
ai
inputLanguage="en-IN"
webmcp
toolName="staff_grid"
customRules={[
{
name: "high-earners",
phrases: ["high earners", "ఎక్కువ జీతం", "ज़्यादा वेतन"],
execute: async ({ executeTool }) =>
(await executeTool("filter", { key: "salary", operator: "greaterThan", value: 100000 })).message,
},
]}
/>
</main>
)
}<div id="staff"></div>
<script>
const grid = yuktai.renderGrid("#staff", {
data: rows,
columns,
rowKey: "id",
agentic: {
title: "Ask about the staff data",
examples: ["salary over 1 lakh", "Engineering in Hyderabad", "average salary by department"]
},
ai: true, // assistant with voice input
inputLanguage: "en-IN",
webmcp: true, // tools for browser AI agents
toolName: "staff_grid",
customRules: [{
name: "high-earners",
phrases: ["high earners", "ఎక్కువ జీతం", "ज़्यादा वेतन"],
execute: async (ctx) =>
(await ctx.executeTool("filter", { key: "salary", operator: "greaterThan", value: 100000 })).message
}],
onAgentResult: (r) => console.log(r.success, r.message)
})
// or from code:
await grid.ask("salary over 1 lakh in Hyderabad")
await grid.askDetailed("average salary by department") // { answer, kind, table, steps, … }
</script>2. Agent without the grid (your own table)
Use the question bar with any table: the agent gives you the rows to show and the IDs to highlight.
Live demo
"use client"
import { useAgenticGrid, AgenticGridBar } from "@yuktishaalaa/yuktai"
export function MyTable({ rows, columns }) {
const agent = useAgenticGrid({ data: rows, columns, rowKey: "id" })
return (
<>
<AgenticGridBar grid={agent} examples={["salary under 60k", "total salary by city"]} />
<table>
<tbody>
{agent.gridData.map((r) => (
<tr key={r.id} aria-current={agent.highlightIds.includes(String(r.id)) || undefined}>
<td>{r.name}</td><td>{r.city}</td><td>{r.salary}</td>
</tr>
))}
</tbody>
</table>
</>
)
}const agentic = yuktai.createAgenticGrid({ data: rows, columns, rowKey: "id" })
yuktai.mountAgenticGridBar("#bar", agentic, { examples: ["salary under 60k", "total salary by city"] })
agentic.subscribe((s) => drawMyTable(s.gridData, s.highlightIds))3. Grid tools and the phrase agent
The grid tools (search, count, columns, get row, filter, clear filters, sort, clear sort, plus highlight, select and open when you pass their handlers: up to 11) can be driven by the phrase agent, by your own code, or by a browser AI agent through WebMCP. Results are always { success, message, data?, error? } and never throw.
Live demo
import { createGridTools, useYuktaiGridAgent, parseGridIntent } from "@yuktishaalaa/yuktai"
// In a component: const agent = useYuktaiGridAgent({ tools, columns, customRules, locale: "te" })
const tools = createGridTools(
{ data: rows, columns, rowKey: "id", onFiltersChange: setFilters, onSortChange: setSort },
{ name: "staff_grid" }
)
const result = await tools.find((t) => t.name.endsWith("count")).execute({})
parseGridIntent("sort by salary desc", { columns }) // which tool to run, with its argumentsconst tools = yuktai.createGridTools(
{ data: rows, columns, rowKey: "id", onFiltersChange, onSortChange },
{ name: "staff_grid" }
)
const agent = yuktai.createGridAgent({ tools, columns, customRules, locale: "te" })
const result = await agent.ask("sort by salary desc") // { success, message, tool, … }
// Browser AI agents (Chrome WebMCP): register the same tools
yuktai.registerWebMCP(tools, { onStatusChange: (s) => console.log(s.state, s.registered) })4. Multi-step tasks
Join steps with “then”: YuktAI plans the steps, runs them in order on the data and reports each one.
Live demo
import { planTasks, runTasks, toGridToolColumns } from "@yuktishaalaa/yuktai"
const plan = planTasks("show salary over 1 lakh, then sort by joined, then summarize")
const result = await runTasks(
"show salary over 1 lakh, then sort by joined, then summarize",
{ data: rows, columns: toGridToolColumns(columns), rowKey: "id" },
{ onStep: (step, i, total) => console.log(`${i + 1}/${total}`, step.message) }
)const plan = yuktai.planTasks("show salary over 1 lakh, then sort by joined, then summarize")
const result = await yuktai.runTasks(
"show salary over 1 lakh, then sort by joined, then summarize",
{ data: rows, columns: yuktai.toGridToolColumns(columns), rowKey: "id" }
)Questions it understands
- Filters: “salary over 1 lakh”, “under 50k”, “Engineering in Hyderabad”, “name starts with R”, “joined this year”. Amounts like 10k, 1.5 lakh, 2 cr and ₹10,000 are understood.
- Sorting and top N: “highest salary first”, “top 3 by salary”, “sort by joined”.
- Summaries and BI: “average salary by department”, “total salary by city”, “trend of salary by year”, “anything unusual?”.
- Grid tools: “how many”, “open Ravi”, “clear filters”, “clear sort”.
- Other languages: add
customRuleswith phrases in Telugu, Hindi or any language.