Logo Query

Query

Tổ chứcPhổ biến
GetStream
query

How list endpoints take filters and sorts, modelled on Stream's query syntax. Read before adding a filter, a sort, or a query endpoint.

Tổng quan

Nhà phát hànhGetStream
Kho mãAgents
Tên kỹ năngquery
Sao
8.2K
Bản fork
709
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được GetStream công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Query trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/GetStream/Agents/tree/main/.claude/skills/query
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/GetStream/Agents.git /tmp/Agents
mkdir -p .claude/skills
cp -r /tmp/Agents/.claude/skills/query .claude/skills/query
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Query trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Query ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Query với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Query

One filter language for every list, the one getstream.io uses for users, channels, messages and calls. A caller who has written one Stream query can write ours.

Paging is the pagination skill (.claude/skills/pagination/SKILL.md). Read it first: this skill decides which rows, that one decides where the page starts.

Shape

A resource that needs more than a couple of equality filters gets POST /v1/<resource>/query, operationId query<Resources>:

json
{
  "filter": {"state": "closed", "created_at": {"$gte": "2026-09-01T00:00:00Z"}},
  "sort": [{"field": "created_at", "direction": -1}],
  "limit": 25,
  "cursor": "…"
}

The answer is a page, {items, has_more, next_cursor}, as in pagination.

  • POST because a filter is a tree, and a tree in a query string is unreadable. It still reads and nothing changes.
  • A simple GET list with a couple of query parameters stays as it is. Add query<Resources> beside it when it outgrows them; don't add a tenth query parameter.
  • filter is optional. An empty filter is every row the caller may see.

Stream calls the field filter_conditions. We call it filter; the grammar is the same.

Filter grammar

A filter is a JSON object. Keys are field names or logical operators, and all keys at one level are ANDed.

OperatorMeaningExample
$eqequal; a bare value is shorthand{"state": "closed"}
$inequal to any of a list{"agent": {"$in": ["a", "b"]}}
$gt $gte $lt $lterange, on numbers and RFC3339 times{"created_at": {"$lt": "…"}}
$existsthe field is set or not{"ended_at": {"$exists": false}}
$containsarray holds the value; object holds every key and value{"custom": {"$contains": {"team": "x"}}}
$autocompleteprefix match on a name{"title": {"$autocomplete": "sup"}}
$qfull-text match{"title": {"$q": "billing refund"}}
$and $ora list of filters{"$or": [{"state": "running"}, {"agent": "x"}]}

custom.<key> is shorthand for $contains on the custom object: {"custom.team": "x"} is {"custom": {"$contains": {"team": "x"}}}.

Not supported, and a 400: $ne, $nin, $nor, $not, regexes. Negative filters walk every row that does not match instead of seeking to the ones that do. Rewrite them as a positive $in. Stream allows $ne only on id and booleans; we allow $ne only on booleans, where it is just $eq with the other value.

Rules

  • Each endpoint declares an allow-list: field → operators, and the column each field reads. Anything else is a 400 that names the field and the operator. Never pass a caller's field name into SQL; it is looked up in the allow-list and the column comes from there.
  • Only allow what an index serves. If (customer_id, agent, created_at, id) exists, agent gets $eq and $in; a field with no index gets nothing until it has one. Custom fields get $eq/$contains only, as containment (@>), which a jsonb_path_ops GIN index on the JSONB column answers. Never $exists on a custom key: key-exists (?, ?|, ?&) needs the default jsonb_ops index, which is several times larger.
  • $and/$or nest one level deep at most, and $in takes at most 100 values. Deeper trees are a 400; they are how a list becomes a table scan.
  • Scope is not a filter. The handler ANDs the customer, and for end users the user, onto whatever arrived, as SessionFilter.UserID does. A caller cannot widen it by writing $or.
  • Values are typed by the field: a time must parse as RFC3339, a number as a number, an enum as one of its values. A wrong type is a 400, not an empty page.

Sort

sort is a list of {"field", "direction"}, direction 1 ascending or -1 descending, as Stream does it. Fields come from a sort allow-list, usually two or three indexed columns.

  • Omitted, the endpoint's default applies, e.g. created_at descending.
  • The server appends id in the direction of the last key, so the order is total.
  • The cursor holds every sort key and a fingerprint of the sort. A cursor sent with a different sort is a 400. See pagination for why the keys are in the cursor.
  • One index per allowed sort, behind the filters it is used with.

Paging

As in pagination: limit + cursor, never offset. Stream Chat's queries page by offset with a 1,000 row ceiling; Stream Video's queryCalls hands back a next pointer. We do what Video does.

  • filter and sort are resent with every page. The cursor is only a position.
  • The next page is the filter ANDed with (sort keys, id) < (cursor values), flipped to > for ascending keys.
  • Fetch limit + 1 for has_more. No counts.

Go

Put the grammar in one package and reuse it; an endpoint only supplies its allow-lists.

  • A short allow-list needs no parser. querySessions (internal/api/session_query.go) declares its filter as closed Huma structs, with one struct per operator (Equals, TextMatch), so the schema validates the request and documents it too. Combinations the schema cannot express, such as a text search with project_id, are refused in sessionQueryOf. The cursor carries the sort, so a cursor from one sort is refused by another. Start here, and move to a tree only when $and, $or or $in are needed.
  • Parse the body into a tree once, validating against the allow-list as you go. The handler gets a typed tree or an invalidRequest APIError.
  • Compile the tree to bun Where clauses with bound values. Field names never reach SQL as text.
  • Where a list merges rows held in memory with rows in Postgres, like live sessions in Manager.find, the same tree needs a Match(item) too, so both halves filter and sort alike.
  • Document the allowed fields, operators and sorts in the operation's description; that is what a caller reads.
  • Tests follow the go-testing skill: one per allowed operator, one for a rejected field and a rejected operator, one for a nested $or, and one that pages a filtered, sorted list to the end without repeating or skipping a row.

SDKs

Go first, as AGENTS.md says. The filter is a plain map in every SDK (map[string]any, a dict, an object), which is how Stream's SDKs take filter_conditions. Sort is a typed list. List methods follow the cursor the way Items.Unwind does.

Câu hỏi thường gặp

Kỹ năng AI Query làm được gì?

How list endpoints take filters and sorts, modelled on Stream's query syntax. Read before adding a filter, a sort, or a query endpoint.

Vì sao nên dùng Query trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Query là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Query trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/GetStream/Agents/tree/main/.claude/skills/query. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Query?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Query với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Query với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Query có miễn phí không?

Có. Kỹ năng này được GetStream phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇