Prompts provides an iterator for all prompts available on the server, automatically fetching pages and managing cursors. The params argument can set the initial cursor. Iteration stops at the first encountered error, which will be yielded.
(ctx context.Context, params *ListPromptsParams)
| 1151 | // The params argument can set the initial cursor. |
| 1152 | // Iteration stops at the first encountered error, which will be yielded. |
| 1153 | func (cs *ClientSession) Prompts(ctx context.Context, params *ListPromptsParams) iter.Seq2[*Prompt, error] { |
| 1154 | if params == nil { |
| 1155 | params = &ListPromptsParams{} |
| 1156 | } |
| 1157 | return paginate(ctx, params, cs.ListPrompts, func(res *ListPromptsResult) []*Prompt { |
| 1158 | return res.Prompts |
| 1159 | }) |
| 1160 | } |
| 1161 | |
| 1162 | // paginate is a generic helper function to provide a paginated iterator. |
| 1163 | func paginate[P listParams, R listResult[T], T any](ctx context.Context, params P, listFunc func(context.Context, P) (R, error), items func(R) []*T) iter.Seq2[*T, error] { |