feat(ai): find lazy tools by search #2255
main fromfeat/lazy-tools-searchmerged by tombeckenham View on GitHubtanstack-source reviewed
@@ -271,4 +291,4 @@271291 }> = []272292 const errors: Array<string> = []273293274- for (const name of args.toolNames) {294+ const names = new Set(args.toolNames ?? [])@@ -271,4 +291,6 @@271291 }> = []272292 const errors: Array<string> = []273293274- for (const name of args.toolNames) {294+ const names = new Set(args.toolNames ?? [])295+ if (args.query) {296+ const found = searchLazyTools(lazyToolMap.values(), args.query)- @@ -31,3 +31,11 @@3131 : description.trim()3232 return desc ? `${name} — ${desc}` : name3333 }34+35+/** Lowercase words of a text, split at non-alphanumerics and camelCase. */36+function words(text: string): Set<string> {37+ return new Set(38+ text39+ .replace(/([a-z0-9])([A-Z])/g, '$1 $2')40+ .toLowerCase()41+ .split(/[^a-z0-9]+/)
Applied a fix from CI9790e79
tanstack-source reviewed
@@ -31,3 +31,11 @@3131 : description.trim()3232 return desc ? `${name} — ${desc}` : name3333 }34+35+/** Lowercase words of a text, split at non-alphanumerics and camelCase. */36+function words(text: string): Set<string> {37+ return new Set(38+ text39+ .replace(/([a-z0-9])([A-Z])/g, '$1 $2')40+ .toLowerCase()41+ .split(/[^a-z0-9]+/)
tombeckenham pushedd1e8398
tombeckenham changed the title
tanstack-source reviewed
@@ -33,0 +106,21 @@106+ toolNames: {107+ type: 'array',108+ items: { type: 'string' },109+ description: 'Exact names of tools to discover.',110+ },111+ },112+ anyOf: [113+ {114+ type: 'object',115+ properties: { query: { type: 'string' } },116+ required: ['query'],117+ },118+ {119+ type: 'object',120+ properties: {121+ toolNames: { type: 'array', items: { type: 'string' } },122+ },123+ required: ['toolNames'],124+ },125+ ],126+}- @@ -33,0 +92,21 @@92+93+/**94+ * Discovery input when `lazyToolsConfig.catalog` is `'search'`.95+ * One of `query` or `toolNames` is required. Each `anyOf` branch has a96+ * `type`, so OpenAI can send the tool with `strict: true`.97+ */98+export const lazySearchInputSchema: JSONSchema = {99+ type: 'object',100+ properties: {101+ query: {102+ type: 'string',103+ description:104+ 'What you need to do, in a few words. Returns the best matching tools.',105+ },106+ toolNames: {107+ type: 'array',108+ items: { type: 'string' },109+ description: 'Exact names of tools to discover.',110+ },111+ },112+ anyOf: [
Applied a fix from CI95076dc
- 2 bot comments
tanstack-source reviewed
@@ -33,0 +106,21 @@106+ toolNames: {107+ type: 'array',108+ items: { type: 'string' },109+ description: 'Exact names of tools to discover.',110+ },111+ },112+ anyOf: [113+ {114+ type: 'object',115+ properties: { query: { type: 'string' } },116+ required: ['query'],117+ },118+ {119+ type: 'object',120+ properties: {121+ toolNames: { type: 'array', items: { type: 'string' } },122+ },123+ required: ['toolNames'],124+ },125+ ],126+}
Applied a fix from CI37ad543
- 2 bot comments
tanstack-source reviewed
@@ -33,0 +106,21 @@106+ toolNames: {107+ type: 'array',108+ items: { type: 'string' },109+ description: 'Exact names of tools to discover.',110+ },111+ },112+ anyOf: [113+ {114+ type: 'object',115+ properties: { query: { type: 'string' } },116+ required: ['query'],117+ },118+ {119+ type: 'object',120+ properties: {121+ toolNames: { type: 'array', items: { type: 'string' } },122+ },123+ required: ['toolNames'],124+ },125+ ],126+}
tombeckenham pushedba5057d
github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: maintainer
github-actions[bot](GitHub profile, opens in a new tab) removed labelswaiting-on: author
tombeckenham approved these changes
github-actions[bot](GitHub profile, opens in a new tab) added labelswaiting-on: author
github-actions[bot](GitHub profile, opens in a new tab) removed labelswaiting-on: maintainer
tombeckenham approved these changes
tombeckenham approved these changes
tombeckenham merged this7d49d2c
tombeckenham closed this
Sign in to join this conversation.
🦋 Changeset detected#
Latest commit: ba5057d9afb11d0c6c4bd9e320b0e7bcf38897c1
The changes in this PR will be included in the next version bump.
This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are.
Click here if you're a maintainer who wants to add another changeset to this PR