Skip to content

Commit 8175329

Browse files
authored
feat(tools): remove feature flag for tools and use env variable instead (#1433)
1 parent ce8e8cc commit 8175329

File tree

14 files changed

+29
-43
lines changed

14 files changed

+29
-43
lines changed

.env

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,4 +175,5 @@ BODY_SIZE_LIMIT=15728640
175175
HF_ORG_ADMIN=
176176
HF_ORG_EARLY_ACCESS=
177177

178-
PUBLIC_SMOOTH_UPDATES=false
178+
PUBLIC_SMOOTH_UPDATES=false
179+
COMMUNITY_TOOLS=false

chart/env/prod.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ envVars:
3030
ADDRESS_HEADER: 'X-Forwarded-For'
3131
ALTERNATIVE_REDIRECT_URLS: '["huggingchat://login/callback"]'
3232
APP_BASE: "/chat"
33+
COMMUNITY_TOOLS: "true"
3334
ENABLE_ASSISTANTS: "true"
3435
ENABLE_ASSISTANTS_RAG: "true"
3536
EXPOSE_API: "true"

src/lib/components/NavMenu.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,7 @@
136136
Assistants
137137
</a>
138138
{/if}
139-
<!-- XXX: feature_flag_tools -->
140-
{#if $page.data.user?.isEarlyAccess}
139+
{#if $page.data.enableCommunityTools}
141140
<a
142141
href="{base}/tools"
143142
class="flex h-9 flex-none items-center gap-1.5 rounded-lg pl-2.5 pr-2 text-gray-500 hover:bg-gray-100 dark:text-gray-400 dark:hover:bg-gray-700"

src/lib/components/ToolsMenu.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,7 @@
8484
{/if}
8585
</button>
8686
</div>
87-
<!-- XXX: feature_flag_tools -->
88-
{#if $page.data.user?.isEarlyAccess}
87+
{#if $page.data.enableCommunityTools}
8988
<a
9089
href="{base}/tools"
9190
class="col-span-2 my-1 h-fit w-fit items-center justify-center rounded-full bg-purple-500/20 px-2.5 py-1.5 text-sm hover:bg-purple-500/30"

src/routes/+layout.server.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ export const load: LayoutServerLoad = async ({ locals, depends, request }) => {
240240
assistant,
241241
enableAssistants,
242242
enableAssistantsRAG: env.ENABLE_ASSISTANTS_RAG === "true",
243+
enableCommunityTools: env.COMMUNITY_TOOLS === "true",
243244
loginRequired,
244245
loginEnabled: requiresUser,
245246
guestMode: requiresUser && messagesBeforeLogin > 0,

src/routes/api/spaces-config/+server.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
import { env } from "$env/dynamic/private";
12
import { Client } from "@gradio/client";
23

3-
export async function GET({ url, locals }) {
4-
// XXX: feature_flag_tools
5-
if (!locals.user?.isEarlyAccess) {
6-
return new Response("Not early access", { status: 403 });
4+
export async function GET({ url }) {
5+
if (env.COMMUNITY_TOOLS !== "true") {
6+
return new Response("Community tools are not enabled", { status: 403 });
77
}
88

99
const space = url.searchParams.get("space");

src/routes/api/tools/[toolId]/+server.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1+
import { env } from "$env/dynamic/private";
12
import { collections } from "$lib/server/database.js";
23
import { toolFromConfigs } from "$lib/server/tools/index.js";
34
import type { CommunityToolDB } from "$lib/types/Tool.js";
45
import { ObjectId } from "mongodb";
56

6-
export async function GET({ params, locals }) {
7-
// XXX: feature_flag_tools
8-
if (!locals.user?.isEarlyAccess) {
9-
return new Response("Not early access", { status: 403 });
7+
export async function GET({ params }) {
8+
if (env.COMMUNITY_TOOLS !== "true") {
9+
return new Response("Community tools are not enabled", { status: 403 });
1010
}
1111

1212
const toolId = params.toolId;

src/routes/api/tools/search/+server.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
import { env } from "$env/dynamic/private";
12
import { collections } from "$lib/server/database.js";
23
import { toolFromConfigs } from "$lib/server/tools/index.js";
34
import type { BaseTool, CommunityToolDB } from "$lib/types/Tool.js";
45
import { generateQueryTokens, generateSearchTokens } from "$lib/utils/searchTokens.js";
56
import type { Filter } from "mongodb";
67

7-
export async function GET({ url, locals }) {
8-
// XXX: feature_flag_tools
9-
if (!locals.user?.isEarlyAccess) {
10-
return new Response("Not early access", { status: 403 });
8+
export async function GET({ url }) {
9+
if (env.COMMUNITY_TOOLS !== "true") {
10+
return new Response("Community tools are not enabled", { status: 403 });
1111
}
1212

1313
const query = url.searchParams.get("q")?.trim() ?? null;

src/routes/settings/(nav)/+server.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,6 @@ export async function POST({ request, locals }) {
2222
})
2323
.parse(body) satisfies SettingsEditable;
2424

25-
// only allow tools to be set to community tools if user is early access
26-
// XXX: feature_flag_tools
27-
if (!locals.user?.isEarlyAccess) {
28-
settings.tools = settings.tools?.filter((toolId) => {
29-
return toolFromConfigs.some((tool) => tool._id.toString() === toolId);
30-
});
31-
}
32-
3325
// make sure all tools exist
3426
// either in db or in config
3527
if (settings.tools) {

src/routes/settings/(nav)/assistants/[assistantId]/edit/+page.server.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ export const actions: Actions = {
171171
allowedDomains: parse.data.ragDomainList,
172172
allowAllDomains: parse.data.ragAllowAll,
173173
},
174-
// XXX: feature_flag_tools
175-
tools: locals.user?.isEarlyAccess ? parse.data.tools : undefined,
174+
tools: parse.data.tools,
176175
dynamicPrompt: parse.data.dynamicPrompt,
177176
searchTokens: generateSearchTokens(parse.data.name),
178177
generateSettings: {

0 commit comments

Comments
 (0)