Skip to content

Commit f088803

Browse files
authored
prioritize featured tools in search results (#15)
Signed-off-by: Grant Linville <[email protected]>
1 parent e4692ca commit f088803

File tree

2 files changed

+58
-5
lines changed

2 files changed

+58
-5
lines changed

src/lib/db.ts

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { Prisma } from '@prisma/client'
22
import { PrismaClient } from '@prisma/client'
33
import type { Tool, ToolExample } from '@/lib/types'
4+
import { FeaturedTools } from '@/lib/featured'
45

56
const prisma = new PrismaClient()
67
const all = -1
@@ -127,19 +128,30 @@ export async function getToolsForQuery(query: string, page: number, pageSize: nu
127128
skip: skip > 0 && page != all ? skip : undefined,
128129
})
129130

131+
const featured: Record<string, Tool[]> = {}
130132
const tools: Record<string, Tool[]> = {}
131133

132134
// Add them to the results so that the ones with the query in the reference come first
133135
for (const entry of toolEntriesWithReference) {
134136
const parsedTool = entry.content as Tool[]
135-
tools[entry.reference] = tools[entry.reference] || []
136-
tools[entry.reference].push(...parsedTool)
137+
if (FeaturedTools.has(entry.reference)) {
138+
featured[entry.reference] = featured[entry.reference] || []
139+
featured[entry.reference].push(...parsedTool)
140+
} else {
141+
tools[entry.reference] = tools[entry.reference] || []
142+
tools[entry.reference].push(...parsedTool)
143+
}
137144
}
138145

139146
for (const entry of toolEntriesWithDescription) {
140147
const parsedTool = entry.content as Tool[]
141-
tools[entry.reference] = tools[entry.reference] || []
142-
tools[entry.reference].push(...parsedTool)
148+
if (FeaturedTools.has(entry.reference)) {
149+
featured[entry.reference] = featured[entry.reference] || []
150+
featured[entry.reference].push(...parsedTool)
151+
} else {
152+
tools[entry.reference] = tools[entry.reference] || []
153+
tools[entry.reference].push(...parsedTool)
154+
}
143155
}
144156

145157
const totalCount = await prisma.toolEntry.count({
@@ -161,5 +173,5 @@ export async function getToolsForQuery(query: string, page: number, pageSize: nu
161173
}
162174
})
163175

164-
return { tools, totalCount }
176+
return { tools: {...featured, ...tools}, totalCount }
165177
}

src/lib/featured.ts

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
export const FeaturedTools = new Set<string>([
2+
"github.com/gptscript-ai/gpt4-v-vision@gateway",
3+
"github.com/gptscript-ai/dalle-image-generation@gateway",
4+
"github.com/gptscript-ai/answers-from-the-internet",
5+
"github.com/gptscript-ai/search-website",
6+
"github.com/gptscript-ai/browser",
7+
"github.com/gptscript-ai/tools/apis/slack/write",
8+
"github.com/gptscript-ai/tools/apis/notion/write",
9+
"github.com/gptscript-ai/tools/apis/trello",
10+
"github.com/gptscript-ai/tools/apis/outlook/mail/manage",
11+
"github.com/gptscript-ai/tools/apis/outlook/calendar/manage",
12+
"github.com/gptscript-ai/[email protected]",
13+
"github.com/gptscript-ai/structured-data-querier",
14+
"github.com/gptscript-ai/json-query",
15+
"github.com/gptscript-ai/context/filesystem",
16+
"github.com/gptscript-ai/context/workspace",
17+
"github.com/gptscript-ai/tools/clis/github",
18+
"github.com/gptscript-ai/tools/clis/aws",
19+
"github.com/gptscript-ai/tools/clis/azure",
20+
"github.com/gptscript-ai/tools/clis/digitalocean",
21+
"github.com/gptscript-ai/tools/clis/eksctl",
22+
"github.com/gptscript-ai/tools/clis/atlas",
23+
"github.com/gptscript-ai/tools/clis/gcp",
24+
"github.com/gptscript-ai/tools/clis/k8s",
25+
"github.com/gptscript-ai/tools/clis/supabase",
26+
"sys.append",
27+
"sys.download",
28+
"sys.exec",
29+
"sys.find",
30+
"sys.getenv",
31+
"sys.http.html2text",
32+
"sys.http.get",
33+
"sys.http.post",
34+
"sys.ls",
35+
"sys.prompt",
36+
"sys.read",
37+
"sys.remove",
38+
"sys.stat",
39+
"sys.time.now",
40+
"sys.write",
41+
])

0 commit comments

Comments
 (0)