src / config.ts
// config.ts
import { createConfigSchematics } from "@lmstudio/sdk";
/** `%s` is replaced with encodeURIComponent(query). */
export const SEARCH_ENGINES = {
google: {
label: "Google",
template: "https://www.google.com/search?q=%s",
},
brave: {
label: "Brave Search",
template: "https://search.brave.com/search?q=%s",
},
duckduckgo: {
label: "DuckDuckGo",
template: "https://duckduckgo.com/?q=%s",
},
bing: {
label: "Bing",
template: "https://www.bing.com/search?q=%s",
},
startpage: {
label: "Startpage",
template: "https://www.startpage.com/sp/search?query=%s",
},
} as const;
export type SearchEngineId = keyof typeof SEARCH_ENGINES;
export function buildSearchUrl(engine: SearchEngineId, query: string): string {
const tpl = SEARCH_ENGINES[engine]?.template ?? SEARCH_ENGINES.duckduckgo.template;
return tpl.replace("%s", encodeURIComponent(query));
}
export const configSchematics = createConfigSchematics()
.field(
"marionetteHost",
"string",
{
displayName: "Marionette host",
hint: "Host where Firefox is listening with --marionette (usually 127.0.0.1).",
placeholder: "127.0.0.1",
},
"127.0.0.1",
)
.field(
"marionettePort",
"numeric",
{
displayName: "Marionette port",
hint: "Marionette TCP port (default 2828).",
int: true,
min: 1,
max: 65535,
slider: { min: 1024, max: 65535, step: 1 },
},
2828,
)
.field(
"searchEngine",
"select",
{
displayName: "Search engine",
hint: "Engine used by the web_search tool.",
options: (Object.keys(SEARCH_ENGINES) as SearchEngineId[]).map((id) => ({
value: id,
displayName: SEARCH_ENGINES[id].label,
})),
},
"duckduckgo",
)
.build();
src / config.ts
// config.ts
import { createConfigSchematics } from "@lmstudio/sdk";
/** `%s` is replaced with encodeURIComponent(query). */
export const SEARCH_ENGINES = {
google: {
label: "Google",
template: "https://www.google.com/search?q=%s",
},
brave: {
label: "Brave Search",
template: "https://search.brave.com/search?q=%s",
},
duckduckgo: {
label: "DuckDuckGo",
template: "https://duckduckgo.com/?q=%s",
},
bing: {
label: "Bing",
template: "https://www.bing.com/search?q=%s",
},
startpage: {
label: "Startpage",
template: "https://www.startpage.com/sp/search?query=%s",
},
} as const;
export type SearchEngineId = keyof typeof SEARCH_ENGINES;
export function buildSearchUrl(engine: SearchEngineId, query: string): string {
const tpl = SEARCH_ENGINES[engine]?.template ?? SEARCH_ENGINES.duckduckgo.template;
return tpl.replace("%s", encodeURIComponent(query));
}
export const configSchematics = createConfigSchematics()
.field(
"marionetteHost",
"string",
{
displayName: "Marionette host",
hint: "Host where Firefox is listening with --marionette (usually 127.0.0.1).",
placeholder: "127.0.0.1",
},
"127.0.0.1",
)
.field(
"marionettePort",
"numeric",
{
displayName: "Marionette port",
hint: "Marionette TCP port (default 2828).",
int: true,
min: 1,
max: 65535,
slider: { min: 1024, max: 65535, step: 1 },
},
2828,
)
.field(
"searchEngine",
"select",
{
displayName: "Search engine",
hint: "Engine used by the web_search tool.",
options: (Object.keys(SEARCH_ENGINES) as SearchEngineId[]).map((id) => ({
value: id,
displayName: SEARCH_ENGINES[id].label,
})),
},
"duckduckgo",
)
.build();